use of com.axelor.apps.account.ebics.schema.h003.EbicsUnsecuredRequestDocument.EbicsUnsecuredRequest.Body in project axelor-open-suite by axelor.
the class UnsecuredRequestElement method build.
@Override
public void build() throws AxelorException {
Header header;
Body body;
EmptyMutableHeaderType mutable;
UnsecuredRequestStaticHeaderType xstatic;
ProductElementType productType;
OrderDetailsType orderDetails;
DataTransfer dataTransfer;
OrderData orderData;
EbicsUnsecuredRequest request;
orderDetails = EbicsXmlFactory.createOrderDetailsType("DZNNN", session.getUser().getNextOrderId(), orderType.getOrderType());
productType = EbicsXmlFactory.creatProductElementType(Optional.ofNullable(AuthUtils.getUser()).map(User::getLanguage).orElse(null), session.getProduct().getName());
try {
xstatic = EbicsXmlFactory.createUnsecuredRequestStaticHeaderType(session.getBankID(), session.getUser().getEbicsPartner().getPartnerId(), session.getUser().getUserId(), productType, orderDetails, session.getUser().getSecurityMedium());
mutable = EbicsXmlFactory.createEmptyMutableHeaderType();
header = EbicsXmlFactory.createHeader(true, mutable, xstatic);
orderData = EbicsXmlFactory.createOrderData(this.orderData);
dataTransfer = EbicsXmlFactory.createDataTransfer(orderData);
body = EbicsXmlFactory.createBody(dataTransfer);
request = EbicsXmlFactory.createEbicsUnsecuredRequest(header, body, 1, "H003");
document = EbicsXmlFactory.createEbicsUnsecuredRequestDocument(request);
} catch (AxelorException e) {
e.printStackTrace();
}
}
use of com.axelor.apps.account.ebics.schema.h003.EbicsUnsecuredRequestDocument.EbicsUnsecuredRequest.Body in project axelor-open-suite by axelor.
the class EbicsXmlFactory method createEbicsUnsecuredRequest.
/**
* Creates a new <code>EbicsUnsecuredRequest</code> XML object
*
* @param header the <code>Header</code> element
* @param body the <code>Body</code> element
* @param revision the current revision
* @param version the current version
* @return the <code>EbicsUnsecuredRequest</code> XML object
*/
public static EbicsUnsecuredRequest createEbicsUnsecuredRequest(Header header, Body body, int revision, String version) {
EbicsUnsecuredRequest newEbicsUnsecuredRequest = EbicsUnsecuredRequest.Factory.newInstance();
newEbicsUnsecuredRequest.setHeader(header);
newEbicsUnsecuredRequest.setBody(body);
newEbicsUnsecuredRequest.setRevision(revision);
newEbicsUnsecuredRequest.setVersion(version);
return newEbicsUnsecuredRequest;
}
use of com.axelor.apps.account.ebics.schema.h003.EbicsUnsecuredRequestDocument.EbicsUnsecuredRequest.Body in project axelor-open-suite by axelor.
the class EbicsXmlFactory method createEbicsNoPubKeyDigestsRequest.
// -----------------------------------------------------------------------------------------------------------------------------------------------
/**
* Creates a new <code>EbicsNoPubKeyDigestsRequest</code> XML object
*
* @param revision the default revision
* @param version the default version
* @param header the <code>
* com.axelor.apps.account.ebics.schema.h003.EbicsNoPubKeyDigestsRequestDocument.EbicsNoPubKeyDigestsRequest.Header
* </code> element
* @param body the <code>
* com.axelor.apps.account.ebics.schema.h003.EbicsNoPubKeyDigestsRequestDocument.EbicsNoPubKeyDigestsRequest.Body
* </code> element
* @return the <code>EbicsNoPubKeyDigestsRequest</code> XML object
*/
public static EbicsNoPubKeyDigestsRequest createEbicsNoPubKeyDigestsRequest(int revision, String version, com.axelor.apps.account.ebics.schema.h003.EbicsNoPubKeyDigestsRequestDocument.EbicsNoPubKeyDigestsRequest.Header header, com.axelor.apps.account.ebics.schema.h003.EbicsNoPubKeyDigestsRequestDocument.EbicsNoPubKeyDigestsRequest.Body body) {
EbicsNoPubKeyDigestsRequest newEbicsNoPubKeyDigestsRequest = EbicsNoPubKeyDigestsRequest.Factory.newInstance();
newEbicsNoPubKeyDigestsRequest.setRevision(revision);
newEbicsNoPubKeyDigestsRequest.setVersion(version);
newEbicsNoPubKeyDigestsRequest.setHeader(header);
newEbicsNoPubKeyDigestsRequest.setBody(body);
return newEbicsNoPubKeyDigestsRequest;
}
use of com.axelor.apps.account.ebics.schema.h003.EbicsUnsecuredRequestDocument.EbicsUnsecuredRequest.Body in project axelor-open-suite by axelor.
the class EbicsXmlFactory method createBody.
/**
* Creates a new <code>Body</code> XML object
*
* @param dataTransfer the <code>DataTransfer</code> element
* @return the <code>Body</code> XML object
*/
public static Body createBody(DataTransfer dataTransfer) {
Body newBody = Body.Factory.newInstance();
newBody.setDataTransfer(dataTransfer);
return newBody;
}
use of com.axelor.apps.account.ebics.schema.h003.EbicsUnsecuredRequestDocument.EbicsUnsecuredRequest.Body 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());
}
Aggregations