Search in sources :

Example 21 with EbicsUser

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

the class EbicsController method generateDn.

public void generateDn(ActionRequest request, ActionResponse response) {
    EbicsUser ebicsUser = Beans.get(EbicsUserRepository.class).find(request.getContext().asType(EbicsUser.class).getId());
    response.setValue("dn", Beans.get(EbicsService.class).makeDN(ebicsUser));
}
Also used : EbicsUserRepository(com.axelor.apps.bankpayment.db.repo.EbicsUserRepository) EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser)

Example 22 with EbicsUser

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

the class DInitializationRequestElement method buildInitialization.

@Override
public void buildInitialization() throws AxelorException {
    EbicsRequest request;
    Header header;
    Body body;
    MutableHeaderType mutable;
    StaticHeaderType xstatic;
    Product product;
    BankPubKeyDigests bankPubKeyDigests;
    Authentication authentication;
    Encryption encryption;
    OrderType orderType;
    StaticHeaderOrderDetailsType orderDetails;
    mutable = EbicsXmlFactory.createMutableHeaderType("Initialisation", null);
    product = EbicsXmlFactory.createProduct(session.getProduct().getLanguage(), session.getProduct().getName());
    authentication = EbicsXmlFactory.createAuthentication("X002", "http://www.w3.org/2001/04/xmlenc#sha256", decodeHex(KeyUtil.getKeyDigest(session.getBankX002Key())));
    encryption = EbicsXmlFactory.createEncryption("E002", "http://www.w3.org/2001/04/xmlenc#sha256", decodeHex(KeyUtil.getKeyDigest(session.getBankE002Key())));
    bankPubKeyDigests = EbicsXmlFactory.createBankPubKeyDigests(authentication, encryption);
    orderType = EbicsXmlFactory.createOrderType(type.getOrderType());
    EbicsUser ebicsUser = session.getUser();
    EbicsPartner ebicsPartner = ebicsUser.getEbicsPartner();
    OrderAttribute orderAttribute = new OrderAttribute(type, ebicsPartner.getEbicsTypeSelect());
    orderAttribute.build();
    if (type.equals(com.axelor.apps.bankpayment.ebics.client.OrderType.FDL)) {
        FDLOrderParamsType fDLOrderParamsType;
        FileFormatType fileFormat;
        fileFormat = EbicsXmlFactory.createFileFormatType(Locale.FRANCE.getCountry().toUpperCase(), session.getSessionParam("FORMAT"));
        fDLOrderParamsType = EbicsXmlFactory.createFDLOrderParamsType(fileFormat);
        if (startRange != null && endRange != null) {
            DateRange range;
            range = EbicsXmlFactory.createDateRange(startRange, endRange);
            fDLOrderParamsType.setDateRange(range);
        }
        if (Boolean.getBoolean(session.getSessionParam("TEST"))) {
            Parameter parameter;
            Value value;
            value = EbicsXmlFactory.createValue("String", "TRUE");
            parameter = EbicsXmlFactory.createParameter("TEST", value);
            fDLOrderParamsType.setParameterArray(new Parameter[] { parameter });
        }
        orderDetails = EbicsXmlFactory.createStaticHeaderOrderDetailsType(ebicsUser.getNextOrderId(), orderAttribute.getOrderAttributes(), orderType, fDLOrderParamsType);
    } else {
        StandardOrderParamsType standardOrderParamsType;
        standardOrderParamsType = EbicsXmlFactory.createStandardOrderParamsType();
        // FIXME Some banks cannot handle OrderID element in download process. Add parameter in
        // configuration!!!
        orderDetails = EbicsXmlFactory.createStaticHeaderOrderDetailsType(// session.getUser().getPartner().nextOrderId(),
        ebicsUser.getNextOrderId(), orderAttribute.getOrderAttributes(), orderType, standardOrderParamsType);
    }
    xstatic = EbicsXmlFactory.createStaticHeaderType(session.getBankID(), nonce, ebicsPartner.getPartnerId(), product, ebicsUser.getSecurityMedium(), ebicsUser.getUserId(), Calendar.getInstance(), orderDetails, bankPubKeyDigests);
    header = EbicsXmlFactory.createEbicsRequestHeader(true, mutable, xstatic);
    body = EbicsXmlFactory.createEbicsRequestBody();
    request = EbicsXmlFactory.createEbicsRequest(1, "H003", header, body);
    document = EbicsXmlFactory.createEbicsRequestDocument(request);
}
Also used : EbicsRequest(com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest) FileFormatType(com.axelor.apps.account.ebics.schema.h003.FileFormatType) StandardOrderParamsType(com.axelor.apps.account.ebics.schema.h003.StandardOrderParamsType) EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser) FDLOrderParamsType(com.axelor.apps.account.ebics.schema.h003.FDLOrderParamsType) Product(com.axelor.apps.account.ebics.schema.h003.StaticHeaderType.Product) StaticHeaderOrderDetailsType(com.axelor.apps.account.ebics.schema.h003.StaticHeaderOrderDetailsType) StaticHeaderType(com.axelor.apps.account.ebics.schema.h003.StaticHeaderType) Encryption(com.axelor.apps.account.ebics.schema.h003.StaticHeaderType.BankPubKeyDigests.Encryption) EbicsPartner(com.axelor.apps.bankpayment.db.EbicsPartner) BankPubKeyDigests(com.axelor.apps.account.ebics.schema.h003.StaticHeaderType.BankPubKeyDigests) MutableHeaderType(com.axelor.apps.account.ebics.schema.h003.MutableHeaderType) DateRange(com.axelor.apps.account.ebics.schema.h003.FDLOrderParamsType.DateRange) OrderType(com.axelor.apps.account.ebics.schema.h003.StaticHeaderOrderDetailsType.OrderType) Header(com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Header) Authentication(com.axelor.apps.account.ebics.schema.h003.StaticHeaderType.BankPubKeyDigests.Authentication) Value(com.axelor.apps.account.ebics.schema.h003.ParameterDocument.Parameter.Value) OrderAttribute(com.axelor.apps.bankpayment.ebics.client.OrderAttribute) Parameter(com.axelor.apps.account.ebics.schema.h003.ParameterDocument.Parameter) Body(com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Body)

