Search in sources :

Example 6 with StaticHeaderType

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

the class EbicsXmlFactory method createStaticHeaderType.

/**
 * Creates a new <code>StaticHeaderType</code> XML object
 *
 * @param hostId the host ID
 * @param nonce the random nonce
 * @param numSegments the segments number
 * @param partnerId the partner ID
 * @param product the <code>Product</code> element
 * @param securityMedium the security medium
 * @param userId the user Id
 * @param timestamp the current time stamp
 * @param orderDetails the <code>StaticHeaderOrderDetailsType</code> element
 * @param bankPubKeyDigests the <code>BankPubKeyDigests</code> element
 * @return the <code>StaticHeaderType</code> XML object
 */
public static StaticHeaderType createStaticHeaderType(String hostId, byte[] nonce, int numSegments, String partnerId, Product product, String securityMedium, String userId, Calendar timestamp, StaticHeaderOrderDetailsType orderDetails, BankPubKeyDigests bankPubKeyDigests) {
    StaticHeaderType newStaticHeaderType = StaticHeaderType.Factory.newInstance();
    newStaticHeaderType.setHostID(hostId);
    newStaticHeaderType.setNonce(nonce);
    newStaticHeaderType.setNumSegments(numSegments);
    newStaticHeaderType.setPartnerID(partnerId);
    newStaticHeaderType.setProduct(product);
    newStaticHeaderType.setSecurityMedium(securityMedium);
    newStaticHeaderType.setUserID(userId);
    newStaticHeaderType.setTimestamp(timestamp);
    newStaticHeaderType.setOrderDetails(orderDetails);
    newStaticHeaderType.setBankPubKeyDigests(bankPubKeyDigests);
    return newStaticHeaderType;
}
Also used : NoPubKeyDigestsRequestStaticHeaderType(com.axelor.apps.account.ebics.schema.h003.NoPubKeyDigestsRequestStaticHeaderType) UnsecuredRequestStaticHeaderType(com.axelor.apps.account.ebics.schema.h003.UnsecuredRequestStaticHeaderType) StaticHeaderType(com.axelor.apps.account.ebics.schema.h003.StaticHeaderType)

Example 7 with StaticHeaderType

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

the class EbicsXmlFactory method createStaticHeaderType.

/**
 * Create the <code>StaticHeaderType</code> XML object
 *
 * @param hostId the host ID
 * @param transactionId the transaction ID
 * @return the <code>StaticHeaderType</code> XML object
 */
public static StaticHeaderType createStaticHeaderType(String hostId, byte[] transactionId) {
    StaticHeaderType newStaticHeaderType = StaticHeaderType.Factory.newInstance();
    newStaticHeaderType.setHostID(hostId);
    newStaticHeaderType.setTransactionID(transactionId);
    return newStaticHeaderType;
}
Also used : NoPubKeyDigestsRequestStaticHeaderType(com.axelor.apps.account.ebics.schema.h003.NoPubKeyDigestsRequestStaticHeaderType) UnsecuredRequestStaticHeaderType(com.axelor.apps.account.ebics.schema.h003.UnsecuredRequestStaticHeaderType) StaticHeaderType(com.axelor.apps.account.ebics.schema.h003.StaticHeaderType)

Example 8 with StaticHeaderType

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

the class ReceiptRequestElement method build.

@Override
public void build() throws AxelorException {
    EbicsRequest request;
    Header header;
    Body body;
    MutableHeaderType mutable;
    StaticHeaderType xstatic;
    TransferReceipt transferReceipt;
    SignedInfo signedInfo;
    mutable = EbicsXmlFactory.createMutableHeaderType("Receipt", null);
    xstatic = EbicsXmlFactory.createStaticHeaderType(session.getBankID(), transactionId);
    header = EbicsXmlFactory.createEbicsRequestHeader(true, mutable, xstatic);
    transferReceipt = EbicsXmlFactory.createTransferReceipt(true, 0);
    body = EbicsXmlFactory.createEbicsRequestBody(transferReceipt);
    request = EbicsXmlFactory.createEbicsRequest(1, "H003", header, body);
    document = EbicsXmlFactory.createEbicsRequestDocument(request);
    signedInfo = new SignedInfo(session.getUser(), getDigest());
    signedInfo.build();
    ((EbicsRequestDocument) document).getEbicsRequest().setAuthSignature(signedInfo.getSignatureType());
    ((EbicsRequestDocument) document).getEbicsRequest().getAuthSignature().setSignatureValue(EbicsXmlFactory.createSignatureValueType(signedInfo.sign(toByteArray())));
}
Also used : EbicsRequest(com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest) MutableHeaderType(com.axelor.apps.account.ebics.schema.h003.MutableHeaderType) TransferReceipt(com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Body.TransferReceipt) Header(com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Header) EbicsRequestDocument(com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument) StaticHeaderType(com.axelor.apps.account.ebics.schema.h003.StaticHeaderType) Body(com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Body)

Example 9 with StaticHeaderType

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

StaticHeaderType (com.axelor.apps.account.ebics.schema.h003.StaticHeaderType)9 EbicsRequest (com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest)6 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 DataTransferRequestType (com.axelor.apps.account.ebics.schema.h003.DataTransferRequestType)3 NoPubKeyDigestsRequestStaticHeaderType (com.axelor.apps.account.ebics.schema.h003.NoPubKeyDigestsRequestStaticHeaderType)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 UnsecuredRequestStaticHeaderType (com.axelor.apps.account.ebics.schema.h003.UnsecuredRequestStaticHeaderType)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