Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
.idea
*.iml
/client/
nb-configuration.xml
*.pub
*.key
265 changes: 162 additions & 103 deletions src/main/java/org/kopi/ebics/client/EbicsClient.java

Large diffs are not rendered by default.

126 changes: 126 additions & 0 deletions src/main/java/org/kopi/ebics/client/EbicsParams.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*
public record EbicsParams(String orderId, OrderParams orderParams) {

public record OrderParams(String serviceName, String scope, String option, String messageName,
String messageVersion, boolean signatureFlag) {
}
}
*/

package org.kopi.ebics.client;
import java.util.Objects;

public class EbicsParams {

private final String orderId;
private final OrderParams orderParams;

public EbicsParams(String orderId, OrderParams orderParams) {
this.orderId = orderId;
this.orderParams = orderParams;
}

public String getOrderId() {
return orderId;
}

public OrderParams getOrderParams() {
return orderParams;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof EbicsParams)) return false;
EbicsParams that = (EbicsParams) o;
return Objects.equals(orderId, that.orderId) &&
Objects.equals(orderParams, that.orderParams);
}

@Override
public int hashCode() {
return Objects.hash(orderId, orderParams);
}

@Override
public String toString() {
return "EbicsParams{" +
"orderId='" + orderId + '\'' +
", orderParams=" + orderParams +
'}';
}

public static class OrderParams {

private final String serviceName;
private final String scope;
private final String option;
private final String messageName;
private final String messageVersion;
private final boolean signatureFlag;

public OrderParams(String serviceName, String scope, String option,
String messageName, String messageVersion, boolean signatureFlag) {
this.serviceName = serviceName;
this.scope = scope;
this.option = option;
this.messageName = messageName;
this.messageVersion = messageVersion;
this.signatureFlag = signatureFlag;
}

public String getServiceName() {
return serviceName;
}

public String getScope() {
return scope;
}

public String getOption() {
return option;
}

public String getMessageName() {
return messageName;
}

public String getMessageVersion() {
return messageVersion;
}

public boolean isSignatureFlag() {
return signatureFlag;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof OrderParams)) return false;
OrderParams that = (OrderParams) o;
return signatureFlag == that.signatureFlag &&
Objects.equals(serviceName, that.serviceName) &&
Objects.equals(scope, that.scope) &&
Objects.equals(option, that.option) &&
Objects.equals(messageName, that.messageName) &&
Objects.equals(messageVersion, that.messageVersion);
}

@Override
public int hashCode() {
return Objects.hash(serviceName, scope, option, messageName, messageVersion, signatureFlag);
}

@Override
public String toString() {
return "OrderParams{" +
"serviceName='" + serviceName + '\'' +
", scope='" + scope + '\'' +
", option='" + option + '\'' +
", messageName='" + messageName + '\'' +
", messageVersion='" + messageVersion + '\'' +
", signatureFlag=" + signatureFlag +
'}';
}
}
}
8 changes: 0 additions & 8 deletions src/main/java/org/kopi/ebics/client/EbicsUploadParams.java

This file was deleted.

47 changes: 41 additions & 6 deletions src/main/java/org/kopi/ebics/client/FileTransfer.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.io.IOException;

