Skip to content
Merged
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
26 changes: 13 additions & 13 deletions src/main/java/org/kopi/ebics/client/EbicsClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
Expand All @@ -46,6 +45,7 @@
import org.kopi.ebics.exception.NoDownloadDataAvailableException;
import org.kopi.ebics.interfaces.Configuration;
import org.kopi.ebics.interfaces.EbicsBank;
import org.kopi.ebics.interfaces.EbicsOrderType;
import org.kopi.ebics.interfaces.EbicsUser;
import org.kopi.ebics.interfaces.InitLetter;
import org.kopi.ebics.interfaces.LetterManager;
Expand Down Expand Up @@ -380,7 +380,7 @@ 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, OrderType orderType) throws Exception {
public void sendFile(File file, User user, Product product, EbicsOrderType orderType) throws Exception {
EbicsSession session = createSession(user, product);
OrderAttributeType.Enum orderAttribute = OrderAttributeType.OZHNN;

Expand All @@ -398,11 +398,11 @@ public void sendFile(File file, User user, Product product, OrderType orderType)
}
}

public void sendFile(File file, OrderType orderType) throws Exception {
public void sendFile(File file, EbicsOrderType orderType) throws Exception {
sendFile(file, defaultUser, defaultProduct, orderType);
}

public void fetchFile(File file, User user, Product product, OrderType orderType,
public void fetchFile(File file, User user, Product product, EbicsOrderType orderType,
boolean isTest, Date start, Date end) throws IOException, EbicsException {
FileTransfer transferManager;
EbicsSession session = createSession(user, product);
Expand All @@ -426,7 +426,7 @@ public void fetchFile(File file, User user, Product product, OrderType orderType
}
}

public void fetchFile(File file, OrderType orderType, Date start, Date end) throws IOException,
public void fetchFile(File file, EbicsOrderType orderType, Date start, Date end) throws IOException,
EbicsException {
fetchFile(file, defaultUser, defaultProduct, orderType, false, start, end);
}
Expand Down Expand Up @@ -574,12 +574,12 @@ public User getDefaultUser() {
return defaultUser;
}

private static void addOption(Options options, OrderType type, String description) {
options.addOption(null, type.name().toLowerCase(), false, description);
private static void addOption(Options options, EbicsOrderType type, String description) {
options.addOption(null, type.getCode().toLowerCase(), false, description);
}

private static boolean hasOption(CommandLine cmd, OrderType type) {
return cmd.hasOption(type.name().toLowerCase());
private static boolean hasOption(CommandLine cmd, EbicsOrderType type) {
return cmd.hasOption(type.getCode().toLowerCase());
}

public static void main(String[] args) throws Exception {
Expand Down Expand Up @@ -642,21 +642,21 @@ public static void main(String[] args) throws Exception {
String outputFileValue = cmd.getOptionValue("o");
String inputFileValue = cmd.getOptionValue("i");

List<OrderType> fetchFileOrders = Arrays.asList(OrderType.STA, OrderType.VMK,
List<? extends EbicsOrderType> fetchFileOrders = Arrays.asList(OrderType.STA, OrderType.VMK,
OrderType.C52, OrderType.C53, OrderType.C54,
OrderType.ZDF, OrderType.ZB6, OrderType.PTK, OrderType.HAC, OrderType.Z01);

for (OrderType type : fetchFileOrders) {
for (EbicsOrderType type : fetchFileOrders) {
if (hasOption(cmd, type)) {
client.fetchFile(getOutputFile(outputFileValue), client.defaultUser,
client.defaultProduct, type, false, null, null);
break;
}
}

List<OrderType> sendFileOrders = Arrays.asList(OrderType.XKD, OrderType.FUL, OrderType.XCT,
List<? extends EbicsOrderType> sendFileOrders = Arrays.asList(OrderType.XKD, OrderType.FUL, OrderType.XCT,
OrderType.XE2, OrderType.CCT);
for (OrderType type : sendFileOrders) {
for (EbicsOrderType type : sendFileOrders) {
if (hasOption(cmd, type)) {
client.sendFile(new File(inputFileValue), client.defaultUser,
client.defaultProduct, type);
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/kopi/ebics/client/FileTransfer.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@

import org.kopi.ebics.exception.EbicsException;
import org.kopi.ebics.interfaces.ContentFactory;
import org.kopi.ebics.interfaces.EbicsOrderType;
import org.kopi.ebics.io.ByteArrayContentFactory;
import org.kopi.ebics.io.Joiner;
import org.kopi.ebics.messages.Messages;
import org.kopi.ebics.schema.h003.OrderAttributeType;
import org.kopi.ebics.session.EbicsSession;
import org.kopi.ebics.session.OrderType;
import org.kopi.ebics.utils.Constants;
import org.kopi.ebics.utils.Utils;
import org.kopi.ebics.xml.DefaultEbicsRootElement;
Expand Down Expand Up @@ -94,7 +94,7 @@ public FileTransfer(EbicsSession session) {
* @throws IOException
* @throws EbicsException
*/
public void sendFile(byte[] content, OrderType orderType, OrderAttributeType.Enum orderAttribute)
public void sendFile(byte[] content, EbicsOrderType orderType, OrderAttributeType.Enum orderAttribute)
throws IOException, EbicsException
{
HttpRequestSender sender = new HttpRequestSender(session);
Expand Down Expand Up @@ -137,7 +137,7 @@ public void sendFile(ContentFactory factory,
int segmentNumber,
boolean lastSegment,
byte[] transactionId,
OrderType orderType)
EbicsOrderType orderType)
throws IOException, EbicsException
{
UploadTransferRequestElement uploader;
Expand Down Expand Up @@ -178,7 +178,7 @@ public void sendFile(ContentFactory factory,
* @throws IOException communication error
* @throws EbicsException server generated error
*/
public void fetchFile(OrderType orderType,
public void fetchFile(EbicsOrderType orderType,
Date start,
Date end,
File outputFile)
Expand Down Expand Up @@ -254,7 +254,7 @@ public void fetchFile(OrderType orderType,
* @throws IOException communication error
* @throws EbicsException server generated error
*/
public void fetchFile(OrderType orderType,
public void fetchFile(EbicsOrderType orderType,
int segmentNumber,
boolean lastSegment,
byte[] transactionId,
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/org/kopi/ebics/interfaces/EbicsOrderType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.kopi.ebics.interfaces;

public interface EbicsOrderType {

String getCode();

}
12 changes: 10 additions & 2 deletions src/main/java/org/kopi/ebics/session/OrderType.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@

package org.kopi.ebics.session;

import org.kopi.ebics.interfaces.EbicsOrderType;

/**
* A BCS order type.
*
* @author Pierre Ducroquet
*
*/
public enum OrderType {
public enum OrderType implements EbicsOrderType {
HIA,
HAA,
HKD,
Expand Down Expand Up @@ -59,5 +61,11 @@ public enum OrderType {
XCT,
C52,
C53,
C54
C54;

@Override
public String getCode() {
return name();
}

}
5 changes: 2 additions & 3 deletions src/main/java/org/kopi/ebics/xml/DefaultEbicsRootElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@
import org.jdom2.output.Format;
import org.jdom2.output.XMLOutputter;
import org.kopi.ebics.exception.EbicsException;
import org.kopi.ebics.interfaces.EbicsOrderType;
import org.kopi.ebics.interfaces.EbicsRootElement;
import org.kopi.ebics.session.EbicsSession;
import org.kopi.ebics.session.OrderType;


public abstract class DefaultEbicsRootElement implements EbicsRootElement {

Expand Down Expand Up @@ -134,7 +133,7 @@ public void insertSchemaLocation(String namespaceURI,
* @param type the order type.
* @return the generated file name.
*/
public static String generateName(OrderType type) {
public static String generateName(EbicsOrderType type) {
return type.toString() + new BigInteger(130, new SecureRandom()).toString(32);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Date;

import org.kopi.ebics.exception.EbicsException;
import org.kopi.ebics.interfaces.EbicsOrderType;
import org.kopi.ebics.schema.h003.EbicsRequestDocument.EbicsRequest;
import org.kopi.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Body;
import org.kopi.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Header;
Expand Down Expand Up @@ -62,7 +63,7 @@ public class DownloadInitializationRequestElement extends InitializationRequestE
* @throws EbicsException
*/
public DownloadInitializationRequestElement(EbicsSession session,
org.kopi.ebics.session.OrderType type,
EbicsOrderType type,
Date startRange,
Date endRange)
throws EbicsException
Expand Down Expand Up @@ -95,7 +96,7 @@ public void buildInitialization() throws EbicsException {
"http://www.w3.org/2001/04/xmlenc#sha256",
decodeHex(session.getUser().getPartner().getBank().getE002Digest()));
bankPubKeyDigests = EbicsXmlFactory.createBankPubKeyDigests(authentication, encryption);
orderType = EbicsXmlFactory.createOrderType(type.toString());
orderType = EbicsXmlFactory.createOrderType(type.getCode());
if (type.equals(org.kopi.ebics.session.OrderType.FDL)) {
FDLOrderParamsType fDLOrderParamsType;
FileFormatType fileFormat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.kopi.ebics.exception.NoDownloadDataAvailableException;
import org.kopi.ebics.exception.ReturnCode;
import org.kopi.ebics.interfaces.ContentFactory;
import org.kopi.ebics.session.OrderType;
import org.kopi.ebics.interfaces.EbicsOrderType;

/**
* The <code>DInitializationResponseElement</code> is the response element
Expand All @@ -41,7 +41,7 @@ public class DownloadInitializationResponseElement extends InitializationRespons
* @param name the element name
*/
public DownloadInitializationResponseElement(ContentFactory factory,
OrderType orderType,
EbicsOrderType orderType,
String name)
{
super(factory, orderType, name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
package org.kopi.ebics.xml;

import org.kopi.ebics.exception.EbicsException;
import org.kopi.ebics.interfaces.EbicsOrderType;
import org.kopi.ebics.schema.h003.MutableHeaderType;
import org.kopi.ebics.schema.h003.StaticHeaderType;
import org.kopi.ebics.schema.h003.EbicsRequestDocument.EbicsRequest;
import org.kopi.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Body;
import org.kopi.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Header;
import org.kopi.ebics.schema.h003.MutableHeaderType.SegmentNumber;
import org.kopi.ebics.session.EbicsSession;
import org.kopi.ebics.session.OrderType;

/**
* The <code>DTransferRequestElement</code> is the common elements
Expand All @@ -47,7 +47,7 @@ public class DownloadTransferRequestElement extends TransferRequestElement {
* @param transactionId the transaction ID
*/
public DownloadTransferRequestElement(EbicsSession session,
OrderType type,
EbicsOrderType type,
int segmentNumber,
boolean lastSegment,
byte[] transactionId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import org.kopi.ebics.exception.EbicsException;
import org.kopi.ebics.interfaces.ContentFactory;
import org.kopi.ebics.session.OrderType;
import org.kopi.ebics.interfaces.EbicsOrderType;

/**
* The <code>DTransferResponseElement</code> is the response element
Expand All @@ -39,7 +39,7 @@ public class DownloadTransferResponseElement extends TransferResponseElement {
* @param name the element name.
*/
public DownloadTransferResponseElement(ContentFactory factory,
OrderType orderType,
EbicsOrderType orderType,
String name)
{
super(factory, name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
import org.apache.commons.codec.binary.Hex;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.kopi.ebics.exception.EbicsException;
import org.kopi.ebics.interfaces.EbicsOrderType;
import org.kopi.ebics.schema.h003.EbicsRequestDocument;
import org.kopi.ebics.session.EbicsSession;
import org.kopi.ebics.session.OrderType;
import org.kopi.ebics.utils.Utils;


Expand All @@ -53,7 +53,7 @@ public abstract class InitializationRequestElement extends DefaultEbicsRootEleme
* @throws EbicsException
*/
public InitializationRequestElement(EbicsSession session,
OrderType type,
EbicsOrderType type,
String name)
throws EbicsException
{
Expand Down Expand Up @@ -108,7 +108,7 @@ public byte[] getDigest() throws EbicsException {
* @return the element type.
*/
public String getType() {
return type.toString();
return type.getCode();
}

/**
Expand Down Expand Up @@ -158,7 +158,7 @@ protected byte[] generateTransactionKey() throws EbicsException {
// --------------------------------------------------------------------

private String name;
protected OrderType type;
protected EbicsOrderType type;
protected byte[] nonce;
private static final long serialVersionUID = 8983807819242699280L;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import org.kopi.ebics.exception.EbicsException;
import org.kopi.ebics.exception.ReturnCode;
import org.kopi.ebics.interfaces.ContentFactory;
import org.kopi.ebics.interfaces.EbicsOrderType;
import org.kopi.ebics.schema.h003.EbicsResponseDocument;
import org.kopi.ebics.schema.h003.EbicsResponseDocument.EbicsResponse;
import org.kopi.ebics.session.OrderType;

/**
* The <code>InitializationResponseElement</code> is the common
Expand All @@ -42,7 +42,7 @@ public class InitializationResponseElement extends DefaultResponseElement {
* @param name the element name
*/
public InitializationResponseElement(ContentFactory factory,
OrderType orderType,
EbicsOrderType orderType,
String name)
{
super(factory, name);
Expand Down Expand Up @@ -81,15 +81,15 @@ public byte[] getTransactionId() {
* @return the order type.
*/
public String getOrderType() {
return orderType.toString();
return orderType.getCode();
}

// --------------------------------------------------------------------
// DATA MEMBERS
// --------------------------------------------------------------------

protected EbicsResponse response;
private OrderType orderType;
private EbicsOrderType orderType;
private byte[] transactionId;
private static final long serialVersionUID = 7684048385353175772L;
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void build() throws EbicsException {
OrderDetailsType orderDetails;

product = EbicsXmlFactory.creatProductElementType(session.getProduct().getLanguage(), session.getProduct().getName());
orderDetails = EbicsXmlFactory.createOrderDetailsType("DZHNN", null, OrderType.HPB.toString());
orderDetails = EbicsXmlFactory.createOrderDetailsType("DZHNN", null, OrderType.HPB.getCode());
xstatic = EbicsXmlFactory.createNoPubKeyDigestsRequestStaticHeaderType(session.getBankID(),
Utils.generateNonce(),
Calendar.getInstance(),
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kopi/ebics/xml/SPRRequestElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void buildInitialization() throws EbicsException {
"http://www.w3.org/2001/04/xmlenc#sha256",
decodeHex(session.getUser().getPartner().getBank().getE002Digest()));
bankPubKeyDigests = EbicsXmlFactory.createBankPubKeyDigests(authentication, encryption);
orderType = EbicsXmlFactory.createOrderType(type.toString());
orderType = EbicsXmlFactory.createOrderType(type.getCode());
standardOrderParamsType = EbicsXmlFactory.createStandardOrderParamsType();
orderDetails = EbicsXmlFactory.createStaticHeaderOrderDetailsType(session.getUser().getPartner().nextOrderId(),
OrderAttributeType.UZHNN,
Expand Down
Loading