Search in sources :

Example 1 with EbicsBank

use of com.axelor.apps.bankpayment.db.EbicsBank in project axelor-open-suite by axelor.

the class CertificateManager method createX002Certificate.

/**
 * Creates the authentication certificate.
 *
 * @param the expiration date of a the certificate.
 * @throws GeneralSecurityException
 * @throws IOException
 */
public void createX002Certificate(Date end) throws GeneralSecurityException, IOException {
    KeyPair keypair = KeyUtil.makeKeyPair(X509Constants.EBICS_KEY_SIZE);
    EbicsBank ebicsBank = user.getEbicsPartner().getEbicsBank();
    x002Certificate = generator.generateX002Certificate(keypair, user.getDn(), new Date(), end, ebicsBank.getUseX509ExtensionBasicConstraints(), ebicsBank.getUseX509ExtensionSubjectKeyIdentifier(), ebicsBank.getUseX509ExtensionAuthorityKeyIdentifier(), ebicsBank.getUseX509ExtensionExtendedKeyUsage());
    x002PrivateKey = keypair.getPrivate();
}
Also used : KeyPair(java.security.KeyPair) Date(java.util.Date) EbicsBank(com.axelor.apps.bankpayment.db.EbicsBank)

Example 2 with EbicsBank

use of com.axelor.apps.bankpayment.db.EbicsBank in project axelor-open-suite by axelor.

the class CertificateManager method createA005Certificate.

/**
 * Creates the signature certificate.
 *
 * @param the expiration date of a the certificate.
 * @throws GeneralSecurityException
 * @throws IOException
 */
public void createA005Certificate(Date end) throws GeneralSecurityException, IOException {
    KeyPair keypair = KeyUtil.makeKeyPair(X509Constants.EBICS_KEY_SIZE);
    EbicsBank ebicsBank = user.getEbicsPartner().getEbicsBank();
    a005Certificate = generator.generateA005Certificate(keypair, user.getDn(), new Date(), end, ebicsBank.getUseX509ExtensionBasicConstraints(), ebicsBank.getUseX509ExtensionSubjectKeyIdentifier(), ebicsBank.getUseX509ExtensionAuthorityKeyIdentifier(), ebicsBank.getUseX509ExtensionExtendedKeyUsage());
    a005PrivateKey = keypair.getPrivate();
}
Also used : KeyPair(java.security.KeyPair) Date(java.util.Date) EbicsBank(com.axelor.apps.bankpayment.db.EbicsBank)

Example 3 with EbicsBank

use of com.axelor.apps.bankpayment.db.EbicsBank in project axelor-open-suite by axelor.

the class HttpRequestSender method send.

/**
 * Sends the request contained in the <code>ContentFactory</code>. The <code>ContentFactory</code>
 * will deliver the request as an <code>InputStream</code>.
 *
 * @param request the ebics request
 * @return the HTTP return code
 * @throws AxelorException
 */
public final int send(ContentFactory request) throws IOException, AxelorException {
    EbicsBank bank = session.getUser().getEbicsPartner().getEbicsBank();
    String url = bank.getUrl();
    if (url == null || !url.startsWith("http://") && !url.startsWith("https://")) {
        throw new AxelorException(TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.EBICS_INVALID_BANK_URL));
    }
    if (bank.getProtocolSelect().equals("ssl")) {
        return sendSSL(request, bank);
    } else {
        return sendTLS(request, bank);
    }
}
Also used : AxelorException(com.axelor.exception.AxelorException) EbicsBank(com.axelor.apps.bankpayment.db.EbicsBank)

Example 4 with EbicsBank

use of com.axelor.apps.bankpayment.db.EbicsBank in project axelor-open-suite by axelor.

the class EbicsUserImport method importEbicsUser.

public Object importEbicsUser(Object bean, Map<String, Object> context) {
    assert bean instanceof EbicsUser;
    EbicsUser user = (EbicsUser) bean;
    updateCertificate(user.getA005Certificate());
    updateCertificate(user.getE002Certificate());
    updateCertificate(user.getX002Certificate());
    EbicsPartner partner = user.getEbicsPartner();
    if (partner != null) {
        EbicsBank ebicsBank = partner.getEbicsBank();
        if (ebicsBank.getVersion() == 0) {
            for (EbicsCertificate cert : ebicsBank.getEbicsCertificateList()) {
                updateCertificate(cert);
            }
            Bank bank = ebicsBank.getBank();
            if (bank.getVersion() == 0) {
                bankService.computeFullName(bank);
                bankService.splitBic(bank);
            }
        }
    }
    return user;
}
Also used : EbicsCertificate(com.axelor.apps.bankpayment.db.EbicsCertificate) EbicsBank(com.axelor.apps.bankpayment.db.EbicsBank) Bank(com.axelor.apps.base.db.Bank) EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser) EbicsPartner(com.axelor.apps.bankpayment.db.EbicsPartner) EbicsBank(com.axelor.apps.bankpayment.db.EbicsBank)

Example 5 with EbicsBank

use of com.axelor.apps.bankpayment.db.EbicsBank in project axelor-open-suite by axelor.

the class EbicsController method confirmCertificates.

private void confirmCertificates(EbicsUser user, X509Certificate[] certificates, ActionResponse response) {
    try {
        EbicsBank bank = user.getEbicsPartner().getEbicsBank();
        response.setView(ActionView.define("Confirm certificates").model("com.axelor.apps.bankpayment.db.EbicsCertificate").add("form", "ebics-certificate-confirmation-form").param("show-toolbar", "false").param("show-confirm", "false").param("popup-save", "false").param("popup", "true").context("ebicsBank", bank).context("url", bank.getUrl()).context("hostId", bank.getHostId()).context("e002Hash", DigestUtils.sha256Hex(certificates[0].getEncoded()).toUpperCase()).context("x002Hash", DigestUtils.sha256Hex(certificates[1].getEncoded()).toUpperCase()).context("certificateE002", Beans.get(EbicsCertificateService.class).convertToPEMString(certificates[0])).context("certificateX002", Beans.get(EbicsCertificateService.class).convertToPEMString(certificates[1])).map());
    } catch (Exception e) {
        response.setFlash("Error in certificate confirmation ");
    }
}
Also used : EbicsCertificateService(com.axelor.apps.bankpayment.ebics.service.EbicsCertificateService) GeneralSecurityException(java.security.GeneralSecurityException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) CertificateEncodingException(java.security.cert.CertificateEncodingException) 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