Search in sources :

Example 1 with EbicsUser

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

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

the class BankOrderController method validate.

public void validate(ActionRequest request, ActionResponse response) throws AxelorException {
    Context context = request.getContext();
    BankOrderService bankOrderService = Beans.get(BankOrderService.class);
    BankOrder bankOrder = context.asType(BankOrder.class);
    bankOrder = Beans.get(BankOrderRepository.class).find(bankOrder.getId());
    try {
        EbicsUser ebicsUser = bankOrder.getSignatoryEbicsUser();
        if (ebicsUser == null) {
            response.setError(I18n.get(IExceptionMessage.EBICS_MISSING_NAME));
        } else {
            if (ebicsUser.getEbicsPartner().getEbicsTypeSelect() == EbicsPartnerRepository.EBICS_TYPE_TS) {
                bankOrderService.validate(bankOrder);
            } else {
                if (context.get("password") == null) {
                    response.setError(I18n.get(IExceptionMessage.EBICS_WRONG_PASSWORD));
                }
                if (context.get("password") != null) {
                    String password = (String) context.get("password");
                    if (ebicsUser.getPassword() == null || !ebicsUser.getPassword().equals(password)) {
                        response.setValue("password", "");
                        response.setError(I18n.get(IExceptionMessage.EBICS_WRONG_PASSWORD));
                    } else {
                        bankOrderService.validate(bankOrder);
                    }
                }
                response.setReload(true);
            }
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Context(com.axelor.rpc.Context) EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser) BankOrderService(com.axelor.apps.bankpayment.service.bankorder.BankOrderService) BankOrder(com.axelor.apps.bankpayment.db.BankOrder) AxelorException(com.axelor.exception.AxelorException)

Example 3 with EbicsUser

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

the class EbicsController method updateEditionDate.

public void updateEditionDate(ActionRequest request, ActionResponse response) {
    EbicsUser ebicsUser = request.getContext().asType(EbicsUser.class);
    ebicsUser = Beans.get(EbicsUserRepository.class).find(ebicsUser.getId());
    Beans.get(EbicsCertificateService.class).updateEditionDate(ebicsUser);
    response.setReload(true);
}
Also used : EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser) EbicsCertificateService(com.axelor.apps.bankpayment.ebics.service.EbicsCertificateService)

Example 4 with EbicsUser

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

the class EbicsController method sendHPBRequest.

public void sendHPBRequest(ActionRequest request, ActionResponse response) {
    EbicsUser ebicsUser = Beans.get(EbicsUserRepository.class).find(request.getContext().asType(EbicsUser.class).getId());
    try {
        X509Certificate[] certificates = Beans.get(EbicsService.class).sendHPBRequest(ebicsUser, null);
        confirmCertificates(ebicsUser, certificates, response);
    } catch (Exception e) {
        e.printStackTrace();
        response.setFlash(stripClass(e.getLocalizedMessage()));
    }
    response.setReload(true);
}
Also used : EbicsUserRepository(com.axelor.apps.bankpayment.db.repo.EbicsUserRepository) EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser) X509Certificate(java.security.cert.X509Certificate) EbicsService(com.axelor.apps.bankpayment.ebics.service.EbicsService) GeneralSecurityException(java.security.GeneralSecurityException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) CertificateEncodingException(java.security.cert.CertificateEncodingException)

Example 5 with EbicsUser

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

the class EbicsController method sendSPRRequest.

public void sendSPRRequest(ActionRequest request, ActionResponse response) {
    EbicsUser ebicsUser = Beans.get(EbicsUserRepository.class).find(request.getContext().asType(EbicsUser.class).getId());
    try {
        Beans.get(EbicsService.class).sendSPRRequest(ebicsUser, null);
    } catch (Exception e) {
        e.printStackTrace();
        response.setFlash(stripClass(e.getLocalizedMessage()));
    }
    response.setReload(true);
}
Also used : EbicsUserRepository(com.axelor.apps.bankpayment.db.repo.EbicsUserRepository) EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser) EbicsService(com.axelor.apps.bankpayment.ebics.service.EbicsService) GeneralSecurityException(java.security.GeneralSecurityException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) CertificateEncodingException(java.security.cert.CertificateEncodingException)

Aggregations

EbicsUser (com.axelor.apps.bankpayment.db.EbicsUser)27 AxelorException (com.axelor.exception.AxelorException)13 EbicsUserRepository (com.axelor.apps.bankpayment.db.repo.EbicsUserRepository)12 IOException (java.io.IOException)12 GeneralSecurityException (java.security.GeneralSecurityException)10 EbicsService (com.axelor.apps.bankpayment.ebics.service.EbicsService)9 CertificateEncodingException (java.security.cert.CertificateEncodingException)9 CertificateException (java.security.cert.CertificateException)9 EbicsPartner (com.axelor.apps.bankpayment.db.EbicsPartner)6 OrderAttribute (com.axelor.apps.bankpayment.ebics.client.OrderAttribute)4 EbicsRequest (com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest)3 Body (com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Body)3 Header (com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Header)3 MutableHeaderType (com.axelor.apps.account.ebics.schema.h003.MutableHeaderType)3 StaticHeaderOrderDetailsType (com.axelor.apps.account.ebics.schema.h003.StaticHeaderOrderDetailsType)3 OrderType (com.axelor.apps.account.ebics.schema.h003.StaticHeaderOrderDetailsType.OrderType)3 StaticHeaderType (com.axelor.apps.account.ebics.schema.h003.StaticHeaderType)3 BankPubKeyDigests (com.axelor.apps.account.ebics.schema.h003.StaticHeaderType.BankPubKeyDigests)3 Authentication (com.axelor.apps.account.ebics.schema.h003.StaticHeaderType.BankPubKeyDigests.Authentication)3 Encryption (com.axelor.apps.account.ebics.schema.h003.StaticHeaderType.BankPubKeyDigests.Encryption)3