public void ActivateServiceAgreement(string activationCode) { if (KeystoreFile.Exists) { throw new ArgumentException("Keystore file " + KeystoreFile.FullName + " already exists - you have already activated."); } GetBankCertificateIfRequired(); var certificateRequestGenerator = new CertificateRequestGenerator(FunctionIdentifier, activationCode); var pkcs10Bytes = certificateRequestGenerator.GetPkcs10Bytes(); var request = new activateServiceAgreement(); var activationAgreement = new activationAgreement { activationCode = Encoding.UTF8.GetBytes(activationCode), certificateRequest = pkcs10Bytes }; request.activationAgreement = activationAgreement; var technicalAddress = new technicalAddress(); var activationHeader = BuildActivationHeader(); var response = CreateClient().activateServiceAgreement(ref technicalAddress, ref activationHeader, request); var pemBlock = Encoding.UTF8.GetString(response.corporateMessage.content); ReceiveAndValidateCertificates(pemBlock, certificateRequestGenerator); }
/// <summary> /// Will renew the current customer certificate, and issue a new one. /// </summary> /// <param name="newKeystoreFile">The new PKCS#12 file will be saved here</param> /// <param name="newKeystorePassword">Password to protect new PKCS#12 file</param> public void RenewCustomerCertificate(FileInfo newKeystoreFile, string newKeystorePassword) { if (newKeystoreFile.Exists) { throw new ArgumentException("Keystore file " + newKeystoreFile.FullName + " already exists!"); } GetBankCertificateIfRequired(); var request = new renewCustomerCertificate(); var certificateRequestGenerator = new CertificateRequestGenerator(FunctionIdentifier); var pkcs10Bytes = certificateRequestGenerator.GetPkcs10Bytes(); request.certificateRequestMessage = new certificateRequestMessage { certificateRequest = pkcs10Bytes }; var client = CreateClient(); var technicalAddress = new technicalAddress(); var serviceHeader = BuildServiceHeader(); var response = client.renewCustomerCertificate(ref technicalAddress, ref serviceHeader, request); var pemBlock = Encoding.UTF8.GetString(response.corporateMessage.content); var pkcs12 = ToPkcs12Bytes(pemBlock, certificateRequestGenerator, newKeystorePassword); File.WriteAllBytes(newKeystoreFile.FullName, pkcs12); }
public getDebitCreditNotificationResponse GetDebitCreditNotification() { GetBankCertificateIfRequired(); var request = new getDebitCreditNotification(); var technicalAddress = new technicalAddress(); var serviceHeader = BuildServiceHeader(); var client = CreateClient(); return(client.getDebitCreditNotification(ref technicalAddress, ref serviceHeader, request)); }
public getCustomerAccountReportResponse GetCustomerAccountReport() { GetBankCertificateIfRequired(); var request = new getCustomerAccountReport(); var technicalAddress = new technicalAddress(); var serviceHeader = BuildServiceHeader(); var client = CreateClient(); return(client.getCustomerAccountReport(ref technicalAddress, ref serviceHeader, request)); }
public void GetBankCertificateIfRequired() { if (CertificateStore.Instance.ServiceCertificate != null) { return; } var client = new SecuredCorporateServiceClient(new EndpointAddress(ServiceProvider.Endpoint)); var technicalAddress = new technicalAddress(); var activationHeader = BuildActivationHeader(); var request = new getBankCertificate(); var response = client.getBankCertificate(ref technicalAddress, ref activationHeader, request); var chain = ReadCertificateChain(response); new CertificateChainValidator(CertificateStore.Instance.TrustedCaCertificates).AssertValid(chain); CertificateStore.Instance.ServiceCertificate = chain[0]; }
public paymentResponse TransferPayment(string xmlPayload) { GetBankCertificateIfRequired(); var request = new transferPayment { paymentMessage = new paymentMessage { format = "ISO20022", mimeType = "text/xml", compressed = "0", content = Encoding.UTF8.GetBytes(xmlPayload) } }; var technicalAddress = new technicalAddress(); var serviceHeader = BuildServiceHeader(); var response = CreateClient().transferPayments(ref technicalAddress, ref serviceHeader, request); return(response.paymentResponse); }