import org.kopi.ebics.exception.EbicsException;
import org.kopi.ebics.exception.NoDownloadDataAvailableException;
import org.kopi.ebics.interfaces.ContentFactory;
import org.kopi.ebics.interfaces.EbicsOrderType;
import org.kopi.ebics.io.ByteArrayContentFactory;
Expand Down Expand Up @@ -91,7 +92,7 @@ public FileTransfer(EbicsSession session) {
* @throws IOException
* @throws EbicsException
*/
public void sendFile(byte[] content, EbicsOrderType orderType, EbicsUploadParams params)
public void sendFile(byte[] content, EbicsOrderType orderType, EbicsParams params)
throws IOException, EbicsException
{
HttpRequestSender sender = new HttpRequestSender(session);
Expand Down Expand Up @@ -167,22 +168,56 @@ public void sendFile(ContentFactory factory,
* No transaction recovery is possible.
* @param orderType type of file to fetch
* @param outputFile where to put the data
* @param params where to put the data
* @throws IOException communication error
* @throws EbicsException server generated error
* @throws NoDownloadDataAvailableException server generated error
*/
public void fetchFile(EbicsOrderType orderType,
File outputFile)
throws IOException, EbicsException
File outputFile, EbicsParams params)
throws IOException, NoDownloadDataAvailableException, EbicsException
{




/*

HttpRequestSender sender = new HttpRequestSender(session);
var initializer = new DownloadInitializationRequestElement(session, orderType, params);
initializer.build();
initializer.validate();
session.getConfiguration().getTraceManager().trace(initializer.getUserSignature());
session.getConfiguration().getTraceManager().trace(initializer);
int httpCode = sender.send(new ByteArrayContentFactory(initializer.prettyPrint()));

Utils.checkHttpCode(httpCode);
InitializationResponseElement response = new InitializationResponseElement(sender.getResponseBody(),
orderType,
DefaultEbicsRootElement.generateName(orderType));
response.build();
session.getConfiguration().getTraceManager().trace(response);

TransferState state = new TransferState(initializer.getSegmentNumber(), response.getTransactionId());


*/


// original ci-dessous


var sender = new HttpRequestSender(session);
var initializer = new DownloadInitializationRequestElement(session, orderType);
var initializer = new DownloadInitializationRequestElement(session, orderType, params);
initializer.build();
initializer.validate();

session.getConfiguration().getTraceManager().trace(initializer);
var request = initializer.prettyPrint();
var httpCode = sender.send(new ByteArrayContentFactory(request));
int httpCode = sender.send(new ByteArrayContentFactory(initializer.prettyPrint()));

Utils.checkHttpCode(httpCode);

var response = new DownloadInitializationResponseElement(sender.getResponseBody(),
orderType,
DefaultEbicsRootElement.generateName(orderType));
Expand Down Expand Up @@ -236,7 +271,7 @@ public void fetchFile(EbicsOrderType orderType,
boolean lastSegment,
byte[] transactionId,
Joiner joiner)
throws IOException, EbicsException
throws IOException, EbicsException,NoDownloadDataAvailableException
{
DownloadTransferRequestElement downloader;
HttpRequestSender sender;
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/org/kopi/ebics/session/OrderType.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ public enum OrderType implements EbicsOrderType {
XCT,
C52,
C53,
C54;
C54,
ZS2,
XTD,
ZQR,
Z54;

@Override
public String getCode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

import org.kopi.ebics.exception.EbicsException;
import org.kopi.ebics.interfaces.EbicsOrderType;
import org.kopi.ebics.io.Splitter;
import org.kopi.ebics.client.EbicsParams;
import org.kopi.ebics.schema.h005.EbicsRequestDocument.EbicsRequest;
import org.kopi.ebics.schema.h005.EbicsRequestDocument.EbicsRequest.Body;
import org.kopi.ebics.schema.h005.EbicsRequestDocument.EbicsRequest.Header;
Expand All @@ -45,14 +47,31 @@
*/
public class DownloadInitializationRequestElement extends InitializationRequestElement {


/**
* Constructs a new <code>DInitializationRequestElement</code> for downloads initializations.
* @param session the current ebics session
* @param type the download order type (FDL, HTD, HPD)
*/
public DownloadInitializationRequestElement(EbicsSession session, EbicsOrderType type) {
super(session, type, generateName(type));
setSaveSuggestedPrefixes("urn:org:ebics:H005", "");
}



/**
* Constructs a new <code>DInitializationRequestElement</code> for downloads initializations.
* @param session the current ebics session
* @param type the download order type (FDL, HTD, HPD)
* @param params
*/
public DownloadInitializationRequestElement(EbicsSession session,
EbicsOrderType type) {
EbicsOrderType type, EbicsParams params) {

super(session, type, generateName(type));
setSaveSuggestedPrefixes("urn:org:ebics:H005", "");
this.downloadParams = params;
}

@Override
Expand Down Expand Up @@ -107,5 +126,12 @@ public void buildInitialization() throws EbicsException {
document = EbicsXmlFactory.createEbicsRequestDocument(request);
}

// --------------------------------------------------------------------
// DATA MEMBERS
// --------------------------------------------------------------------
private EbicsParams downloadParams = null;
private UserSignature userSignature;
private Splitter splitter;
private static final long serialVersionUID = 3776072549761880272L;

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,14 @@

import org.apache.commons.codec.binary.Base64;
import org.apache.xmlbeans.XmlObject;
import org.kopi.ebics.client.EbicsUploadParams;
import org.kopi.ebics.client.EbicsParams;
import org.kopi.ebics.exception.EbicsException;
import org.kopi.ebics.interfaces.ContentFactory;
import org.kopi.ebics.interfaces.EbicsOrderType;
import org.kopi.ebics.io.Splitter;
import org.kopi.ebics.schema.h005.BTUOrderParamsDocument;
import org.kopi.ebics.schema.h005.DataEncryptionInfoType.EncryptionPubKeyDigest;
import org.kopi.ebics.schema.h005.DataTransferRequestType;
import org.kopi.ebics.schema.h005.DataTransferRequestType.DataEncryptionInfo;
import org.kopi.ebics.schema.h005.DataTransferRequestType.SignatureData;
import org.kopi.ebics.schema.h005.EbicsRequestDocument.EbicsRequest;
import org.kopi.ebics.schema.h005.EbicsRequestDocument.EbicsRequest.Body;
import org.kopi.ebics.schema.h005.EbicsRequestDocument.EbicsRequest.Header;
import org.kopi.ebics.schema.h005.MutableHeaderType;
import org.kopi.ebics.schema.h005.StandardOrderParamsType;
import org.kopi.ebics.schema.h005.StaticHeaderOrderDetailsType;
import org.kopi.ebics.schema.h005.StaticHeaderType;
import org.kopi.ebics.schema.h005.StaticHeaderType.BankPubKeyDigests;
import org.kopi.ebics.schema.h005.StaticHeaderType.BankPubKeyDigests.Authentication;
import org.kopi.ebics.schema.h005.StaticHeaderType.BankPubKeyDigests.Encryption;
import org.kopi.ebics.schema.h005.StaticHeaderType.Product;
import org.kopi.ebics.session.EbicsSession;
import org.kopi.ebics.utils.Utils;

Expand All @@ -67,7 +54,7 @@ public class UploadInitializationRequestElement extends InitializationRequestEle
* @param userData the user data to be uploaded
*/
public UploadInitializationRequestElement(EbicsSession session, EbicsOrderType orderType,
EbicsUploadParams params,
EbicsParams params,
byte[] userData) {
super(session, orderType, generateName(orderType));
setSaveSuggestedPrefixes("urn:org:ebics:H005", "");
Expand Down Expand Up @@ -98,18 +85,18 @@ public void buildInitialization() throws EbicsException {
decodeHex(session.getUser().getPartner().getBank().getE002Digest()));
var bankPubKeyDigests = EbicsXmlFactory.createBankPubKeyDigests(authentication, encryption);

String nextOrderId = uploadParams.orderId();
String nextOrderId = uploadParams.getOrderId();

var type = StaticHeaderOrderDetailsType.AdminOrderType.Factory.newInstance();
type.setStringValue(this.getType());

var orderParamsType = (XmlObject) EbicsXmlFactory.createStandardOrderParamsType();
var orderParamsSchema = StandardOrderParamsType.type;

if (uploadParams.orderParams() != null) {
var p = uploadParams.orderParams();
orderParamsType = EbicsXmlFactory.createBTUParams(p.serviceName(), p.scope(),
p.option(), p.messageName(), p.messageVersion(), p.signatureFlag());
if (uploadParams.getOrderParams() != null) {
var p = uploadParams.getOrderParams();
orderParamsType = EbicsXmlFactory.createBTUParams(p.getServiceName(), p.getScope(),
p.getOption(), p.getMessageName(), p.getMessageVersion(), p.isSignatureFlag());
orderParamsSchema = BTUOrderParamsDocument.type;
}

Expand Down Expand Up @@ -173,7 +160,7 @@ public int getSegmentNumber() {
// --------------------------------------------------------------------
// DATA MEMBERS
// --------------------------------------------------------------------
private final EbicsUploadParams uploadParams;
private final EbicsParams uploadParams;
private final byte[] userData;
private UserSignature userSignature;
private final Splitter splitter;
Expand Down
Loading