Search in sources :

Example 1 with CertificateManager

use of com.axelor.apps.bankpayment.ebics.certificate.CertificateManager in project axelor-open-suite by axelor.

the class EbicsController method generateCertificate.

@Transactional
public void generateCertificate(ActionRequest request, ActionResponse response) {
    EbicsUser ebicsUser = Beans.get(EbicsUserRepository.class).find(request.getContext().asType(EbicsUser.class).getId());
    if (ebicsUser.getStatusSelect() != EbicsUserRepository.STATUS_WAITING_CERTIFICATE_CONFIG && ebicsUser.getStatusSelect() != EbicsUserRepository.STATUS_CERTIFICATES_SHOULD_BE_RENEWED) {
        return;
    }
    CertificateManager cm = new CertificateManager(ebicsUser);
    try {
        cm.create();
        ebicsUser.setStatusSelect(EbicsUserRepository.STATUS_WAITING_SENDING_SIGNATURE_CERTIFICATE);
        Beans.get(EbicsUserRepository.class).save(ebicsUser);
    } catch (GeneralSecurityException | IOException e) {
        e.printStackTrace();
    }
    response.setReload(true);
}
Also used : EbicsUserRepository(com.axelor.apps.bankpayment.db.repo.EbicsUserRepository) EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser) GeneralSecurityException(java.security.GeneralSecurityException) CertificateManager(com.axelor.apps.bankpayment.ebics.certificate.CertificateManager) IOException(java.io.IOException) Transactional(com.google.inject.persist.Transactional)

Aggregations

EbicsUser (com.axelor.apps.bankpayment.db.EbicsUser)1 EbicsUserRepository (com.axelor.apps.bankpayment.db.repo.EbicsUserRepository)1 CertificateManager (com.axelor.apps.bankpayment.ebics.certificate.CertificateManager)1 Transactional (com.google.inject.persist.Transactional)1 IOException (java.io.IOException)1 GeneralSecurityException (java.security.GeneralSecurityException)1