Search in sources :

Example 6 with EbicsCertificate

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

the class EbicsCertificateService method updateEditionDate.

@Transactional
public void updateEditionDate(EbicsUser user) {
    LocalDateTime now = appBaseService.getTodayDateTime().toLocalDateTime();
    EbicsCertificate certificate = user.getA005Certificate();
    if (certificate != null) {
        certificate.setInitLetterEditionDate(now);
        certRepo.save(certificate);
    }
    certificate = user.getE002Certificate();
    if (certificate != null) {
        certificate.setInitLetterEditionDate(now);
        certRepo.save(certificate);
    }
    certificate = user.getX002Certificate();
    if (certificate != null) {
        certificate.setInitLetterEditionDate(now);
        certRepo.save(certificate);
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) EbicsCertificate(com.axelor.apps.bankpayment.db.EbicsCertificate) Transactional(com.google.inject.persist.Transactional)

Example 7 with EbicsCertificate

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

the class EbicsController method loadCertificate.

public void loadCertificate(ActionRequest request, ActionResponse response) throws AxelorException, CertificateEncodingException, IOException {
    EbicsCertificate ebicsCertificate = request.getContext().asType(EbicsCertificate.class);
    ebicsCertificate = Beans.get(EbicsCertificateRepository.class).find(ebicsCertificate.getId());
    byte[] certs = ebicsCertificate.getCertificate();
    if (certs != null && certs.length > 0) {
        X509Certificate certificate = EbicsCertificateService.getCertificate(certs, ebicsCertificate.getTypeSelect());
        ebicsCertificate = Beans.get(EbicsCertificateService.class).updateCertificate(certificate, ebicsCertificate, true);
        response.setValue("validFrom", ebicsCertificate.getValidFrom());
        response.setValue("validTo", ebicsCertificate.getValidTo());
        response.setValue("issuer", ebicsCertificate.getIssuer());
        response.setValue("subject", ebicsCertificate.getSubject());
        response.setValue("publicKeyModulus", ebicsCertificate.getPublicKeyModulus());
        response.setValue("publicKeyExponent", ebicsCertificate.getPublicKeyExponent());
        response.setValue("fullName", ebicsCertificate.getFullName());
        response.setValue("pemString", ebicsCertificate.getPemString());
        response.setValue("sha2has", ebicsCertificate.getSha2has());
        response.setValue("serial", ebicsCertificate.getSerial());
    }
}
Also used : EbicsCertificate(com.axelor.apps.bankpayment.db.EbicsCertificate) X509Certificate(java.security.cert.X509Certificate)

Example 8 with EbicsCertificate

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

the class HIARequestOrderDataElement method build.

@Override
public void build() {
    HIARequestOrderDataType request;
    AuthenticationPubKeyInfoType authenticationPubKeyInfo;
    EncryptionPubKeyInfoType encryptionPubKeyInfo;
    PubKeyValueType encryptionPubKeyValue;
    X509DataType encryptionX509Data = null;
    RSAKeyValueType encryptionRsaKeyValue;
    PubKeyValueType authPubKeyValue;
    X509DataType authX509Data = null;
    RSAKeyValueType authRsaKeyValue;
    EbicsCertificate certificate = session.getUser().getE002Certificate();
    encryptionX509Data = EbicsXmlFactory.createX509DataType(session.getUser().getDn(), certificate.getCertificate());
    // Include Certificate issuer and serial ?
    // encryptionX509Data = EbicsXmlFactory.createX509DataType(session.getUser().getDn(),
    // certificate.getCertificate(), certificate.getIssuer(),   new
    // BigInteger(certificate.getSerial(), 16));
    encryptionRsaKeyValue = EbicsXmlFactory.createRSAKeyValueType(new BigInteger(certificate.getPublicKeyExponent(), 16).toByteArray(), new BigInteger(certificate.getPublicKeyModulus(), 16).toByteArray());
    encryptionPubKeyValue = EbicsXmlFactory.createH003PubKeyValueType(encryptionRsaKeyValue, Calendar.getInstance());
    encryptionPubKeyInfo = EbicsXmlFactory.createEncryptionPubKeyInfoType("E002", encryptionPubKeyValue, encryptionX509Data);
    certificate = session.getUser().getX002Certificate();
    authX509Data = EbicsXmlFactory.createX509DataType(session.getUser().getDn(), certificate.getCertificate());
    // Include Certificate issuer and serial ?
    // authX509Data = EbicsXmlFactory.createX509DataType(session.getUser().getDn(),
    // certificate.getCertificate(), certificate.getIssuer(),   new
    // BigInteger(certificate.getSerial(), 16));
    authRsaKeyValue = EbicsXmlFactory.createRSAKeyValueType(new BigInteger(certificate.getPublicKeyExponent(), 16).toByteArray(), new BigInteger(certificate.getPublicKeyModulus(), 16).toByteArray());
    authPubKeyValue = EbicsXmlFactory.createH003PubKeyValueType(authRsaKeyValue, Calendar.getInstance());
    authenticationPubKeyInfo = EbicsXmlFactory.createAuthenticationPubKeyInfoType("X002", authPubKeyValue, authX509Data);
    request = EbicsXmlFactory.createHIARequestOrderDataType(authenticationPubKeyInfo, encryptionPubKeyInfo, session.getUser().getEbicsPartner().getPartnerId(), session.getUser().getUserId());
    document = EbicsXmlFactory.createHIARequestOrderDataDocument(request);
}
Also used : X509DataType(com.axelor.apps.account.ebics.schema.xmldsig.X509DataType) EbicsCertificate(com.axelor.apps.bankpayment.db.EbicsCertificate) AuthenticationPubKeyInfoType(com.axelor.apps.account.ebics.schema.h003.AuthenticationPubKeyInfoType) PubKeyValueType(com.axelor.apps.account.ebics.schema.h003.PubKeyValueType) BigInteger(java.math.BigInteger) HIARequestOrderDataType(com.axelor.apps.account.ebics.schema.h003.HIARequestOrderDataType) RSAKeyValueType(com.axelor.apps.account.ebics.schema.xmldsig.RSAKeyValueType) EncryptionPubKeyInfoType(com.axelor.apps.account.ebics.schema.h003.EncryptionPubKeyInfoType)

Example 9 with EbicsCertificate

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

the class SignaturePubKeyOrderDataElement method build.

@Override
public void build() throws AxelorException {
    SignaturePubKeyInfoType signaturePubKeyInfo;
    X509DataType x509Data;
    RSAKeyValueType rsaKeyValue;
    PubKeyValueType pubKeyValue;
    SignaturePubKeyOrderDataType signaturePubKeyOrderData;
    EbicsCertificate certificate = session.getUser().getA005Certificate();
    System.out.println("Certificate : " + new String(certificate.getCertificate()));
    System.out.println("Certificate size : " + certificate.getCertificate().length);
    EbicsCertificate ebicsEertificate = session.getUser().getA005Certificate();
    // Include certificate issuer and serial (certificate information)
    // x509Data = EbicsXmlFactory.createX509DataType(ebicsEertificate.getSubject(), certEncoded,
    // ebicsEertificate.getIssuer(),  new BigInteger(ebicsEertificate.getSerial(), 16));
    x509Data = EbicsXmlFactory.createX509DataType(ebicsEertificate.getSubject(), ebicsEertificate.getCertificate());
    rsaKeyValue = EbicsXmlFactory.createRSAKeyValueType(new BigInteger(ebicsEertificate.getPublicKeyExponent(), 16).toByteArray(), new BigInteger(ebicsEertificate.getPublicKeyModulus(), 16).toByteArray());
    pubKeyValue = EbicsXmlFactory.createPubKeyValueType(rsaKeyValue, Calendar.getInstance());
    signaturePubKeyInfo = EbicsXmlFactory.createSignaturePubKeyInfoType(x509Data, pubKeyValue, "A005");
    signaturePubKeyOrderData = EbicsXmlFactory.createSignaturePubKeyOrderData(signaturePubKeyInfo, session.getUser().getEbicsPartner().getPartnerId(), session.getUser().getUserId());
    document = EbicsXmlFactory.createSignaturePubKeyOrderDataDocument(signaturePubKeyOrderData);
}
Also used : X509DataType(com.axelor.apps.account.ebics.schema.xmldsig.X509DataType) EbicsCertificate(com.axelor.apps.bankpayment.db.EbicsCertificate) PubKeyValueType(com.axelor.apps.account.ebics.schema.s001.PubKeyValueType) SignaturePubKeyOrderDataType(com.axelor.apps.account.ebics.schema.s001.SignaturePubKeyOrderDataType) BigInteger(java.math.BigInteger) RSAKeyValueType(com.axelor.apps.account.ebics.schema.xmldsig.RSAKeyValueType) SignaturePubKeyInfoType(com.axelor.apps.account.ebics.schema.s001.SignaturePubKeyInfoType)

Aggregations

EbicsCertificate (com.axelor.apps.bankpayment.db.EbicsCertificate)9 RSAKeyValueType (com.axelor.apps.account.ebics.schema.xmldsig.RSAKeyValueType)2 X509DataType (com.axelor.apps.account.ebics.schema.xmldsig.X509DataType)2 EbicsUser (com.axelor.apps.bankpayment.db.EbicsUser)2 Transactional (com.google.inject.persist.Transactional)2 BigInteger (java.math.BigInteger)2 AuthenticationPubKeyInfoType (com.axelor.apps.account.ebics.schema.h003.AuthenticationPubKeyInfoType)1 EncryptionPubKeyInfoType (com.axelor.apps.account.ebics.schema.h003.EncryptionPubKeyInfoType)1 HIARequestOrderDataType (com.axelor.apps.account.ebics.schema.h003.HIARequestOrderDataType)1 PubKeyValueType (com.axelor.apps.account.ebics.schema.h003.PubKeyValueType)1 PubKeyValueType (com.axelor.apps.account.ebics.schema.s001.PubKeyValueType)1 SignaturePubKeyInfoType (com.axelor.apps.account.ebics.schema.s001.SignaturePubKeyInfoType)1 SignaturePubKeyOrderDataType (com.axelor.apps.account.ebics.schema.s001.SignaturePubKeyOrderDataType)1 EbicsBank (com.axelor.apps.bankpayment.db.EbicsBank)1 EbicsPartner (com.axelor.apps.bankpayment.db.EbicsPartner)1 EbicsUserRepository (com.axelor.apps.bankpayment.db.repo.EbicsUserRepository)1 EbicsCertificateService (com.axelor.apps.bankpayment.ebics.service.EbicsCertificateService)1 Bank (com.axelor.apps.base.db.Bank)1 AppBaseService (com.axelor.apps.base.service.app.AppBaseService)1 Template (com.axelor.apps.message.db.Template)1