Search in sources :

Example 1 with EbicsRequest

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

the class UInitializationRequestElement 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;
    FULOrderParamsType fULOrderParams;
    OrderType orderType;
    FileFormatType fileFormat;
    List<Parameter> parameters;
    EbicsUser ebicsUser = session.getUser();
    EbicsPartner ebicsPartner = ebicsUser.getEbicsPartner();
    if (ebicsPartner.getEbicsTypeSelect() == EbicsPartnerRepository.EBICS_TYPE_TS) {
        EbicsUser signatoryUser = session.getSignatoryUser();
        userSignature = new UserSignature(signatoryUser, generateName("UserSignature"), "A005", userData, userSignatureData);
    } else {
        userSignature = new UserSignature(ebicsUser, generateName("UserSignature"), "A005", userData, null);
    }
    userSignature.build();
    log.debug("user signature pretty print : {}", userSignature.toString());
    userSignature.validate();
    log.debug("user signature pretty print : {}", userSignature.toString());
    splitter.readInput(true, keySpec);
    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());
    fileFormat = EbicsXmlFactory.createFileFormatType(Locale.FRANCE.getCountry(), session.getSessionParam("FORMAT"));
    fULOrderParams = EbicsXmlFactory.createFULOrderParamsType(fileFormat);
    parameters = new ArrayList<Parameter>();
    if (Boolean.valueOf(session.getSessionParam("TEST")).booleanValue()) {
        Parameter parameter;
        Value value;
        value = EbicsXmlFactory.createValue("String", "TRUE");
        parameter = EbicsXmlFactory.createParameter("TEST", value);
        parameters.add(parameter);
    }
    if (Boolean.valueOf(session.getSessionParam("EBCDIC")).booleanValue()) {
        Parameter parameter;
        Value value;
        value = EbicsXmlFactory.createValue("String", "TRUE");
        parameter = EbicsXmlFactory.createParameter("EBCDIC", value);
        parameters.add(parameter);
    }
    if (parameters.size() > 0) {
        fULOrderParams.setParameterArray(parameters.toArray(new Parameter[parameters.size()]));
    }
    OrderAttribute orderAttribute = new OrderAttribute(type, ebicsPartner.getEbicsTypeSelect());
    orderAttribute.build();
    orderDetails = EbicsXmlFactory.createStaticHeaderOrderDetailsType(ebicsUser.getNextOrderId(), orderAttribute.getOrderAttributes(), orderType, fULOrderParams);
    xstatic = EbicsXmlFactory.createStaticHeaderType(session.getBankID(), nonce, splitter.getSegmentNumber(), 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.getBankE002Key())));
    System.out.println("signature ----------------------------------------------------------------------------");
    System.out.println(userSignature.toString());
    // USE PREVALIDATION
    // PreValidation preValidation = PreValidation.Factory.newInstance();
    // preValidation.setAuthenticate(true);
    // DataDigestType dataDigest = DataDigestType.Factory.newInstance();
    // dataDigest.setSignatureVersion("A005");
    // dataDigest.setStringValue("XXXXXXX);
    // preValidation.setDataDigestArray(new DataDigestType[] {dataDigest});
    signatureData = EbicsXmlFactory.createSignatureData(true, EbicsUtils.encrypt(EbicsUtils.zip(userSignature.prettyPrint()), keySpec));
    dataEncryptionInfo = EbicsXmlFactory.createDataEncryptionInfo(true, encryptionPubKeyDigest, generateTransactionKey());
    dataTransfer = EbicsXmlFactory.createDataTransferRequestType(dataEncryptionInfo, signatureData);
    // USE PREVALIDATION
    // body = EbicsXmlFactory.createEbicsRequestBody(dataTransfer, preValidation);
    body = EbicsXmlFactory.createEbicsRequestBody(dataTransfer);
    request = EbicsXmlFactory.createEbicsRequest(1, "H003", header, body);
    document = EbicsXmlFactory.createEbicsRequestDocument(request);
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    try {
        this.save(bout);
    } catch (JDOMException e) {
        // TODO Bloc catch généré automatiquement
        e.printStackTrace();
    }
    System.out.println("Requete signature ----------------------------------------------------------------------------");
    System.out.println(bout.toString());
}
Also used : EbicsRequest(com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest) DataTransferRequestType(com.axelor.apps.account.ebics.schema.h003.DataTransferRequestType) 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) OrderType(com.axelor.apps.account.ebics.schema.h003.StaticHeaderOrderDetailsType.OrderType) OrderAttribute(com.axelor.apps.bankpayment.ebics.client.OrderAttribute) Body(com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Body) EncryptionPubKeyDigest(com.axelor.apps.account.ebics.schema.h003.DataEncryptionInfoType.EncryptionPubKeyDigest) FileFormatType(com.axelor.apps.account.ebics.schema.h003.FileFormatType) EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser) ByteArrayOutputStream(java.io.ByteArrayOutputStream) JDOMException(org.jdom.JDOMException) 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) 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) Parameter(com.axelor.apps.account.ebics.schema.h003.ParameterDocument.Parameter) FULOrderParamsType(com.axelor.apps.account.ebics.schema.h003.FULOrderParamsType)

Example 2 with EbicsRequest

use of com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest 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 EbicsRequest

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

the class DTransferRequestElement method buildTransfer.

