You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by zr...@apache.org on 2018/05/07 12:18:56 UTC
[camel] branch master updated: Fixes checkstyle issues and removes
trailing wh...
This is an automated email from the ASF dual-hosted git repository.
zregvart pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new 730c9f0 Fixes checkstyle issues and removes trailing wh...
730c9f0 is described below
commit 730c9f003e7d1e3e9e520f4780c5af5a9b929a92
Author: Zoran Regvart <zr...@apache.org>
AuthorDate: Mon May 7 14:18:52 2018 +0200
Fixes checkstyle issues and removes trailing wh...
...itespace
---
.../apache/camel/component/as2/api/AS2Charset.java | 4 +-
.../component/as2/api/AS2ClientConnection.java | 14 +--
.../camel/component/as2/api/AS2ClientManager.java | 24 ++---
.../camel/component/as2/api/AS2Constants.java | 28 +++---
.../apache/camel/component/as2/api/AS2Header.java | 2 +-
.../component/as2/api/AS2MessageStructure.java | 8 +-
.../camel/component/as2/api/AS2MicAlgorithm.java | 6 +-
.../camel/component/as2/api/AS2ReportType.java | 4 +-
.../component/as2/api/AS2ServerConnection.java | 16 +--
.../camel/component/as2/api/AS2ServerManager.java | 22 ++---
.../component/as2/api/AS2SignedDataGenerator.java | 14 +--
.../component/as2/api/AS2TransferEncoding.java | 2 +-
.../component/as2/api/CanonicalOutputStream.java | 2 +-
.../component/as2/api/InvalidAS2NameException.java | 14 +--
.../apache/camel/component/as2/api/MDNField.java | 2 +-
.../org/apache/camel/component/as2/api/Util.java | 36 +++----
.../as2/api/entity/AS2DispositionModifier.java | 16 +--
.../as2/api/entity/AS2DispositionType.java | 8 +-
.../AS2MessageDispositionNotificationEntity.java | 8 +-
.../as2/api/entity/ApplicationEDIEntity.java | 10 +-
.../as2/api/entity/ApplicationEDIFACTEntity.java | 2 +-
.../entity/ApplicationPkcs7SignatureEntity.java | 18 ++--
.../component/as2/api/entity/DispositionMode.java | 4 +-
...spositionNotificationMultipartReportEntity.java | 14 +--
.../api/entity/DispositionNotificationOptions.java | 6 +-
.../DispositionNotificationOptionsParser.java | 10 +-
.../component/as2/api/entity/EntityParser.java | 70 ++++++-------
.../camel/component/as2/api/entity/Importance.java | 8 +-
.../camel/component/as2/api/entity/MimeEntity.java | 40 ++++----
.../as2/api/entity/MultipartMimeEntity.java | 14 +--
.../as2/api/entity/MultipartReportEntity.java | 4 +-
.../as2/api/entity/MultipartSignedEntity.java | 22 ++---
.../component/as2/api/entity/TextPlainEntity.java | 12 +--
.../as2/api/io/AS2BHttpServerConnection.java | 2 +-
.../as2/api/io/AS2SessionInputBuffer.java | 8 +-
.../component/as2/api/protocol/RequestAS2.java | 14 +--
.../component/as2/api/protocol/RequestMDN.java | 8 +-
.../component/as2/api/protocol/ResponseMDN.java | 32 +++---
.../component/as2/api/util/AS2HeaderUtils.java | 8 +-
.../util/DispositionNotificationContentUtils.java | 18 ++--
.../camel/component/as2/api/util/EntityUtils.java | 40 ++++----
.../component/as2/api/util/HttpMessageUtils.java | 12 +--
.../camel/component/as2/api/util/MicUtils.java | 24 ++---
.../camel/component/as2/api/util/SigningUtils.java | 6 +-
.../camel/component/as2/api/AS2MessageTest.java | 78 +++++++--------
.../org/apache/camel/component/as2/api/Utils.java | 2 +-
.../component/as2/api/entity/EntityParserTest.java | 110 ++++++++++-----------
.../component/as2/api/util/AS2HeaderUtilsTest.java | 6 +-
.../DispositionNotificationContentUtilsTest.java | 22 ++---
.../camel/component/as2/api/util/MicUtilsTest.java | 44 ++++-----
.../camel/component/as2/AS2Configuration.java | 106 ++++++++++----------
.../apache/camel/component/as2/AS2Consumer.java | 18 ++--
.../apache/camel/component/as2/AS2Endpoint.java | 12 +--
.../as2/internal/AS2ConnectionHelper.java | 16 +--
.../as2/AS2ClientManagerIntegrationTest.java | 52 +++++-----
.../as2/AS2ServerManagerIntegrationTest.java | 54 +++++-----
.../java/org/apache/camel/component/as2/Utils.java | 2 +-
57 files changed, 579 insertions(+), 579 deletions(-)
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2Charset.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2Charset.java
index 2b43afd..07712c4 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2Charset.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2Charset.java
@@ -17,12 +17,12 @@
package org.apache.camel.component.as2.api;
public interface AS2Charset {
-
+
/**
* Name of charset parameter in Content-Type header values.
*/
public static final String PARAM = "charset";
-
+
/**
* Character Set Name for US ASCII
*/
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ClientConnection.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ClientConnection.java
index 672f25d..2198d21 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ClientConnection.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ClientConnection.java
@@ -41,21 +41,21 @@ import org.apache.http.protocol.RequestUserAgent;
import org.apache.http.util.Args;
public class AS2ClientConnection {
-
+
private HttpHost targetHost;
private HttpProcessor httpProcessor;
private DefaultBHttpClientConnection httpConnection;
private String as2Version;
private String userAgent;
private String clientFqdn;
-
+
public AS2ClientConnection(String as2Version, String userAgent, String clientFqdn, String targetHostName, Integer targetPortNumber) throws UnknownHostException, IOException {
this.as2Version = Args.notNull(as2Version, "as2Version");
this.userAgent = Args.notNull(userAgent, "userAgent");
this.clientFqdn = Args.notNull(clientFqdn, "clientFqdn");
this.targetHost = new HttpHost(Args.notNull(targetHostName, "targetHostName"), Args.notNull(targetPortNumber, "targetPortNumber"));
-
+
// Build Processor
httpProcessor = HttpProcessorBuilder.create()
.add(new RequestAS2(as2Version, clientFqdn))
@@ -66,7 +66,7 @@ public class AS2ClientConnection {
.add(new RequestContent(true))
.add(new RequestConnControl())
.add(new RequestExpectContinue(true)).build();
-
+
// Create Socket
Socket socket = new Socket(targetHost.getHostName(), targetHost.getPort());
@@ -74,7 +74,7 @@ public class AS2ClientConnection {
httpConnection = new AS2BHttpClientConnection(8 * 1024);
httpConnection.bind(socket);
}
-
+
public String getAs2Version() {
return as2Version;
}
@@ -88,13 +88,13 @@ public class AS2ClientConnection {
}
public HttpResponse send(HttpRequest request, HttpCoreContext httpContext) throws HttpException, IOException {
-
+
httpContext.setTargetHost(targetHost);
// Execute Request
HttpRequestExecutor httpexecutor = new HttpRequestExecutor();
httpexecutor.preProcess(request, httpProcessor, httpContext);
- HttpResponse response = httpexecutor.execute(request, httpConnection, httpContext);
+ HttpResponse response = httpexecutor.execute(request, httpConnection, httpContext);
httpexecutor.postProcess(response, httpProcessor, httpContext);
return response;
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ClientManager.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ClientManager.java
index 8d62876..72f5807 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ClientManager.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ClientManager.java
@@ -34,7 +34,7 @@ import org.apache.http.util.Args;
/**
* AS2 Client Manager
- *
+ *
* <p>
* Sends EDI Messages over HTTP
*
@@ -55,17 +55,17 @@ public class AS2ClientManager {
* The HTTP Context Attribute indicating the AS2 message structure to be sent.
*/
public static final String AS2_MESSAGE_STRUCTURE = CAMEL_AS2_CLIENT_PREFIX + "as2-message-structure";
-
+
/**
* The HTTP Context Attribute indicating the EDI message content type to be sent.
*/
public static final String EDI_MESSAGE_CONTENT_TYPE = CAMEL_AS2_CLIENT_PREFIX + "edi-message-content-type";
-
+
/**
* The HTTP Context Attribute indicating the EDI message transfer encoding to be sent.
*/
public static final String EDI_MESSAGE_TRANSFER_ENCODING = CAMEL_AS2_CLIENT_PREFIX + "edi-message-transfer-encoding";
-
+
/**
* The HTTP Context Attribute containing the HTTP request message
* transporting the EDI message
@@ -136,13 +136,13 @@ public class AS2ClientManager {
/**
* The HTTP Context Attribute containing the internet e-mail address of
- * sending system requesting a message disposition notification.
+ * sending system requesting a message disposition notification.
*/
public static final String DISPOSITION_NOTIFICATION_TO = CAMEL_AS2_CLIENT_PREFIX + "disposition-notification-to";
/**
- * The HTTP Context Attribute containing the list of names of the requested MIC algorithms to be used
- * by the receiving system to construct a message disposition notification.
+ * The HTTP Context Attribute containing the list of names of the requested MIC algorithms to be used
+ * by the receiving system to construct a message disposition notification.
*/
public static final String SIGNED_RECEIPT_MIC_ALGORITHMS = CAMEL_AS2_CLIENT_PREFIX + "signed-receipt-mic-algorithms";
@@ -156,7 +156,7 @@ public class AS2ClientManager {
/**
* Send <code>ediMessage</code> to trading partner.
- *
+ *
* @param ediMessage
* - EDI message to transport
* @param httpContext
@@ -177,12 +177,12 @@ public class AS2ClientManager {
String dispositionNotificationTo,
String[] signedReceiptMicAlgorithms)
throws HttpException {
-
+
Args.notNull(ediMessage, "EDI Message");
Args.notNull(as2MessageStructure, "AS2 Message Structure");
Args.notNull(requestUri, "Request URI");
Args.notNull(ediMessageContentType, "EDI Message Content Type");
-
+
// Add Context attributes
HttpCoreContext httpContext = HttpCoreContext.create();
httpContext.setAttribute(AS2ClientManager.REQUEST_URI, requestUri);
@@ -197,7 +197,7 @@ public class AS2ClientManager {
httpContext.setAttribute(AS2ClientManager.SIGNING_PRIVATE_KEY, signingPrivateKey);
httpContext.setAttribute(AS2ClientManager.DISPOSITION_NOTIFICATION_TO, dispositionNotificationTo);
httpContext.setAttribute(AS2ClientManager.SIGNED_RECEIPT_MIC_ALGORITHMS, signedReceiptMicAlgorithms);
-
+
BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", requestUri);
httpContext.setAttribute(HTTP_REQUEST, request);
@@ -257,7 +257,7 @@ public class AS2ClientManager {
if (privateKey == null) {
throw new HttpException("Signing private key missing");
}
-
+
return SigningUtils.createSigningGenerator(certificateChain, privateKey);
}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2Constants.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2Constants.java
index 5a9faf8..9a4f4e1 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2Constants.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2Constants.java
@@ -22,27 +22,27 @@ import org.apache.http.protocol.HttpCoreContext;
* Constants for AS2 component.
*/
public interface AS2Constants {
-
+
/**
* The Value of User Agent Header used by AS2 Camel Component.
*/
public static final String HTTP_USER_AGENT = "Camel AS2 Component";
-
+
/**
* The Value of Origin Server Header used by AS2 Camel Component.
*/
public static final String HTTP_ORIGIN_SERVER = "Camel AS2 Component";
-
+
/**
* Fully Qualified Domain Name used by AS2 Camel Component in Message ID Header.
*/
public static final String HTTP_MESSAGE_ID_FQDN = "camel.apache.org";
-
+
/**
* The Value of User Agent Header used by AS2 Camel Component.
*/
public static final String MIME_VERSION = "1.0";
-
+
//
// HTTP Context Attribute Names
//
@@ -51,40 +51,40 @@ public interface AS2Constants {
* HTTP Context Attribute Name for HTTP Client Connection object stored in context.
*/
public static final String HTTP_CLIENT_CONNECTION = HttpCoreContext.HTTP_CONNECTION;
-
+
/**
* HTTP Context Attribute Name for HTTP Client Processor object stored in context.
*/
public static final String HTTP_CLIENT_PROCESSOR = "http.processor";
-
+
/**
* HTTP Context Attribute Name for HTTP Client Fully Qualified Domain Name (FQDN) stored in context.
*/
public static final String HTTP_CLIENT_FQDN = "client.fqdn";
-
+
/**
* HTTP Context Attribute Name for HTTP Server Connection object stored in context.
*/
public static final String HTTP_SERVER_CONNECTION = "http.server.connection";
-
+
/**
* HTTP Context Attribute Name for HTTP Server Processor object stored in context.
*/
public static final String HTTP_SERVER_PROCESSOR = "http.server.processor";
-
+
/**
* HTTP Context Attribute Name for HTTP Server Service object stored in context.
*/
public static final String HTTP_SERVER_SERVICE = "http.server.service";
-
-
+
+
//
// AS2 MIME Content Types
//
-
+
/**
* Application EDIFACT content type
*/
public static final String APPLICATION_EDIFACT_MIME_TYPE = "Application/EDIFACT";
-
+
}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2Header.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2Header.java
index d31d04e..c6cc323 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2Header.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2Header.java
@@ -19,7 +19,7 @@ package org.apache.camel.component.as2.api;
import org.apache.http.protocol.HTTP;
public interface AS2Header {
-
+
/**
* Message Header Name for MIME Version
*/
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2MessageStructure.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2MessageStructure.java
index 0bb9202..3c8210a 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2MessageStructure.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2MessageStructure.java
@@ -17,21 +17,21 @@
package org.apache.camel.component.as2.api;
public enum AS2MessageStructure {
- PLAIN(false, false, false),
+ PLAIN(false, false, false),
SIGNED(false, false, false),
ENCRYPTED(false, false, false),
ENCRYPTED_SIGNED(false, false, false);
-
+
private final boolean isSigned;
private final boolean isEncrypted;
private final boolean isCompressed;
-
+
private AS2MessageStructure(boolean isSigned, boolean isEncrypted, boolean isCompressed) {
this.isSigned = isSigned;
this.isEncrypted = isEncrypted;
this.isCompressed = isCompressed;
}
-
+
public boolean isSigned() {
return isSigned;
}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2MicAlgorithm.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2MicAlgorithm.java
index b6c9082..a6be90f 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2MicAlgorithm.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2MicAlgorithm.java
@@ -30,7 +30,7 @@ public enum AS2MicAlgorithm {
private String jdkAlgorithmName;
private String as2AlgorithmName;
-
+
private AS2MicAlgorithm(String jdkAlgorithmName, String as2AlgorithmName) {
this.jdkAlgorithmName = jdkAlgorithmName;
this.as2AlgorithmName = as2AlgorithmName;
@@ -54,7 +54,7 @@ public enum AS2MicAlgorithm {
return null;
}
}
-
+
public static String getAS2AlgorithmName(String jdkAlgorithmName) {
switch(jdkAlgorithmName) {
case Constants.MD5_JDK_ALGORITHM_NAME:
@@ -65,5 +65,5 @@ public enum AS2MicAlgorithm {
return null;
}
}
-
+
}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ReportType.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ReportType.java
index 2f3c969..075c1c7 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ReportType.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ReportType.java
@@ -17,10 +17,10 @@
package org.apache.camel.component.as2.api;
public interface AS2ReportType {
-
+
/**
* Disposition Notification Report Type
*/
public static final String DISPOSITION_NOTIFICATION = "disposition-notification";
-
+
}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ServerConnection.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ServerConnection.java
index 9e40149..3b383fe 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ServerConnection.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ServerConnection.java
@@ -52,7 +52,7 @@ public class AS2ServerConnection {
private static final String REQUEST_LISTENER_THREAD_NAME_PREFIX = "AS2Svr-";
private static final String REQUEST_HANDLER_THREAD_NAME_PREFIX = "AS2Hdlr-";
-
+
static class RequestListenerThread extends Thread {
private final ServerSocket serversocket;
@@ -105,11 +105,11 @@ public class AS2ServerConnection {
}
}
}
-
+
void registerHandler(String requestUriPattern, HttpRequestHandler httpRequestHandler) {
reqistry.register(requestUriPattern, httpRequestHandler);
}
-
+
void unregisterHandler(String requestUri) {
reqistry.unregister(requestUri);
}
@@ -155,9 +155,9 @@ public class AS2ServerConnection {
}
}
}
-
+
}
-
+
private RequestListenerThread listenerThread;
private String as2Version;
private String originServer;
@@ -184,7 +184,7 @@ public class AS2ServerConnection {
listenerThread.setDaemon(true);
listenerThread.start();
}
-
+
public void close() {
if (listenerThread != null) {
synchronized (listenerThread) {
@@ -206,9 +206,9 @@ public class AS2ServerConnection {
}
}
}
-
+
public void stopListening(String requestUri) {
-
+
if (listenerThread != null) {
listenerThread.unregisterHandler(requestUri);
}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ServerManager.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ServerManager.java
index dfcf973..7a94953 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ServerManager.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ServerManager.java
@@ -27,13 +27,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * AS2 Server Manager
- *
- * <p>Receives EDI Messages over HTTP
+ * AS2 Server Manager
+ *
+ * <p>Receives EDI Messages over HTTP
*
*/
public class AS2ServerManager {
-
+
//
// AS2 HTTP Context Attribute Keys
//
@@ -57,13 +57,13 @@ public class AS2ServerManager {
public static final String FROM = CAMEL_AS2_SERVER_PREFIX + "from";
private static final Logger LOG = LoggerFactory.getLogger(AS2ServerManager.class);
-
+
private AS2ServerConnection as2ServerConnection;
-
+
public AS2ServerManager(AS2ServerConnection as2ServerConnection) {
this.as2ServerConnection = as2ServerConnection;
}
-
+
public void listen(String requestUriPattern, HttpRequestHandler handler) {
try {
as2ServerConnection.listen(requestUriPattern, handler);
@@ -71,15 +71,15 @@ public class AS2ServerManager {
LOG.error("Failed to listen for '" + requestUriPattern + "' requests: " + e.getMessage(), e);
throw new RuntimeException("Failed to listen for '" + requestUriPattern + "' requests: " + e.getMessage(), e);
}
-
+
}
-
+
public void stopListening(String requestUri) {
as2ServerConnection.stopListening(requestUri);
}
-
+
public void handleMDNResponse(HttpEntityEnclosingRequest request, HttpResponse response, HttpContext httpContext, String subject, String from) throws HttpException {
- // Add Context attributes for Response
+ // Add Context attributes for Response
httpContext.setAttribute(SUBJECT, subject);
httpContext.setAttribute(FROM, from);
}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2SignedDataGenerator.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2SignedDataGenerator.java
index 791d98f..9441c17 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2SignedDataGenerator.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2SignedDataGenerator.java
@@ -66,7 +66,7 @@ public class AS2SignedDataGenerator extends CMSSignedDataGenerator {
STANDARD_MICALGS = Collections.unmodifiableMap(stdMicAlgs);
}
-
+
/**
* Signing algorithms for DSA keys in order of preference
*/
@@ -90,7 +90,7 @@ public class AS2SignedDataGenerator extends CMSSignedDataGenerator {
"MD5WITHRSA",
"MD2WITHRSA",
};
-
+
/**
* Signing algorithms for EC keys in order of preference
*/
@@ -104,10 +104,10 @@ public class AS2SignedDataGenerator extends CMSSignedDataGenerator {
public AS2SignedDataGenerator() {
}
-
+
/**
* Creates a <code>multipart/signed</code> content type containing the algorithms used by this generator.
- *
+ *
* @return A <code>multipart/signed</code> content type
*/
public ContentType createMultipartSignedContentType(String boundary) {
@@ -170,12 +170,12 @@ public class AS2SignedDataGenerator extends CMSSignedDataGenerator {
header.append('\"');
}
}
-
+
return ContentType.parse(header.toString());
}
-
+
public static String[] getSupportedSignatureAlgorithmNamesForKey(Key key) {
-
+
switch (key.getAlgorithm()) {
case "DSA":
return DSA_SIGNING_ALGORITHMS;
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2TransferEncoding.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2TransferEncoding.java
index 801c63e..2631721 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2TransferEncoding.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2TransferEncoding.java
@@ -17,7 +17,7 @@
package org.apache.camel.component.as2.api;
public interface AS2TransferEncoding {
- public static final String NONE = null;
+ public static final String NONE = null;
public static final String BASE64 = "base64";
public static final String SEVENBIT = "7bit";
}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/CanonicalOutputStream.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/CanonicalOutputStream.java
index e926422..165860b 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/CanonicalOutputStream.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/CanonicalOutputStream.java
@@ -31,7 +31,7 @@ public class CanonicalOutputStream extends FilterOutputStream {
newline[1] = (byte) '\n';
}
- private String charset;
+ private String charset;
public CanonicalOutputStream(OutputStream out, String charset) {
super(out);
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/InvalidAS2NameException.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/InvalidAS2NameException.java
index 6439fdc..f5084f4 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/InvalidAS2NameException.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/InvalidAS2NameException.java
@@ -24,22 +24,22 @@ public class InvalidAS2NameException extends Exception {
private static final long serialVersionUID = -6284079291785073089L;
private final String name;
-
+
private final int index;
-
+
/**
* Constructs an <code>InvalidAS2NameException</code> for the
* specified name and index.
- *
+ *
* @param name - the AS2 name that is invalid.
- * @param index - the index in the <code>name</code> of the invalid character
+ * @param index - the index in the <code>name</code> of the invalid character
*/
public InvalidAS2NameException(String name, int index) {
super();
this.name = name;
this.index = index;
}
-
+
/* (non-Javadoc)
* @see java.lang.Throwable#getMessage()
*/
@@ -55,7 +55,7 @@ public class InvalidAS2NameException extends Exception {
/**
* Returns the invalid AS2 name
- *
+ *
* @return the invalid AS2 name
*/
public String getName() {
@@ -64,7 +64,7 @@ public class InvalidAS2NameException extends Exception {
/**
* Returns the index of the invalid character in <code>name</code>
- *
+ *
* @return the index of the invalid character in <code>name</code>
*/
public int getIndex() {
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/MDNField.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/MDNField.java
index 6352740..5e9dc38 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/MDNField.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/MDNField.java
@@ -17,7 +17,7 @@
package org.apache.camel.component.as2.api;
public interface MDNField {
-
+
/**
* Field Name for Reporting UA
*/
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/Util.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/Util.java
index ce1c613..e7ea0b7 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/Util.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/Util.java
@@ -39,29 +39,29 @@ import org.apache.http.StatusLine;
* Utility Methods used in AS2 Component
*/
public final class Util {
-
+
public static final String DQUOTE = "\"";
public static final String BACKSLASH = "\\\\";
public static final String AS2_TEXT_CHAR_SET = "[\u0021\u0023-\\\u005B\\\u005D-\u007E]";
public static final String AS2_QUOTED_TEXT_CHAR_SET = "[\u0020\u0021\u0023-\\\u005B\\\u005D-\u007E]";
- public static final String AS2_QUOTED_PAIR = BACKSLASH + DQUOTE + "|" + BACKSLASH + BACKSLASH;
-
+ public static final String AS2_QUOTED_PAIR = BACKSLASH + DQUOTE + "|" + BACKSLASH + BACKSLASH;
+
public static final String AS2_QUOTED_NAME = DQUOTE + "(" + AS2_QUOTED_TEXT_CHAR_SET + "|" + AS2_QUOTED_PAIR + "){1,128}" + DQUOTE;
public static final String AS2_ATOMIC_NAME = "(" + AS2_TEXT_CHAR_SET + "){1,128}";
public static final String AS2_NAME = AS2_ATOMIC_NAME + "|" + AS2_QUOTED_NAME;
-
+
public static final Pattern AS_NAME_PATTERN = Pattern.compile(AS2_NAME);
-
+
private static Random generator = new Random();
-
+
private Util() {
}
-
+
/**
* Validates if the given <code>name</code> is a valid AS2 Name
- *
+ *
* @param name - the name to validate.
- * @throws InvalidAS2NameException
+ * @throws InvalidAS2NameException
*/
public static void validateAS2Name(String name) throws InvalidAS2NameException {
Matcher matcher = AS_NAME_PATTERN.matcher(name);
@@ -77,7 +77,7 @@ public final class Util {
throw new InvalidAS2NameException(name, i);
}
}
-
+
/**
* Generates a globally unique message ID which includes <code>fqdn</code>: a fully qualified domain name (FQDN)
* @param fqdn - the fully qualified domain name to use in message id.
@@ -87,8 +87,8 @@ public final class Util {
/* Wall Clock Time in Nanoseconds */ /* 64 Bit Random Number */ /* Fully Qualified Domain Name */
return "<" + Long.toString(System.nanoTime(), 36) + "." + Long.toString(generator.nextLong(), 36) + "@" + fqdn + ">";
}
-
-
+
+
/**
* Determines if <code>c</code> is a printable character.
* @param c - the character to test
@@ -99,7 +99,7 @@ public final class Util {
return (!Character.isISOControl(c)) && c != KeyEvent.CHAR_UNDEFINED && block != null
&& block != Character.UnicodeBlock.SPECIALS;
}
-
+
public static String printRequest(HttpRequest request) throws IOException {
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos, true, "utf-8")) {
@@ -108,7 +108,7 @@ public final class Util {
return content;
}
}
-
+
public static String printMessage(HttpMessage message) throws IOException {
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos, true, "utf-8")) {
@@ -117,10 +117,10 @@ public final class Util {
return content;
}
}
-
+
/**
* Prints the contents of request to given print stream.
- *
+ *
* @param out
* - the stream printed to.
* @param request
@@ -148,7 +148,7 @@ public final class Util {
/**
* Prints the contents of an Http Message to given print stream.
- *
+ *
* @param out - the stream printed to.
* @param message - the request printed.
* @throws IOException
@@ -168,7 +168,7 @@ public final class Util {
out.println(header.getName() + ": " + (header.getValue() == null ? "" : header.getValue()));
}
out.println(); // write empty line separating header from body.
-
+
if (message instanceof HttpEntityEnclosingRequest) {
// Write entity
HttpEntity entity = ((HttpEntityEnclosingRequest)message).getEntity();
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/AS2DispositionModifier.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/AS2DispositionModifier.java
index b4ed117..caa2e0a 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/AS2DispositionModifier.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/AS2DispositionModifier.java
@@ -17,7 +17,7 @@
package org.apache.camel.component.as2.api.entity;
public final class AS2DispositionModifier {
-
+
public static final AS2DispositionModifier ERROR = new AS2DispositionModifier("error");
public static final AS2DispositionModifier ERROR_AUTHENTICATION_FAILED = new AS2DispositionModifier("error: authentication-failed");
public static final AS2DispositionModifier ERROR_DECOMPRESSION_FAILED = new AS2DispositionModifier("error: decompression-failed");
@@ -26,17 +26,17 @@ public final class AS2DispositionModifier {
public static final AS2DispositionModifier ERROR_INTEGRITY_CHECK_FAILED = new AS2DispositionModifier("error: integrity-check-failed");
public static final AS2DispositionModifier ERROR_UNEXPECTED_PROCESSING_ERROR = new AS2DispositionModifier("error: unexpected-processing-error");
public static final AS2DispositionModifier WARNING = new AS2DispositionModifier("warning");
-
+
private String modifier;
-
+
private AS2DispositionModifier(String modifier) {
this.modifier = modifier;
}
-
+
public String getModifier() {
return modifier;
}
-
+
public boolean isError() {
return modifier.startsWith("error: ");
}
@@ -57,11 +57,11 @@ public final class AS2DispositionModifier {
public static AS2DispositionModifier createWarning(String description) {
return new AS2DispositionModifier("warning: " + description);
}
-
+
public static AS2DispositionModifier createFailure(String description) {
return new AS2DispositionModifier("failure: " + description);
}
-
+
public static AS2DispositionModifier parseDispositionType(String dispositionModifierString) {
switch(dispositionModifierString) {
case "error":
@@ -87,5 +87,5 @@ public final class AS2DispositionModifier {
return null;
}
}
-
+
}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/AS2DispositionType.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/AS2DispositionType.java
index 13b1fff..9d3d5ea 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/AS2DispositionType.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/AS2DispositionType.java
@@ -19,9 +19,9 @@ package org.apache.camel.component.as2.api.entity;
public enum AS2DispositionType {
PROCESSED("processed"),
FAILED("failed");
-
+
private String type;
-
+
private AS2DispositionType(String type) {
this.type = type;
}
@@ -29,12 +29,12 @@ public enum AS2DispositionType {
public String getType() {
return type;
}
-
+
@Override
public String toString() {
return type;
}
-
+
public static AS2DispositionType parseDispositionType(String dispositionTypeString) {
switch(dispositionTypeString) {
case "processed":
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/AS2MessageDispositionNotificationEntity.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/AS2MessageDispositionNotificationEntity.java
index b1a4bf2..dd933d0 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/AS2MessageDispositionNotificationEntity.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/AS2MessageDispositionNotificationEntity.java
@@ -79,16 +79,16 @@ public class AS2MessageDispositionNotificationEntity extends MimeEntity {
boolean isMainBody) throws HttpException {
setMainBody(isMainBody);
setContentType(ContentType.create(AS2MimeType.MESSAGE_DISPOSITION_NOTIFICATION, charset));
-
+
this.finalRecipient = HttpMessageUtils.getHeaderValue(request, AS2Header.AS2_TO);
if (this.finalRecipient == null) {
throw new HttpException("The " + AS2Header.AS2_TO + " is missing");
}
-
+
this.originalMessageId = HttpMessageUtils.getHeaderValue(request, AS2Header.MESSAGE_ID);
this.receivedContentMic = MicUtils.createReceivedContentMic(request);
-
+
this.reportingUA = HttpMessageUtils.getHeaderValue(response, AS2Header.SERVER);
this.dispositionMode = Args.notNull(dispositionMode, "Disposition Mode");
@@ -103,7 +103,7 @@ public class AS2MessageDispositionNotificationEntity extends MimeEntity {
this.extensionFields.putAll(extensionFields);
}
}
-
+
public AS2MessageDispositionNotificationEntity(String reportingUA,
String mtnName,
String finalRecipient,
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/ApplicationEDIEntity.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/ApplicationEDIEntity.java
index a49396a..73ec7ff 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/ApplicationEDIEntity.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/ApplicationEDIEntity.java
@@ -27,16 +27,16 @@ import org.apache.http.entity.ContentType;
import org.apache.http.util.Args;
public abstract class ApplicationEDIEntity extends MimeEntity {
-
+
private final String ediMessage;
-
+
protected ApplicationEDIEntity(String ediMessage, ContentType contentType, String contentTransferEncoding, boolean isMainBody) {
this.ediMessage = Args.notNull(ediMessage, "EDI Message");
setContentType(Args.notNull(contentType, "Content Type").toString());
setContentTransferEncoding(contentTransferEncoding);
setMainBody(isMainBody);
}
-
+
public String getEdiMessage() {
return ediMessage;
}
@@ -48,7 +48,7 @@ public abstract class ApplicationEDIEntity extends MimeEntity {
try (CanonicalOutputStream canonicalOutstream = new CanonicalOutputStream(ncos, AS2Charset.US_ASCII)) {
// Write out mime part headers if this is not the main body of message.
- if (!isMainBody()) {
+ if (!isMainBody()) {
HeaderIterator it = headerIterator();
while (it.hasNext()) {
Header header = it.nextHeader();
@@ -56,7 +56,7 @@ public abstract class ApplicationEDIEntity extends MimeEntity {
}
canonicalOutstream.writeln(); // ensure empty line between headers and body; RFC2046 - 5.1.1
}
-
+
canonicalOutstream.write(ediMessage.getBytes(getCharset()), 0, ediMessage.length());
}
}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/ApplicationEDIFACTEntity.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/ApplicationEDIFACTEntity.java
index 4e94456..5f34088 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/ApplicationEDIFACTEntity.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/ApplicationEDIFACTEntity.java
@@ -25,5 +25,5 @@ public class ApplicationEDIFACTEntity extends ApplicationEDIEntity {
boolean isMainBody) {
super(content, ContentType.create(AS2MediaType.APPLICATION_EDIFACT, charset), contentTransferEncoding, isMainBody);
}
-
+
}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/ApplicationPkcs7SignatureEntity.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/ApplicationPkcs7SignatureEntity.java
index 2b78f6e..a64db26 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/ApplicationPkcs7SignatureEntity.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/ApplicationPkcs7SignatureEntity.java
@@ -36,17 +36,17 @@ import org.bouncycastle.cms.CMSSignedDataGenerator;
import org.bouncycastle.cms.CMSTypedData;
public class ApplicationPkcs7SignatureEntity extends MimeEntity {
-
+
private static final String CONTENT_DISPOSITION = "attachment; filename=\"smime.p7s\"";
-
+
private static final String CONTENT_DESCRIPTION = "S/MIME Cryptographic Signature";
-
+
private byte[] signature;
-
+
public ApplicationPkcs7SignatureEntity(MimeEntity data, CMSSignedDataGenerator signer, String charset, String contentTransferEncoding, boolean isMainBody) throws HttpException {
Args.notNull(data, "Data");
Args.notNull(signer, "Signer");
-
+
ContentType contentType = ContentType.parse(EntityUtils.appendParameter(AS2MediaType.APPLICATION_PKCS7_SIGNATURE, "charset", charset));
setContentType(contentType.toString());
setContentTransferEncoding(contentTransferEncoding);
@@ -59,7 +59,7 @@ public class ApplicationPkcs7SignatureEntity extends MimeEntity {
throw new HttpException("Failed to create signed data", e);
}
}
-
+
public ApplicationPkcs7SignatureEntity(String charset,
String contentTransferEncoding,
byte[] signature,
@@ -74,7 +74,7 @@ public class ApplicationPkcs7SignatureEntity extends MimeEntity {
addHeader(AS2Header.CONTENT_DESCRIPTION, CONTENT_DESCRIPTION);
setMainBody(isMainBody);
}
-
+
public byte[] getSignature() {
return signature;
}
@@ -107,7 +107,7 @@ public class ApplicationPkcs7SignatureEntity extends MimeEntity {
throw new IOException("Failed to write to output stream", e);
}
}
-
+
private byte[] createSignature(MimeEntity data, CMSSignedDataGenerator signer) throws Exception {
try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
data.writeTo(bos);
@@ -119,7 +119,7 @@ public class ApplicationPkcs7SignatureEntity extends MimeEntity {
} catch (Exception e) {
throw new Exception("", e);
}
-
+
}
}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/DispositionMode.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/DispositionMode.java
index 4ddb6c6..4a334e0 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/DispositionMode.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/DispositionMode.java
@@ -21,7 +21,7 @@ public enum DispositionMode {
MANUAL_ACTION_MDN_SENT_AUTOMATICALLY("manual-action", "MDN-sent-automatically"),
AUTOMATIC_ACTION_MDN_SENT_MANUALLY("automatic-action", "MDN-sent-manually"),
AUTOMATIC_ACTION_MDN_SENT_AUTOMATICALLY("automatic-action", "MDN-sent-automatically");
-
+
private String actionMode;
private String sendingMode;
@@ -29,7 +29,7 @@ public enum DispositionMode {
this.actionMode = actionMode;
this.sendingMode = sendingMode;
}
-
+
public String getActionMode() {
return actionMode;
}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/DispositionNotificationMultipartReportEntity.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/DispositionNotificationMultipartReportEntity.java
index 30a8023..64708d7 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/DispositionNotificationMultipartReportEntity.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/DispositionNotificationMultipartReportEntity.java
@@ -31,7 +31,7 @@ import org.apache.http.message.BasicHeader;
import org.apache.http.util.CharArrayBuffer;
public class DispositionNotificationMultipartReportEntity extends MultipartReportEntity {
-
+
public DispositionNotificationMultipartReportEntity(HttpEntityEnclosingRequest request,
HttpResponse response,
DispositionMode dispositionMode,
@@ -49,13 +49,13 @@ public class DispositionNotificationMultipartReportEntity extends MultipartRepor
this.contentType = new BasicHeader(AS2Header.CONTENT_TYPE, AS2MimeType.MULTIPART_REPORT);
Header reportType = new BasicHeader(AS2Header.REPORT_TYPE, getReportTypeValue(boundary));
addHeader(reportType);
-
+
addPart(buildPlainTextReport(request, response, dispositionMode, dispositionType,
dispositionModifier, failureFields, errorFields, warningFields, extensionFields));
addPart(new AS2MessageDispositionNotificationEntity(request, response, dispositionMode, dispositionType,
dispositionModifier, failureFields, errorFields, warningFields, extensionFields, charset, false));
}
-
+
protected DispositionNotificationMultipartReportEntity(String boundary, boolean isMainBody) {
this.boundary = boundary;
this.isMainBody = isMainBody;
@@ -76,12 +76,12 @@ public class DispositionNotificationMultipartReportEntity extends MultipartRepor
String originalMessageId = HttpMessageUtils.getHeaderValue(request, AS2Header.MESSAGE_ID);
String sentDate = HttpMessageUtils.getHeaderValue(request, AS2Header.DATE);
String subject = HttpMessageUtils.getHeaderValue(request, AS2Header.SUBJECT);
-
+
String receivedFrom = HttpMessageUtils.getHeaderValue(request, AS2Header.AS2_FROM);
String sentTo = HttpMessageUtils.getHeaderValue(request, AS2Header.AS2_TO);
-
+
String receivedDate = HttpMessageUtils.getHeaderValue(response, AS2Header.DATE);
-
+
charBuffer.append("MDN for -\n");
charBuffer.append(" Message ID: " + originalMessageId + "\n");
charBuffer.append(" Subject: " + (subject == null ? "" : subject) + "\n");
@@ -93,7 +93,7 @@ public class DispositionNotificationMultipartReportEntity extends MultipartRepor
return new TextPlainEntity(charBuffer.toString(), AS2Charset.US_ASCII, AS2TransferEncoding.SEVENBIT, false);
}
-
+
protected String getReportTypeValue(String boundary) {
return "disposition-notification; boundary=\"" + boundary + "\"";
}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/DispositionNotificationOptions.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/DispositionNotificationOptions.java
index ca9c628..093cfc6 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/DispositionNotificationOptions.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/DispositionNotificationOptions.java
@@ -19,10 +19,10 @@ package org.apache.camel.component.as2.api.entity;
import org.apache.camel.component.as2.api.util.AS2HeaderUtils.Parameter;
public class DispositionNotificationOptions {
-
+
private Parameter signedReceiptProtocol;
private Parameter signedReceiptMicalg;
-
+
public DispositionNotificationOptions(Parameter signedReceiptProtocol, Parameter signedReceiptMicalg) {
this.signedReceiptProtocol = signedReceiptProtocol;
this.signedReceiptMicalg = signedReceiptMicalg;
@@ -35,5 +35,5 @@ public class DispositionNotificationOptions {
public Parameter getSignedReceiptMicalg() {
return signedReceiptMicalg;
}
-
+
}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/DispositionNotificationOptionsParser.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/DispositionNotificationOptionsParser.java
index 5688c58..dd4d6f0 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/DispositionNotificationOptionsParser.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/DispositionNotificationOptionsParser.java
@@ -51,18 +51,18 @@ public class DispositionNotificationOptionsParser {
final ParserCursor cursor) {
Args.notNull(buffer, "buffer");
Args.notNull(cursor, "cursor");
-
+
Map<String, Parameter> parameters = new HashMap<String, Parameter>();
while (!cursor.atEnd()) {
Parameter parameter = AS2HeaderUtils.parseParameter(buffer, cursor);
parameters.put(parameter.getAttribute(), parameter);
}
-
+
Parameter signedReceiptProtocolParameter = parameters.get(SIGNED_RECEIPT_PROTOCOL_ATTR_NAME);
-
+
Parameter signedReceiptMicalgParameter = parameters.get(SIGNED_RECEIPT_MICALG_ATTR_NAME);
-
-
+
+
return new DispositionNotificationOptions(signedReceiptProtocolParameter, signedReceiptMicalgParameter);
}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/EntityParser.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/EntityParser.java
index 8b884f1..ce17586 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/EntityParser.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/EntityParser.java
@@ -49,14 +49,14 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class EntityParser {
-
+
private static final Logger LOG = LoggerFactory.getLogger(EntityParser.class);
private static final int DEFAULT_BUFFER_SIZE = 8 * 1024;
private static final String APPLICATION_EDI_CONTENT_TYPE_PREFIX = "application/edi";
-
+
private EntityParser() {
}
@@ -178,7 +178,7 @@ public final class EntityParser {
Args.check(entity.isStreaming(), "Entity is not streaming");
try {
-
+
// Determine and validate the Content Type
Header contentTypeHeader = entity.getContentType();
if (contentTypeHeader == null) {
@@ -188,14 +188,14 @@ public final class EntityParser {
if (!contentType.getMimeType().equals(AS2MimeType.MULTIPART_SIGNED)) {
throw new HttpException("Entity has invalid MIME type '" + contentType.getMimeType() + "'");
}
-
+
// Determine Charset
String charsetName = AS2Charset.US_ASCII;
Charset charset = contentType.getCharset();
if (charset != null) {
charsetName = charset.name();
}
-
+
// Determine content transfer encoding
String contentTransferEncoding = HttpMessageUtils.getHeaderValue(message, AS2Header.CONTENT_TRANSFER_ENCODING);
@@ -207,18 +207,18 @@ public final class EntityParser {
if (boundary == null) {
throw new HttpException("Failed to retrive boundary value");
}
-
+
multipartSignedEntity = parseMultipartSignedEntityBody(inbuffer, boundary, charsetName, contentTransferEncoding);
-
+
EntityUtils.setMessageEntity(message, multipartSignedEntity);
-
+
} catch (HttpException e) {
throw e;
} catch (Exception e) {
throw new HttpException("Failed to parse entity content", e);
}
}
-
+
public static void parseApplicationEDIEntity(HttpMessage message) throws HttpException {
ApplicationEDIEntity applicationEDIEntity = null;
HttpEntity entity = Args.notNull(EntityUtils.getMessageEntity(message), "message entity");
@@ -288,14 +288,14 @@ public final class EntityParser {
if (!contentType.getMimeType().equals(AS2MimeType.MULTIPART_REPORT)) {
throw new HttpException("Entity has invalid MIME type '" + contentType.getMimeType() + "'");
}
-
+
// Determine Charset
String charsetName = AS2Charset.US_ASCII;
Charset charset = contentType.getCharset();
if (charset != null) {
charsetName = charset.name();
}
-
+
// Determine content transfer encoding
String contentTransferEncoding = HttpMessageUtils.getHeaderValue(message, AS2Header.CONTENT_TRANSFER_ENCODING);
@@ -307,7 +307,7 @@ public final class EntityParser {
if (boundary == null) {
throw new HttpException("Failed to retrive boundary value");
}
-
+
dispositionNotificationMultipartReportEntity = parseMultipartReportEntityBody(inbuffer, boundary, charsetName, contentTransferEncoding);
EntityUtils.setMessageEntity(message, dispositionNotificationMultipartReportEntity);
@@ -350,7 +350,7 @@ public final class EntityParser {
}
}
}
-
+
public static MultipartSignedEntity parseMultipartSignedEntityBody(AS2SessionInputBuffer inbuffer,
String boundary,
String charsetName,
@@ -369,16 +369,16 @@ public final class EntityParser {
inbuffer.setCharsetDecoder(charsetDecoder);
inbuffer.setTransferEncoding(contentTransferEncoding);
-
- MultipartSignedEntity multipartSignedEntity = new MultipartSignedEntity(boundary, false);
+
+ MultipartSignedEntity multipartSignedEntity = new MultipartSignedEntity(boundary, false);
// Skip Preamble and Start Boundary line
skipPreambleAndStartBoundary(inbuffer, boundary);
-
+
//
// Parse Signed Entity Part
- //
-
+ //
+
// Read Text Report Body Part Headers
Header[] headers = AbstractMessageParser.parseHeaders(inbuffer, -1, -1, BasicLineParser.INSTANCE,
new ArrayList<CharArrayBuffer>());
@@ -401,12 +401,12 @@ public final class EntityParser {
if (signedEntityContentType == null) {
throw new HttpException("Failed to find Content-Type header in signed entity body part");
}
-
+
MimeEntity signedEntity = parseEntityBody(inbuffer, boundary, signedEntityContentType, signedEntityContentTransferEncoding, headers);
signedEntity.removeAllHeaders();
signedEntity.setHeaders(headers);
multipartSignedEntity.addPart(signedEntity);
-
+
//
// End Signed Entity Part
@@ -440,7 +440,7 @@ public final class EntityParser {
throw new HttpException(
"Invalid content type '" + signatureContentType.getMimeType() + "' for signature body part");
}
-
+
ApplicationPkcs7SignatureEntity applicationPkcs7SignatureEntity = parseApplicationPkcs7SignatureEntityBody(inbuffer, boundary, signatureContentType, signatureContentTransferEncoding);
applicationPkcs7SignatureEntity.removeAllHeaders();
applicationPkcs7SignatureEntity.setHeaders(headers);
@@ -453,7 +453,7 @@ public final class EntityParser {
multipartSignedEntity.setContentType(contentType);
multipartSignedEntity.setContentTransferEncoding(contentTransferEncoding);
return multipartSignedEntity;
-
+
} catch (Exception e) {
ParseException parseException = new ParseException("failed to parse text entity");
parseException.initCause(e);
@@ -484,7 +484,7 @@ public final class EntityParser {
inbuffer.setTransferEncoding(contentTransferEncoding);
DispositionNotificationMultipartReportEntity dispositionNotificationMultipartReportEntity = new DispositionNotificationMultipartReportEntity(boundary, false);
-
+
// Skip Preamble and Start Boundary line
skipPreambleAndStartBoundary(inbuffer, boundary);
@@ -518,7 +518,7 @@ public final class EntityParser {
throw new HttpException("Invalid content type '" + textReportContentType.getMimeType()
+ "' for first body part of disposition notification");
}
-
+
String textReportCharsetName = textReportContentType.getCharset() == null ? AS2Charset.US_ASCII : textReportContentType.getCharset().name();
TextPlainEntity textReportEntity = parseTextPlainEntityBody(inbuffer, boundary, textReportCharsetName, textReportContentTransferEncoding);
textReportEntity.setHeaders(headers);
@@ -567,7 +567,7 @@ public final class EntityParser {
//
// End Disposition Notification Body Part
-
+
ContentType contentType = ContentType.create(AS2MimeType.MULTIPART_REPORT, charset);
dispositionNotificationMultipartReportEntity.setContentType(contentType);
dispositionNotificationMultipartReportEntity.setContentTransferEncoding(contentTransferEncoding);
@@ -601,7 +601,7 @@ public final class EntityParser {
inbuffer.setCharsetDecoder(charsetDecoder);
inbuffer.setTransferEncoding(contentTransferEncoding);
-
+
String text = parseBodyPartText(inbuffer, boundary);
return new TextPlainEntity(text, charsetName, contentTransferEncoding, false);
} catch (Exception e) {
@@ -649,7 +649,7 @@ public final class EntityParser {
inbuffer.setTransferEncoding(previousContentTransferEncoding);
}
}
-
+
public static MimeEntity parseEntityBody(AS2SessionInputBuffer inbuffer,
String boundary,
ContentType entityContentType,
@@ -717,7 +717,7 @@ public final class EntityParser {
}
}
-
+
public static ApplicationEDIEntity parseEDIEntityBody(AS2SessionInputBuffer inbuffer,
String boundary,
ContentType ediMessageContentType,
@@ -750,15 +750,15 @@ public final class EntityParser {
inbuffer.setTransferEncoding(previousContentTransferEncoding);
}
}
-
+
public static ApplicationPkcs7SignatureEntity parseApplicationPkcs7SignatureEntityBody(AS2SessionInputBuffer inbuffer,
String boundary,
ContentType contentType,
String contentTransferEncoding) throws ParseException {
-
+
CharsetDecoder previousDecoder = inbuffer.getCharsetDecoder();
String previousContentTransferEncoding = inbuffer.getTransferEncoding();
-
+
try {
Charset charset = contentType.getCharset();
if (charset == null) {
@@ -770,7 +770,7 @@ public final class EntityParser {
inbuffer.setTransferEncoding(contentTransferEncoding);
String pkcs7SignatureBodyContent = parseBodyPartText(inbuffer, boundary);
-
+
String charsetName = charset.toString();
ApplicationPkcs7SignatureEntity applicationPkcs7SignatureEntity = new ApplicationPkcs7SignatureEntity(
charsetName, contentTransferEncoding, pkcs7SignatureBodyContent.getBytes(charset), false);
@@ -784,7 +784,7 @@ public final class EntityParser {
inbuffer.setTransferEncoding(previousContentTransferEncoding);
}
}
-
+
public static String parseBodyPartText(final AS2SessionInputBuffer inbuffer,
final String boundary)
throws IOException {
@@ -802,12 +802,12 @@ public final class EntityParser {
buffer.setLength(length - 2);
break;
}
-
+
buffer.append(line);
buffer.append("\r\n");
line.clear();
}
-
+
return buffer.toString();
}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/Importance.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/Importance.java
index d22ac00..93071a1 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/Importance.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/Importance.java
@@ -19,17 +19,17 @@ package org.apache.camel.component.as2.api.entity;
public enum Importance {
REQUIRED("required"),
OPTIONAL("optional");
-
+
private String importance;
-
+
private Importance(String importance) {
this.importance = importance;
}
-
+
public String getImportance() {
return importance;
}
-
+
@Override
public String toString() {
return importance;
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/MimeEntity.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/MimeEntity.java
index 6ae0687..56b8a4a 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/MimeEntity.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/MimeEntity.java
@@ -36,7 +36,7 @@ import org.apache.http.protocol.HTTP;
import org.apache.http.util.Args;
public abstract class MimeEntity extends AbstractHttpEntity {
-
+
/**
* An OuputStream wrapper that doesn't close its underlying output stream.
* <p>
@@ -56,7 +56,7 @@ public abstract class MimeEntity extends AbstractHttpEntity {
}
protected static final long UNKNOWN_CONTENT_LENGTH = -1;
-
+
protected static final long RECALCULATE_CONTENT_LENGTH = -2;
protected boolean isMainBody;
@@ -66,18 +66,18 @@ public abstract class MimeEntity extends AbstractHttpEntity {
protected long contentLength = RECALCULATE_CONTENT_LENGTH;
private final HeaderGroup headergroup = new HeaderGroup();
-
+
protected MimeEntity() {
}
-
+
public boolean isMainBody() {
return isMainBody;
}
-
+
public void setMainBody(boolean isMainBody) {
this.isMainBody = isMainBody;
}
-
+
public String getContentTypeValue() {
Header contentTypeHeader = getContentType();
if (contentTypeHeader != null) {
@@ -85,21 +85,21 @@ public abstract class MimeEntity extends AbstractHttpEntity {
}
return null;
}
-
+
public void setContentType(ContentType contentType) {
super.setContentType(contentType == null ? null : contentType.toString());
}
-
+
@Override
public void setContentType(Header contentType) {
super.setContentType(contentType);
if (contentType != null) {
- addHeader(contentType);
+ addHeader(contentType);
} else {
- removeHeaders(AS2Header.CONTENT_TYPE);
+ removeHeaders(AS2Header.CONTENT_TYPE);
}
}
-
+
public String getContentEncodingValue() {
Header contentEncodingHeader = getContentEncoding();
if (contentEncodingHeader != null) {
@@ -107,14 +107,14 @@ public abstract class MimeEntity extends AbstractHttpEntity {
}
return null;
}
-
+
@Override
public void setContentEncoding(Header contentEncoding) {
super.setContentEncoding(contentEncoding);
if (contentEncoding != null) {
- addHeader(contentEncoding);
+ addHeader(contentEncoding);
} else {
- removeHeaders(HTTP.CONTENT_ENCODING);
+ removeHeaders(HTTP.CONTENT_ENCODING);
}
}
@@ -125,7 +125,7 @@ public abstract class MimeEntity extends AbstractHttpEntity {
}
return null;
}
-
+
/**
* Obtains the Content-Transfer-Encoding header.
* The default implementation returns the value of the
@@ -148,9 +148,9 @@ public abstract class MimeEntity extends AbstractHttpEntity {
public void setContentTranserEncoding(final Header contentTransferEncoding) {
this.contentTransferEncoding = contentTransferEncoding;
if (contentTransferEncoding != null) {
- addHeader(contentTransferEncoding);
+ addHeader(contentTransferEncoding);
} else {
- removeHeaders(AS2Header.CONTENT_TRANSFER_ENCODING);
+ removeHeaders(AS2Header.CONTENT_TRANSFER_ENCODING);
}
}
@@ -171,7 +171,7 @@ public abstract class MimeEntity extends AbstractHttpEntity {
}
-
+
public boolean containsHeader(final String name) {
return this.headergroup.containsHeader(name);
}
@@ -229,7 +229,7 @@ public abstract class MimeEntity extends AbstractHttpEntity {
}
}
}
-
+
public void removeAllHeaders() {
this.headergroup.clear();
}
@@ -251,7 +251,7 @@ public abstract class MimeEntity extends AbstractHttpEntity {
public boolean isStreaming() {
return !isRepeatable();
}
-
+
@Override
public long getContentLength() {
if (contentLength == RECALCULATE_CONTENT_LENGTH) {
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/MultipartMimeEntity.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/MultipartMimeEntity.java
index d4563aa..b7390c2 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/MultipartMimeEntity.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/MultipartMimeEntity.java
@@ -44,15 +44,15 @@ public abstract class MultipartMimeEntity extends MimeEntity {
public MultipartMimeEntity(ContentType contentType, boolean isMainBody, String boundary) {
setContentType(contentType);
setMainBody(isMainBody);
-
+
if (boundary != null && EntityUtils.validateBoundaryValue(boundary)) {
this.boundary = boundary;
} else {
- this.boundary = EntityUtils.createBoundaryValue();
+ this.boundary = EntityUtils.createBoundaryValue();
}
}
-
+
protected MultipartMimeEntity() {
}
@@ -94,7 +94,7 @@ public abstract class MultipartMimeEntity extends MimeEntity {
try (CanonicalOutputStream canonicalOutstream = new CanonicalOutputStream(ncos, getCharset())) {
// Write out mime part headers if this is not the main body of message.
- if (!isMainBody()) {
+ if (!isMainBody()) {
HeaderIterator it = headerIterator();
while (it.hasNext()) {
Header header = it.nextHeader();
@@ -102,7 +102,7 @@ public abstract class MultipartMimeEntity extends MimeEntity {
}
canonicalOutstream.writeln(); // ensure empty line between headers and body; RFC2046 - 5.1.1
}
-
+
// Write out each part separated by a boundary delimiter line
String boundary = "--" + this.boundary;
// Write out parts
@@ -111,10 +111,10 @@ public abstract class MultipartMimeEntity extends MimeEntity {
part.writeTo(outstream);
canonicalOutstream.writeln(); // ensure boundary occurs at the beginning of a line; RFC2046 - 5.1.1
}
-
+
// Write out closing boundary delimiter line
canonicalOutstream.writeln(boundary + "--");
-
+
}
}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/MultipartReportEntity.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/MultipartReportEntity.java
index 20855b2..135ec6d8 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/MultipartReportEntity.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/MultipartReportEntity.java
@@ -30,9 +30,9 @@ public class MultipartReportEntity extends MultipartMimeEntity {
super(ContentType.create(AS2MimeType.MULTIPART_REPORT, charset), isMainBody, boundary);
}
-
+
protected MultipartReportEntity() {
-
+
}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/MultipartSignedEntity.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/MultipartSignedEntity.java
index 4d7c856..6869b5f 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/MultipartSignedEntity.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/MultipartSignedEntity.java
@@ -46,20 +46,20 @@ public class MultipartSignedEntity extends MultipartMimeEntity {
ApplicationPkcs7SignatureEntity signature = new ApplicationPkcs7SignatureEntity(data, signer, signatureCharSet, signatureTransferEncoding, false);
addPart(signature);
}
-
+
protected MultipartSignedEntity(String boundary, boolean isMainBody) {
this.boundary = boundary;
this.isMainBody = isMainBody;
}
-
- public boolean isValid() {
- MimeEntity signedEntity = getSignedDataEntity();
+
+ public boolean isValid() {
+ MimeEntity signedEntity = getSignedDataEntity();
ApplicationPkcs7SignatureEntity applicationPkcs7SignatureEntity = getSignatureEntity();
-
+
if (signedEntity == null || applicationPkcs7SignatureEntity == null) {
return false;
}
-
+
try {
ByteArrayOutputStream outstream = new ByteArrayOutputStream();
signedEntity.writeTo(outstream);
@@ -86,23 +86,23 @@ public class MultipartSignedEntity extends MultipartMimeEntity {
} catch (Exception e) {
return false;
}
-
+
return true;
}
-
+
public MimeEntity getSignedDataEntity() {
if (getPartCount() > 0) {
return getPart(0);
}
-
+
return null;
}
-
+
public ApplicationPkcs7SignatureEntity getSignatureEntity() {
if (getPartCount() > 1 && getPart(1) instanceof ApplicationPkcs7SignatureEntity) {
return (ApplicationPkcs7SignatureEntity) getPart(1);
}
-
+
return null;
}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/TextPlainEntity.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/TextPlainEntity.java
index 0061619..7bc6f12 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/TextPlainEntity.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/TextPlainEntity.java
@@ -28,16 +28,16 @@ import org.apache.http.entity.ContentType;
import org.apache.http.util.Args;
public class TextPlainEntity extends MimeEntity {
-
+
private String content;
-
+
public TextPlainEntity(String content, String charset, String contentTransferEncoding, boolean isMainBody) {
this.content = Args.notNull(content, "Content");
setContentType(ContentType.create(AS2MediaType.TEXT_PLAIN, charset));
setContentTransferEncoding(contentTransferEncoding);
setMainBody(isMainBody);
}
-
+
public String getText() {
return content;
}
@@ -48,7 +48,7 @@ public class TextPlainEntity extends MimeEntity {
try (CanonicalOutputStream canonicalOutstream = new CanonicalOutputStream(ncos, AS2Charset.US_ASCII)) {
// Write out mime part headers if this is not the main body of message.
- if (!isMainBody()) {
+ if (!isMainBody()) {
HeaderIterator it = headerIterator();
while (it.hasNext()) {
Header header = it.nextHeader();
@@ -56,10 +56,10 @@ public class TextPlainEntity extends MimeEntity {
}
canonicalOutstream.writeln(); // ensure empty line between headers and body; RFC2046 - 5.1.1
}
-
+
// Write out content
canonicalOutstream.write(content.getBytes(AS2Charset.US_ASCII), 0, content.length());
- }
+ }
}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/io/AS2BHttpServerConnection.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/io/AS2BHttpServerConnection.java
index 9564e9b..bad2bc9 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/io/AS2BHttpServerConnection.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/io/AS2BHttpServerConnection.java
@@ -56,7 +56,7 @@ public class AS2BHttpServerConnection extends DefaultBHttpServerConnection {
super(buffersize, fragmentSizeHint, chardecoder, charencoder, constraints, incomingContentStrategy,
outgoingContentStrategy, requestParserFactory, responseWriterFactory);
}
-
+
@Override
public void receiveRequestEntity(HttpEntityEnclosingRequest request) throws HttpException, IOException {
super.receiveRequestEntity(request);
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/io/AS2SessionInputBuffer.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/io/AS2SessionInputBuffer.java
index 3ddc5dd..b4ab8c0 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/io/AS2SessionInputBuffer.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/io/AS2SessionInputBuffer.java
@@ -45,7 +45,7 @@ public class AS2SessionInputBuffer implements SessionInputBuffer, BufferInfo {
private final MessageConstraints constraints;
private CharsetDecoder decoder;
-
+
private String transferEncoding;
private InputStream instream;
@@ -78,7 +78,7 @@ public class AS2SessionInputBuffer implements SessionInputBuffer, BufferInfo {
public void setCharsetDecoder(CharsetDecoder chardecoder) {
this.decoder = chardecoder;
}
-
+
public String getTransferEncoding() {
return transferEncoding;
}
@@ -239,7 +239,7 @@ public class AS2SessionInputBuffer implements SessionInputBuffer, BufferInfo {
}
return lineFromLineBuffer(charbuffer);
}
-
+
@Override
public String readLine() throws IOException {
final CharArrayBuffer charbuffer = new CharArrayBuffer(64);
@@ -359,6 +359,6 @@ public class AS2SessionInputBuffer implements SessionInputBuffer, BufferInfo {
} catch (Exception e) {
throw new IOException("failed to decode transfer encoding", e);
}
-
+
}
}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/protocol/RequestAS2.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/protocol/RequestAS2.java
index 1cef65f..be1ee6a 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/protocol/RequestAS2.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/protocol/RequestAS2.java
@@ -30,10 +30,10 @@ import org.apache.http.protocol.HttpContext;
import org.apache.http.protocol.HttpCoreContext;
public class RequestAS2 implements HttpRequestInterceptor {
-
+
private final String as2Version;
private final String clientFQDN;
-
+
public RequestAS2(String as2Version, String clientFQDN) {
this.as2Version = as2Version;
this.clientFQDN = clientFQDN;
@@ -41,16 +41,16 @@ public class RequestAS2 implements HttpRequestInterceptor {
@Override
public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
-
+
HttpCoreContext coreContext = HttpCoreContext.adapt(context);
-
+
/* MIME header */
request.addHeader(AS2Header.MIME_VERSION, AS2Constants.MIME_VERSION);
-
+
/* Subject header */
String subject = coreContext.getAttribute(AS2ClientManager.SUBJECT, String.class);
request.addHeader(AS2Header.SUBJECT, subject);
-
+
/* From header */
String from = coreContext.getAttribute(AS2ClientManager.FROM, String.class);
request.addHeader(AS2Header.FROM, from);
@@ -75,7 +75,7 @@ public class RequestAS2 implements HttpRequestInterceptor {
throw new HttpException("Invalid AS-To name", e);
}
request.addHeader(AS2Header.AS2_TO, as2To);
-
+
/* Message-Id header*/
// SHOULD be set to aid in message reconciliation
request.addHeader(AS2Header.MESSAGE_ID, Util.createMessageId(clientFQDN));
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/protocol/RequestMDN.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/protocol/RequestMDN.java
index 618c401..db11dd6 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/protocol/RequestMDN.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/protocol/RequestMDN.java
@@ -28,19 +28,19 @@ import org.apache.http.protocol.HttpCoreContext;
import org.apache.http.util.CharArrayBuffer;
public class RequestMDN implements HttpRequestInterceptor {
-
+
private static final String SIGNED_RECEIPT_PREFIX = "signed-receipt-protocol=optional, pkcs7-signature; signed-receipt-micalg=optional";
@Override
public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
-
+
HttpCoreContext coreContext = HttpCoreContext.adapt(context);
-
+
/* Disposition-Notification-To */
String dispositionNotificationTo = coreContext.getAttribute(AS2ClientManager.DISPOSITION_NOTIFICATION_TO, String.class);
if (dispositionNotificationTo != null) {
request.addHeader(AS2Header.DISPOSITION_NOTIFICATION_TO, dispositionNotificationTo);
-
+
String[] micAlgorithms = coreContext.getAttribute(AS2ClientManager.SIGNED_RECEIPT_MIC_ALGORITHMS, String[].class);
if (micAlgorithms == null) {
// requesting unsigned receipt: indicate by not setting Disposition-Notification-Options header
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/protocol/ResponseMDN.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/protocol/ResponseMDN.java
index 10b6056..581f76c 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/protocol/ResponseMDN.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/protocol/ResponseMDN.java
@@ -51,11 +51,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ResponseMDN implements HttpResponseInterceptor {
-
+
public static final String BOUNDARY_PARAM_NAME = "boundary";
-
+
private static final Logger LOG = LoggerFactory.getLogger(ResponseMDN.class);
-
+
private final String as2Version;
private final String serverFQDN;
private Certificate[] signingCertificateChain;
@@ -70,7 +70,7 @@ public class ResponseMDN implements HttpResponseInterceptor {
@Override
public void process(HttpResponse response, HttpContext context) throws HttpException, IOException {
-
+
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode < 200 || statusCode >= 300) {
LOG.debug("MDN not added due to response status code: " + statusCode);
@@ -79,14 +79,14 @@ public class ResponseMDN implements HttpResponseInterceptor {
LOG.debug("Adding MDN to response: " + response);
HttpCoreContext coreContext = HttpCoreContext.adapt(context);
-
+
HttpEntityEnclosingRequest request = coreContext.getAttribute(HttpCoreContext.HTTP_REQUEST, HttpEntityEnclosingRequest.class);
if (request == null) {
LOG.debug("MDN not added due to null request");
return;
}
LOG.debug("Processing MDN for request: " + request);
-
+
/* MIME header */
response.addHeader(AS2Header.MIME_VERSION, AS2Constants.MIME_VERSION);
@@ -97,14 +97,14 @@ public class ResponseMDN implements HttpResponseInterceptor {
String subjectPrefix = coreContext.getAttribute(AS2ServerManager.SUBJECT, String.class);
String subject = HttpMessageUtils.getHeaderValue(request, AS2Header.SUBJECT);
if (subjectPrefix != null && subject != null) {
- subject = subjectPrefix + subject;
+ subject = subjectPrefix + subject;
} else if (subject != null) {
subject = "MDN Response To:" + subject;
} else {
subject = "Your Requested MDN Response";
}
response.addHeader(AS2Header.SUBJECT, subject);
-
+
/* From header */
String from = coreContext.getAttribute(AS2ServerManager.FROM, String.class);
response.addHeader(AS2Header.FROM, from);
@@ -130,9 +130,9 @@ public class ResponseMDN implements HttpResponseInterceptor {
/* Message-Id header*/
// SHOULD be set to aid in message reconciliation
response.addHeader(AS2Header.MESSAGE_ID, Util.createMessageId(serverFQDN));
-
+
if (HttpMessageUtils.getHeaderValue(request, AS2Header.DISPOSITION_NOTIFICATION_TO) != null) {
- // Return a Message Disposition Notification Receipt in response body
+ // Return a Message Disposition Notification Receipt in response body
String boundary = EntityUtils.createBoundaryValue();
DispositionNotificationMultipartReportEntity multipartReportEntity = new DispositionNotificationMultipartReportEntity(
request, response, DispositionMode.AUTOMATIC_ACTION_MDN_SENT_AUTOMATICALLY,
@@ -141,19 +141,19 @@ public class ResponseMDN implements HttpResponseInterceptor {
DispositionNotificationOptions dispositionNotificationOptions = DispositionNotificationOptionsParser
.parseDispositionNotificationOptions(
HttpMessageUtils.getHeaderValue(request, AS2Header.DISPOSITION_NOTIFICATION_OPTIONS), null);
-
+
String receiptAddress = HttpMessageUtils.getHeaderValue(request, AS2Header.RECEIPT_DELIVERY_OPTION);
- if (receiptAddress != null) {
+ if (receiptAddress != null) {
// Asynchronous Delivery
// TODO Implement
- } else {
+ } else {
// Synchronous Delivery
-
+
AS2SignedDataGenerator gen = null;
if (dispositionNotificationOptions.getSignedReceiptProtocol() != null && signingCertificateChain != null && signingPrivateKey != null) {
gen = SigningUtils.createSigningGenerator(signingCertificateChain, signingPrivateKey);
}
-
+
if (gen != null) {
// Create signed receipt
try {
@@ -173,7 +173,7 @@ public class ResponseMDN implements HttpResponseInterceptor {
EntityUtils.setMessageEntity(response, multipartReportEntity);
}
}
-
+
}
LOG.debug(Util.printMessage(response));
}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/util/AS2HeaderUtils.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/util/AS2HeaderUtils.java
index 0d6eebd..deac117 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/util/AS2HeaderUtils.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/util/AS2HeaderUtils.java
@@ -83,10 +83,10 @@ public final class AS2HeaderUtils {
private AS2HeaderUtils() {
}
-
+
public static Header createHeader(String headerName, String[]... elements) {
StringBuilder sb = new StringBuilder();
-
+
boolean firstElement = true;
for (String[] element: elements) {
if (element.length == 0) {
@@ -105,7 +105,7 @@ public final class AS2HeaderUtils {
BasicHeader header = new BasicHeader(headerName, sb.toString());
return header;
}
-
+
public static Parameter parseParameter(final CharArrayBuffer buffer, final ParserCursor cursor) {
Args.notNull(buffer, "Char array buffer");
Args.notNull(cursor, "Parser cursor");
@@ -161,5 +161,5 @@ public final class AS2HeaderUtils {
}
return null;
}
-
+
}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/util/DispositionNotificationContentUtils.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/util/DispositionNotificationContentUtils.java
index 3fcbace..599f107 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/util/DispositionNotificationContentUtils.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/util/DispositionNotificationContentUtils.java
@@ -36,7 +36,7 @@ import org.apache.http.util.Args;
import org.apache.http.util.CharArrayBuffer;
public final class DispositionNotificationContentUtils {
-
+
private static final String REPORTING_UA = "reporting-ua";
private static final String MDN_GATEWAY = "mdn-gateway";
private static final String FINAL_RECIPIENT = "final-recipient";
@@ -109,7 +109,7 @@ public final class DispositionNotificationContentUtils {
return builder.toString();
}
-
+
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
@@ -231,7 +231,7 @@ public final class DispositionNotificationContentUtils {
extensionFields.put(field.getName(), field.getValue());
}
}
-
+
return new AS2MessageDispositionNotificationEntity(reportingUA,
mtaName,
finalRecipient,
@@ -254,7 +254,7 @@ public final class DispositionNotificationContentUtils {
final String fieldName = fieldLine.substringTrimmed(0, colon);
ParserCursor cursor = new ParserCursor(colon + 1, fieldLine.length());
-
+
final List<Element> elements = new ArrayList<Element>();
while (!cursor.atEnd()) {
final Element element = parseDispositionFieldElement(fieldLine, cursor);
@@ -262,23 +262,23 @@ public final class DispositionNotificationContentUtils {
elements.add(element);
}
}
-
+
return new Field(fieldName, elements.toArray(new Element[elements.size()]));
}
public static Element parseDispositionFieldElement(CharArrayBuffer fieldLine, ParserCursor cursor) {
-
+
final String value = TOKEN_PARSER.parseToken(fieldLine, cursor, TOKEN_DELIMS);
if (cursor.atEnd()) {
return new Element(value, null);
}
-
+
final char delim = fieldLine.charAt(cursor.getPos());
cursor.updatePos(cursor.getPos() + 1);
if (delim == ELEM_DELIMITER) {
return new Element(value, null);
}
-
+
final List<String> parameters = new ArrayList<String>();
while (!cursor.atEnd()) {
final String parameter = TOKEN_PARSER.parseToken(fieldLine, cursor, TOKEN_DELIMS);
@@ -294,7 +294,7 @@ public final class DispositionNotificationContentUtils {
break;
}
}
-
+
return new Element(value, parameters.toArray(new String[parameters.size()]));
}
}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/util/EntityUtils.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/util/EntityUtils.java
index ab8c108..1bfdc70 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/util/EntityUtils.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/util/EntityUtils.java
@@ -44,11 +44,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class EntityUtils {
-
+
private static final Logger LOG = LoggerFactory.getLogger(EntityUtils.class);
private static AtomicLong partNumber = new AtomicLong();
-
+
private EntityUtils() {
}
@@ -60,7 +60,7 @@ public final class EntityUtils {
* <p>
* The generated string contains only US-ASCII characters and hence is safe
* for use in RFC822 headers.
- *
+ *
* @return The generated boundary string.
*/
public static String createBoundaryValue() {
@@ -78,15 +78,15 @@ public final class EntityUtils {
public static String appendParameter(String headerString, String parameterName, String parameterValue) {
return headerString + "; " + parameterName + "=" + parameterValue;
}
-
+
public static byte[] encode(byte[] data, String encoding) throws Exception {
Args.notNull(data, "Data");
-
+
if (encoding == null) {
// Identity encoding
return data;
}
-
+
switch(encoding.toLowerCase()) {
case "base64":
return Base64.encode(data);
@@ -102,10 +102,10 @@ public final class EntityUtils {
throw new Exception("Unknown encoding: " + encoding);
}
}
-
+
public static OutputStream encode(OutputStream os, String encoding) throws Exception {
Args.notNull(os, "Output Stream");
-
+
if (encoding == null) {
// Identity encoding
return os;
@@ -125,10 +125,10 @@ public final class EntityUtils {
throw new Exception("Unknown encoding: " + encoding);
}
}
-
+
public static byte[] decode(byte[] data, String encoding) throws Exception {
Args.notNull(data, "Input Stream");
-
+
if (encoding == null) {
// Identity encoding
return data;
@@ -147,10 +147,10 @@ public final class EntityUtils {
throw new Exception("Unknown encoding: " + encoding);
}
}
-
+
public static InputStream decode(InputStream is, String encoding) throws Exception {
Args.notNull(is, "Input Stream");
-
+
if (encoding == null) {
// Identity encoding
return is;
@@ -170,24 +170,24 @@ public final class EntityUtils {
throw new Exception("Unknown encoding: " + encoding);
}
}
-
+
public static ApplicationEDIEntity createEDIEntity(String ediMessage, ContentType ediMessageContentType, String contentTransferEncoding, boolean isMainBody) throws Exception {
Args.notNull(ediMessage, "EDI Message");
Args.notNull(ediMessageContentType, "EDI Message Content Type");
String charset = ediMessageContentType.getCharset() == null ? AS2Charset.US_ASCII : ediMessageContentType.getCharset().toString();
switch(ediMessageContentType.getMimeType().toLowerCase()) {
case AS2MediaType.APPLICATION_EDIFACT:
- return new ApplicationEDIFACTEntity(ediMessage, charset, contentTransferEncoding, isMainBody);
+ return new ApplicationEDIFACTEntity(ediMessage, charset, contentTransferEncoding, isMainBody);
case AS2MediaType.APPLICATION_EDI_X12:
- return new ApplicationEDIX12Entity(ediMessage, charset, contentTransferEncoding, isMainBody);
+ return new ApplicationEDIX12Entity(ediMessage, charset, contentTransferEncoding, isMainBody);
case AS2MediaType.APPLICATION_EDI_CONSENT:
- return new ApplicationEDIConsentEntity(ediMessage, charset, contentTransferEncoding, isMainBody);
+ return new ApplicationEDIConsentEntity(ediMessage, charset, contentTransferEncoding, isMainBody);
default:
throw new Exception("Invalid EDI entity mime type: " + ediMessageContentType.getMimeType());
}
-
+
}
-
+
public static byte[] getContent(HttpEntity entity) {
try {
final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
@@ -239,9 +239,9 @@ public final class EntityUtils {
contentCharset = StandardCharsets.US_ASCII;
}
return decode(bodyPartContent.getBytes(contentCharset), bodyPartTransferEncoding);
-
+
}
-
+
}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/util/HttpMessageUtils.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/util/HttpMessageUtils.java
index 0b757d7..133de6b 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/util/HttpMessageUtils.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/util/HttpMessageUtils.java
@@ -29,15 +29,15 @@ import org.apache.http.util.Args;
import org.apache.http.util.CharArrayBuffer;
public final class HttpMessageUtils {
-
+
private HttpMessageUtils() {
}
-
+
public static String getHeaderValue(HttpMessage message, String headerName) {
Header header = message.getFirstHeader(headerName);
return header == null ? null : header.getValue();
}
-
+
public static void setHeaderValue(HttpMessage message, String headerName, String headerValue) {
Args.notNull(message, "message");
Args.notNull(headerName, "headerName");
@@ -47,7 +47,7 @@ public final class HttpMessageUtils {
message.setHeader(headerName, headerValue);
}
}
-
+
public static <T> T getEntity(HttpMessage request, Class<T> type) {
if (request instanceof HttpEntityEnclosingRequest) {
HttpEntity entity = ((HttpEntityEnclosingRequest)request).getEntity();
@@ -79,7 +79,7 @@ public final class HttpMessageUtils {
if (!foundMultipartEndBoundary) {
throw new HttpException("Failed to find end boundary delimiter for body part");
}
-
+
return bodyPartContentBuffer.toString();
} catch (HttpException e) {
throw e;
@@ -104,5 +104,5 @@ public final class HttpMessageUtils {
}
return null;
}
-
+
}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/util/MicUtils.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/util/MicUtils.java
index 2189951..30d6243 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/util/MicUtils.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/util/MicUtils.java
@@ -38,20 +38,20 @@ import org.slf4j.LoggerFactory;
public final class MicUtils {
private static final Logger LOG = LoggerFactory.getLogger(MicUtils.class);
-
+
private MicUtils() {
}
public static class ReceivedContentMic {
private final String digestAlgorithmId;
private final String encodedMessageDigest;
-
+
public ReceivedContentMic(String digestAlgorithmId, byte[] messageDigest) throws Exception {
this.digestAlgorithmId = digestAlgorithmId;
messageDigest = EntityUtils.encode(messageDigest, "base64");
this.encodedMessageDigest = new String(messageDigest, AS2Charset.US_ASCII);
}
-
+
// Used when parsing received content MIC from received string
protected ReceivedContentMic(String digestAlgorithmId, String encodedMessageDigest) {
this.digestAlgorithmId = digestAlgorithmId;
@@ -65,13 +65,13 @@ public final class MicUtils {
public String getEncodedMessageDigest() {
return encodedMessageDigest;
}
-
+
@Override
public String toString() {
return encodedMessageDigest + "," + digestAlgorithmId;
}
}
-
+
public static byte[] createMic(byte[] content, String algorithmId) {
try {
MessageDigest messageDigest = MessageDigest.getInstance(algorithmId, "BC");
@@ -81,9 +81,9 @@ public final class MicUtils {
return null;
}
}
-
+
public static ReceivedContentMic createReceivedContentMic(HttpEntityEnclosingRequest request) throws HttpException {
-
+
String dispositionNotificationOptionsString = HttpMessageUtils.getHeaderValue(request, AS2Header.DISPOSITION_NOTIFICATION_OPTIONS);
if (dispositionNotificationOptionsString == null) {
LOG.debug("do not create MIC: no disposition notification options in request");
@@ -102,7 +102,7 @@ public final class MicUtils {
return null;
}
ContentType contentType = ContentType.parse(contentTypeString);
-
+
HttpEntity entity = null;
switch (contentType.getMimeType().toLowerCase()) {
case AS2MimeType.APPLICATION_EDIFACT:
@@ -124,9 +124,9 @@ public final class MicUtils {
+ "' for message integrity check");
return null;
}
-
+
byte[] content = EntityUtils.getContent(entity);
-
+
String micAS2AlgorithmName = AS2MicAlgorithm.getAS2AlgorithmName(micJdkAlgorithmName);
byte[] mic = createMic(content, micJdkAlgorithmName);
try {
@@ -135,7 +135,7 @@ public final class MicUtils {
throw new HttpException("failed to encode MIC", e);
}
}
-
+
public static String getMicJdkAlgorithmName(String[] micAs2AlgorithmNames) {
if (micAs2AlgorithmNames == null) {
return AS2MicAlgorithm.SHA_1.getJdkAlgorithmName();
@@ -145,7 +145,7 @@ public final class MicUtils {
if (micJdkAlgorithmName != null) {
return micJdkAlgorithmName;
}
- }
+ }
return AS2MicAlgorithm.SHA_1.getJdkAlgorithmName();
}
}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/util/SigningUtils.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/util/SigningUtils.java
index 7ee3bde..ab608bb 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/util/SigningUtils.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/util/SigningUtils.java
@@ -43,7 +43,7 @@ public final class SigningUtils {
}
public static AS2SignedDataGenerator createSigningGenerator(Certificate[] certificateChain, PrivateKey privateKey) throws HttpException {
-
+
AS2SignedDataGenerator gen = new AS2SignedDataGenerator();
// Get first certificate in chain for signing
@@ -77,7 +77,7 @@ public final class SigningUtils {
throw new HttpException("Failed to create signer info");
}
gen.addSignerInfoGenerator(signerInfoGenerator);
-
+
// Create and populate certificate store.
try {
JcaCertStore certs = new JcaCertStore(Arrays.asList(certificateChain));
@@ -87,6 +87,6 @@ public final class SigningUtils {
}
return gen;
-
+
}
}
diff --git a/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/AS2MessageTest.java b/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/AS2MessageTest.java
index 19eb0ef..34730db 100644
--- a/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/AS2MessageTest.java
+++ b/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/AS2MessageTest.java
@@ -16,11 +16,6 @@
*/
package org.apache.camel.component.as2.api;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
@@ -64,8 +59,13 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
public class AS2MessageTest {
-
+
public static final String EDI_MESSAGE = "UNB+UNOA:1+005435656:1+006415160:1+060515:1434+00000000000778'\n"
+ "UNH+00000000000117+INVOIC:D:97B:UN'\n"
+ "BGM+380+342459+9'\n"
@@ -109,12 +109,12 @@ public class AS2MessageTest {
private static final String SERVER_FQDN = "server.example.org";
private static final String DISPOSITION_NOTIFICATION_TO = "mrAS@example.org";
private static final String[] SIGNED_RECEIPT_MIC_ALGORITHMS = new String[] {"sha1", "md5"};
-
+
private static AS2ServerConnection testServer;
private AS2SignedDataGenerator gen;
-
+
private KeyPair issueKP;
private X509Certificate issueCert;
@@ -134,7 +134,7 @@ public class AS2MessageTest {
issueKP = kpg.generateKeyPair();
issueCert = Utils.makeCertificate(
issueKP, issueDN, issueKP, issueDN);
-
+
//
// certificate we sign against
//
@@ -142,18 +142,18 @@ public class AS2MessageTest {
signingKP = kpg.generateKeyPair();
signingCert = Utils.makeCertificate(
signingKP, signingDN, issueKP, issueDN);
-
+
certList = new ArrayList<X509Certificate>();
certList.add(signingCert);
certList.add(issueCert);
}
-
+
@BeforeClass
public static void setUpOnce() throws Exception {
Security.addProvider(new BouncyCastleProvider());
-
+
//
// set up our certificates
//
@@ -165,7 +165,7 @@ public class AS2MessageTest {
KeyPair issueKP = kpg.generateKeyPair();
X509Certificate issueCert = Utils.makeCertificate(
issueKP, issueDN, issueKP, issueDN);
-
+
//
// certificate we sign against
//
@@ -173,13 +173,13 @@ public class AS2MessageTest {
KeyPair signingKP = kpg.generateKeyPair();
X509Certificate signingCert = Utils.makeCertificate(
signingKP, signingDN, issueKP, issueDN);
-
+
List<X509Certificate> certList = new ArrayList<X509Certificate>();
certList.add(signingCert);
certList.add(issueCert);
-
+
testServer = new AS2ServerConnection(AS2_VERSION, "MyServer-HTTP/1.1", SERVER_FQDN, 8080, certList.toArray(new Certificate[0]), signingKP.getPrivate());
testServer.listen("*", new HttpRequestHandler() {
@Override
@@ -195,19 +195,19 @@ public class AS2MessageTest {
}
});
}
-
+
@AfterClass
public static void tearDownOnce() throws Exception {
testServer.close();
}
-
+
@Before
public void setUp() throws Exception {
Security.addProvider(new BouncyCastleProvider());
-
+
setupKeysAndCertificates();
-
+
// Create and populate certificate store.
JcaCertStore certs = new JcaCertStore(certList);
@@ -221,7 +221,7 @@ public class AS2MessageTest {
ASN1EncodableVector attributes = new ASN1EncodableVector();
attributes.add(new SMIMEEncryptionKeyPreferenceAttribute(new IssuerAndSerialNumber(new X500Name(signingCert.getIssuerDN().getName()), signingCert.getSerialNumber())));
attributes.add(new SMIMECapabilitiesAttribute(capabilities));
-
+
for (String signingAlgorithmName : AS2SignedDataGenerator
.getSupportedSignatureAlgorithmNamesForKey(signingKP.getPrivate())) {
try {
@@ -236,21 +236,21 @@ public class AS2MessageTest {
continue;
}
}
-
+
if (this.gen == null) {
throw new Exception("failed to create signing generator");
}
}
-
+
@Test
public void plainEDIMessageTest() throws Exception {
AS2ClientConnection clientConnection = new AS2ClientConnection(AS2_VERSION, USER_AGENT, CLIENT_FQDN, TARGET_HOST, TARGET_PORT);
AS2ClientManager clientManager = new AS2ClientManager(clientConnection);
-
+
HttpCoreContext httpContext = clientManager.send(EDI_MESSAGE, REQUEST_URI, SUBJECT, FROM, AS2_NAME, AS2_NAME,
AS2MessageStructure.PLAIN, ContentType.create(AS2MediaType.APPLICATION_EDIFACT, AS2Charset.US_ASCII),
null, null, null, DISPOSITION_NOTIFICATION_TO, SIGNED_RECEIPT_MIC_ALGORITHMS);
-
+
HttpRequest request = httpContext.getRequest();
assertEquals("Unexpected method value", METHOD, request.getRequestLine().getMethod());
assertEquals("Unexpected request URI value", REQUEST_URI, request.getRequestLine().getUri());
@@ -281,17 +281,17 @@ public class AS2MessageTest {
public void multipartSignedMessageTest() throws Exception {
AS2ClientConnection clientConnection = new AS2ClientConnection(AS2_VERSION, USER_AGENT, CLIENT_FQDN, TARGET_HOST, TARGET_PORT);
AS2ClientManager clientManager = new AS2ClientManager(clientConnection);
-
+
HttpCoreContext httpContext = clientManager.send(EDI_MESSAGE, REQUEST_URI, SUBJECT, FROM, AS2_NAME, AS2_NAME,
AS2MessageStructure.SIGNED, ContentType.create(AS2MediaType.APPLICATION_EDIFACT, AS2Charset.US_ASCII),
null, certList.toArray(new Certificate[0]), signingKP.getPrivate(), DISPOSITION_NOTIFICATION_TO,
SIGNED_RECEIPT_MIC_ALGORITHMS);
-
+
HttpRequest request = httpContext.getRequest();
assertEquals("Unexpected method value", METHOD, request.getRequestLine().getMethod());
assertEquals("Unexpected request URI value", REQUEST_URI, request.getRequestLine().getUri());
assertEquals("Unexpected HTTP version value", HttpVersion.HTTP_1_1, request.getRequestLine().getProtocolVersion());
-
+
assertEquals("Unexpected subject value", SUBJECT, request.getFirstHeader(AS2Header.SUBJECT).getValue());
assertEquals("Unexpected from value", FROM, request.getFirstHeader(AS2Header.FROM).getValue());
assertEquals("Unexpected AS2 version value", AS2_VERSION, request.getFirstHeader(AS2Header.AS2_VERSION).getValue());
@@ -303,7 +303,7 @@ public class AS2MessageTest {
assertNotNull("Date value missing", request.getFirstHeader(AS2Header.DATE));
assertNotNull("Content length value missing", request.getFirstHeader(AS2Header.CONTENT_LENGTH));
assertTrue("Unexpected content type for message", request.getFirstHeader(AS2Header.CONTENT_TYPE).getValue().startsWith(AS2MediaType.MULTIPART_SIGNED));
-
+
assertTrue("Request does not contain entity", request instanceof BasicHttpEntityEnclosingRequest);
HttpEntity entity = ((BasicHttpEntityEnclosingRequest)request).getEntity();
assertNotNull("Request does not contain entity", entity);
@@ -311,31 +311,31 @@ public class AS2MessageTest {
MultipartSignedEntity signedEntity = (MultipartSignedEntity)entity;
assertTrue("Entity not set as main body of request", signedEntity.isMainBody());
assertTrue("Request contains invalid number of mime parts", signedEntity.getPartCount() == 2);
-
+
// Validated first mime part.
assertTrue("First mime part incorrect type ", signedEntity.getPart(0) instanceof ApplicationEDIFACTEntity);
ApplicationEDIFACTEntity ediEntity = (ApplicationEDIFACTEntity) signedEntity.getPart(0);
assertTrue("Unexpected content type for first mime part", ediEntity.getContentType().getValue().startsWith(AS2MediaType.APPLICATION_EDIFACT));
assertFalse("First mime type set as main body of request", ediEntity.isMainBody());
-
+
// Validate second mime part.
assertTrue("Second mime part incorrect type ", signedEntity.getPart(1) instanceof ApplicationPkcs7SignatureEntity);
ApplicationPkcs7SignatureEntity signatureEntity = (ApplicationPkcs7SignatureEntity) signedEntity.getPart(1);
assertTrue("Unexpected content type for second mime part", signatureEntity.getContentType().getValue().startsWith(AS2MediaType.APPLICATION_PKCS7_SIGNATURE));
assertFalse("First mime type set as main body of request", signatureEntity.isMainBody());
-
+
}
-
+
@Test
public void signatureVerificationTest() throws Exception {
AS2ClientConnection clientConnection = new AS2ClientConnection(AS2_VERSION, USER_AGENT, CLIENT_FQDN, TARGET_HOST, TARGET_PORT);
AS2ClientManager clientManager = new AS2ClientManager(clientConnection);
-
+
HttpCoreContext httpContext = clientManager.send(EDI_MESSAGE, REQUEST_URI, SUBJECT, FROM, AS2_NAME, AS2_NAME,
AS2MessageStructure.SIGNED, ContentType.create(AS2MediaType.APPLICATION_EDIFACT, AS2Charset.US_ASCII),
null, certList.toArray(new Certificate[0]), signingKP.getPrivate(), DISPOSITION_NOTIFICATION_TO,
SIGNED_RECEIPT_MIC_ALGORITHMS);
-
+
HttpRequest request = httpContext.getRequest();
assertTrue("Request does not contain entity", request instanceof BasicHttpEntityEnclosingRequest);
HttpEntity entity = ((BasicHttpEntityEnclosingRequest)request).getEntity();
@@ -348,23 +348,23 @@ public class AS2MessageTest {
assertNotNull("Multipart signed entity does not contain EDI message entity", ediMessageEntity);
ApplicationPkcs7SignatureEntity signatureEntity = multipartSignedEntity.getSignatureEntity();
assertNotNull("Multipart signed entity does not contain signature entity", signatureEntity);
-
+
// Validate Signature
assertTrue("Signature is invalid", multipartSignedEntity.isValid());
}
-
+
@Test
public void mdnMessageTest() throws Exception {
AS2ClientConnection clientConnection = new AS2ClientConnection(AS2_VERSION, USER_AGENT, CLIENT_FQDN, TARGET_HOST, TARGET_PORT);
AS2ClientManager clientManager = new AS2ClientManager(clientConnection);
-
+
HttpCoreContext httpContext = clientManager.send(EDI_MESSAGE, REQUEST_URI, SUBJECT, FROM, AS2_NAME, AS2_NAME,
AS2MessageStructure.PLAIN, ContentType.create(AS2MediaType.APPLICATION_EDIFACT, AS2Charset.US_ASCII),
null, null, null, DISPOSITION_NOTIFICATION_TO, null);
-
+
@SuppressWarnings("unused")
HttpResponse response = httpContext.getResponse();
}
-
+
}
diff --git a/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/Utils.java b/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/Utils.java
index 9ba2082..2c2823c 100644
--- a/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/Utils.java
+++ b/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/Utils.java
@@ -45,7 +45,7 @@ public final class Utils {
private Utils() {
}
-
+
public static AuthorityKeyIdentifier createAuthorityKeyId(PublicKey pub) throws IOException {
SubjectPublicKeyInfo info = SubjectPublicKeyInfo.getInstance(pub.getEncoded());
diff --git a/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/entity/EntityParserTest.java b/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/entity/EntityParserTest.java
index 6180e0e..eae510d 100644
--- a/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/entity/EntityParserTest.java
+++ b/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/entity/EntityParserTest.java
@@ -42,94 +42,94 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
public class EntityParserTest {
-
- public static final String REPORT_TYPE_HEADER_VALUE =
+
+ public static final String REPORT_TYPE_HEADER_VALUE =
"disposition-notification; boundary=\"----=_Part_56_1672293592.1028122454656\"\r\n";
-
- public static final String DISPOSITION_NOTIFICATION_REPORT_CONTENT =
+
+ public static final String DISPOSITION_NOTIFICATION_REPORT_CONTENT =
"\r\n"
- + "------=_Part_56_1672293592.1028122454656\r\n"
+ + "------=_Part_56_1672293592.1028122454656\r\n"
+ "Content-Type: text/plain\r\n"
- + "Content-Transfer-Encoding: 7bit\r\n" + "\r\n"
+ + "Content-Transfer-Encoding: 7bit\r\n" + "\r\n"
+ "MDN for -\r\n"
- + " Message ID: <200207310834482A70BF63@\\\"~~foo~~\\\">\r\n"
+ + " Message ID: <200207310834482A70BF63@\\\"~~foo~~\\\">\r\n"
+ " From: \"\\\" as2Name \\\"\"\r\n"
- + " To: \"0123456780000\""
- + " Received on: 2002-07-31 at 09:34:14 (EDT)\r\n"
+ + " To: \"0123456780000\""
+ + " Received on: 2002-07-31 at 09:34:14 (EDT)\r\n"
+ " Status: processed\r\n"
+ " Comment: This is not a guarantee that the message has\r\n"
- + " been completely processed or &understood by the receiving\r\n"
+ + " been completely processed or &understood by the receiving\r\n"
+ " translator\r\n" + "\r\n"
- + "------=_Part_56_1672293592.1028122454656\r\n"
+ + "------=_Part_56_1672293592.1028122454656\r\n"
+ "Content-Type: message/disposition-notification\r\n"
- + "Content-Transfer-Encoding: 7bit\r\n" + "\r\n"
+ + "Content-Transfer-Encoding: 7bit\r\n" + "\r\n"
+ "Reporting-UA: AS2 Server\r\n"
- + "MDN-Gateway: dns; example.com\r\n"
+ + "MDN-Gateway: dns; example.com\r\n"
+ "Original-Recipient: rfc822; 0123456780000\r\n"
+ "Final-Recipient: rfc822; 0123456780000\r\n"
+ "Original-Message-ID: <200207310834482A70BF63@\\\"~~foo~~\\\">\r\n"
- + "Disposition: automatic-action/MDN-sent-automatically;\r\n"
+ + "Disposition: automatic-action/MDN-sent-automatically;\r\n"
+ " processed/warning: you're awesome\r\n"
- + "Failure: oops-a-failure\r\n" + "Error: oops-an-error\r\n"
+ + "Failure: oops-a-failure\r\n" + "Error: oops-an-error\r\n"
+ "Warning: oops-a-warning\r\n"
- + "Received-content-MIC: 7v7F++fQaNB1sVLFtMRp+dF+eG4=, sha1\r\n"
+ + "Received-content-MIC: 7v7F++fQaNB1sVLFtMRp+dF+eG4=, sha1\r\n"
+ "\r\n"
+ "------=_Part_56_1672293592.1028122454656--\r\n";
public static final String DISPOSITION_NOTIFICATION_REPORT_CONTENT_BOUNDARY = "----=_Part_56_1672293592.1028122454656";
-
+
public static final String DISPOSITION_NOTIFICATION_REPORT_CONTENT_CHARSET_NAME = "US-ASCII";
-
+
public static final String DISPOSITION_NOTIFICATION_REPORT_CONTENT_TRANSFER_ENCODING = "7bit";
- public static final String TEXT_PLAIN_CONTENT =
+ public static final String TEXT_PLAIN_CONTENT =
"MDN for -\r\n"
- + " Message ID: <200207310834482A70BF63@\\\"~~foo~~\\\">\r\n"
+ + " Message ID: <200207310834482A70BF63@\\\"~~foo~~\\\">\r\n"
+ " From: \"\\\" as2Name \\\"\"\r\n"
- + " To: \"0123456780000\""
- + " Received on: 2002-07-31 at 09:34:14 (EDT)\r\n"
+ + " To: \"0123456780000\""
+ + " Received on: 2002-07-31 at 09:34:14 (EDT)\r\n"
+ " Status: processed\r\n"
+ " Comment: This is not a guarantee that the message has\r\n"
- + " been completely processed or &understood by the receiving\r\n"
- + " translator\r\n"
+ + " been completely processed or &understood by the receiving\r\n"
+ + " translator\r\n"
+ "\r\n"
+ "------=_Part_56_1672293592.1028122454656--\r\n";
-
+
public static final String TEXT_PLAIN_CONTENT_BOUNDARY = "----=_Part_56_1672293592.1028122454656";
-
+
public static final String TEXT_PLAIN_CONTENT_CHARSET_NAME = "US-ASCII";
-
+
public static final String TEXT_PLAIN_CONTENT_TRANSFER_ENCODING = "7bit";
- public static final String EXPECTED_TEXT_PLAIN_CONTENT =
+ public static final String EXPECTED_TEXT_PLAIN_CONTENT =
"MDN for -\r\n"
- + " Message ID: <200207310834482A70BF63@\\\"~~foo~~\\\">\r\n"
+ + " Message ID: <200207310834482A70BF63@\\\"~~foo~~\\\">\r\n"
+ " From: \"\\\" as2Name \\\"\"\r\n"
- + " To: \"0123456780000\""
- + " Received on: 2002-07-31 at 09:34:14 (EDT)\r\n"
+ + " To: \"0123456780000\""
+ + " Received on: 2002-07-31 at 09:34:14 (EDT)\r\n"
+ " Status: processed\r\n"
+ " Comment: This is not a guarantee that the message has\r\n"
- + " been completely processed or &understood by the receiving\r\n"
- + " translator\r\n";
-
- public static final String DISPOSITION_NOTIFICATION_CONTENT =
+ + " been completely processed or &understood by the receiving\r\n"
+ + " translator\r\n";
+
+ public static final String DISPOSITION_NOTIFICATION_CONTENT =
"Reporting-UA: AS2 Server\r\n"
- + "MDN-Gateway: dns; example.com\r\n"
+ + "MDN-Gateway: dns; example.com\r\n"
+ "Original-Recipient: rfc822; 0123456780000\r\n"
+ "Final-Recipient: rfc822; 0123456780000\r\n"
+ "Original-Message-ID: <200207310834482A70BF63@\\\"~~foo~~\\\">\r\n"
- + "Disposition: automatic-action/MDN-sent-automatically;\r\n"
+ + "Disposition: automatic-action/MDN-sent-automatically;\r\n"
+ " processed/warning: you're awesome\r\n"
- + "Failure: oops-a-failure\r\n" + "Error: oops-an-error\r\n"
+ + "Failure: oops-a-failure\r\n" + "Error: oops-an-error\r\n"
+ "Warning: oops-a-warning\r\n"
- + "Received-content-MIC: 7v7F++fQaNB1sVLFtMRp+dF+eG4=, sha1\r\n"
+ + "Received-content-MIC: 7v7F++fQaNB1sVLFtMRp+dF+eG4=, sha1\r\n"
+ "\r\n"
+ "------=_Part_56_1672293592.1028122454656--\r\n";
-
+
public static final String DISPOSITION_NOTIFICATION_CONTENT_BOUNDARY = "----=_Part_56_1672293592.1028122454656";
-
+
public static final String DISPOSITION_NOTIFICATION_CONTENT_CHARSET_NAME = "US-ASCII";
-
+
public static final String DISPOSITION_NOTIFICATION_CONTENT_TRANSFER_ENCODING = "7bit";
public static final String EXPECTED_REPORTING_UA = "AS2 Server";
@@ -145,9 +145,9 @@ public class EntityParserTest {
public static final String[] EXPECTED_WARNING = {"oops-a-warning"};
public static final String EXPECTED_ENCODED_MESSAGE_DIGEST = "7v7F++fQaNB1sVLFtMRp+dF+eG4=";
public static final String EXPECTED_DIGEST_ALGORITHM_ID = "sha1";
-
+
private static final int DEFAULT_BUFFER_SIZE = 8 * 1024;
-
+
@Before
public void setUp() throws Exception {
}
@@ -155,28 +155,28 @@ public class EntityParserTest {
@After
public void tearDown() throws Exception {
}
-
+
@Test
public void parseMessageDispositionNotificationReportMessageTest() throws Exception {
HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, EnglishReasonPhraseCatalog.INSTANCE.getReason(HttpStatus.SC_OK, null));
HttpMessageUtils.setHeaderValue(response, AS2Header.CONTENT_TRANSFER_ENCODING, DISPOSITION_NOTIFICATION_CONTENT_TRANSFER_ENCODING);
HttpMessageUtils.setHeaderValue(response, AS2Header.REPORT_TYPE, REPORT_TYPE_HEADER_VALUE);
-
+
BasicHttpEntity entity = new BasicHttpEntity();
entity.setContentType(AS2MimeType.MULTIPART_REPORT);
InputStream is = new ByteArrayInputStream(DISPOSITION_NOTIFICATION_REPORT_CONTENT.getBytes(DISPOSITION_NOTIFICATION_REPORT_CONTENT_CHARSET_NAME));
entity.setContent(is);
EntityUtils.setMessageEntity(response, entity);
-
+
EntityParser.parseMessageDispositionNotificationReportEntity(response);
HttpEntity parsedEntity = EntityUtils.getMessageEntity(response);
assertNotNull("Unexpected Null message disposition notification report entity", parsedEntity);
assertTrue("Unexpected type for message disposition notification report entity", parsedEntity instanceof DispositionNotificationMultipartReportEntity);
}
-
+
@Test
public void parseMessageDispositionNotificationReportBodyTest() throws Exception {
-
+
InputStream is = new ByteArrayInputStream(DISPOSITION_NOTIFICATION_REPORT_CONTENT.getBytes(DISPOSITION_NOTIFICATION_REPORT_CONTENT_CHARSET_NAME));
AS2SessionInputBuffer inbuffer = new AS2SessionInputBuffer(new HttpTransportMetricsImpl(), DEFAULT_BUFFER_SIZE, DEFAULT_BUFFER_SIZE, null);
inbuffer.bind(is);
@@ -185,25 +185,25 @@ public class EntityParserTest {
.parseMultipartReportEntityBody(inbuffer, DISPOSITION_NOTIFICATION_REPORT_CONTENT_BOUNDARY,
DISPOSITION_NOTIFICATION_REPORT_CONTENT_CHARSET_NAME,
DISPOSITION_NOTIFICATION_REPORT_CONTENT_TRANSFER_ENCODING);
-
+
assertNotNull("Unexpected Null disposition notification multipart entity", dispositionNotificationMultipartReportEntity);
assertEquals("Unexpected number of body parts", 2, dispositionNotificationMultipartReportEntity.getPartCount());
-
+
assertTrue("Unexpected type for first body part", dispositionNotificationMultipartReportEntity.getPart(0) instanceof TextPlainEntity);
assertTrue("Unexpected type for second body part", dispositionNotificationMultipartReportEntity.getPart(1) instanceof AS2MessageDispositionNotificationEntity);
}
@Test
public void parseTextPlainBodyTest() throws Exception {
-
+
InputStream is = new ByteArrayInputStream(TEXT_PLAIN_CONTENT.getBytes(TEXT_PLAIN_CONTENT_CHARSET_NAME));
AS2SessionInputBuffer inbuffer = new AS2SessionInputBuffer(new HttpTransportMetricsImpl(), DEFAULT_BUFFER_SIZE, DEFAULT_BUFFER_SIZE, null);
inbuffer.bind(is);
TextPlainEntity textPlainEntity = EntityParser.parseTextPlainEntityBody(inbuffer, TEXT_PLAIN_CONTENT_BOUNDARY, TEXT_PLAIN_CONTENT_CHARSET_NAME, TEXT_PLAIN_CONTENT_TRANSFER_ENCODING);
-
+
String text = textPlainEntity.getText();
-
+
assertEquals("Unexpected text", EXPECTED_TEXT_PLAIN_CONTENT, text);
}
@@ -213,7 +213,7 @@ public class EntityParserTest {
InputStream is = new ByteArrayInputStream(DISPOSITION_NOTIFICATION_CONTENT.getBytes(DISPOSITION_NOTIFICATION_CONTENT_CHARSET_NAME));
AS2SessionInputBuffer inbuffer = new AS2SessionInputBuffer(new HttpTransportMetricsImpl(), DEFAULT_BUFFER_SIZE, DEFAULT_BUFFER_SIZE, null);
inbuffer.bind(is);
-
+
AS2MessageDispositionNotificationEntity messageDispositionNotificationEntity = EntityParser
.parseMessageDispositionNotificationEntityBody(inbuffer, DISPOSITION_NOTIFICATION_CONTENT_BOUNDARY,
DISPOSITION_NOTIFICATION_CONTENT_CHARSET_NAME,
diff --git a/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/util/AS2HeaderUtilsTest.java b/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/util/AS2HeaderUtilsTest.java
index 7804125..1bd6a0b 100644
--- a/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/util/AS2HeaderUtilsTest.java
+++ b/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/util/AS2HeaderUtilsTest.java
@@ -33,19 +33,19 @@ public class AS2HeaderUtilsTest {
private static final String SIGNED_RECEIPT_MICALG_ATTRIBUTE = "signed-receipt-micalg";
private static final String SIGNED_RECEIPT_MICALG_IMPORTANCE = "required";
private static final String[] SIGNED_RECEIPT_MICALG_VALUES = {"sha1"};
-
+
@Test
public void parseNameValuePairTest() {
final CharArrayBuffer buffer = new CharArrayBuffer(TEST_NAME_VALUES.length());
buffer.append(TEST_NAME_VALUES);
final ParserCursor cursor = new ParserCursor(0, TEST_NAME_VALUES.length());
-
+
Parameter parameter = AS2HeaderUtils.parseParameter(buffer, cursor);
assertEquals("Unexpected value for parameter attribute", SIGNED_RECEIPT_PROTOCOL_ATTRIBUTE, parameter.getAttribute());
assertEquals("Unexpected value for parameter importance", SIGNED_RECEIPT_PROTOCOL_IMPORTANCE, parameter.getImportance().getImportance());
assertArrayEquals("Unexpected value for parameter values", SIGNED_RECEIPT_PROTOCOL_VALUES, parameter.getValues());
-
+
parameter = AS2HeaderUtils.parseParameter(buffer, cursor);
assertEquals("Unexpected value for parameter attribute", SIGNED_RECEIPT_MICALG_ATTRIBUTE, parameter.getAttribute());
assertEquals("Unexpected value for parameter importance", SIGNED_RECEIPT_MICALG_IMPORTANCE, parameter.getImportance().getImportance());
diff --git a/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/util/DispositionNotificationContentUtilsTest.java b/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/util/DispositionNotificationContentUtilsTest.java
index 2b189d5..daa9233 100644
--- a/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/util/DispositionNotificationContentUtilsTest.java
+++ b/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/util/DispositionNotificationContentUtilsTest.java
@@ -38,18 +38,18 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public class DispositionNotificationContentUtilsTest {
-
- public static final String DISPOSITION_NOTIFICATION_CONTENT =
+
+ public static final String DISPOSITION_NOTIFICATION_CONTENT =
"Reporting-UA: AS2 Server\r\n"
- + "MDN-Gateway: dns; example.com\r\n"
+ + "MDN-Gateway: dns; example.com\r\n"
+ "Original-Recipient: rfc822; 0123456780000\r\n"
+ "Final-Recipient: rfc822; 0123456780000\r\n"
+ "Original-Message-ID: <200207310834482A70BF63@\\\"~~foo~~\\\">\r\n"
- + "Disposition: automatic-action/MDN-sent-automatically;\r\n"
+ + "Disposition: automatic-action/MDN-sent-automatically;\r\n"
+ " processed/warning: you're awesome\r\n"
- + "Failure: oops-a-failure\r\n"
+ + "Failure: oops-a-failure\r\n"
+ "Error: oops-an-error\r\n" + "Warning: oops-a-warning\r\n"
- + "Received-content-MIC: 7v7F++fQaNB1sVLFtMRp+dF+eG4=, sha1\r\n"
+ + "Received-content-MIC: 7v7F++fQaNB1sVLFtMRp+dF+eG4=, sha1\r\n"
+ "\r\n";
public static final String EXPECTED_REPORTING_UA = "AS2 Server";
@@ -65,7 +65,7 @@ public class DispositionNotificationContentUtilsTest {
public static final String[] EXPECTED_WARNING = {"oops-a-warning"};
public static final String EXPECTED_ENCODED_MESSAGE_DIGEST = "7v7F++fQaNB1sVLFtMRp+dF+eG4=";
public static final String EXPECTED_DIGEST_ALGORITHM_ID = "sha1";
-
+
@Before
public void setUp() throws Exception {
@@ -77,15 +77,15 @@ public class DispositionNotificationContentUtilsTest {
@Test
public void test() throws Exception {
-
+
InputStream is = new ByteArrayInputStream(DISPOSITION_NOTIFICATION_CONTENT.getBytes());
-
+
AS2SessionInputBuffer inbuffer = new AS2SessionInputBuffer(new HttpTransportMetricsImpl(), 8 * 1024);
inbuffer.bind(is);
-
+
List<CharArrayBuffer> dispositionNotificationFields = EntityParser.parseBodyPartFields(inbuffer, null, BasicLineParser.INSTANCE, new ArrayList<CharArrayBuffer>());
AS2MessageDispositionNotificationEntity messageDispositionNotificationEntity = DispositionNotificationContentUtils.parseDispositionNotification(dispositionNotificationFields);
-
+
assertEquals("Unexpected Reporting UA value", EXPECTED_REPORTING_UA, messageDispositionNotificationEntity.getReportingUA());
assertEquals("Unexpected MTN Name", EXPECTED_MTN_NAME, messageDispositionNotificationEntity.getMtnName());
assertEquals("Unexpected Original Recipient", EXPECTED_ORIGINAL_RECIPIENT, messageDispositionNotificationEntity.getExtensionFields().get("Original-Recipient"));
diff --git a/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/util/MicUtilsTest.java b/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/util/MicUtilsTest.java
index 6674df8..f535786 100644
--- a/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/util/MicUtilsTest.java
+++ b/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/util/MicUtilsTest.java
@@ -40,37 +40,37 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public class MicUtilsTest {
-
+
public static final Logger LOG = LoggerFactory.getLogger(MicUtilsTest.class);
private static final String DISPOSITION_NOTIFICATION_OPTIONS_VALUE = " signed-receipt-protocol = optional , pkcs7-signature ; signed-receipt-micalg = required , sha1 ";
private static final String CONTENT_TYPE_VALUE = AS2MimeType.APPLICATION_EDIFACT;
- private static final String EDI_MESSAGE =
+ private static final String EDI_MESSAGE =
"UNB+UNOA:1+005435656:1+006415160:1+060515:1434+00000000000778'\n"
- + "UNH+00000000000117+INVOIC:D:97B:UN'\n"
- + "BGM+380+342459+9'\n"
+ + "UNH+00000000000117+INVOIC:D:97B:UN'\n"
+ + "BGM+380+342459+9'\n"
+ "DTM+3:20060515:102'\n"
- + "RFF+ON:521052'\n"
+ + "RFF+ON:521052'\n"
+ "NAD+BY+792820524::16++CUMMINS MID-RANGE ENGINE PLANT'\n"
- + "NAD+SE+005435656::16++GENERAL WIDGET COMPANY'\n"
- + "CUX+1:USD'\n"
+ + "NAD+SE+005435656::16++GENERAL WIDGET COMPANY'\n"
+ + "CUX+1:USD'\n"
+ "LIN+1++157870:IN'\n"
- + "IMD+F++:::WIDGET'\n"
- + "QTY+47:1020:EA'\n"
+ + "IMD+F++:::WIDGET'\n"
+ + "QTY+47:1020:EA'\n"
+ "ALI+US'\n"
- + "MOA+203:1202.58'\n"
+ + "MOA+203:1202.58'\n"
+ "PRI+INV:1.179'\n"
- + "LIN+2++157871:IN'\n"
- + "IMD+F++:::DIFFERENT WIDGET'\n"
- + "QTY+47:20:EA'\n"
+ + "LIN+2++157871:IN'\n"
+ + "IMD+F++:::DIFFERENT WIDGET'\n"
+ + "QTY+47:20:EA'\n"
+ "ALI+JP'\n"
- + "MOA+203:410'\n"
- + "PRI+INV:20.5'\n"
- + "UNS+S'\n"
- + "MOA+39:2137.58'\n"
- + "ALC+C+ABG'\n"
+ + "MOA+203:410'\n"
+ + "PRI+INV:20.5'\n"
+ + "UNS+S'\n"
+ + "MOA+39:2137.58'\n"
+ + "ALC+C+ABG'\n"
+ "MOA+8:525'\n"
- + "UNT+23+00000000000117'\n"
+ + "UNT+23+00000000000117'\n"
+ "UNZ+1+00000000000778'";
private static final String EXPECTED_MESSAGE_DIGEST_ALGORITHM = "sha1";
@@ -87,11 +87,11 @@ public class MicUtilsTest {
@Test
public void createReceivedContentMicTest() throws Exception {
-
+
HttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/", HttpVersion.HTTP_1_1);
request.addHeader(AS2Header.DISPOSITION_NOTIFICATION_OPTIONS, DISPOSITION_NOTIFICATION_OPTIONS_VALUE);
request.addHeader(AS2Header.CONTENT_TYPE, CONTENT_TYPE_VALUE);
-
+
ApplicationEDIFACTEntity edifactEntity = new ApplicationEDIFACTEntity(EDI_MESSAGE, AS2Charset.US_ASCII, AS2TransferEncoding.NONE, true);
InputStream is = edifactEntity.getContent();
BasicHttpEntity basicEntity = new BasicHttpEntity();
@@ -105,7 +105,7 @@ public class MicUtilsTest {
assertEquals("Unexpected digest algorithm value", EXPECTED_MESSAGE_DIGEST_ALGORITHM, receivedContentMic.getDigestAlgorithmId());
LOG.debug("Encoded Message Digest: " + receivedContentMic.getEncodedMessageDigest());
assertEquals("Unexpected encoded message digest value", EXPECTED_ENCODED_MESSAGE_DIGEST, receivedContentMic.getEncodedMessageDigest());
-
+
}
}
diff --git a/components/camel-as2/camel-as2-component/src/main/java/org/apache/camel/component/as2/AS2Configuration.java b/components/camel-as2/camel-as2-component/src/main/java/org/apache/camel/component/as2/AS2Configuration.java
index 6ad35c1..6fb4dd3 100644
--- a/components/camel-as2/camel-as2-component/src/main/java/org/apache/camel/component/as2/AS2Configuration.java
+++ b/components/camel-as2/camel-as2-component/src/main/java/org/apache/camel/component/as2/AS2Configuration.java
@@ -41,73 +41,73 @@ public class AS2Configuration {
@UriPath
@Metadata(required = "true")
private String methodName;
-
+
@UriPath
private String as2Version = "1.1";
@UriParam
private String userAgent = "Camel AS2 Client Endpoint";
-
+
@UriParam
private String server = "Camel AS2 Server Endpoint";
-
+
@UriParam
private String serverFqdn = "camel.apache.org";
-
+
@UriParam
private String targetHostname;
-
+
@UriParam
private Integer targetPortNumber;
-
+
@UriParam
private String clientFqdn = "camel.apache.org";
-
+
@UriParam
private Integer serverPortNumber;
-
+
@UriParam
private String requestUri = "/";
-
+
@UriParam
private ContentType ediMessageType;
-
+
@UriParam
private String ediMessageTransferEncoding;
-
+
@UriParam
private AS2MessageStructure as2MessageStructure;
-
+
@UriParam
private String subject;
-
+
@UriParam
private String from;
-
+
@UriParam
private String as2From;
-
+
@UriParam
private String as2To;
-
+
@UriParam
private String signingAlgorithmName;
-
+
@UriParam
private Certificate[] signingCertificateChain;
-
+
@UriParam
private PrivateKey signingPrivateKey;
-
+
@UriParam
private String dispositionNotificationTo;
-
+
@UriParam
private String[] signedReceiptMicAlgorithms;
-
+
/**
* What kind of operation to perform
- *
+ *
* @return the API Name
*/
public AS2ApiName getApiName() {
@@ -116,7 +116,7 @@ public class AS2Configuration {
/**
* What kind of operation to perform
- *
+ *
* @param apiName -
* the API Name to set
*/
@@ -126,7 +126,7 @@ public class AS2Configuration {
/**
* What sub operation to use for the selected operation
- *
+ *
* @return The methodName
*/
public String getMethodName() {
@@ -135,7 +135,7 @@ public class AS2Configuration {
/**
* What sub operation to use for the selected operation
- *
+ *
* @param methodName -
* the methodName to set
*/
@@ -145,7 +145,7 @@ public class AS2Configuration {
/**
* The version of the AS2 protocol.
- *
+ *
* @return The version of the AS2 protocol.
*/
public String getAs2Version() {
@@ -154,7 +154,7 @@ public class AS2Configuration {
/**
* The version of the AS2 protocol.
- *
+ *
* @param as2Version - the version of the AS2 protocol.
*/
public void setAs2Version(String as2Version) {
@@ -167,7 +167,7 @@ public class AS2Configuration {
/**
* The value included in the <code>User-Agent</code>
* message header identifying the AS2 user agent.
- *
+ *
* @return AS2 user agent identification string.
*/
public String getUserAgent() {
@@ -177,7 +177,7 @@ public class AS2Configuration {
/**
* The value included in the <code>User-Agent</code>
* message header identifying the AS2 user agent.
- *
+ *
* @param userAgent - AS2 user agent identification string.
*/
public void setUserAgent(String userAgent) {
@@ -185,9 +185,9 @@ public class AS2Configuration {
}
/**
- * The value included in the <code>Server</code>
+ * The value included in the <code>Server</code>
* message header identifying the AS2 Server.
- *
+ *
* @return AS2 server identification string.
*/
public String getServer() {
@@ -195,9 +195,9 @@ public class AS2Configuration {
}
/**
- * The value included in the <code>Server</code>
+ * The value included in the <code>Server</code>
* message header identifying the AS2 Server.
- *
+ *
* @param server - AS2 server identification string.
*/
public void setServer(String server) {
@@ -205,10 +205,10 @@ public class AS2Configuration {
}
/**
- * The Server Fully Qualified Domain Name (FQDN).
- *
+ * The Server Fully Qualified Domain Name (FQDN).
+ *
* <p> Used in message ids sent by endpoint.
- *
+ *
* @return The FQDN of client.
*/
public String getServerFqdn() {
@@ -216,10 +216,10 @@ public class AS2Configuration {
}
/**
- * The Server Fully Qualified Domain Name (FQDN).
- *
+ * The Server Fully Qualified Domain Name (FQDN).
+ *
* <p> Used in message ids sent by endpoint.
- *
+ *
* @param clientFqdn - the FQDN of client.
*/
public void setServerFqdn(String serverFqdn) {
@@ -231,7 +231,7 @@ public class AS2Configuration {
/**
* The host name (IP or DNS) of target host.
- *
+ *
* @return The target host name (IP or DNS name).
*/
public String getTargetHostname() {
@@ -240,7 +240,7 @@ public class AS2Configuration {
/**
* The host name (IP or DNS name) of target host.
- *
+ *
* @param targetHostname - the target host name (IP or DNS name).
*/
public void setTargetHostname(String targetHostname) {
@@ -249,7 +249,7 @@ public class AS2Configuration {
/**
* The port number of target host.
- *
+ *
* @return The target port number. -1 indicates the scheme default port.
*/
public int getTargetPortNumber() {
@@ -258,7 +258,7 @@ public class AS2Configuration {
/**
* The port number of target host.
- *
+ *
* @param targetPortNumber - the target port number. -1 indicates the scheme default port.
*/
public void setTargetPortNumber(String targetPortNumber) {
@@ -270,10 +270,10 @@ public class AS2Configuration {
}
/**
- * The Client Fully Qualified Domain Name (FQDN).
- *
+ * The Client Fully Qualified Domain Name (FQDN).
+ *
* <p> Used in message ids sent by endpoint.
- *
+ *
* @return The FQDN of client.
*/
public String getClientFqdn() {
@@ -281,10 +281,10 @@ public class AS2Configuration {
}
/**
- * The Client Fully Qualified Domain Name (FQDN).
- *
+ * The Client Fully Qualified Domain Name (FQDN).
+ *
* <p> Used in message ids sent by endpoint.
- *
+ *
* @param clientFqdn - the FQDN of client.
*/
public void setClientFqdn(String clientFqdn) {
@@ -296,7 +296,7 @@ public class AS2Configuration {
/**
* The port number of server.
- *
+ *
* @return The server port number.
*/
public Integer getServerPortNumber() {
@@ -305,7 +305,7 @@ public class AS2Configuration {
/**
* The port number of server.
- *
+ *
* @param serverPortNumber - the server port number.
*/
public void setServerPortNumber(String serverPortNumber) {
@@ -427,6 +427,6 @@ public class AS2Configuration {
public void setSignedReceiptMicAlgorithms(String[] signedReceiptMicAlgorithms) {
this.signedReceiptMicAlgorithms = signedReceiptMicAlgorithms;
}
-
-
+
+
}
diff --git a/components/camel-as2/camel-as2-component/src/main/java/org/apache/camel/component/as2/AS2Consumer.java b/components/camel-as2/camel-as2-component/src/main/java/org/apache/camel/component/as2/AS2Consumer.java
index 2616b59..b5e579e 100644
--- a/components/camel-as2/camel-as2-component/src/main/java/org/apache/camel/component/as2/AS2Consumer.java
+++ b/components/camel-as2/camel-as2-component/src/main/java/org/apache/camel/component/as2/AS2Consumer.java
@@ -41,14 +41,14 @@ import org.apache.http.protocol.HttpRequestHandler;
* The AS2 consumer.
*/
public class AS2Consumer extends AbstractApiConsumer<AS2ApiName, AS2Configuration> implements HttpRequestHandler {
-
+
private static final String HANDLER_PROPERTY = "handler";
private static final String REQUEST_URI_PROPERTY = "requestUri";
private AS2ServerConnection as2ServerConnection;
-
+
private AS2ServerManager apiProxy;
-
+
private final ApiMethod apiMethod;
private final Map<String, Object> properties;
@@ -65,7 +65,7 @@ public class AS2Consumer extends AbstractApiConsumer<AS2ApiName, AS2Configuratio
properties.put(HANDLER_PROPERTY, this);
as2ServerConnection = endpoint.getAS2ServerConnection();
-
+
apiProxy = new AS2ServerManager(as2ServerConnection);
}
@@ -73,7 +73,7 @@ public class AS2Consumer extends AbstractApiConsumer<AS2ApiName, AS2Configuratio
public void interceptPropertyNames(Set<String> propertyNames) {
propertyNames.add(HANDLER_PROPERTY);
}
-
+
@Override
protected int poll() throws Exception {
return 0;
@@ -82,11 +82,11 @@ public class AS2Consumer extends AbstractApiConsumer<AS2ApiName, AS2Configuratio
@Override
protected void doStart() throws Exception {
super.doStart();
-
+
// invoke the API method to start listening
ApiMethodHelper.invokeMethod(apiProxy, apiMethod, properties);
}
-
+
@Override
protected void doStop() throws Exception {
String requestUri = (String) properties.get(REQUEST_URI_PROPERTY);
@@ -110,7 +110,7 @@ public class AS2Consumer extends AbstractApiConsumer<AS2ApiName, AS2Configuratio
} catch (Exception e) {
log.info("Received exception consuming AS2 message: ", e);
}
-
+
}
-
+
}
diff --git a/components/camel-as2/camel-as2-component/src/main/java/org/apache/camel/component/as2/AS2Endpoint.java b/components/camel-as2/camel-as2-component/src/main/java/org/apache/camel/component/as2/AS2Endpoint.java
index 6002fd4..2237469 100644
--- a/components/camel-as2/camel-as2-component/src/main/java/org/apache/camel/component/as2/AS2Endpoint.java
+++ b/components/camel-as2/camel-as2-component/src/main/java/org/apache/camel/component/as2/AS2Endpoint.java
@@ -50,7 +50,7 @@ public class AS2Endpoint extends AbstractApiEndpoint<AS2ApiName, AS2Configuratio
private String name;
private Object apiProxy;
-
+
private AS2ClientConnection as2ClientConnection;
private AS2ServerConnection as2ServerConnection;
@@ -60,7 +60,7 @@ public class AS2Endpoint extends AbstractApiEndpoint<AS2ApiName, AS2Configuratio
super(uri, component, apiName, methodName, AS2ApiCollection.getCollection().getHelper(apiName), endpointConfiguration);
}
-
+
public AS2ClientConnection getAS2ClientConnection() {
return as2ClientConnection;
}
@@ -107,7 +107,7 @@ public class AS2Endpoint extends AbstractApiEndpoint<AS2ApiName, AS2Configuratio
break;
}
}
-
+
@Override
public Object getApiProxy(ApiMethod method, Map<String, Object> args) {
if (apiProxy == null) {
@@ -115,7 +115,7 @@ public class AS2Endpoint extends AbstractApiEndpoint<AS2ApiName, AS2Configuratio
}
return apiProxy;
}
-
+
/**
* Some description of this option, and what it does
*/
@@ -139,7 +139,7 @@ public class AS2Endpoint extends AbstractApiEndpoint<AS2ApiName, AS2Configuratio
throw new IllegalArgumentException("Invalid API name " + apiName);
}
}
-
+
private void createAS2ClientConnection() {
try {
as2ClientConnection = AS2ConnectionHelper.createAS2ClientConnection(configuration);
@@ -150,7 +150,7 @@ public class AS2Endpoint extends AbstractApiEndpoint<AS2ApiName, AS2Configuratio
throw new RuntimeCamelException("Client HTTP connection failed", e);
}
}
-
+
private void createAS2ServerConnection() {
try {
as2ServerConnection = AS2ConnectionHelper.createAS2ServerConnection(configuration);
diff --git a/components/camel-as2/camel-as2-component/src/main/java/org/apache/camel/component/as2/internal/AS2ConnectionHelper.java b/components/camel-as2/camel-as2-component/src/main/java/org/apache/camel/component/as2/internal/AS2ConnectionHelper.java
index 23e769c..2ebdf9a 100644
--- a/components/camel-as2/camel-as2-component/src/main/java/org/apache/camel/component/as2/internal/AS2ConnectionHelper.java
+++ b/components/camel-as2/camel-as2-component/src/main/java/org/apache/camel/component/as2/internal/AS2ConnectionHelper.java
@@ -29,18 +29,18 @@ import org.apache.camel.component.as2.api.AS2ServerConnection;
* Utility class for creating AS2 connections.
*/
public final class AS2ConnectionHelper {
-
- private static Map<Integer, AS2ServerConnection> serverConnections = new HashMap<Integer, AS2ServerConnection>();
-
+
+ private static Map<Integer, AS2ServerConnection> serverConnections = new HashMap<Integer, AS2ServerConnection>();
+
/**
* Prevent instantiation
*/
private AS2ConnectionHelper() {
}
-
+
/**
* Create an AS2 client connection.
- *
+ *
* @param configuration - configuration used to configure connection.
* @return The AS2 client connection.
* @throws UnknownHostException Failed to establish connection due to unknown host.
@@ -50,13 +50,13 @@ public final class AS2ConnectionHelper {
return new AS2ClientConnection(configuration.getAs2Version(), configuration.getUserAgent(), configuration.getClientFqdn(),
configuration.getTargetHostname(), configuration.getTargetPortNumber());
}
-
+
/**
* Create an AS2 server connection.
- *
+ *
* @param configuration - configuration used to configure connection.
* @return The AS2 server connection.
- * @throws IOException
+ * @throws IOException
*/
public static AS2ServerConnection createAS2ServerConnection(AS2Configuration configuration) throws IOException {
synchronized (serverConnections) {
diff --git a/components/camel-as2/camel-as2-component/src/test/java/org/apache/camel/component/as2/AS2ClientManagerIntegrationTest.java b/components/camel-as2/camel-as2-component/src/test/java/org/apache/camel/component/as2/AS2ClientManagerIntegrationTest.java
index e4074bc..f862ada 100644
--- a/components/camel-as2/camel-as2-component/src/test/java/org/apache/camel/component/as2/AS2ClientManagerIntegrationTest.java
+++ b/components/camel-as2/camel-as2-component/src/test/java/org/apache/camel/component/as2/AS2ClientManagerIntegrationTest.java
@@ -84,11 +84,11 @@ public class AS2ClientManagerIntegrationTest extends AbstractAS2TestSupport {
private static final String SUBJECT = "Test Case";
private static final String AS2_NAME = "878051556";
private static final String FROM = "mrAS@example.org";
-
+
private static final String MDN_FROM = "as2Test@server.example.com";
private static final String MDN_SUBJECT_PREFIX = "MDN Response:";
-
- private static final String EDI_MESSAGE =
+
+ private static final String EDI_MESSAGE =
"UNB+UNOA:1+005435656:1+006415160:1+060515:1434+00000000000778'\n"
+ "UNH+00000000000117+INVOIC:D:97B:UN'\n"
+ "BGM+380+342459+9'\n"
@@ -115,11 +115,11 @@ public class AS2ClientManagerIntegrationTest extends AbstractAS2TestSupport {
+ "MOA+8:525'\n"
+ "UNT+23+00000000000117'\n"
+ "UNZ+1+00000000000778'\n";
-
+
private static final String EXPECTED_AS2_VERSION = "1.1";
private static final String EXPECTED_MDN_SUBJECT = MDN_SUBJECT_PREFIX + SUBJECT;
private static final String[] SIGNED_RECEIPT_MIC_ALGORITHMS = new String[] {"sha1", "md5"};
-
+
private static AS2ServerConnection serverConnection;
private static KeyPair serverSigningKP;
private static List<X509Certificate> serverCertList;
@@ -134,11 +134,11 @@ public class AS2ClientManagerIntegrationTest extends AbstractAS2TestSupport {
@Before
public void setUp() throws Exception {
- super.setUp();
+ super.setUp();
Security.addProvider(new BouncyCastleProvider());
-
+
setupKeysAndCertificates();
-
+
// Create and populate certificate store.
JcaCertStore certs = new JcaCertStore(certList);
@@ -152,7 +152,7 @@ public class AS2ClientManagerIntegrationTest extends AbstractAS2TestSupport {
ASN1EncodableVector attributes = new ASN1EncodableVector();
attributes.add(new SMIMEEncryptionKeyPreferenceAttribute(new IssuerAndSerialNumber(new X500Name(signingCert.getIssuerDN().getName()), signingCert.getSerialNumber())));
attributes.add(new SMIMECapabilitiesAttribute(capabilities));
-
+
for (String signingAlgorithmName : AS2SignedDataGenerator
.getSupportedSignatureAlgorithmNamesForKey(signingKP.getPrivate())) {
try {
@@ -167,7 +167,7 @@ public class AS2ClientManagerIntegrationTest extends AbstractAS2TestSupport {
continue;
}
}
-
+
if (this.gen == null) {
throw new Exception("failed to create signing generator");
}
@@ -213,7 +213,7 @@ public class AS2ClientManagerIntegrationTest extends AbstractAS2TestSupport {
assertTrue("Request body does not contain EDI entity", entity instanceof ApplicationEDIEntity);
String ediMessage = ((ApplicationEDIEntity)entity).getEdiMessage();
assertEquals("EDI message is different", EDI_MESSAGE, ediMessage);
-
+
HttpResponse response = result.getResponse();
assertNotNull("Response", response);
assertEquals("Unexpected response type", AS2MimeType.MULTIPART_REPORT, HttpMessageUtils.getHeaderValue(response, AS2Header.CONTENT_TYPE));
@@ -224,7 +224,7 @@ public class AS2ClientManagerIntegrationTest extends AbstractAS2TestSupport {
assertEquals("Unexpected AS2 from", AS2_NAME, HttpMessageUtils.getHeaderValue(response, AS2Header.AS2_FROM));
assertEquals("Unexpected AS2 to", AS2_NAME, HttpMessageUtils.getHeaderValue(response, AS2Header.AS2_TO));
assertNotNull("Missing message id", HttpMessageUtils.getHeaderValue(response, AS2Header.MESSAGE_ID));
-
+
HttpEntity responseEntity = response.getEntity();
assertNotNull("Response entity", responseEntity);
assertTrue("Unexpected response entity type", responseEntity instanceof DispositionNotificationMultipartReportEntity);
@@ -276,13 +276,13 @@ public class AS2ClientManagerIntegrationTest extends AbstractAS2TestSupport {
HttpEntity entity = ((HttpEntityEnclosingRequest)request).getEntity();
assertNotNull("Request body", entity);
assertTrue("Request body does not contain EDI entity", entity instanceof MultipartSignedEntity);
-
+
MimeEntity signedEntity = ((MultipartSignedEntity)entity).getSignedDataEntity();
assertTrue("Signed entity wrong type", signedEntity instanceof ApplicationEDIEntity);
ApplicationEDIEntity ediMessageEntity = (ApplicationEDIEntity) signedEntity;
String ediMessage = ediMessageEntity.getEdiMessage();
assertEquals("EDI message is different", EDI_MESSAGE, ediMessage);
-
+
HttpResponse response = result.getResponse();
assertNotNull("Response", response);
String contentTypeHeaderValue = HttpMessageUtils.getHeaderValue(response, AS2Header.CONTENT_TYPE);
@@ -295,7 +295,7 @@ public class AS2ClientManagerIntegrationTest extends AbstractAS2TestSupport {
assertEquals("Unexpected AS2 from", AS2_NAME, HttpMessageUtils.getHeaderValue(response, AS2Header.AS2_FROM));
assertEquals("Unexpected AS2 to", AS2_NAME, HttpMessageUtils.getHeaderValue(response, AS2Header.AS2_TO));
assertNotNull("Missing message id", HttpMessageUtils.getHeaderValue(response, AS2Header.MESSAGE_ID));
-
+
HttpEntity responseEntity = response.getEntity();
assertNotNull("Response entity", responseEntity);
assertTrue("Unexpected response entity type", responseEntity instanceof MultipartSignedEntity);
@@ -316,10 +316,10 @@ public class AS2ClientManagerIntegrationTest extends AbstractAS2TestSupport {
@BeforeClass
public static void setupTest() throws Exception {
- setupServerKeysAndCertificates();
+ setupServerKeysAndCertificates();
receiveTestMessages();
}
-
+
@AfterClass
public static void teardownTest() throws Exception {
if (serverConnection != null) {
@@ -338,7 +338,7 @@ public class AS2ClientManagerIntegrationTest extends AbstractAS2TestSupport {
}
}
-
+
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@@ -349,10 +349,10 @@ public class AS2ClientManagerIntegrationTest extends AbstractAS2TestSupport {
}
};
}
-
+
private static void setupServerKeysAndCertificates() throws Exception {
Security.addProvider(new BouncyCastleProvider());
-
+
//
// set up our certificates
//
@@ -364,21 +364,21 @@ public class AS2ClientManagerIntegrationTest extends AbstractAS2TestSupport {
KeyPair issueKP = kpg.generateKeyPair();
X509Certificate issueCert = Utils.makeCertificate(
issueKP, issueDN, issueKP, issueDN);
-
+
//
// certificate we sign against
//
String signingDN = "CN=William J. Collins, E=punkhornsw@gmail.com, O=Punkhorn Software, C=US";
serverSigningKP = kpg.generateKeyPair();
X509Certificate signingCert = Utils.makeCertificate(
- serverSigningKP, signingDN, issueKP, issueDN);
-
+ serverSigningKP, signingDN, issueKP, issueDN);
+
serverCertList = new ArrayList<X509Certificate>();
serverCertList.add(signingCert);
serverCertList.add(issueCert);
}
-
+
private static void receiveTestMessages() throws IOException {
serverConnection = new AS2ServerConnection("1.1", "AS2ClientManagerIntegrationTest Server",
"server.example.com", 8888, serverCertList.toArray(new Certificate[0]), serverSigningKP.getPrivate());
@@ -397,7 +397,7 @@ public class AS2ClientManagerIntegrationTest extends AbstractAS2TestSupport {
issueKP = kpg.generateKeyPair();
issueCert = Utils.makeCertificate(
issueKP, issueDN, issueKP, issueDN);
-
+
//
// certificate we sign against
//
@@ -405,7 +405,7 @@ public class AS2ClientManagerIntegrationTest extends AbstractAS2TestSupport {
signingKP = kpg.generateKeyPair();
signingCert = Utils.makeCertificate(
signingKP, signingDN, issueKP, issueDN);
-
+
certList = new ArrayList<X509Certificate>();
certList.add(signingCert);
diff --git a/components/camel-as2/camel-as2-component/src/test/java/org/apache/camel/component/as2/AS2ServerManagerIntegrationTest.java b/components/camel-as2/camel-as2-component/src/test/java/org/apache/camel/component/as2/AS2ServerManagerIntegrationTest.java
index 272adbe..229c314 100644
--- a/components/camel-as2/camel-as2-component/src/test/java/org/apache/camel/component/as2/AS2ServerManagerIntegrationTest.java
+++ b/components/camel-as2/camel-as2-component/src/test/java/org/apache/camel/component/as2/AS2ServerManagerIntegrationTest.java
@@ -110,21 +110,21 @@ public class AS2ServerManagerIntegrationTest extends AbstractAS2TestSupport {
+ "MOA+8:525'\n"
+ "UNT+23+00000000000117'\n"
+ "UNZ+1+00000000000778'";
-
+
private AS2SignedDataGenerator gen;
-
+
private KeyPair issueKP;
private X509Certificate issueCert;
private KeyPair signingKP;
private X509Certificate signingCert;
private List<X509Certificate> certList;
-
+
@Test
public void receivePlainEDIMessageTest() throws Exception {
AS2ClientConnection clientConnection = new AS2ClientConnection(AS2_VERSION, USER_AGENT, CLIENT_FQDN, TARGET_HOST, TARGET_PORT);
AS2ClientManager clientManager = new AS2ClientManager(clientConnection);
-
+
clientManager.send(EDI_MESSAGE, REQUEST_URI, SUBJECT, FROM, AS2_NAME, AS2_NAME, AS2MessageStructure.PLAIN,
ContentType.create(AS2MediaType.APPLICATION_EDIFACT, AS2Charset.US_ASCII), null, null, null,
DISPOSITION_NOTIFICATION_TO, SIGNED_RECEIPT_MIC_ALGORITHMS);
@@ -133,12 +133,12 @@ public class AS2ServerManagerIntegrationTest extends AbstractAS2TestSupport {
mockEndpoint.expectedMinimumMessageCount(1);
mockEndpoint.setResultWaitTime(TimeUnit.MILLISECONDS.convert(30, TimeUnit.SECONDS));
mockEndpoint.assertIsSatisfied();
-
+
final List<Exchange> exchanges = mockEndpoint.getExchanges();
assertNotNull("listen result", exchanges);
assertFalse("listen result", exchanges.isEmpty());
LOG.debug("poll result: " + exchanges);
-
+
Exchange exchange = exchanges.get(0);
Message message = exchange.getIn();
assertNotNull("exchange message", message);
@@ -161,8 +161,8 @@ public class AS2ServerManagerIntegrationTest extends AbstractAS2TestSupport {
assertNotNull("Date value missing", request.getFirstHeader(AS2Header.DATE));
assertNotNull("Content length value missing", request.getFirstHeader(AS2Header.CONTENT_LENGTH));
assertTrue("Unexpected content type for message", request.getFirstHeader(AS2Header.CONTENT_TYPE).getValue().startsWith(AS2MediaType.APPLICATION_EDIFACT));
-
-
+
+
assertTrue("Request does not contain entity", request instanceof BasicHttpEntityEnclosingRequest);
HttpEntity entity = ((BasicHttpEntityEnclosingRequest)request).getEntity();
assertNotNull("Request does not contain entity", entity);
@@ -170,31 +170,31 @@ public class AS2ServerManagerIntegrationTest extends AbstractAS2TestSupport {
ApplicationEDIFACTEntity ediEntity = (ApplicationEDIFACTEntity) entity;
assertTrue("Unexpected content type for entity", ediEntity.getContentType().getValue().startsWith(AS2MediaType.APPLICATION_EDIFACT));
assertTrue("Entity not set as main body of request", ediEntity.isMainBody());
-
+
}
@Test
public void receiveMultipartSignedMessageTest() throws Exception {
setupSigningGenerator();
-
+
AS2ClientConnection clientConnection = new AS2ClientConnection(AS2_VERSION, USER_AGENT, CLIENT_FQDN, TARGET_HOST, TARGET_PORT);
AS2ClientManager clientManager = new AS2ClientManager(clientConnection);
-
+
clientManager.send(EDI_MESSAGE, REQUEST_URI, SUBJECT, FROM, AS2_NAME, AS2_NAME, AS2MessageStructure.SIGNED,
ContentType.create(AS2MediaType.APPLICATION_EDIFACT, AS2Charset.US_ASCII), null,
certList.toArray(new Certificate[0]), signingKP.getPrivate(), DISPOSITION_NOTIFICATION_TO,
SIGNED_RECEIPT_MIC_ALGORITHMS);
-
+
MockEndpoint mockEndpoint = getMockEndpoint("mock:as2RcvMsgs");
mockEndpoint.expectedMinimumMessageCount(1);
mockEndpoint.setResultWaitTime(TimeUnit.MILLISECONDS.convert(30, TimeUnit.SECONDS));
mockEndpoint.assertIsSatisfied();
-
+
final List<Exchange> exchanges = mockEndpoint.getExchanges();
assertNotNull("listen result", exchanges);
assertFalse("listen result", exchanges.isEmpty());
LOG.debug("poll result: " + exchanges);
-
+
Exchange exchange = exchanges.get(0);
Message message = exchange.getIn();
assertNotNull("exchange message", message);
@@ -206,7 +206,7 @@ public class AS2ServerManagerIntegrationTest extends AbstractAS2TestSupport {
assertEquals("Unexpected method value", METHOD, request.getRequestLine().getMethod());
assertEquals("Unexpected request URI value", REQUEST_URI, request.getRequestLine().getUri());
assertEquals("Unexpected HTTP version value", HttpVersion.HTTP_1_1, request.getRequestLine().getProtocolVersion());
-
+
assertEquals("Unexpected subject value", SUBJECT, request.getFirstHeader(AS2Header.SUBJECT).getValue());
assertEquals("Unexpected from value", FROM, request.getFirstHeader(AS2Header.FROM).getValue());
assertEquals("Unexpected AS2 version value", AS2_VERSION, request.getFirstHeader(AS2Header.AS2_VERSION).getValue());
@@ -218,7 +218,7 @@ public class AS2ServerManagerIntegrationTest extends AbstractAS2TestSupport {
assertNotNull("Date value missing", request.getFirstHeader(AS2Header.DATE));
assertNotNull("Content length value missing", request.getFirstHeader(AS2Header.CONTENT_LENGTH));
assertTrue("Unexpected content type for message", request.getFirstHeader(AS2Header.CONTENT_TYPE).getValue().startsWith(AS2MediaType.MULTIPART_SIGNED));
-
+
assertTrue("Request does not contain entity", request instanceof BasicHttpEntityEnclosingRequest);
HttpEntity entity = ((BasicHttpEntityEnclosingRequest)request).getEntity();
assertNotNull("Request does not contain entity", entity);
@@ -226,28 +226,28 @@ public class AS2ServerManagerIntegrationTest extends AbstractAS2TestSupport {
MultipartSignedEntity signedEntity = (MultipartSignedEntity)entity;
assertTrue("Entity not set as main body of request", signedEntity.isMainBody());
assertTrue("Request contains invalid number of mime parts", signedEntity.getPartCount() == 2);
-
+
// Validated first mime part.
assertTrue("First mime part incorrect type ", signedEntity.getPart(0) instanceof ApplicationEDIFACTEntity);
ApplicationEDIFACTEntity ediEntity = (ApplicationEDIFACTEntity) signedEntity.getPart(0);
assertTrue("Unexpected content type for first mime part", ediEntity.getContentType().getValue().startsWith(AS2MediaType.APPLICATION_EDIFACT));
assertFalse("First mime type set as main body of request", ediEntity.isMainBody());
-
+
// Validate second mime part.
assertTrue("Second mime part incorrect type ", signedEntity.getPart(1) instanceof ApplicationPkcs7SignatureEntity);
ApplicationPkcs7SignatureEntity signatureEntity = (ApplicationPkcs7SignatureEntity) signedEntity.getPart(1);
assertTrue("Unexpected content type for second mime part", signatureEntity.getContentType().getValue().startsWith(AS2MediaType.APPLICATION_PKCS7_SIGNATURE));
assertFalse("First mime type set as main body of request", signatureEntity.isMainBody());
-
+
// Validate Signature
assertTrue("Signature is invalid", signedEntity.isValid());
}
-
+
private void setupSigningGenerator() throws Exception {
Security.addProvider(new BouncyCastleProvider());
-
+
setupKeysAndCertificates();
-
+
// Create and populate certificate store.
JcaCertStore certs = new JcaCertStore(certList);
@@ -261,10 +261,10 @@ public class AS2ServerManagerIntegrationTest extends AbstractAS2TestSupport {
ASN1EncodableVector attributes = new ASN1EncodableVector();
attributes.add(new SMIMEEncryptionKeyPreferenceAttribute(new IssuerAndSerialNumber(new X500Name(signingCert.getIssuerDN().getName()), signingCert.getSerialNumber())));
attributes.add(new SMIMECapabilitiesAttribute(capabilities));
-
+
gen = SigningUtils.createSigningGenerator(certList.toArray(new X509Certificate[0]), signingKP.getPrivate());
gen.addCertificates(certs);
-
+
}
private void setupKeysAndCertificates() throws Exception {
@@ -279,7 +279,7 @@ public class AS2ServerManagerIntegrationTest extends AbstractAS2TestSupport {
issueKP = kpg.generateKeyPair();
issueCert = Utils.makeCertificate(
issueKP, issueDN, issueKP, issueDN);
-
+
//
// certificate we sign against
//
@@ -287,7 +287,7 @@ public class AS2ServerManagerIntegrationTest extends AbstractAS2TestSupport {
signingKP = kpg.generateKeyPair();
signingCert = Utils.makeCertificate(
signingKP, signingDN, issueKP, issueDN);
-
+
certList = new ArrayList<X509Certificate>();
certList.add(signingCert);
@@ -295,7 +295,7 @@ public class AS2ServerManagerIntegrationTest extends AbstractAS2TestSupport {
}
-
+
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
diff --git a/components/camel-as2/camel-as2-component/src/test/java/org/apache/camel/component/as2/Utils.java b/components/camel-as2/camel-as2-component/src/test/java/org/apache/camel/component/as2/Utils.java
index 1dcc0ff..9060b88 100644
--- a/components/camel-as2/camel-as2-component/src/test/java/org/apache/camel/component/as2/Utils.java
+++ b/components/camel-as2/camel-as2-component/src/test/java/org/apache/camel/component/as2/Utils.java
@@ -42,7 +42,7 @@ public final class Utils {
// certificate serial number seed.
//
static int serialNo = 1;
-
+
private Utils() {
}
--
To stop receiving notification emails like this one, please contact
zregvart@apache.org.