コード例 #1
0
ファイル: UDataView.cs プロジェクト: huamanhtuyen/VNACCS
 private void rmnsignatureVerification_Click(object sender, EventArgs e)
 {
     StreamReader reader = null;
     int num = 0;
     new Hashtable();
     SMimeFormat format = null;
     IData data = null;
     int num2 = -2146889721;
     int num3 = -2146893818;
     int num4 = 0;
     int num5 = 0;
     int num6 = 0;
     int num7 = 0;
     int num8 = 0;
     int num9 = 0;
     int num10 = 0;
     int num11 = 0;
     StringBuilder builder = new StringBuilder();
     if (this.dgvDataView.SelectedRows.Count > 0)
     {
         for (int i = 0; i < this.dgvDataView.RowCount; i++)
         {
             string str = this.dgvDataView.Rows[i].Cells["clmSignflg"].Value.ToString();
             if (this.dgvDataView.Rows[i].Selected && (str != "0"))
             {
                 num++;
                 data = this.GetData(int.Parse(this.dgvDataView.Rows[i].Cells["clmID"].Value.ToString()));
                 string path = this.dgvDataView.Rows[i].Cells["clmSignFilePath"].Value.ToString();
                 if (File.Exists(path))
                 {
                     ULogClass.LogWrite(string.Format("SignatureVerification FilePath={0}", path), null, false);
                     try
                     {
                         try
                         {
                             reader = new StreamReader(path);
                             string sMIMEmessage = reader.ReadToEnd();
                             format = new SMimeFormat();
                             if (format.SignCheck(sMIMEmessage))
                             {
                                 this.dgvDataView.Rows[i].Cells["clmSignflg"].Value = "2";
                                 data.Signflg = 2;
                                 this.DataViewDataSave(data, this.dgvDataView.Rows[i].Cells["clmFileName"].Value.ToString());
                             }
                             else
                             {
                                 this.dgvDataView.Rows[i].Cells["clmSignflg"].Value = "9";
                                 data.Signflg = 9;
                                 this.DataViewDataSave(data, this.dgvDataView.Rows[i].Cells["clmFileName"].Value.ToString());
                                 if (format.GetThisCertificateErr == "NotTimeValid")
                                 {
                                     num4++;
                                 }
                                 else if (format.GetThisCertificateErr == "UntrustedRoot")
                                 {
                                     num5++;
                                 }
                                 else if (format.GetThisCertificateErr == "Revoked")
                                 {
                                     num6++;
                                 }
                                 else
                                 {
                                     num7++;
                                 }
                                 if (!builder.ToString().Contains(format.GetThisCertificateErr))
                                 {
                                     builder.Append(format.GetThisCertificateErr + "\r\n");
                                 }
                             }
                         }
                         catch (Exception exception)
                         {
                             this.dgvDataView.Rows[i].Cells["clmSignflg"].Value = "9";
                             data.Signflg = 9;
                             this.DataViewDataSave(data, this.dgvDataView.Rows[i].Cells["clmFileName"].Value.ToString());
                             int num13 = (int) exception.GetType().GetProperty("HResult", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(exception, new object[0]);
                             if (num13 == num2)
                             {
                                 num9++;
                             }
                             else if (num13 == num3)
                             {
                                 num8++;
                             }
                             else
                             {
                                 num10++;
                             }
                             if (!builder.ToString().Contains(exception.Message))
                             {
                                 builder.Append(exception.Message + "\r\n");
                             }
                         }
                         continue;
                     }
                     finally
                     {
                         reader.Close();
                     }
                 }
                 num11++;
                 if (!builder.ToString().Contains("CheckFileExistError"))
                 {
                     builder.Append("CheckFileExistError\r\n");
                 }
                 this.dgvDataView.Rows[i].Cells["clmSignflg"].Value = "9";
                 data.Signflg = 9;
                 this.DataViewDataSave(data, this.dgvDataView.Rows[i].Cells["clmFileName"].Value.ToString());
             }
         }
         MessageDialog dialog = new MessageDialog();
         int num14 = ((num4 + num5) + num6) + num7;
         int num15 = (num8 + num9) + num10;
         int num16 = (num14 + num15) + num11;
         string messageCode = "";
         ULogClass.LogWrite(string.Format("SignatureVerificationResult ErrCount={0}", num16.ToString()), null, false);
         if (num != 0)
         {
             if (num16 == 0)
             {
                 messageCode = "I106";
                 dialog.ShowMessage(messageCode, "");
             }
             else
             {
                 if (((num15 != 0) && (num14 == 0)) && (num11 == 0))
                 {
                     if (((num9 != 0) && (num8 == 0)) && (num10 == 0))
                     {
                         messageCode = "E126";
                     }
                     else if (((num9 == 0) && (num8 != 0)) && (num10 == 0))
                     {
                         messageCode = "E128";
                     }
                     else
                     {
                         messageCode = "E129";
                     }
                 }
                 else if (((num15 == 0) && (num14 != 0)) && (num11 == 0))
                 {
                     if (((num4 != 0) && (num5 == 0)) && ((num6 == 0) && (num7 == 0)))
                     {
                         messageCode = "E130";
                     }
                     else if (((num4 == 0) && (num5 != 0)) && ((num6 == 0) && (num7 == 0)))
                     {
                         messageCode = "E131";
                     }
                     else if (((num4 == 0) && (num5 == 0)) && ((num6 != 0) && (num7 == 0)))
                     {
                         messageCode = "E136";
                     }
                     else
                     {
                         messageCode = "E127";
                     }
                 }
                 else if (((num15 == 0) && (num14 == 0)) && (num11 != 0))
                 {
                     messageCode = "E132";
                 }
                 else
                 {
                     messageCode = "E125";
                 }
                 dialog.ShowMessage(messageCode, num16.ToString(), builder.ToString());
             }
         }
         else
         {
             dialog.ShowMessage("E133", "");
         }
         this.DataViewRepaint(false);
     }
 }
コード例 #2
0
ファイル: HttpClient.cs プロジェクト: huamanhtuyen/VNACCS
 public MemoryStream MakeSendData(HttpWebRequest request, ComParameter senddata)
 {
     MemoryStream message = null;
     string boundaryString = MimeFormat.BoundaryString;
     if (senddata.AttachCount > 0)
     {
         message = this.mBuilder.ToMemoryStream(senddata, boundaryString, this.mTrace);
         request.SendChunked = false;
         request.ContentType = MimeFormat.MultiContentType(boundaryString);
         request.ContentLength = message.ToArray().Length;
         this.mTrace.WriteString(this.mTracekind, string.Format("+ {0,-16} : {1}", "MakeSendData", string.Format("ContentType={0} Length={1}", request.ContentType, request.ContentLength)));
     }
     else if (!string.IsNullOrEmpty(senddata.DataString))
     {
         message = this.mBuilder.ToMemoryStream(senddata, boundaryString, this.mTrace);
         request.SendChunked = false;
         request.ContentType = MimeFormat.TextContentType(this.mBuilder.BaseCharset);
         request.ContentLength = message.ToArray().Length;
         this.mTrace.WriteString(this.mTracekind, string.Format("+ {0,-16} : {1}", "MakeSendData", string.Format("ContentType={0} Length={1}", request.ContentType, request.ContentLength)));
     }
     if (senddata.Sign == "1")
     {
         this.mTrace.WriteString(this.mTracekind, string.Format("+ {0,-16} : {1}", "ConvertSMIMEstr", string.Format("ContentType={0} Length={1}", request.ContentType, request.ContentLength)));
         if (this.cSMime == null)
         {
             this.cSMime = new SMimeFormat();
         }
         string header = request.ContentType.ToString();
         message = this.cSMime.ConvertSMIME(message, header, senddata.SelectSign);
         request.ContentType = string.Format("multipart/signed; micalg=\"sha1\"; boundary=\"{0}\"; protocol=\"application/x-pkcs7-signature\"", this.cSMime.GetThisBoundary);
         request.ContentLength = message.ToArray().Length;
         this.mTrace.WriteString(this.mTracekind, string.Format("+ {0,-16} : {1}", "ConvertSMIMEend", string.Format("ContentType={0} Length={1}", request.ContentType, request.ContentLength)));
     }
     return message;
 }