Пример #1
0
 /// <summary>
 /// Verifies a Digital Signature based on the encoding type
 /// </summary>
 /// <param name="encodingType"></param>
 /// <returns></returns>
 public bool VerifySignature(Encoding encodingType)
 {
     try
     {
         SignedData signedData = new SignedDataClass();
         Utilities  u          = new UtilitiesClass();
         if (_bDetached)
         {
             signedData.Content = u.ByteArrayToBinaryString(encodingType.GetBytes(Content));
             //signedData.set_Content(u.ByteArrayToBinaryString(encodingType.GetBytes(Content)));
         }
         signedData.Verify(SignedContent, Detached, CAPICOM_SIGNED_DATA_VERIFY_FLAG.CAPICOM_VERIFY_SIGNATURE_ONLY);
         SignerCert = null;
         Signer s = (Signer)signedData.Signers[1];
         SignerCert = (Certificate)s.Certificate;
         if (!_bDetached)
         {
             //Content = encodingType.GetString((byte[])u.BinaryStringToByteArray(signedData.get_Content()));
             Content = encodingType.GetString((byte[])u.BinaryStringToByteArray(signedData.Content));
         }
         return(true);
     }
     catch (COMException e)
     {
         Console.WriteLine("{0}: {1}", e.Source, e.Message);
         return(false);
     }
 }
Пример #2
0
 private void MakeResponse(ExchangeRequest req, string responseType, string refuseReason, string exportedReport, string xml)
 {
     RESFORM source = new RESFORM {
         TYPE_REQ = new RESFORMTYPE_REQ()
     };
     source.TYPE_REQ.QUERY_ID = req.QueryId;
     source.TYPE_REQ.GUID = req.Guid;
     source.TYPE_REQ.TYPE = req.Type;
     source.TYPE_REQ.TYPE_NAME = "Получение справки о начислениях и оплате для единого окна";
     source.TYPE_RES = new RESFORMTYPE_RES();
     source.TYPE_RES.TYPE = string.IsNullOrEmpty(exportedReport) ? ((byte) 1) : ((byte) 0);
     source.TYPE_RES.TYPE_NAME = responseType;
     source.TYPE_RES.DATE_RES = System.DateTime.Today.ToShortDateString();
     source.BODY_RES = new RESFORMBODY_RES();
     source.BODY_RES.USER = User.CurrentUser.Name;
     source.BODY_RES.AREA = AIS.SN.Model.Constants.OrgName;
     source.BODY_RES.REASON = refuseReason;
     source.BODY_RES.FORM = exportedReport;
     source.BODY_RES.FORMXML = xml;
     source.BODY_RES.FORM_SIGNATURE = new byte[0];
     source.BODY_RES.FORMXML_SIGNATURE = new byte[0];
     if (this.cbCrypt.get_Checked() && (exportedReport != ""))
     {
         Utilities utilities = new UtilitiesClass();
         source.BODY_RES.FORM_SIGNATURE = new ForBytes().Sign(System.Convert.FromBase64String(exportedReport));
         source.BODY_RES.FORMXML_SIGNATURE = new ForBytes().Sign((byte[]) utilities.BinaryStringToByteArray(xml));
     }
     string inxml = Serializer.ToXml<RESFORM>(source, (System.Text.Encoding) System.Text.Encoding.Unicode);
     string str2 = new DocsVisionWebService().RespondSnDg(inxml);
     XmlDocument document = new XmlDocument();
     document.LoadXml(str2);
     string str3 = document.GetElementsByTagName("CODE").get_ItemOf(0).get_InnerText();
     if (str3 != "0")
     {
         string str4 = document.GetElementsByTagName("ERROR").get_ItemOf(0).get_InnerText();
         System.ApplicationException exception = new System.ApplicationException(string.Concat((string[]) new string[] { "Ошибка отправки сообщения", System.Environment.get_NewLine(), "Код ошибки: ", str3, System.Environment.get_NewLine(), "Сообщение: ", str4 }));
         throw exception;
     }
     req.XmlOut = inxml;
     req.Status = ExchangeStatus.Processed;
     req.Update();
 }