Search in sources :

Example 1 with StandardOrderParamsType

use of com.axelor.apps.account.ebics.schema.h003.StandardOrderParamsType in project axelor-open-suite by axelor.

the class EbicsXmlFactory method createStaticHeaderOrderDetailsType.

/**
 * Creates a new <code>StaticHeaderOrderDetailsType</code> XML object
 *
 * @param orderId the order ID
 * @param orderAttribute the order attribute
 * @param orderType the order type
 * @param orderParams the <code>StandardOrderParamsType</code> element
 * @return the <code>StaticHeaderOrderDetailsType</code> XML object
 */
public static StaticHeaderOrderDetailsType createStaticHeaderOrderDetailsType(String orderId, String orderAttribute, OrderType orderType, StandardOrderParamsType orderParams) {
    StaticHeaderOrderDetailsType newStaticHeaderOrderDetailsType = StaticHeaderOrderDetailsType.Factory.newInstance();
    newStaticHeaderOrderDetailsType.setOrderID(orderId);
    newStaticHeaderOrderDetailsType.setOrderAttribute(com.axelor.apps.account.ebics.schema.h003.OrderAttributeType.Enum.forString(orderAttribute));
    newStaticHeaderOrderDetailsType.setOrderType(orderType);
    newStaticHeaderOrderDetailsType.setOrderParams(orderParams);
    qualifySubstitutionGroup(newStaticHeaderOrderDetailsType.getOrderParams(), StandardOrderParamsDocument.type.getDocumentElementName(), null);
    return newStaticHeaderOrderDetailsType;
}
Also used : StaticHeaderOrderDetailsType(com.axelor.apps.account.ebics.schema.h003.StaticHeaderOrderDetailsType)

Example 2 with StandardOrderParamsType

use of com.axelor.apps.account.ebics.schema.h003.StandardOrderParamsType 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 3 with StandardOrderParamsType

use of com.axelor.apps.account.ebics.schema.h003.StandardOrderParamsType in project axelor-open-suite by axelor.

the class SPRRequestElement 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;
    DataTransferRequestType dataTransfer;
    DataEncryptionInfo dataEncryptionInfo;
    SignatureData signatureData;
    EncryptionPubKeyDigest encryptionPubKeyDigest;
    StaticHeaderOrderDetailsType orderDetails;
    OrderType orderType;
    StandardOrderParamsType standardOrderParamsType;
    UserSignature userSignature;
    EbicsUser ebicsUser = session.getUser();
    EbicsPartner ebicsPartner = ebicsUser.getEbicsPartner();
    userSignature = new UserSignature(ebicsUser, generateName("SIG"), "A005", " ".getBytes(), " ".getBytes());
    // TODO Manage the ebics ts case, with an eletronic signature of the user
    userSignature.build();
    userSignature.validate();
    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());
    standardOrderParamsType = EbicsXmlFactory.createStandardOrderParamsType();
    OrderAttribute orderAttribute = new OrderAttribute(type, ebicsPartner.getEbicsTypeSelect());
    orderAttribute.build();
    orderDetails = EbicsXmlFactory.createStaticHeaderOrderDetailsType(ebicsUser.getNextOrderId(), orderAttribute.getOrderAttributes(), orderType, standardOrderParamsType);
    xstatic = EbicsXmlFactory.createStaticHeaderType(session.getBankID(), nonce, 0, ebicsPartner.getPartnerId(), product, ebicsUser.getSecurityMedium(), ebicsUser.getUserId(), Calendar.getInstance(), orderDetails, bankPubKeyDigests);
    header = EbicsXmlFactory.createEbicsRequestHeader(true, mutable, xstatic);
    encryptionPubKeyDigest = EbicsXmlFactory.createEncryptionPubKeyDigest("E002", "http://www.w3.org/2001/04/xmlenc#sha256", decodeHex(KeyUtil.getKeyDigest(session.getBankX002Key())));
    signatureData = EbicsXmlFactory.createSignatureData(true, EbicsUtils.encrypt(EbicsUtils.zip(userSignature.prettyPrint()), keySpec));
    dataEncryptionInfo = EbicsXmlFactory.createDataEncryptionInfo(true, encryptionPubKeyDigest, generateTransactionKey());
    dataTransfer = EbicsXmlFactory.createDataTransferRequestType(dataEncryptionInfo, signatureData);
    body = EbicsXmlFactory.createEbicsRequestBody(dataTransfer);
    request = EbicsXmlFactory.createEbicsRequest(1, "H003", header, body);
    document = EbicsXmlFactory.createEbicsRequestDocument(request);
}
Also used : EbicsRequest(com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest) DataTransferRequestType(com.axelor.apps.account.ebics.schema.h003.DataTransferRequestType) EncryptionPubKeyDigest(com.axelor.apps.account.ebics.schema.h003.DataEncryptionInfoType.EncryptionPubKeyDigest) StandardOrderParamsType(com.axelor.apps.account.ebics.schema.h003.StandardOrderParamsType) EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser) 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) DataEncryptionInfo(com.axelor.apps.account.ebics.schema.h003.DataTransferRequestType.DataEncryptionInfo) 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) SignatureData(com.axelor.apps.account.ebics.schema.h003.DataTransferRequestType.SignatureData) 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) OrderAttribute(com.axelor.apps.bankpayment.ebics.client.OrderAttribute) Body(com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Body)

Aggregations

StaticHeaderOrderDetailsType (com.axelor.apps.account.ebics.schema.h003.StaticHeaderOrderDetailsType)3 EbicsRequest (com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest)2 Body (com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Body)2 Header (com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Header)2 MutableHeaderType (com.axelor.apps.account.ebics.schema.h003.MutableHeaderType)2 StandardOrderParamsType (com.axelor.apps.account.ebics.schema.h003.StandardOrderParamsType)2 OrderType (com.axelor.apps.account.ebics.schema.h003.StaticHeaderOrderDetailsType.OrderType)2 StaticHeaderType (com.axelor.apps.account.ebics.schema.h003.StaticHeaderType)2 BankPubKeyDigests (com.axelor.apps.account.ebics.schema.h003.StaticHeaderType.BankPubKeyDigests)2 Authentication (com.axelor.apps.account.ebics.schema.h003.StaticHeaderType.BankPubKeyDigests.Authentication)2 Encryption (com.axelor.apps.account.ebics.schema.h003.StaticHeaderType.BankPubKeyDigests.Encryption)2 Product (com.axelor.apps.account.ebics.schema.h003.StaticHeaderType.Product)2 EbicsPartner (com.axelor.apps.bankpayment.db.EbicsPartner)2 EbicsUser (com.axelor.apps.bankpayment.db.EbicsUser)2 OrderAttribute (com.axelor.apps.bankpayment.ebics.client.OrderAttribute)2 EncryptionPubKeyDigest (com.axelor.apps.account.ebics.schema.h003.DataEncryptionInfoType.EncryptionPubKeyDigest)1 DataTransferRequestType (com.axelor.apps.account.ebics.schema.h003.DataTransferRequestType)1 DataEncryptionInfo (com.axelor.apps.account.ebics.schema.h003.DataTransferRequestType.DataEncryptionInfo)1 SignatureData (com.axelor.apps.account.ebics.schema.h003.DataTransferRequestType.SignatureData)1 FDLOrderParamsType (com.axelor.apps.account.ebics.schema.h003.FDLOrderParamsType)1