Search in sources :

Example 1 with EbicsCertificate

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

the class BatchEbicsCertificate method process.

@Override
protected void process() {
    Template template = templateRepo.find(bankPaymentBatch.getTemplate().getId());
    List<EbicsUser> users = Beans.get(EbicsUserRepository.class).all().filter("self.a005Certificate != null OR self.e002Certificate != null OR self.x002Certificate != null").fetch();
    Set<EbicsCertificate> certificatesSet = new HashSet<>();
    LocalDate today = Beans.get(AppBaseService.class).getTodayDate(bankPaymentBatch.getCompany());
    LocalDate commingDay = today.plusDays(bankPaymentBatch.getDaysNbr());
    for (EbicsUser user : users) {
        if (user.getA005Certificate() != null && user.getA005Certificate().getValidTo().isBefore(commingDay)) {
            certificatesSet.add(user.getA005Certificate());
        }
        if (user.getE002Certificate() != null && user.getE002Certificate().getValidTo().isBefore(commingDay)) {
            certificatesSet.add(user.getE002Certificate());
        }
        if (user.getX002Certificate() != null && user.getX002Certificate().getValidTo().isBefore(commingDay)) {
            certificatesSet.add(user.getX002Certificate());
        }
    }
    certificatesSet.addAll(Beans.get(EbicsCertificateRepository.class).all().filter("self.ebicsBank != null AND self.validTo <= ?1", commingDay).fetch());
    for (EbicsCertificate certificate : certificatesSet) {
        certificate.addBatchSetItem(batchRepo.find(batch.getId()));
        try {
            templateMessageService.generateMessage(certificate, template);
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | AxelorException | IOException e) {
            e.printStackTrace();
        }
    }
}
Also used : EbicsUserRepository(com.axelor.apps.bankpayment.db.repo.EbicsUserRepository) AxelorException(com.axelor.exception.AxelorException) EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser) IOException(java.io.IOException) LocalDate(java.time.LocalDate) Template(com.axelor.apps.message.db.Template) EbicsCertificate(com.axelor.apps.bankpayment.db.EbicsCertificate) AppBaseService(com.axelor.apps.base.service.app.AppBaseService) HashSet(java.util.HashSet)

Example 2 with EbicsCertificate

use of com.axelor.apps.bankpayment.db.EbicsCertificate 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 3 with EbicsCertificate

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

the class UserSignatureVerify method loadCertificate.

public void loadCertificate() {
    EbicsCertificate certificate = user.getA005Certificate();
    this.modulus = certificate.getPublicKeyModulus();
    this.exponent = certificate.getPublicKeyExponent();
}
Also used : EbicsCertificate(com.axelor.apps.bankpayment.db.EbicsCertificate)

Example 4 with EbicsCertificate

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

the class CertificateManager method updateCertificate.

private EbicsCertificate updateCertificate(X509Certificate certificate, EbicsCertificate cert, byte[] privateKey, String type) throws CertificateEncodingException, IOException {
    if (cert == null) {
        cert = new EbicsCertificate();
        cert.setTypeSelect(type);
    }
    EbicsCertificateService certificateService = Beans.get(EbicsCertificateService.class);
    cert = certificateService.updateCertificate(certificate, cert, true);
    cert.setPrivateKey(privateKey);
    return cert;
}
Also used : EbicsCertificate(com.axelor.apps.bankpayment.db.EbicsCertificate) EbicsCertificateService(com.axelor.apps.bankpayment.ebics.service.EbicsCertificateService)

Example 5 with EbicsCertificate

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

the class EbicsCertificateService method createCertificate.

@Transactional
public EbicsCertificate createCertificate(X509Certificate certificate, EbicsBank bank, String type) throws CertificateEncodingException, IOException {
    EbicsCertificate cert = getEbicsCertificate(bank, type);
    if (cert == null) {
        log.debug("Creating bank certicate for bank: {}, type: {}", bank.getName(), type);
        cert = new EbicsCertificate();
        cert.setEbicsBank(bank);
        cert.setTypeSelect(type);
    }
    cert = updateCertificate(certificate, cert, true);
    return certRepo.save(cert);
}
Also used : EbicsCertificate(com.axelor.apps.bankpayment.db.EbicsCertificate) Transactional(com.google.inject.persist.Transactional)

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