@Override
public void buildTransfer() throws AxelorException {
    EbicsRequest request;
    Header header;
    Body body;
    MutableHeaderType mutable;
    SegmentNumber segmentNumber;
    StaticHeaderType xstatic;
    segmentNumber = EbicsXmlFactory.createSegmentNumber(this.segmentNumber, lastSegment);
    mutable = EbicsXmlFactory.createMutableHeaderType("Transfer", segmentNumber);
    xstatic = EbicsXmlFactory.createStaticHeaderType(session.getBankID(), transactionId);
    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) MutableHeaderType(com.axelor.apps.account.ebics.schema.h003.MutableHeaderType) SegmentNumber(com.axelor.apps.account.ebics.schema.h003.MutableHeaderType.SegmentNumber) Header(com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Header) StaticHeaderType(com.axelor.apps.account.ebics.schema.h003.StaticHeaderType) Body(com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Body)

Example 4 with EbicsRequest

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

the class EbicsXmlFactory method createEbicsRequest.

/**
 * Creates a new <code>EbicsRequest</code> XML object
 *
 * @param revision the default revision
 * @param version the default version
 * @param header the <code>
 *     com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Header</code>
 *     element
 * @param body the <code>
 *     com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Body</code>
 *     element
 * @return the <code>EbicsRequest</code> XML object
 */
public static EbicsRequest createEbicsRequest(int revision, String version, com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Header header, com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Body body) {
    EbicsRequest newEbicsRequest = EbicsRequest.Factory.newInstance();
    newEbicsRequest.setRevision(revision);
    newEbicsRequest.setVersion(version);
    newEbicsRequest.setHeader(header);
    newEbicsRequest.setBody(body);
    return newEbicsRequest;
}
Also used : EbicsRequest(com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest)

Example 5 with EbicsRequest

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

the class UTransferRequestElement method buildTransfer.

@Override
public void buildTransfer() throws AxelorException {
    EbicsRequest request;
    Header header;
    Body body;
    MutableHeaderType mutable;
    SegmentNumber segmentNumber;
    StaticHeaderType xstatic;
    OrderData orderData;
    DataTransferRequestType dataTransfer;
    segmentNumber = EbicsXmlFactory.createSegmentNumber(this.segmentNumber, lastSegment);
    mutable = EbicsXmlFactory.createMutableHeaderType("Transfer", segmentNumber);
    xstatic = EbicsXmlFactory.createStaticHeaderType(session.getBankID(), transactionId);
    header = EbicsXmlFactory.createEbicsRequestHeader(true, mutable, xstatic);
    orderData = EbicsXmlFactory.createEbicsRequestOrderData(IOUtils.getFactoryContent(content));
    dataTransfer = EbicsXmlFactory.createDataTransferRequestType(orderData);
    // TODO CHECK
    body = EbicsXmlFactory.createEbicsRequestBody(dataTransfer);
    request = EbicsXmlFactory.createEbicsRequest(1, "H003", header, body);
    document = EbicsXmlFactory.createEbicsRequestDocument(request);
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    try {
        this.save(bout);
    } catch (JDOMException e) {
        // TODO Bloc catch généré automatiquement
        e.printStackTrace();
    }
    System.out.println("Requete data ----------------------------------------------------------------------------");
    System.out.println(bout.toString());
}
Also used : EbicsRequest(com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest) MutableHeaderType(com.axelor.apps.account.ebics.schema.h003.MutableHeaderType) SegmentNumber(com.axelor.apps.account.ebics.schema.h003.MutableHeaderType.SegmentNumber) DataTransferRequestType(com.axelor.apps.account.ebics.schema.h003.DataTransferRequestType) Header(com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Header) StaticHeaderType(com.axelor.apps.account.ebics.schema.h003.StaticHeaderType) OrderData(com.axelor.apps.account.ebics.schema.h003.DataTransferRequestType.OrderData) ByteArrayOutputStream(java.io.ByteArrayOutputStream) JDOMException(org.jdom.JDOMException) Body(com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Body)

Aggregations

EbicsRequest (com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest)7 Body (com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Body)6 Header (com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Header)6 MutableHeaderType (com.axelor.apps.account.ebics.schema.h003.MutableHeaderType)6 StaticHeaderType (com.axelor.apps.account.ebics.schema.h003.StaticHeaderType)6 DataTransferRequestType (com.axelor.apps.account.ebics.schema.h003.DataTransferRequestType)3 StaticHeaderOrderDetailsType (com.axelor.apps.account.ebics.schema.h003.StaticHeaderOrderDetailsType)3 OrderType (com.axelor.apps.account.ebics.schema.h003.StaticHeaderOrderDetailsType.OrderType)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 Product (com.axelor.apps.account.ebics.schema.h003.StaticHeaderType.Product)3 EbicsPartner (com.axelor.apps.bankpayment.db.EbicsPartner)3 EbicsUser (com.axelor.apps.bankpayment.db.EbicsUser)3 OrderAttribute (com.axelor.apps.bankpayment.ebics.client.OrderAttribute)3 EncryptionPubKeyDigest (com.axelor.apps.account.ebics.schema.h003.DataEncryptionInfoType.EncryptionPubKeyDigest)2 DataEncryptionInfo (com.axelor.apps.account.ebics.schema.h003.DataTransferRequestType.DataEncryptionInfo)2 SignatureData (com.axelor.apps.account.ebics.schema.h003.DataTransferRequestType.SignatureData)2 EbicsRequestDocument (com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument)2 FileFormatType (com.axelor.apps.account.ebics.schema.h003.FileFormatType)2