Search in sources :

Example 6 with EbicsBank

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);
}
Also used : Context(com.axelor.rpc.Context) AxelorException(com.axelor.exception.AxelorException) EbicsCertificateService(com.axelor.apps.bankpayment.ebics.service.EbicsCertificateService) CertificateException(java.security.cert.CertificateException) IOException(java.io.IOException) X509Certificate(java.security.cert.X509Certificate) EbicsBank(com.axelor.apps.bankpayment.db.EbicsBank)

Example 7 with EbicsBank

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();
}
Also used : KeyPair(java.security.KeyPair) Date(java.util.Date) EbicsBank(com.axelor.apps.bankpayment.db.EbicsBank)

Aggregations

EbicsBank (com.axelor.apps.bankpayment.db.EbicsBank)7 AxelorException (com.axelor.exception.AxelorException)3 KeyPair (java.security.KeyPair)3 Date (java.util.Date)3 EbicsCertificateService (com.axelor.apps.bankpayment.ebics.service.EbicsCertificateService)2 IOException (java.io.IOException)2 CertificateException (java.security.cert.CertificateException)2 EbicsCertificate (com.axelor.apps.bankpayment.db.EbicsCertificate)1 EbicsPartner (com.axelor.apps.bankpayment.db.EbicsPartner)1 EbicsUser (com.axelor.apps.bankpayment.db.EbicsUser)1 Bank (com.axelor.apps.base.db.Bank)1 Context (com.axelor.rpc.Context)1 GeneralSecurityException (java.security.GeneralSecurityException)1 CertificateEncodingException (java.security.cert.CertificateEncodingException)1 X509Certificate (java.security.cert.X509Certificate)1