Skip to content

Commit 1734ad7

Browse files
author
dcollet
committed
final update
1 parent e6b8a6f commit 1734ad7

File tree

7 files changed

+369
-127
lines changed

7 files changed

+369
-127
lines changed

src/main/java/org/kopi/ebics/client/EbicsClient.java

Lines changed: 162 additions & 103 deletions
Large diffs are not rendered by default.
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
/*
2+
public record EbicsParams(String orderId, OrderParams orderParams) {
3+
4+
public record OrderParams(String serviceName, String scope, String option, String messageName,
5+
String messageVersion, boolean signatureFlag) {
6+
}
7+
}
8+
*/
9+
10+
package org.kopi.ebics.client;
11+
import java.util.Objects;
12+
13+
public class EbicsParams {
14+
15+
private final String orderId;
16+
private final OrderParams orderParams;
17+
18+
public EbicsParams(String orderId, OrderParams orderParams) {
19+
this.orderId = orderId;
20+
this.orderParams = orderParams;
21+
}
22+
23+
public String getOrderId() {
24+
return orderId;
25+
}
26+
27+
public OrderParams getOrderParams() {
28+
return orderParams;
29+
}
30+
31+
@Override
32+
public boolean equals(Object o) {
33+
if (this == o) return true;
34+
if (!(o instanceof EbicsParams)) return false;
35+
EbicsParams that = (EbicsParams) o;
36+
return Objects.equals(orderId, that.orderId) &&
37+
Objects.equals(orderParams, that.orderParams);
38+
}
39+
40+
@Override
41+
public int hashCode() {
42+
return Objects.hash(orderId, orderParams);
43+
}
44+
45+
@Override
46+
public String toString() {
47+
return "EbicsParams{" +
48+
"orderId='" + orderId + '\'' +
49+
", orderParams=" + orderParams +
50+
'}';
51+
}
52+
53+
public static class OrderParams {
54+
55+
private final String serviceName;
56+
private final String scope;
57+
private final String option;
58+
private final String messageName;
59+
private final String messageVersion;
60+
private final boolean signatureFlag;
61+
62+
public OrderParams(String serviceName, String scope, String option,
63+
String messageName, String messageVersion, boolean signatureFlag) {
64+
this.serviceName = serviceName;
65+
this.scope = scope;
66+
this.option = option;
67+
this.messageName = messageName;
68+
this.messageVersion = messageVersion;
69+
this.signatureFlag = signatureFlag;
70+
}
71+
72+
public String getServiceName() {
73+
return serviceName;
74+
}
75+
76+
public String getScope() {
77+
return scope;
78+
}
79+
80+
public String getOption() {
81+
return option;
82+
}
83+
84+
public String getMessageName() {
85+
return messageName;
86+
}
87+
88+
public String getMessageVersion() {
89+
return messageVersion;
90+
}
91+
92+
public boolean isSignatureFlag() {
93+
return signatureFlag;
94+
}
95+
96+
@Override
97+
public boolean equals(Object o) {
98+
if (this == o) return true;
99+
if (!(o instanceof OrderParams)) return false;
100+
OrderParams that = (OrderParams) o;
101+
return signatureFlag == that.signatureFlag &&
102+
Objects.equals(serviceName, that.serviceName) &&
103+
Objects.equals(scope, that.scope) &&
104+
Objects.equals(option, that.option) &&
105+
Objects.equals(messageName, that.messageName) &&
106+
Objects.equals(messageVersion, that.messageVersion);
107+
}
108+
109+
@Override
110+
public int hashCode() {
111+
return Objects.hash(serviceName, scope, option, messageName, messageVersion, signatureFlag);
112+
}
113+
114+
@Override
115+
public String toString() {
116+
return "OrderParams{" +
117+
"serviceName='" + serviceName + '\'' +
118+
", scope='" + scope + '\'' +
119+
", option='" + option + '\'' +
120+
", messageName='" + messageName + '\'' +
121+
", messageVersion='" + messageVersion + '\'' +
122+
", signatureFlag=" + signatureFlag +
123+
'}';
124+
}
125+
}
126+
}

src/main/java/org/kopi/ebics/client/EbicsUploadParams.java

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/main/java/org/kopi/ebics/client/FileTransfer.java

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.io.IOException;
2424

