public void SetCertificateVerify(VerifyMode mode, RemoteValidationCallback callback) { this.managed_cert_callback = callback; if (callback != null) { verify_callback = new VerifyCallback(OnVerifyCallback); } native_openssl_set_certificate_verify(handle, (int)mode, verify_callback, null, 10); }
public XElement BillPull(string guid, XElement billPullRequest) { MFEPMessage <BillsRecord> deserializedResponse = new MFEPMessage <BillsRecord>(); XElement serializedResponse = null; string fileGuid = Guid.NewGuid().ToString(); try { // Write the request to physical path WriteToPhysicalPath(billPullRequest, BillPullRequestPath, fileGuid); MFEPMessage <BillInquiryRequestEntity> deserializedRequest = billPullRequest.FromXElement <MFEPMessage <BillInquiryRequestEntity> >(); deserializedResponse.Header.TimeStamp = DateTime.Now.ToString("s"); deserializedResponse.Header.Guid = guid; deserializedResponse.Header.TransmitInfo = new TransmitInfo() { SenderCode = deserializedRequest.Header.TransmitInfo.ReceiverCode, ResponseType = ProcessesCodes.BILPULRS }; deserializedResponse.Header.Result = new Result(); bool isTestReponse = IsTestReponse; if (!isTestReponse) { // Verifying if (EnableSecuity) { if (deserializedRequest == null || deserializedRequest.Footer.Security == null || deserializedRequest.Footer.Security.Signature == null || string.IsNullOrWhiteSpace(deserializedRequest.Footer.Security.Signature.Trim())) { Result result_1 = new Result(); result_1.ErrorCode = (int)ServiceErrors.InvalidSignature; result_1.ErrorDesc = ServiceErrors.InvalidSignature.ToString(); result_1.Severity = Severity.Error; deserializedResponse.Header.Result = result_1; serializedResponse = deserializedResponse.ToXElement <MFEPMessage <BillsRecord> >(); // Write the request to physical path WriteToPhysicalPath(serializedResponse, BillPullResponsePath, fileGuid); return(serializedResponse); } else { VerifyMode verifyMode = VerifyMode.WithFormat; if (SecurityMode.Equals("WithOutFormat", StringComparison.CurrentCultureIgnoreCase)) { verifyMode = VerifyMode.WithOutFormat; } Collection <string> xPath = new Collection <string> { XPath }; bool verifiedSuccessfully = CertificateManager.VerifyMessageSignature(deserializedRequest.ToXElement <MFEPMessage <BillInquiryRequestEntity> >(), xPath, deserializedRequest.Footer.Security.Signature, BillerCertificateSerialNumber, verifyMode); if (!verifiedSuccessfully) { Result result_2 = new Result(); result_2.ErrorCode = (int)ServiceErrors.InvalidSignature; result_2.ErrorDesc = ServiceErrors.InvalidSignature.ToString(); result_2.Severity = Severity.Error; deserializedResponse.Header.Result = result_2; serializedResponse = deserializedResponse.ToXElement <MFEPMessage <BillsRecord> >(); WriteToPhysicalPath(serializedResponse, BillPullResponsePath, fileGuid); return(serializedResponse); } } if (deserializedRequest.Header.TransmitInfo.SenderCode != MFEPCode) { Result result_3 = new Result(); result_3.ErrorCode = (int)ServiceErrors.InvalidSenderCode; result_3.ErrorDesc = ServiceErrors.InvalidSenderCode.ToString(); result_3.Severity = Severity.Error; deserializedResponse.Header.Result = result_3; serializedResponse = deserializedResponse.ToXElement <MFEPMessage <BillsRecord> >(); // Write the request to physical path WriteToPhysicalPath(serializedResponse, BillPullResponsePath, fileGuid); return(serializedResponse); } // Validate Biller code if (deserializedRequest.Header.TransmitInfo.ReceiverCode != BillerCode) { Result result_4 = new Result(); result_4.ErrorCode = (int)ServiceErrors.UnsuccessfulBillPullRequest; result_4.ErrorDesc = ServiceErrors.UnsuccessfulBillPullRequest.ToString(); result_4.Severity = Severity.Error; deserializedResponse.Header.Result = result_4; serializedResponse = deserializedResponse.ToXElement <MFEPMessage <BillsRecord> >(); // Write the request to physical path WriteToPhysicalPath(serializedResponse, BillPullResponsePath, fileGuid); return(serializedResponse); } // Validate Service Type if (!ServiceType.Equals(deserializedRequest.Body.ServiceType, StringComparison.CurrentCultureIgnoreCase)) { Result result_5 = new Result(); result_5.ErrorCode = (int)ServiceErrors.UnrecognizedServiceType; result_5.ErrorDesc = ServiceErrors.UnrecognizedServiceType.ToString(); result_5.Severity = Severity.Error; deserializedResponse.Header.Result = result_5; serializedResponse = deserializedResponse.ToXElement <MFEPMessage <BillsRecord> >(); // Write the request to physical path WriteToPhysicalPath(serializedResponse, BillPullResponsePath, fileGuid); return(serializedResponse); } // Get Bill and generate the response DAL dal = new DAL(); BillRecord billRecord = dal.GetBillInfo(deserializedRequest.Body.AccountInfo.BillNumber, deserializedRequest.Body.AccountInfo.BillingNumber, deserializedRequest.Body.ServiceType); if (billRecord != null) { billRecord.IssueDate = billRecord.IssueDate.Value.AddMinutes(TimeDifference); billRecord.DueDate = billRecord.DueDate.Value.AddMinutes(TimeDifference); deserializedResponse.Body = new BillsRecord() { RecCount = 1 }; deserializedResponse.Body.BillRecords.Add(billRecord); } else { deserializedResponse.Body = new BillsRecord() { RecCount = 0, BillRecords = null }; } // Sign the response if (EnableSecuity) { SignMode signMode = SignMode.WithFormat; if (SecurityMode.Equals("WithOutFormat", StringComparison.CurrentCultureIgnoreCase)) { signMode = SignMode.WithOutFormat; } Collection <string> xPath = new Collection <string> { XPath }; deserializedResponse.Footer = new MFEPFooter(); deserializedResponse.Footer.Security.Signature = CertificateManager.SignMessage(deserializedResponse.ToXElement <MFEPMessage <BillsRecord> >(), xPath, BillerCertificateSerialNumber, signMode); } else { SignMode signMode = SignMode.WithFormat; if (SecurityMode.Equals("WithOutFormat", StringComparison.CurrentCultureIgnoreCase)) { signMode = SignMode.WithOutFormat; } Collection <string> xPath = new Collection <string> { XPath }; deserializedResponse.Footer = new MFEPFooter(); deserializedResponse.Footer.Security.Signature = CertificateManager.SignMessage(deserializedResponse.ToXElement <MFEPMessage <BillsRecord> >(), xPath, BillerCertificateSerialNumber, signMode); } serializedResponse = deserializedResponse.ToXElement <MFEPMessage <BillsRecord> >(); // Write the request to physical path WriteToPhysicalPath(serializedResponse, BillPullResponsePath, fileGuid); return(serializedResponse); } // Sign the response return(GenerateAutoResponse(guid, billPullRequest)); /* serializedResponse = deserializedResponse.ToXElement<MFEPMessage<BillsRecord>>(); * // Write the request to physical path * WriteToPhysicalPath(serializedResponse, BillPullResponsePath, fileGuid); * */ /*return serializedResponse;*/ } else { return(GenerateAutoResponse(guid, billPullRequest)); } } catch (Exception exception) { string ex = exception.Message + "\n" + exception.StackTrace; WriteException(ex, ExceptionPath); Result result = new Result(); result.ErrorCode = (int)ServiceErrors.InternalError; result.ErrorDesc = ServiceErrors.InternalError.ToString(); result.Severity = Severity.Error; deserializedResponse.Header.Result = result; return(deserializedResponse.ToXElement <MFEPMessage <BillsRecord> >()); } }
public XElement ReceivePaymentNotification(string guid, XElement paymentNotification) { MFEPMessage <PaymentNotificationTransaction> deserializedResponse = new MFEPMessage <PaymentNotificationTransaction>(); XElement serializedResponse = null; string fileName = Guid.NewGuid().ToString(); try { MFEPMessage <PaymentNotificationTransaction> deserializedRequest = paymentNotification.FromXElement <MFEPMessage <PaymentNotificationTransaction> >(); deserializedResponse.Header.TimeStamp = DateTime.Now.ToString("s"); deserializedResponse.Header.Guid = guid; deserializedResponse.Header.TransmitInfo = new TransmitInfo() { SenderCode = deserializedRequest.Header.TransmitInfo.ReceiverCode, ResponseType = ProcessesCodes.BLRPMTNTFRS }; deserializedResponse.Header.Result = new Result(); fileName = deserializedRequest.Body.Transactions[0].ServiceType.SrvsTypValue.ToString() + fileName; if (!IsTestReponse) { // Verifying if (EnableSecuity) { if (deserializedRequest == null || deserializedRequest.Footer.Security == null || deserializedRequest.Footer.Security.Signature == null || string.IsNullOrWhiteSpace(deserializedRequest.Footer.Security.Signature.Trim())) { Result result = new Result(); result.ErrorCode = (int)ServiceErrors.InvalidSignature; result.ErrorDesc = ServiceErrors.InvalidSignature.ToString(); result.Severity = Severity.Error; deserializedResponse.Header.Result = result; WriteToPhysicalPath(paymentNotification, FailedPMTNotiRequestPath, fileName); // Write to failed notifications serializedResponse = deserializedResponse.ToXElement <MFEPMessage <PaymentNotificationTransaction> >(); WriteToPhysicalPath(serializedResponse, FailedPMTNotiResponsePath, fileName); return(serializedResponse); } else { VerifyMode verifyMode = VerifyMode.WithFormat; if (SecurityMode.Equals("WithOutFormat", StringComparison.CurrentCultureIgnoreCase)) { verifyMode = VerifyMode.WithOutFormat; } Collection <string> xPath = new Collection <string> { XPath }; bool verifiedSuccessfully = CertificateManager.VerifyMessageSignature(paymentNotification, xPath, deserializedRequest.Footer.Security.Signature, BillerCertificateSerialNumber, verifyMode); if (!verifiedSuccessfully) { Result result = new Result(); result.ErrorCode = (int)ServiceErrors.InvalidSignature; result.ErrorDesc = ServiceErrors.InvalidSignature.ToString(); result.Severity = Severity.Error; deserializedResponse.Header.Result = result; WriteToPhysicalPath(paymentNotification, FailedPMTNotiRequestPath, fileName); // Write to failed notifications serializedResponse = deserializedResponse.ToXElement <MFEPMessage <PaymentNotificationTransaction> >(); WriteToPhysicalPath(serializedResponse, FailedPMTNotiResponsePath, fileName); return(serializedResponse); } } } // Validation // Validate MFEP code if (deserializedRequest.Header.TransmitInfo.SenderCode != MFEPCode) { Result result = new Result(); result.ErrorCode = (int)ServiceErrors.InvalidSenderCode; result.ErrorDesc = ServiceErrors.InvalidSenderCode.ToString(); result.Severity = Severity.Error; deserializedResponse.Header.Result = result; WriteToPhysicalPath(paymentNotification, FailedPMTNotiRequestPath, fileName); // Write to failed notifications serializedResponse = deserializedResponse.ToXElement <MFEPMessage <PaymentNotificationTransaction> >(); WriteToPhysicalPath(serializedResponse, FailedPMTNotiResponsePath, fileName); return(serializedResponse); } // Validate Biller code if (deserializedRequest.Header.TransmitInfo.ReceiverCode != BillerCode) { Result result = new Result(); result.ErrorCode = (int)ServiceErrors.UnsuccessfulPaymentNotification; result.ErrorDesc = ServiceErrors.UnsuccessfulPaymentNotification.ToString(); result.Severity = Severity.Error; deserializedResponse.Header.Result = result; WriteToPhysicalPath(paymentNotification, FailedPMTNotiRequestPath, fileName); // Write to failed notifications serializedResponse = deserializedResponse.ToXElement <MFEPMessage <PaymentNotificationTransaction> >(); WriteToPhysicalPath(serializedResponse, FailedPMTNotiResponsePath, fileName); return(serializedResponse); } // if the serviceType is IndividualSecurity then insert it to database otherwise just write it ti physical directory if (ServiceType.Equals(deserializedRequest.Body.Transactions[0].ServiceType.SrvsTypValue.ToString(), StringComparison.CurrentCultureIgnoreCase)) { // Insert this payment DAL dal = new DAL(); dal.InsertPaymentNotification(deserializedRequest.Body.Transactions[0].AccountInfo.BillingNumber); } PaymentNotificationTransaction transaction = new PaymentNotificationTransaction { Transactions = new Collection <PaymentNotificationEntity>() }; foreach (PaymentNotificationEntity pne in deserializedRequest.Body.Transactions) { PaymentNotificationEntity notificationEntity = new PaymentNotificationEntity { JOEBPPSTrx = pne.JOEBPPSTrx, ProcessDate = pne.ProcessDate, STMTDate = pne.STMTDate, Result = new Result() }; transaction.Transactions.Add(notificationEntity); } deserializedResponse.Body = transaction; // Sign the response if (EnableSecuity) { SignMode signMode = SignMode.WithFormat; if (SecurityMode.Equals("WithOutFormat", StringComparison.CurrentCultureIgnoreCase)) { signMode = SignMode.WithOutFormat; } Collection <string> xPath = new Collection <string> { XPath }; deserializedResponse.Footer = new MFEPFooter(); deserializedResponse.Footer.Security.Signature = CertificateManager.SignMessage(deserializedResponse.ToXElement <MFEPMessage <PaymentNotificationTransaction> >(), xPath, BillerCertificateSerialNumber, signMode); } else { deserializedResponse.Footer = new MFEPFooter(); } WriteToPhysicalPath(paymentNotification, SuccessPMTNotiRequestPath, fileName); // Write to success notifications serializedResponse = deserializedResponse.ToXElement <MFEPMessage <PaymentNotificationTransaction> >(); WriteToPhysicalPath(serializedResponse, SuccessPMTNotiResponsePath, fileName); return(serializedResponse); } else { return(GenerateAutoResponse(guid, deserializedRequest, guid)); } } catch (Exception exception) { string ex = exception.Message + "\n" + exception.StackTrace; WriteException(ex, ExceptionPath); Result result = new Result(); result.ErrorCode = (int)ServiceErrors.InternalError; result.ErrorDesc = ServiceErrors.InternalError.ToString(); result.Severity = Severity.Error; deserializedResponse.Header.Result = result; WriteToPhysicalPath(paymentNotification, FailedPMTNotiRequestPath, fileName); // Write to success notifications serializedResponse = deserializedResponse.ToXElement <MFEPMessage <PaymentNotificationTransaction> >(); WriteToPhysicalPath(serializedResponse, FailedPMTNotiResponsePath, fileName); return(serializedResponse); } }
/// <summary> /// Verify worker thread. /// </summary> private void VerifyWorker2(VerifyMode mode) { // // delegates for messaging UI thread // AppendText appendText = new AppendText(this.txtOutput.AppendText); VoidMethod updateControls = new VoidMethod(this.UpdateControls); try { if ((mode & VerifyMode.VerifyProgram) == VerifyMode.VerifyProgram) { // // start stopwatch // this.stopwatch.Reset(); this.stopwatch.Start(); // // display verifying message // this.Invoke(appendText, Strings.VerifyingProgramMemory); // // verify program memory // this.programmer.Verify(0x000000, this.programMemory, this.selectedDevice.ProgramMemroySize, 0x000000, false, this.selectedDevice); // // stop the stopwatch // this.stopwatch.Stop(); // // display success message // this.Invoke(appendText, Strings.Success); this.Invoke(appendText, string.Format(" ({0})", this.stopwatch.Elapsed.ToString())); this.Invoke(appendText, Environment.NewLine); } if ((mode & VerifyMode.VerifyConfiguration) == VerifyMode.VerifyConfiguration) { // // restart the stopwatch // this.stopwatch.Reset(); this.stopwatch.Start(); // // display message // this.Invoke(appendText, "Verifying configuration bits..."); // // verify configuration memory // this.programmer.Verify(this.selectedDevice.ConfigAddress, this.configMemory, this.selectedDevice.ConfigBytes / 3, 0x000000, true, this.selectedDevice); // // stop the stopwatch // this.stopwatch.Stop(); // // display success mmessage // this.Invoke(appendText, Strings.Success); this.Invoke(appendText, string.Format(" ({0})", this.stopwatch.Elapsed.ToString())); this.Invoke(appendText, Environment.NewLine); } } catch (ThreadAbortException) { // // display abort message // //this.Invoke(appendText, Strings.Aborted); //this.Invoke(appendText, Environment.NewLine); } catch (AddressException) { // // display error // this.Invoke(appendText, Strings.Failed); this.Invoke(appendText, Environment.NewLine); this.Invoke(appendText, Strings.AddressError); this.Invoke(appendText, Environment.NewLine); } catch (VerifyException) { // // display error // this.Invoke(appendText, Strings.Failed); this.Invoke(appendText, Environment.NewLine); } catch (Exception ex) { // // display error // this.Invoke(appendText, Strings.Failed); this.Invoke(appendText, Environment.NewLine); this.Invoke(appendText, ex.Message); this.Invoke(appendText, Environment.NewLine); } finally { // // stop the stopwatch // if (this.stopwatch.IsRunning) { this.stopwatch.Stop(); } // // update controls // this.Invoke(updateControls); } }
/// <summary> /// Sets the certificate verification mode and callback - calls SSL_CTX_set_verify /// </summary> /// <param name="mode"></param> /// <param name="callback"></param> public void SetVerify(VerifyMode mode, RemoteCertificateValidationHandler callback) { OnVerifyCert = callback; Native.SSL_CTX_set_verify(ptr, (int)mode, callback == null ? null : _ptrOnVerifyCertThunk); }
/// <summary> /// Verifies the file. /// </summary> /// <param name="baseDirectory">The base directory.</param> /// <param name="verifyData">The verify data.</param> /// <param name="verificationMode">The verification mode.</param> /// <returns></returns> public static bool VerifyFile(string baseDirectory, IVerifiableFile verifyData, VerifyMode verificationMode) { if (string.IsNullOrEmpty(baseDirectory)) { throw new ArgumentNullException("baseDirectory"); } else if (verifyData == null) { throw new ArgumentNullException("verifyData"); } string path = QQnPath.Combine(baseDirectory, verifyData.Filename); FileInfo fif = new FileInfo(path); if (!fif.Exists) { return(false); } if (verificationMode < VerifyMode.Time) { return(true); } bool hasTime = verifyData.LastWriteTimeUtc.HasValue; bool timeFailed = hasTime && fif.LastWriteTimeUtc != verifyData.LastWriteTimeUtc.Value; if (timeFailed && verificationMode == VerifyMode.Time) { return(false); } if (verificationMode < VerifyMode.TimeSize) { return(true); } bool hasSize = (verifyData.FileSize >= 0); bool sizeFailed = hasSize && fif.Length != verifyData.FileSize; if ((timeFailed || sizeFailed) && verificationMode == VerifyMode.TimeSize) { return(false); } if (verificationMode < VerifyMode.FileHash) { return(true); } if (!string.IsNullOrEmpty(verifyData.FileHash) && !QQnCryptoHelpers.VerifyFileHash(fif.FullName, verifyData.FileHash)) { return(false); } return(true); }
public Idcard(VerifyMode mode, DateTime maxDate) { Mode = mode; MaxDate = maxDate; }
/// <summary> /// Sets the certificate verification mode and callback - calls SSL_CTX_set_verify /// </summary> /// <param name="mode"></param> /// <param name="callback"></param> public void SetVerify(VerifyMode mode, RemoteCertificateValidationHandler callback) { this._verifyCertCallbackThunk = new VerifyCertCallbackThunk(callback); Native.SSL_CTX_set_verify(this.ptr, (int)mode, _verifyCertCallbackThunk.Callback); }
public VerifyEventArgs(VerifyMode mode, Image image) { this.VerifyMode = mode; this.VerifyImage = image; this.VerifyCode = string.Empty; }
public VerificationRequest() { this.verifyMode = VerifyMode.Verify; this.selectiveVerifyModuleNames = new List<string>(); }
Idcard(VerifyMode mode) : this(mode, DateTime.MaxValue) { }
bool Has(VerifyMode mode) { return((Mode & mode) == mode); }
public VerificationRequest() { verifyMode = VerifyMode.Verify; selectiveVerifyModuleNames = new List <string>(); }
public void SetCertificateVerify (VerifyMode mode, RemoteValidationCallback callback) { this.managed_cert_callback = callback; if (callback != null) verify_callback = new VerifyCallback (OnVerifyCallback); native_openssl_set_certificate_verify (handle, (int)mode, verify_callback, null, 10); }
bool Has(VerifyMode mode) { return (Mode & mode) == mode; }