Example 23 with EbicsUser

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

the class BankOrderCreateService method createBankOrder.

/**
 * Créer un ordre bancaire avec tous les paramètres
 *
 * @param
 * @return
 * @throws AxelorException
 */
public BankOrder createBankOrder(PaymentMode paymentMode, Integer partnerType, LocalDate bankOrderDate, Company senderCompany, BankDetails senderBankDetails, Currency currency, String senderReference, String senderLabel, int technicalOriginSelect) throws AxelorException {
    BankOrderFileFormat bankOrderFileFormat = paymentMode.getBankOrderFileFormat();
    BankOrder bankOrder = new BankOrder();
    bankOrder.setOrderTypeSelect(paymentMode.getOrderTypeSelect());
    bankOrder.setPaymentMode(paymentMode);
    bankOrder.setPartnerTypeSelect(partnerType);
    if (!bankOrderFileFormat.getIsMultiDate()) {
        bankOrder.setBankOrderDate(bankOrderDate);
    }
    bankOrder.setStatusSelect(BankOrderRepository.STATUS_DRAFT);
    bankOrder.setRejectStatusSelect(BankOrderRepository.REJECT_STATUS_NOT_REJECTED);
    bankOrder.setSenderCompany(senderCompany);
    bankOrder.setSenderBankDetails(senderBankDetails);
    EbicsUser signatoryEbicsUser = bankOrderService.getDefaultEbicsUserFromBankDetails(senderBankDetails);
    User signatoryUser = null;
    if (signatoryEbicsUser != null) {
        signatoryUser = signatoryEbicsUser.getAssociatedUser();
        bankOrder.setSignatoryEbicsUser(signatoryEbicsUser);
    }
    if (signatoryUser != null) {
        bankOrder.setSignatoryUser(signatoryUser);
    }
    if (!bankOrderFileFormat.getIsMultiCurrency()) {
        bankOrder.setBankOrderCurrency(currency);
    }
    bankOrder.setCompanyCurrency(senderCompany.getCurrency());
    bankOrder.setSenderReference(senderReference);
    bankOrder.setSenderLabel(senderLabel);
    bankOrder.setBankOrderLineList(new ArrayList<BankOrderLine>());
    bankOrder.setBankOrderFileFormat(bankOrderFileFormat);
    bankOrder.setTechnicalOriginSelect(technicalOriginSelect);
    return bankOrder;
}
Also used : EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser) User(com.axelor.auth.db.User) BankOrderLine(com.axelor.apps.bankpayment.db.BankOrderLine) EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser) BankOrderFileFormat(com.axelor.apps.bankpayment.db.BankOrderFileFormat) BankOrder(com.axelor.apps.bankpayment.db.BankOrder)

Example 24 with EbicsUser

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

the class BankOrderServiceImpl method sendFile.

protected void sendFile(BankOrder bankOrder, File dataFileToSend, File signatureFileToSend) throws AxelorException {
    PaymentMode paymentMode = bankOrder.getPaymentMode();
    if (paymentMode != null && !paymentMode.getAutomaticTransmission()) {
        return;
    }
    EbicsUser signatoryEbicsUser = bankOrder.getSignatoryEbicsUser();
    ebicsService.sendFULRequest(signatoryEbicsUser.getEbicsPartner().getTransportEbicsUser(), signatoryEbicsUser, null, dataFileToSend, bankOrder.getBankOrderFileFormat(), signatureFileToSend);
}
Also used : EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser) PaymentMode(com.axelor.apps.account.db.PaymentMode)

Example 25 with EbicsUser

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

the class BankOrderServiceImpl method makeEbicsUserFollow.

/**
 * The signatory ebics user will follow the bank order record
 *
 * @param bankOrder
 */
protected void makeEbicsUserFollow(BankOrder bankOrder) {
    EbicsUser ebicsUser = bankOrder.getSignatoryEbicsUser();
    if (ebicsUser != null) {
        User signatoryUser = ebicsUser.getAssociatedUser();
        Beans.get(MailFollowerRepository.class).follow(bankOrder, signatoryUser);
    }
}
Also used : MailFollowerRepository(com.axelor.mail.db.repo.MailFollowerRepository) EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser) User(com.axelor.auth.db.User) EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser)

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