use of com.axelor.apps.bankpayment.db.EbicsBank in project axelor-open-suite by axelor.
the class EbicsController method addCertificates.
public void addCertificates(ActionRequest request, ActionResponse response) throws AxelorException {
Context context = request.getContext();
EbicsBank ebicsBank = (EbicsBank) context.get("ebicsBank");
ebicsBank = Beans.get(EbicsBankRepository.class).find(ebicsBank.getId());
try {
X509Certificate certificate = Beans.get(EbicsCertificateService.class).convertToCertificate((String) context.get("certificateE002"));
Beans.get(EbicsCertificateService.class).createCertificate(certificate, ebicsBank, EbicsCertificateRepository.TYPE_ENCRYPTION);
certificate = Beans.get(EbicsCertificateService.class).convertToCertificate((String) context.get("certificateX002"));
Beans.get(EbicsCertificateService.class).createCertificate(certificate, ebicsBank, EbicsCertificateRepository.TYPE_AUTHENTICATION);
} catch (CertificateException | IOException e) {
e.printStackTrace();
throw new AxelorException(e, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get("Error in adding bank certificate"));
}
response.setCanClose(true);
}
use of com.axelor.apps.bankpayment.db.EbicsBank in project axelor-open-suite by axelor.
the class CertificateManager method createE002Certificate.
/**
* Creates the encryption certificate.
*
* @param the expiration date of a the certificate.
* @throws GeneralSecurityException
* @throws IOException
*/
public void createE002Certificate(Date end) throws GeneralSecurityException, IOException {
KeyPair keypair = KeyUtil.makeKeyPair(X509Constants.EBICS_KEY_SIZE);
EbicsBank ebicsBank = user.getEbicsPartner().getEbicsBank();
e002Certificate = generator.generateE002Certificate(keypair, user.getDn(), new Date(), end, ebicsBank.getUseX509ExtensionBasicConstraints(), ebicsBank.getUseX509ExtensionSubjectKeyIdentifier(), ebicsBank.getUseX509ExtensionAuthorityKeyIdentifier(), ebicsBank.getUseX509ExtensionExtendedKeyUsage());
e002PrivateKey = keypair.getPrivate();
}
Aggregations