Search in sources :

Example 16 with EbicsUser

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

the class EbicsController method sendHPDRequest.

public void sendHPDRequest(ActionRequest request, ActionResponse response) {
    EbicsUser ebicsUser = Beans.get(EbicsUserRepository.class).find(request.getContext().asType(EbicsUser.class).getId());
    try {
        Beans.get(EbicsService.class).sendHPDRequest(ebicsUser, null, null, null);
        downloadFile(response, ebicsUser);
    } catch (Exception e) {
        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)

Example 17 with EbicsUser

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

the class EbicsController method printCertificates.

public void printCertificates(ActionRequest request, ActionResponse response) throws AxelorException {
    EbicsUser ebicsUser = request.getContext().asType(EbicsUser.class);
    ArrayList<Long> certIds = new ArrayList<Long>();
    if (ebicsUser.getA005Certificate() != null) {
        certIds.add(ebicsUser.getA005Certificate().getId());
    }
    if (ebicsUser.getE002Certificate() != null) {
        certIds.add(ebicsUser.getE002Certificate().getId());
    }
    if (ebicsUser.getX002Certificate() != null) {
        certIds.add(ebicsUser.getX002Certificate().getId());
    }
    if (certIds.isEmpty()) {
        throw new AxelorException(ebicsUser, TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.EBICS_MISSING_CERTIFICATES));
    }
    String title = I18n.get("EbicsCertificate");
    ReportSettings report = ReportFactory.createReport(IReport.EBICS_CERTIFICATE, title + "-${date}${time}");
    report.addParam("CertificateId", Joiner.on(",").join(certIds));
    report.addParam("EbicsUserId", ebicsUser.getId());
    report.addParam("Timezone", ebicsUser.getAssociatedUser() != null ? ebicsUser.getAssociatedUser().getActiveCompany() : null);
    report.toAttach(ebicsUser);
    report.generate();
    response.setView(ActionView.define(title).add("html", report.getFileLink()).map());
}
Also used : AxelorException(com.axelor.exception.AxelorException) ReportSettings(com.axelor.apps.report.engine.ReportSettings) EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser) ArrayList(java.util.ArrayList)

Example 18 with EbicsUser

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

the class EbicsController method sendPTKRequest.

public void sendPTKRequest(ActionRequest request, ActionResponse response) {
    EbicsUser ebicsUser = Beans.get(EbicsUserRepository.class).find(request.getContext().asType(EbicsUser.class).getId());
    try {
        Beans.get(EbicsService.class).sendPTKRequest(ebicsUser, null, null, null);
        downloadFile(response, ebicsUser);
    } catch (Exception e) {
        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)

Example 19 with EbicsUser

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

Example 20 with EbicsUser

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

the class EbicsController method sendFULRequest.

public void sendFULRequest(ActionRequest request, ActionResponse response) {
    EbicsUser ebicsUser = Beans.get(EbicsUserRepository.class).find(request.getContext().asType(EbicsUser.class).getId());
    try {
        MetaFile testDataMetaFile = ebicsUser.getTestDataFile();
        MetaFile testSignatureMetaFile = ebicsUser.getTestSignatureFile();
        BankOrderFileFormat bankOrderFileFormat = ebicsUser.getTestBankOrderFileFormat();
        if (testDataMetaFile != null && bankOrderFileFormat != null) {
            File testSignatureFile = null;
            if (ebicsUser.getEbicsPartner().getEbicsTypeSelect() == EbicsPartnerRepository.EBICS_TYPE_TS && testSignatureMetaFile != null) {
                testSignatureFile = MetaFiles.getPath(testSignatureMetaFile).toFile();
            }
            Beans.get(EbicsService.class).sendFULRequest(ebicsUser, ebicsUser.getTestSignatoryEbicsUser(), null, MetaFiles.getPath(testDataMetaFile).toFile(), bankOrderFileFormat, testSignatureFile);
        } else {
            response.setFlash(I18n.get(IExceptionMessage.EBICS_TEST_MODE_NOT_ENABLED));
        }
    } catch (Exception e) {
        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) MetaFile(com.axelor.meta.db.MetaFile) BankOrderFileFormat(com.axelor.apps.bankpayment.db.BankOrderFileFormat) File(java.io.File) MetaFile(com.axelor.meta.db.MetaFile) 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