2525
import org.kopi.ebics.exception.EbicsException;
26+
import org.kopi.ebics.exception.NoDownloadDataAvailableException;
2627
import org.kopi.ebics.interfaces.ContentFactory;
2728
import org.kopi.ebics.interfaces.EbicsOrderType;
2829
import org.kopi.ebics.io.ByteArrayContentFactory;
@@ -91,7 +92,7 @@ public FileTransfer(EbicsSession session) {
9192
* @throws IOException
9293
* @throws EbicsException
9394
*/
94-
public void sendFile(byte[] content, EbicsOrderType orderType, EbicsUploadParams params)
95+
public void sendFile(byte[] content, EbicsOrderType orderType, EbicsParams params)
9596
throws IOException, EbicsException
9697
{
9798
HttpRequestSender sender = new HttpRequestSender(session);
@@ -167,22 +168,56 @@ public void sendFile(ContentFactory factory,
167168
* No transaction recovery is possible.
168169
* @param orderType type of file to fetch
169170
* @param outputFile where to put the data
171+
* @param params where to put the data
170172
* @throws IOException communication error
171173
* @throws EbicsException server generated error
174+
* @throws NoDownloadDataAvailableException server generated error
172175
*/
173176
public void fetchFile(EbicsOrderType orderType,
174-
File outputFile)
175-
throws IOException, EbicsException
177+
File outputFile, EbicsParams params)
178+
throws IOException, NoDownloadDataAvailableException, EbicsException
176179
{
180+
181+
182+
183+
184+
/*
185+
186+
HttpRequestSender sender = new HttpRequestSender(session);
187+
var initializer = new DownloadInitializationRequestElement(session, orderType, params);
188+
initializer.build();
189+
initializer.validate();
190+
session.getConfiguration().getTraceManager().trace(initializer.getUserSignature());
191+
session.getConfiguration().getTraceManager().trace(initializer);
192+
int httpCode = sender.send(new ByteArrayContentFactory(initializer.prettyPrint()));
193+
194+
Utils.checkHttpCode(httpCode);
195+
InitializationResponseElement response = new InitializationResponseElement(sender.getResponseBody(),
196+
orderType,
197+
DefaultEbicsRootElement.generateName(orderType));
198+
response.build();
199+
session.getConfiguration().getTraceManager().trace(response);
200+
201+
TransferState state = new TransferState(initializer.getSegmentNumber(), response.getTransactionId());
202+
203+
204+
*/
205+
206+
207+
// original ci-dessous
208+
209+
177210
var sender = new HttpRequestSender(session);
178-
var initializer = new DownloadInitializationRequestElement(session, orderType);
211+
var initializer = new DownloadInitializationRequestElement(session, orderType, params);
179212
initializer.build();
180213
initializer.validate();
181214

182215
session.getConfiguration().getTraceManager().trace(initializer);
183216
var request = initializer.prettyPrint();
184-
var httpCode = sender.send(new ByteArrayContentFactory(request));
217+
int httpCode = sender.send(new ByteArrayContentFactory(initializer.prettyPrint()));
218+
185219
Utils.checkHttpCode(httpCode);
220+
186221
var response = new DownloadInitializationResponseElement(sender.getResponseBody(),
187222
orderType,
188223
DefaultEbicsRootElement.generateName(orderType));
@@ -236,7 +271,7 @@ public void fetchFile(EbicsOrderType orderType,
236271
boolean lastSegment,
237272
byte[] transactionId,
238273
Joiner joiner)
239-
throws IOException, EbicsException
274+
throws IOException, EbicsException,NoDownloadDataAvailableException
240275
{
241276
DownloadTransferRequestElement downloader;
242277
HttpRequestSender sender;

src/main/java/org/kopi/ebics/session/OrderType.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ public enum OrderType implements EbicsOrderType {
5959
XCT,
6060
C52,
6161
C53,
62-
C54;
62+
C54,
63+
ZS2,
64+
XTD,
65+
ZQR,
66+
Z54;
6367

6468
@Override
6569
public String getCode() {

src/main/java/org/kopi/ebics/xml/DownloadInitializationRequestElement.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
import org.kopi.ebics.exception.EbicsException;
2424
import org.kopi.ebics.interfaces.EbicsOrderType;
25+
import org.kopi.ebics.io.Splitter;
26+
import org.kopi.ebics.client.EbicsParams;
2527
import org.kopi.ebics.schema.h005.EbicsRequestDocument.EbicsRequest;
2628
import org.kopi.ebics.schema.h005.EbicsRequestDocument.EbicsRequest.Body;
2729
import org.kopi.ebics.schema.h005.EbicsRequestDocument.EbicsRequest.Header;
@@ -45,14 +47,31 @@
4547
*/
4648
public class DownloadInitializationRequestElement extends InitializationRequestElement {
4749

50+
51+
/**
52+
* Constructs a new <code>DInitializationRequestElement</code> for downloads initializations.
53+
* @param session the current ebics session
54+
* @param type the download order type (FDL, HTD, HPD)
55+
*/
56+
public DownloadInitializationRequestElement(EbicsSession session, EbicsOrderType type) {
57+
super(session, type, generateName(type));
58+
setSaveSuggestedPrefixes("urn:org:ebics:H005", "");
59+
}
60+
61+
62+
4863
/**
4964
* Constructs a new <code>DInitializationRequestElement</code> for downloads initializations.
5065
* @param session the current ebics session
5166
* @param type the download order type (FDL, HTD, HPD)
67+
* @param params
5268
*/
5369
public DownloadInitializationRequestElement(EbicsSession session,
54-
EbicsOrderType type) {
70+
EbicsOrderType type, EbicsParams params) {
71+
5572
super(session, type, generateName(type));
73+
setSaveSuggestedPrefixes("urn:org:ebics:H005", "");
74+
this.downloadParams = params;
5675
}
5776

5877
@Override
@@ -107,5 +126,12 @@ public void buildInitialization() throws EbicsException {
107126
document = EbicsXmlFactory.createEbicsRequestDocument(request);
108127
}
109128

129+
// --------------------------------------------------------------------
130+
// DATA MEMBERS
131+
// --------------------------------------------------------------------
132+
private EbicsParams downloadParams = null;
133+
private UserSignature userSignature;
134+
private Splitter splitter;
110135
private static final long serialVersionUID = 3776072549761880272L;
136+
111137
}

src/main/java/org/kopi/ebics/xml/UploadInitializationRequestElement.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
import org.apache.commons.codec.binary.Base64;
2828
import org.apache.xmlbeans.XmlObject;
29-
import org.kopi.ebics.client.EbicsUploadParams;
29+
import org.kopi.ebics.client.EbicsParams;
3030
import org.kopi.ebics.exception.EbicsException;
3131
import org.kopi.ebics.interfaces.ContentFactory;
3232
import org.kopi.ebics.interfaces.EbicsOrderType;
@@ -54,7 +54,7 @@ public class UploadInitializationRequestElement extends InitializationRequestEle
5454
* @param userData the user data to be uploaded
5555
*/
5656
public UploadInitializationRequestElement(EbicsSession session, EbicsOrderType orderType,
57-
EbicsUploadParams params,
57+
EbicsParams params,
5858
byte[] userData) {
5959
super(session, orderType, generateName(orderType));
6060
setSaveSuggestedPrefixes("urn:org:ebics:H005", "");
@@ -85,18 +85,18 @@ public void buildInitialization() throws EbicsException {
8585
decodeHex(session.getUser().getPartner().getBank().getE002Digest()));
8686
var bankPubKeyDigests = EbicsXmlFactory.createBankPubKeyDigests(authentication, encryption);
8787

88-
String nextOrderId = uploadParams.orderId();
88+
String nextOrderId = uploadParams.getOrderId();
8989

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

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

96-
if (uploadParams.orderParams() != null) {
97-
var p = uploadParams.orderParams();
98-
orderParamsType = EbicsXmlFactory.createBTUParams(p.serviceName(), p.scope(),
99-
p.option(), p.messageName(), p.messageVersion(), p.signatureFlag());
96+
if (uploadParams.getOrderParams() != null) {
97+
var p = uploadParams.getOrderParams();
98+
orderParamsType = EbicsXmlFactory.createBTUParams(p.getServiceName(), p.getScope(),
99+
p.getOption(), p.getMessageName(), p.getMessageVersion(), p.isSignatureFlag());
100100
orderParamsSchema = BTUOrderParamsDocument.type;
101101
}
102102

@@ -160,7 +160,7 @@ public int getSegmentNumber() {
160160
// --------------------------------------------------------------------
161161
// DATA MEMBERS
162162
// --------------------------------------------------------------------
163-
private final EbicsUploadParams uploadParams;
163+
private final EbicsParams uploadParams;
164164
private final byte[] userData;
165165
private UserSignature userSignature;
166166
private final Splitter splitter;

0 commit comments

Comments
 (0)