diff --git a/.gitignore b/.gitignore
index a799df63..94b6c813 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,6 @@
.idea
*.iml
/client/
+nb-configuration.xml
+*.pub
+*.key
diff --git a/src/main/java/org/kopi/ebics/client/EbicsClient.java b/src/main/java/org/kopi/ebics/client/EbicsClient.java
index d743d31e..c725426a 100644
--- a/src/main/java/org/kopi/ebics/client/EbicsClient.java
+++ b/src/main/java/org/kopi/ebics/client/EbicsClient.java
@@ -15,7 +15,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
-
package org.kopi.ebics.client;
import java.io.File;
@@ -40,6 +39,7 @@
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.help.HelpFormatter;
+import org.apache.http.MethodNotSupportedException;
import org.apache.xml.security.Init;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.kopi.ebics.exception.EbicsException;
@@ -68,6 +68,7 @@
*
*/
public class EbicsClient {
+
private static File getRootDir() {
return new File(System.getProperty("user.home"), "ebics" + File.separator + "client");
}
@@ -91,8 +92,7 @@ private static File getRootDir() {
/**
* Constructs a new ebics client application
*
- * @param configuration
- * the application configuration
+ * @param configuration the application configuration
* @param properties
*/
public EbicsClient(Configuration configuration, ConfigProperties properties) {
@@ -113,12 +113,11 @@ private EbicsSession createSession(User user, Product product) {
/**
* Creates the user necessary directories
*
- * @param user
- * the concerned user
+ * @param user the concerned user
*/
public void createUserDirectories(EbicsUser user) {
log.info(
- messages.getString("user.create.directories", user.getUserId()));
+ messages.getString("user.create.directories", user.getUserId()));
IOUtils.createDirectories(configuration.getUserDirectory(user));
IOUtils.createDirectories(configuration.getTransferTraceDirectory(user));
IOUtils.createDirectories(configuration.getKeystoreDirectory(user));
@@ -129,14 +128,10 @@ public void createUserDirectories(EbicsUser user) {
* Creates a new EBICS bank with the data you should have obtained from the
* bank.
*
- * @param url
- * the bank URL
- * @param name
- * the bank name
- * @param hostId
- * the bank host ID
- * @param useCertificate
- * does the bank use certificates ?
+ * @param url the bank URL
+ * @param name the bank name
+ * @param hostId the bank host ID
+ * @param useCertificate does the bank use certificates ?
* @return the created ebics bank
*/
private Bank createBank(URL url, String name, String hostId, boolean useCertificate) {
@@ -148,10 +143,8 @@ private Bank createBank(URL url, String name, String hostId, boolean useCertific
/**
* Creates a new ebics partner
*
- * @param bank
- * the bank
- * @param partnerId
- * the partner ID
+ * @param bank the bank
+ * @param partnerId the partner ID
*/
private Partner createPartner(EbicsBank bank, String partnerId) {
Partner partner = new Partner(bank, partnerId);
@@ -162,45 +155,33 @@ private Partner createPartner(EbicsBank bank, String partnerId) {
/**
* Creates a new ebics user and generates its certificates.
*
- * @param url
- * the bank url
- * @param bankName
- * the bank name
- * @param hostId
- * the bank host ID
- * @param partnerId
- * the partner ID
- * @param userId
- * UserId as obtained from the bank.
- * @param name
- * the user name,
- * @param email
- * the user email
- * @param country
- * the user country
- * @param organization
- * the user organization or company
- * @param useCertificates
- * does the bank use certificates ?
- * @param saveCertificates
- * save generated certificates?
- * @param passwordCallback
- * a callback-handler that supplies us with the password. This
- * parameter can be null, in this case no password is used.
+ * @param url the bank url
+ * @param bankName the bank name
+ * @param hostId the bank host ID
+ * @param partnerId the partner ID
+ * @param userId UserId as obtained from the bank.
+ * @param name the user name,
+ * @param email the user email
+ * @param country the user country
+ * @param organization the user organization or company
+ * @param useCertificates does the bank use certificates ?
+ * @param saveCertificates save generated certificates?
+ * @param passwordCallback a callback-handler that supplies us with the
+ * password. This parameter can be null, in this case no password is used.
* @return Ebics User
* @throws Exception
*/
public User createUser(URL url, String bankName, String hostId, String partnerId,
- String userId, String name, String email, String country, String organization,
- boolean useCertificates, boolean saveCertificates, PasswordCallback passwordCallback)
- throws Exception {
+ String userId, String name, String email, String country, String organization,
+ boolean useCertificates, boolean saveCertificates, PasswordCallback passwordCallback)
+ throws Exception {
log.info(messages.getString("user.create.info", userId));
Bank bank = createBank(url, bankName, hostId, useCertificates);
Partner partner = createPartner(bank, partnerId);
try {
User user = new User(partner, userId, name, email, country, organization,
- passwordCallback);
+ passwordCallback);
createUserDirectories(user);
if (saveCertificates) {
user.saveUserCertificates(configuration.getKeystoreDirectory(user));
@@ -222,11 +203,11 @@ public User createUser(URL url, String bankName, String hostId, String partnerId
}
private void createLetters(EbicsUser user, boolean useCertificates)
- throws GeneralSecurityException, IOException, EbicsException {
+ throws GeneralSecurityException, IOException, EbicsException {
user.getPartner().getBank().setUseCertificate(useCertificates);
LetterManager letterManager = configuration.getLetterManager();
List letters = List.of(letterManager.createA005Letter(user),
- letterManager.createE002Letter(user), letterManager.createX002Letter(user));
+ letterManager.createE002Letter(user), letterManager.createX002Letter(user));
File directory = configuration.getLettersDirectory(user);
for (InitLetter letter : letters) {
@@ -240,7 +221,7 @@ private void createLetters(EbicsUser user, boolean useCertificates)
* Loads a user knowing its ID
*/
public User loadUser(String hostId, String partnerId, String userId,
- PasswordCallback passwordCallback) throws Exception {
+ PasswordCallback passwordCallback) throws Exception {
log.info(messages.getString("user.load.info", userId));
try {
@@ -248,15 +229,15 @@ public User loadUser(String hostId, String partnerId, String userId,
Partner partner;
User user;
try (ObjectInputStream input = configuration.getSerializationManager().deserialize(
- hostId)) {
+ hostId)) {
bank = (Bank) input.readObject();
}
try (ObjectInputStream input = configuration.getSerializationManager().deserialize(
- "partner-" + partnerId)) {
+ "partner-" + partnerId)) {
partner = new Partner(bank, input);
}
try (ObjectInputStream input = configuration.getSerializationManager().deserialize(
- "user-" + userId)) {
+ "user-" + userId)) {
user = new User(partner, input, passwordCallback);
}
users.put(userId, user);
@@ -286,7 +267,7 @@ public void sendINIRequest(User user, Product product) throws Exception {
EbicsSession session = createSession(user, product);
KeyManagement keyManager = new KeyManagement(session);
configuration.getTraceManager().setTraceDirectory(
- configuration.getTransferTraceDirectory(user));
+ configuration.getTransferTraceDirectory(user));
try {
keyManager.sendINI(null);
user.setInitialized(true);
@@ -300,10 +281,8 @@ public void sendINIRequest(User user, Product product) throws Exception {
/**
* Sends a HIA request to the ebics server.
*
- * @param user
- * the user ID.
- * @param product
- * the application product.
+ * @param user the user ID.
+ * @param product the application product.
*/
public void sendHIARequest(User user, Product product) throws Exception {
String userId = user.getUserId();
@@ -316,7 +295,7 @@ public void sendHIARequest(User user, Product product) throws Exception {
EbicsSession session = createSession(user, product);
KeyManagement keyManager = new KeyManagement(session);
configuration.getTraceManager().setTraceDirectory(
- configuration.getTransferTraceDirectory(user));
+ configuration.getTransferTraceDirectory(user));
try {
keyManager.sendHIA(null);
user.setInitializedHIA(true);
@@ -338,7 +317,7 @@ public void sendHPBRequest(User user, Product product) throws Exception {
KeyManagement keyManager = new KeyManagement(session);
configuration.getTraceManager().setTraceDirectory(
- configuration.getTransferTraceDirectory(user));
+ configuration.getTransferTraceDirectory(user));
try {
keyManager.sendHPB();
@@ -352,10 +331,8 @@ public void sendHPBRequest(User user, Product product) throws Exception {
/**
* Sends the SPR order to the bank.
*
- * @param user
- * the user ID
- * @param product
- * the session product
+ * @param user the user ID
+ * @param product the session product
* @throws Exception
*/
public void revokeSubscriber(User user, Product product) throws Exception {
@@ -367,7 +344,7 @@ public void revokeSubscriber(User user, Product product) throws Exception {
KeyManagement keyManager = new KeyManagement(session);
configuration.getTraceManager().setTraceDirectory(
- configuration.getTransferTraceDirectory(user));
+ configuration.getTransferTraceDirectory(user));
try {
keyManager.lockAccess();
@@ -381,56 +358,69 @@ public void revokeSubscriber(User user, Product product) throws Exception {
/**
* Sends a file to the ebics bank server
+ *
* @throws Exception
*/
- public void sendFile(File file, User user, Product product, EbicsOrderType orderType, EbicsUploadParams params) throws Exception {
+ public void sendFile(File file, User user, Product product, EbicsOrderType orderType, EbicsParams params) throws Exception {
EbicsSession session = createSession(user, product);
FileTransfer transferManager = new FileTransfer(session);
configuration.getTraceManager().setTraceDirectory(
- configuration.getTransferTraceDirectory(user));
+ configuration.getTransferTraceDirectory(user));
try {
transferManager.sendFile(IOUtils.getFileContent(file), orderType, params);
- } catch (IOException | EbicsException e) {
- log
- .error(messages.getString("upload.file.error", file.getAbsolutePath()));
+ } catch (EbicsException e) {
+ log.error(messages.getString("upload.file.error", file.getAbsolutePath()));
throw e;
}
}
- public void sendFile(File file, EbicsOrderType orderType, EbicsUploadParams params) throws Exception {
+ public void sendFile(File file, EbicsOrderType orderType, EbicsParams params) throws Exception {
sendFile(file, defaultUser, defaultProduct, orderType, params);
}
- public void sendFile(File file, EbicsOrderType orderType) throws Exception {
- EbicsUploadParams params;
- if (orderType == OrderType.XE2) {
- var orderParams = new EbicsUploadParams.OrderParams("MCT", "CH", null, "pain.001",
- "03", true);
- params = new EbicsUploadParams(null, orderParams);
- } else {
- params = new EbicsUploadParams(defaultUser.getPartner().nextOrderId(), null);
+ public void sendFileV3(File file, EbicsOrderType orderType) throws Exception {
+ EbicsParams params;
+
+ switch (orderType.getCode()) {
+ case "XE2":
+ var orderParams = new EbicsParams.OrderParams("MCT", "CH", null, "pain.001",
+ "03", true);
+ params = new EbicsParams(null, orderParams);
+ break;
+ default:
+ throw new UnsupportedOperationException(orderType.getCode() + " not yet implemented");
}
+
+ sendFile(file, defaultUser, defaultProduct, orderType, params);
+
+ }
+
+ public void sendFileV2(File file, EbicsOrderType orderType) throws Exception {
+
+ EbicsParams params = new EbicsParams(defaultUser.getPartner().nextOrderId(), null);
+
sendFile(file, defaultUser, defaultProduct, orderType, params);
}
- public void fetchFile(File file, User user, Product product, EbicsOrderType orderType,
- boolean isTest) throws IOException, EbicsException {
+ public void fetchFile(File file, User user, Product product, EbicsOrderType orderType, EbicsParams params,
+ boolean isTest) throws IOException, EbicsException, NoDownloadDataAvailableException {
+
FileTransfer transferManager;
EbicsSession session = createSession(user, product);
- session.addSessionParam("FORMAT", "pain.xxx.cfonb160.dct");
+
if (isTest) {
session.addSessionParam("TEST", "true");
}
transferManager = new FileTransfer(session);
configuration.getTraceManager().setTraceDirectory(
- configuration.getTransferTraceDirectory(user));
+ configuration.getTransferTraceDirectory(user));
try {
- transferManager.fetchFile(orderType, file);
+ transferManager.fetchFile(orderType, file, params);
} catch (NoDownloadDataAvailableException e) {
// don't log this exception as an error, caller can decide how to handle
throw e;
@@ -440,9 +430,51 @@ public void fetchFile(File file, User user, Product product, EbicsOrderType orde
}
}
- public void fetchFile(File file, EbicsOrderType orderType, Date start, Date end) throws IOException,
- EbicsException {
- fetchFile(file, defaultUser, defaultProduct, orderType, false);
+ public void fetchFileV3(File file, User user, Product product, EbicsOrderType orderType,
+ boolean isTest) throws IOException, EbicsException {
+
+ EbicsParams params;
+
+ switch (orderType.getCode()) {
+
+ case "ZQR":
+ var orderParams = new EbicsParams.OrderParams("REP", "CH", "XQRR", "camt.054", "04", true);
+ params = new EbicsParams(orderType.getCode(), orderParams);
+ break;
+ case "Z54":
+ orderParams = new EbicsParams.OrderParams("REP", "CH", "", "camt.054", "08", false);
+ params = new EbicsParams(orderType.getCode(), orderParams);
+ break;
+ case "ZS2":
+ orderParams = new EbicsParams.OrderParams("REP", "CH", "XDCI", "camt.054", "04", true);
+ params = new EbicsParams(orderType.getCode(), orderParams);
+ break;
+ case "XTD":
+ orderParams = new EbicsParams.OrderParams("OTH", "BIL", "CH004TPE", "", "", true);
+ params = new EbicsParams(orderType.getCode(), orderParams);
+ break;
+ default:
+ throw new UnsupportedOperationException(orderType.getCode() + " not yet implemented");
+ }
+
+ fetchFile(file, user, product, orderType, params, isTest);
+
+ }
+
+ public void fetchFileV2(File file, User user, Product product, EbicsOrderType orderType, boolean isTest) throws IOException,
+ EbicsException {
+
+ EbicsParams params = new EbicsParams(defaultUser.getPartner().nextOrderId(), null);
+
+ fetchFile(file, user, product, orderType, params, false);
+ }
+
+ public void fetchFileV2(File file, EbicsOrderType orderType, Date start, Date end) throws IOException,
+ EbicsException {
+
+ EbicsParams params = new EbicsParams(defaultUser.getPartner().nextOrderId(), null);
+
+ fetchFile(file, defaultUser, defaultProduct, orderType, params, false);
}
/**
@@ -453,7 +485,7 @@ public void quit() {
for (User user : users.values()) {
if (user.needsSave()) {
log
- .info(messages.getString("app.quit.users", user.getUserId()));
+ .info(messages.getString("app.quit.users", user.getUserId()));
configuration.getSerializationManager().serialize(user);
}
}
@@ -461,7 +493,7 @@ public void quit() {
for (Partner partner : partners.values()) {
if (partner.needsSave()) {
log
- .info(messages.getString("app.quit.partners", partner.getPartnerId()));
+ .info(messages.getString("app.quit.partners", partner.getPartnerId()));
configuration.getSerializationManager().serialize(partner);
}
}
@@ -469,7 +501,7 @@ public void quit() {
for (Bank bank : banks.values()) {
if (bank.needsSave()) {
log
- .info(messages.getString("app.quit.banks", bank.getHostId()));
+ .info(messages.getString("app.quit.banks", bank.getHostId()));
configuration.getSerializationManager().serialize(bank);
}
}
@@ -486,6 +518,7 @@ public void clearTraces() {
}
public static class ConfigProperties {
+
Properties properties = new Properties();
public ConfigProperties(File file) throws IOException {
@@ -502,7 +535,7 @@ public String get(String key) {
}
private User createUser(ConfigProperties properties, PasswordCallback pwdHandler)
- throws Exception {
+ throws Exception {
String userId = properties.get("userId");
String partnerId = properties.get("partnerId");
String bankUrl = properties.get("bank.url");
@@ -515,11 +548,11 @@ private User createUser(ConfigProperties properties, PasswordCallback pwdHandler
boolean useCertificates = false;
boolean saveCertificates = true;
return createUser(new URL(bankUrl), bankName, hostId, partnerId, userId, userName, userEmail,
- userCountry, userOrg, useCertificates, saveCertificates, pwdHandler);
+ userCountry, userOrg, useCertificates, saveCertificates, pwdHandler);
}
private static CommandLine parseArguments(Options options, String[] args)
- throws ParseException, IOException {
+ throws ParseException, IOException {
CommandLineParser parser = new DefaultParser();
options.addOption(null, "help", false, "Print this help text");
CommandLine line = parser.parse(options, args);
@@ -542,7 +575,7 @@ public static EbicsClient createEbicsClient(File rootDir, File configFile) throw
final Locale locale = new Locale(language, country);
DefaultConfiguration configuration = new DefaultConfiguration(rootDir,
- properties.properties) {
+ properties.properties) {
@Override
public Locale getLocale() {
@@ -620,13 +653,16 @@ public static void main(String[] args) throws Exception {
addOption(options, OrderType.XCT, "Send XCT file (any format)");
addOption(options, OrderType.XE2, "Send XE2 file (any format)");
addOption(options, OrderType.CCT, "Send CCT file (any format)");
+ addOption(options, OrderType.ZS2, "Fetch Camt.054 file 008 version (ZIP)");
+ addOption(options, OrderType.XTD, "Fetch test files Postfinance (ZIP)");
+ addOption(options, OrderType.ZQR, "Fetch test files Postfinance (ZIP)");
+ addOption(options, OrderType.Z54, "Fetch test files Postfinance (ZIP)");
options.addOption(null, "skip_order", true, "Skip a number of order ids");
options.addOption("o", "output", true, "output file");
options.addOption("i", "input", true, "input file");
-
CommandLine cmd = parseArguments(options, args);
File defaultRootDir = getRootDir();
@@ -656,30 +692,53 @@ public static void main(String[] args) throws Exception {
String outputFileValue = cmd.getOptionValue("o");
String inputFileValue = cmd.getOptionValue("i");
+ //Ebics 2.X
var fetchFileOrders = List.of(OrderType.STA, OrderType.VMK,
- OrderType.C52, OrderType.C53, OrderType.C54,
- OrderType.ZDF, OrderType.ZB6, OrderType.PTK, OrderType.HAC, OrderType.Z01);
+ OrderType.C52, OrderType.C53, OrderType.C54,
+ OrderType.ZDF, OrderType.ZB6, OrderType.PTK, OrderType.HAC, OrderType.Z01);
for (EbicsOrderType type : fetchFileOrders) {
if (hasOption(cmd, type)) {
- client.fetchFile(getOutputFile(outputFileValue), client.defaultUser,
- client.defaultProduct, type, false);
+ client.fetchFileV2(getOutputFile(outputFileValue), client.defaultUser,
+ client.defaultProduct, type, false);
+ break;
+ }
+ }
+
+ //Ebics 3.X
+ try {
+ fetchFileOrders = List.of(OrderType.ZS2, OrderType.XTD, OrderType.ZQR, OrderType.Z54);
+
+ for (EbicsOrderType type : fetchFileOrders) {
+
+ if (hasOption(cmd, type)) {
+ client.fetchFileV3(getOutputFile(outputFileValue), client.defaultUser,
+ client.defaultProduct, type, false);
+ break;
+ }
+ }
+ } catch (NoDownloadDataAvailableException nda) {
+ System.out.println(nda.getMessage());
+ }
+ var sendFileOrders = List.of(OrderType.XKD, OrderType.FUL, OrderType.XCT, OrderType.CCT);
+ for (EbicsOrderType type : sendFileOrders) {
+ if (hasOption(cmd, type)) {
+ client.sendFileV2(new File(inputFileValue), type);
break;
}
}
- var sendFileOrders = List.of(OrderType.XKD, OrderType.FUL, OrderType.XCT,
- OrderType.XE2, OrderType.CCT);
+ sendFileOrders = List.of(OrderType.XE2);
for (EbicsOrderType type : sendFileOrders) {
if (hasOption(cmd, type)) {
- client.sendFile(new File(inputFileValue), type);
+ client.sendFileV3(new File(inputFileValue), type);
break;
}
}
if (cmd.hasOption("skip_order")) {
int count = Integer.parseInt(cmd.getOptionValue("skip_order"));
- while(count-- > 0) {
+ while (count-- > 0) {
client.defaultUser.getPartner().nextOrderId();
}
}
diff --git a/src/main/java/org/kopi/ebics/client/EbicsParams.java b/src/main/java/org/kopi/ebics/client/EbicsParams.java
new file mode 100644
index 00000000..b27b97d7
--- /dev/null
+++ b/src/main/java/org/kopi/ebics/client/EbicsParams.java
@@ -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 +
+ '}';
+ }
+ }
+}
diff --git a/src/main/java/org/kopi/ebics/client/EbicsUploadParams.java b/src/main/java/org/kopi/ebics/client/EbicsUploadParams.java
deleted file mode 100644
index 327dfdab..00000000
--- a/src/main/java/org/kopi/ebics/client/EbicsUploadParams.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.kopi.ebics.client;
-
-public record EbicsUploadParams(String orderId, OrderParams orderParams) {
-
- public record OrderParams(String serviceName, String scope, String option, String messageName,
- String messageVersion, boolean signatureFlag) {
- }
-}
diff --git a/src/main/java/org/kopi/ebics/client/FileTransfer.java b/src/main/java/org/kopi/ebics/client/FileTransfer.java
index 001571f1..6b2311c2 100644
--- a/src/main/java/org/kopi/ebics/client/FileTransfer.java
+++ b/src/main/java/org/kopi/ebics/client/FileTransfer.java
@@ -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;
@@ -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);
@@ -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));
@@ -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;
diff --git a/src/main/java/org/kopi/ebics/session/OrderType.java b/src/main/java/org/kopi/ebics/session/OrderType.java
index 1f107607..274c95ee 100644
--- a/src/main/java/org/kopi/ebics/session/OrderType.java
+++ b/src/main/java/org/kopi/ebics/session/OrderType.java
@@ -59,7 +59,11 @@ public enum OrderType implements EbicsOrderType {
XCT,
C52,
C53,
- C54;
+ C54,
+ ZS2,
+ XTD,
+ ZQR,
+ Z54;
@Override
public String getCode() {
diff --git a/src/main/java/org/kopi/ebics/xml/DownloadInitializationRequestElement.java b/src/main/java/org/kopi/ebics/xml/DownloadInitializationRequestElement.java
index df1d29cc..16c2c505 100644
--- a/src/main/java/org/kopi/ebics/xml/DownloadInitializationRequestElement.java
+++ b/src/main/java/org/kopi/ebics/xml/DownloadInitializationRequestElement.java
@@ -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;
@@ -45,14 +47,31 @@
*/
public class DownloadInitializationRequestElement extends InitializationRequestElement {
+
+ /**
+ * Constructs a new DInitializationRequestElement 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 DInitializationRequestElement 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
@@ -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;
+
}
diff --git a/src/main/java/org/kopi/ebics/xml/UploadInitializationRequestElement.java b/src/main/java/org/kopi/ebics/xml/UploadInitializationRequestElement.java
index cca19d28..4022b1db 100644
--- a/src/main/java/org/kopi/ebics/xml/UploadInitializationRequestElement.java
+++ b/src/main/java/org/kopi/ebics/xml/UploadInitializationRequestElement.java
@@ -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;
@@ -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", "");
@@ -98,7 +85,7 @@ 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());
@@ -106,10 +93,10 @@ public void buildInitialization() throws EbicsException {
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;
}
@@ -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;