[ 
https://issues.apache.org/jira/browse/CAMEL-11257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16530878#comment-16530878
 ] 

ASF GitHub Bot commented on CAMEL-11257:
----------------------------------------

oscerd closed pull request #2404: [CAMEL-11257] Updated documentation fixed 
processing of asynchronous MDN
URL: https://github.com/apache/camel/pull/2404
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2AsynchronousMDNManager.java
 
b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2AsynchronousMDNManager.java
index 6c9f2e7667c..2d48227ce47 100644
--- 
a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2AsynchronousMDNManager.java
+++ 
b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2AsynchronousMDNManager.java
@@ -24,8 +24,6 @@
 import java.security.cert.Certificate;
 
 import 
org.apache.camel.component.as2.api.entity.DispositionNotificationMultipartReportEntity;
-import org.apache.camel.component.as2.api.entity.EntityParser;
-import org.apache.camel.component.as2.api.io.AS2BHttpClientConnection;
 import org.apache.camel.component.as2.api.protocol.RequestAsynchronousMDN;
 import org.apache.camel.component.as2.api.util.EntityUtils;
 import org.apache.http.HttpException;
@@ -82,7 +80,13 @@
      */
     public static final String RECIPIENT_ADDRESS = CAMEL_AS2_ASYNC_MDN_PREFIX 
+ "recipient-address";
 
+    /**
+     * The HTTP Context Attribute containing an asynchronous MDN receipt.
+     */
+    public static final String ASYNCHRONOUS_MDN = CAMEL_AS2_ASYNC_MDN_PREFIX + 
"asynchronous-mdn";
+
     private HttpProcessor httpProcessor;
+    
     @SuppressWarnings("unused")
     private Certificate[] signingCertificateChain;
     @SuppressWarnings("unused")
@@ -120,7 +124,7 @@ public HttpCoreContext 
send(DispositionNotificationMultipartReportEntity mdn,
         
         String requestUri = buildRequestURI(uri);
         
-        AS2BHttpClientConnection httpConnection = new 
AS2BHttpClientConnection(8 * 1024);
+        DefaultBHttpClientConnection httpConnection = new 
DefaultBHttpClientConnection(8 * 1024);
         
         try {
             
@@ -145,7 +149,6 @@ public HttpCoreContext 
send(DispositionNotificationMultipartReportEntity mdn,
             try {
                 httpContext.setAttribute(AS2_CONNECTION, httpConnection);
                 response = send(httpConnection, request, httpContext);
-                EntityParser.parseAS2MessageEntity(response);
             } catch (IOException e) {
                 throw new HttpException("Failed to send http request message", 
e);
             }
@@ -159,7 +162,7 @@ public HttpCoreContext 
send(DispositionNotificationMultipartReportEntity mdn,
                 httpConnection.flush();
                 httpConnection.close();
             } catch (IOException e) {
-                throw new HttpException("Failed to flush and close 
connection", e);
+                // Ignore.
             }
         }
     }
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 e9f340dd35d..ae2b553e3b0 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
@@ -24,19 +24,20 @@
 import java.security.PrivateKey;
 import java.security.cert.Certificate;
 
+import 
org.apache.camel.component.as2.api.entity.DispositionNotificationMultipartReportEntity;
 import org.apache.camel.component.as2.api.io.AS2BHttpServerConnection;
 import org.apache.camel.component.as2.api.protocol.ResponseMDN;
 import org.apache.http.ConnectionClosedException;
 import org.apache.http.HttpException;
 import org.apache.http.HttpInetConnection;
-import org.apache.http.HttpResponseInterceptor;
 import org.apache.http.HttpServerConnection;
 import org.apache.http.protocol.BasicHttpContext;
 import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.HttpCoreContext;
 import org.apache.http.protocol.HttpProcessor;
+import org.apache.http.protocol.HttpProcessorBuilder;
 import org.apache.http.protocol.HttpRequestHandler;
 import org.apache.http.protocol.HttpService;
-import org.apache.http.protocol.ImmutableHttpProcessor;
 import org.apache.http.protocol.ResponseConnControl;
 import org.apache.http.protocol.ResponseContent;
 import org.apache.http.protocol.ResponseDate;
@@ -53,7 +54,7 @@
     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 {
+    class RequestListenerThread extends Thread {
 
         private final ServerSocket serversocket;
         private final HttpService httpService;
@@ -64,20 +65,14 @@ public RequestListenerThread(String as2Version, String 
originServer, String serv
             serversocket = new ServerSocket(port);
 
             // Set up HTTP protocol processor for incoming connections
-            final HttpProcessor inhttpproc = new ImmutableHttpProcessor(new 
HttpResponseInterceptor[] {
-            new ResponseContent(true),
-            new ResponseServer(originServer),
-            new ResponseDate(),
-            new ResponseConnControl(),
-            new ResponseMDN(as2Version, serverFqdn, signingCertificateChain, 
signingPrivateKey)
-            });
+            final HttpProcessor inhttpproc = initProtocolProcessor(as2Version, 
originServer, serverFqdn, port, signingCertificateChain, signingPrivateKey);
 
             reqistry = new UriHttpRequestHandlerMapper();
 
             // Set up the HTTP service
             httpService = new HttpService(inhttpproc, reqistry);
         }
-
+        
         @Override
         public void run() {
             LOG.info("Listening on port " + this.serversocket.getLocalPort());
@@ -116,7 +111,7 @@ void unregisterHandler(String requestUri) {
 
     }
 
-    static class RequestHandlerThread extends Thread {
+    class RequestHandlerThread extends Thread {
         private HttpService httpService;
         private HttpServerConnection serverConnection;
 
@@ -140,8 +135,19 @@ public void run() {
                 while (!Thread.interrupted()) {
 
                     this.httpService.handleRequest(this.serverConnection, 
context);
-                    
+
                     // Send asynchronous MDN if any.
+                    HttpCoreContext coreContext = 
HttpCoreContext.adapt(context);
+                    String recipientAddress = 
coreContext.getAttribute(AS2AsynchronousMDNManager.RECIPIENT_ADDRESS,
+                            String.class);
+                    if (recipientAddress != null) {
+                        DispositionNotificationMultipartReportEntity 
multipartReportEntity = coreContext.getAttribute(
+                                AS2AsynchronousMDNManager.ASYNCHRONOUS_MDN,
+                                
DispositionNotificationMultipartReportEntity.class);
+                        AS2AsynchronousMDNManager asynchronousMDNManager = new 
AS2AsynchronousMDNManager(as2Version,
+                                originServer, serverFqdn, 
signingCertificateChain, signingPrivateKey);
+                        asynchronousMDNManager.send(multipartReportEntity, 
recipientAddress);
+                    }
 
                 }
             } catch (final ConnectionClosedException ex) {
@@ -216,4 +222,15 @@ public void stopListening(String requestUri) {
         }
     }
 
+    protected HttpProcessor initProtocolProcessor(String as2Version,
+                                                  String originServer,
+                                                  String serverFqdn,
+                                                  int port,
+                                                  Certificate[] 
signingCertificateChain,
+                                                  PrivateKey 
signingPrivateKey) {
+        return HttpProcessorBuilder.create().add(new 
ResponseContent(true)).add(new ResponseServer(originServer))
+                .add(new ResponseDate()).add(new ResponseConnControl())
+                .add(new ResponseMDN(as2Version, serverFqdn, 
signingCertificateChain, signingPrivateKey)).build();
+    }
+
 }
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 3beec3b76f7..98a72fa0400 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
@@ -20,6 +20,7 @@
 import java.security.PrivateKey;
 import java.security.cert.Certificate;
 
+import org.apache.camel.component.as2.api.AS2AsynchronousMDNManager;
 import org.apache.camel.component.as2.api.AS2Charset;
 import org.apache.camel.component.as2.api.AS2Constants;
 import org.apache.camel.component.as2.api.AS2Header;
@@ -105,7 +106,10 @@ public void process(HttpResponse response, HttpContext 
context) throws HttpExcep
         String receiptAddress = HttpMessageUtils.getHeaderValue(request, 
AS2Header.RECEIPT_DELIVERY_OPTION);
         if (receiptAddress != null) {
             // Asynchronous Delivery
-            // TODO Implement
+
+            
coreContext.setAttribute(AS2AsynchronousMDNManager.RECIPIENT_ADDRESS, 
receiptAddress);
+            
coreContext.setAttribute(AS2AsynchronousMDNManager.ASYNCHRONOUS_MDN, 
multipartReportEntity);
+            
         } else {
             // Synchronous Delivery
 
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 60d90812c10..9d84709770f 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
@@ -433,7 +433,7 @@ public void mdnMessageTest() throws Exception {
     }
 
     @Test
-    public void synchronousMdnMessageTest() throws Exception {
+    public void asynchronousMdnMessageTest() throws Exception {
 
         AS2AsynchronousMDNManager mdnManager = new 
AS2AsynchronousMDNManager(AS2_VERSION, USER_AGENT, CLIENT_FQDN,
                 certList.toArray(new X509Certificate[0]), 
signingKP.getPrivate());
diff --git a/components/camel-as2/camel-as2-component/pom.xml 
b/components/camel-as2/camel-as2-component/pom.xml
index 47ad83e3937..7fe94b48655 100644
--- a/components/camel-as2/camel-as2-component/pom.xml
+++ b/components/camel-as2/camel-as2-component/pom.xml
@@ -90,6 +90,11 @@
       <artifactId>camel-test</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-jetty</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>
@@ -147,17 +152,17 @@
             <configuration>
               <apis>
                 <api>
-                    <apiName>send</apiName>
+                    <apiName>client</apiName>
                     
<proxyClass>org.apache.camel.component.as2.api.AS2ClientManager</proxyClass>
                     <fromJavadoc>
                       <excludeMethods>createSigningGenerator</excludeMethods>
                     </fromJavadoc>
                 </api>
                 <api>
-                    <apiName>listen</apiName>
+                    <apiName>server</apiName>
                     
<proxyClass>org.apache.camel.component.as2.api.AS2ServerManager</proxyClass>
                        <fromJavadoc>
-                         
<excludeMethods>stopListening|handleMDNResponse</excludeMethods>
+                      
<excludeMethods>stopListening|handleMDNResponse</excludeMethods>
                        </fromJavadoc>
                     <excludeConfigNames>handler</excludeConfigNames>
                 </api>
diff --git 
a/components/camel-as2/camel-as2-component/src/main/docs/as2-component.adoc 
b/components/camel-as2/camel-as2-component/src/main/docs/as2-component.adoc
index 572f5a5cbd5..8b897179439 100644
--- a/components/camel-as2/camel-as2-component/src/main/docs/as2-component.adoc
+++ b/components/camel-as2/camel-as2-component/src/main/docs/as2-component.adoc
@@ -3,7 +3,13 @@
 
 *Available as of Camel version 2.22*
 
-NOTE: This component is currently work in progress.
+The AS2 component provides transport of EDI messages using the HTTP transfer 
protocol
+as specified in https://tools.ietf.org/html/rfc4130[RFC4130]. 
+
+NOTE: This component is currently a work in progress. Expect URI options and 
path and query parameters to change in future versions of this component.
+
+Maven users will need to add the following dependency to their pom.xml
+for this component:
 
 [source,xml]
 ----
@@ -15,7 +21,7 @@ NOTE: This component is currently work in progress.
 </dependency>
 ----
 
-=== URI Options
+=== AS2 Options
 
 
 // component options: START
@@ -64,3 +70,135 @@ with the following path and query parameters:
 | *synchronous* (advanced) | Sets whether synchronous processing should be 
strictly used, or Camel is allowed to use asynchronous processing (if 
supported). | false | boolean
 |===
 // endpoint options: END
+
+=== URI format
+
+[source]
+----
+as2://apiName/methodName
+----
+
+apiName can be one of:
+
+* client
+* server
+
+=== Client Endpoints:
+
+Client endpoints use the endpoint prefix *`client`* followed by the name of a 
method
+and associated options described next. The endpoint URI MUST contain the 
prefix *`client`*.
+
+[source]
+----
+as2://client/method?[options]
+----
+
+Endpoint options that are not mandatory are denoted by *[]*. When there
+are no mandatory options for an endpoint, one of the set of *[]* options
+MUST be provided. Producer endpoints can also use a special
+option *`inBody`* that in turn should contain the name of the endpoint
+option whose value will be contained in the Camel Exchange In message.
+
+Any of the endpoint options can be provided in either the endpoint URI,
+or dynamically in a message header. The message header name must be of
+the format *`CamelAS2.<option>`*. Note that the *`inBody`* option
+overrides message header, i.e. the endpoint
+option *`inBody=option`* would override a *`CamelAS2.option`* header.
+
+If a value is not provided for the option *defaultRequest* either in the
+endpoint URI or in a message header, it will be assumed to be `null`.
+Note that the `null` value will only be used if other options do not
+satisfy matching endpoints.
+
+In case of AS2 API errors the endpoint will throw a
+RuntimeCamelException with a
+*org.apache.http.HttpException* derived exception
+cause.
+
+[width="100%",cols="10%,10%,70%",options="header"]
+|===
+|Method |Options |Result Body Type
+
+|send |ediMessage, requestUri, subject, from, as2From, as2To, 
as2MessageStructure, ediMessageContentType, ediMessageTransferEncoding, 
dispositionNotificationTo, signedReceiptMicAlgorithms 
|org.apache.http.protocol.HttpCoreContext
+|===
+
+URI Options for _client_
+
+
+[width="100%",cols="10%,90%",options="header"]
+|===
+|Name |Type
+
+|ediMessage |String
+
+|requestUri |String
+
+|subject |String
+
+|from |String
+
+|as2From |String
+
+|as2To |String
+
+|as2MessageStructure |org.apache.camel.component.as2.api.AS2MessageStructure
+
+|ediMessageContentType |String
+
+|ediMessageTransferEncoding |String
+
+|dispositionNotificationTo |String
+
+|signedReceiptMicAlgorithms |String[]
+|===
+
+
+=== Server Endpoints:
+
+Server endpoints use the endpoint prefix *`server`* followed by the name of a 
method
+and associated options described next. The endpoint URI MUST contain the 
prefix *`server`*.
+
+[source]
+----
+as2://server/method?[options]
+----
+
+Endpoint options that are not mandatory are denoted by *[]*. When there
+are no mandatory options for an endpoint, one of the set of *[]* options
+MUST be provided. Producer endpoints can also use a special
+option *`inBody`* that in turn should contain the name of the endpoint
+option whose value will be contained in the Camel Exchange In message.
+
+Any of the endpoint options can be provided in either the endpoint URI,
+or dynamically in a message header. The message header name must be of
+the format *`CamelAS2.<option>`*. Note that the *`inBody`* option
+overrides message header, i.e. the endpoint
+option *`inBody=option`* would override a *`CamelAS2.option`* header.
+
+If a value is not provided for the option *defaultRequest* either in the
+endpoint URI or in a message header, it will be assumed to be `null`.
+Note that the `null` value will only be used if other options do not
+satisfy matching endpoints.
+
+In case of AS2 API errors the endpoint will throw a
+RuntimeCamelException with a
+*org.apache.http.HttpException* derived exception
+cause.
+
+[width="100%",cols="10%,10%,70%",options="header"]
+|===
+|Method |Options |Result Body Type
+
+|listen |requestUriPattern |org.apache.http.protocol.HttpCoreContext
+|===
+
+URI Options for _server_
+
+
+[width="100%",cols="10%,90%",options="header"]
+|===
+|Name |Type
+
+|requestUriPattern |String
+|===
+
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 b03d0a5c4b4..5e72564c56a 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
@@ -97,10 +97,10 @@ protected String getThreadProfileName() {
     protected void afterConfigureProperties() {
         // create HTTP connection eagerly, a good way to validate configuration
         switch (apiName) {
-        case SEND:
+        case CLIENT:
             createAS2ClientConnection();
             break;
-        case LISTEN:
+        case SERVER:
             createAS2ServerConnection();
             break;
         default:
@@ -129,10 +129,10 @@ public String getName() {
 
     private void createApiProxy(ApiMethod method, Map<String, Object> args) {
         switch (apiName) {
-        case SEND:
+        case CLIENT:
             apiProxy = new AS2ClientManager(getAS2ClientConnection());
             break;
-        case LISTEN:
+        case SERVER:
             apiProxy = new AS2ServerManager(getAS2ServerConnection());
             break;
         default:
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 c2bae4e7e0b..df55e9215f3 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
@@ -28,7 +28,9 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.as2.api.AS2AsynchronousMDNManager;
 import org.apache.camel.component.as2.api.AS2Charset;
 import org.apache.camel.component.as2.api.AS2Constants;
 import org.apache.camel.component.as2.api.AS2Header;
@@ -38,6 +40,8 @@
 import org.apache.camel.component.as2.api.AS2ServerConnection;
 import org.apache.camel.component.as2.api.AS2ServerManager;
 import org.apache.camel.component.as2.api.AS2SignedDataGenerator;
+import org.apache.camel.component.as2.api.Util;
+import org.apache.camel.component.as2.api.entity.AS2DispositionModifier;
 import org.apache.camel.component.as2.api.entity.AS2DispositionType;
 import 
org.apache.camel.component.as2.api.entity.AS2MessageDispositionNotificationEntity;
 import org.apache.camel.component.as2.api.entity.ApplicationEDIEntity;
@@ -46,18 +50,26 @@
 import 
org.apache.camel.component.as2.api.entity.DispositionNotificationMultipartReportEntity;
 import org.apache.camel.component.as2.api.entity.MimeEntity;
 import org.apache.camel.component.as2.api.entity.MultipartSignedEntity;
+import org.apache.camel.component.as2.api.util.EntityUtils;
 import org.apache.camel.component.as2.api.util.HttpMessageUtils;
 import org.apache.camel.component.as2.api.util.MicUtils;
 import org.apache.camel.component.as2.api.util.MicUtils.ReceivedContentMic;
 import org.apache.camel.component.as2.internal.AS2ApiCollection;
 import org.apache.camel.component.as2.internal.AS2ClientManagerApiMethod;
+import org.apache.camel.http.common.HttpMessage;
+import org.apache.camel.test.AvailablePortFinder;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpEntityEnclosingRequest;
 import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
+import org.apache.http.HttpVersion;
 import org.apache.http.entity.ContentType;
+import org.apache.http.message.BasicHttpEntityEnclosingRequest;
+import org.apache.http.message.BasicHttpResponse;
 import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.HttpCoreContext;
+import org.apache.http.protocol.HttpDateGenerator;
 import org.apache.http.protocol.HttpRequestHandler;
 import org.bouncycastle.asn1.ASN1EncodableVector;
 import org.bouncycastle.asn1.cms.AttributeTable;
@@ -85,6 +97,7 @@
     private static final Logger LOG = 
LoggerFactory.getLogger(AS2ClientManagerIntegrationTest.class);
     private static final String PATH_PREFIX = 
AS2ApiCollection.getCollection().getApiName(AS2ClientManagerApiMethod.class).getName();
 
+    private static final String SERVER_FQDN = "server.example.com";
     private static final String ORIGIN_SERVER_NAME = 
"AS2ClientManagerIntegrationTest Server";
     private static final String AS2_VERSION = "1.1";
     private static final String REQUEST_URI = "/";
@@ -127,11 +140,18 @@
     private static final String EXPECTED_AS2_VERSION = AS2_VERSION;
     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 final String DISPOSITION_NOTIFICATION_OPTIONS = 
"signed-receipt-protocol=optional,pkcs7-signature; 
signed-receipt-micalg=optional,sha1";
+    private static final int PARTNER_TARGET_PORT = 8888;
+    private static final int MDN_TARGET_PORT = 
AvailablePortFinder.getNextAvailable(8889);
+    private static final String RECIPIENT_DELIVERY_ADDRESS = 
"http://localhost:"; + MDN_TARGET_PORT + "/handle-receipts";
+    private static final String REPORTING_UA = "Server Responding with MDN";
 
     private static AS2ServerConnection serverConnection;
     private static KeyPair serverSigningKP;
     private static List<X509Certificate> serverCertList;
 
+    private static final HttpDateGenerator DATE_GENERATOR = new 
HttpDateGenerator();
+
     private KeyPair issueKP;
     private X509Certificate issueCert;
 
@@ -224,7 +244,7 @@ public void plainMessageSendTest() throws Exception {
 
         HttpResponse response = result.getResponse();
         assertNotNull("Response", response);
-        assertEquals("Unexpected response type", AS2MimeType.MULTIPART_REPORT, 
HttpMessageUtils.getHeaderValue(response, AS2Header.CONTENT_TYPE));
+        assertTrue("Unexpected response type", 
HttpMessageUtils.getHeaderValue(response, 
AS2Header.CONTENT_TYPE).startsWith(AS2MimeType.MULTIPART_REPORT));
         assertEquals("Unexpected mime version", AS2Constants.MIME_VERSION, 
HttpMessageUtils.getHeaderValue(response, AS2Header.MIME_VERSION));
         assertEquals("Unexpected AS2 version", EXPECTED_AS2_VERSION, 
HttpMessageUtils.getHeaderValue(response, AS2Header.AS2_VERSION));
         assertEquals("Unexpected MDN subject", EXPECTED_MDN_SUBJECT, 
HttpMessageUtils.getHeaderValue(response, AS2Header.SUBJECT));
@@ -344,6 +364,50 @@ public void multipartSignedMessageTest() throws Exception {
         assertEquals("Received content MIC does not match computed", 
computedContentMic.getEncodedMessageDigest(), 
receivedContentMic.getEncodedMessageDigest());
     }
 
+    @Test
+    public void asyncMDNTest() throws Exception {
+        AS2AsynchronousMDNManager mdnManager = new 
AS2AsynchronousMDNManager(AS2_VERSION, ORIGIN_SERVER_NAME, SERVER_FQDN,
+                certList.toArray(new X509Certificate[0]), 
signingKP.getPrivate());
+
+        // Create plain edi request message to acknowledge
+        ApplicationEDIEntity ediEntity = 
EntityUtils.createEDIEntity(EDI_MESSAGE,
+                ContentType.create(AS2MediaType.APPLICATION_EDIFACT, 
AS2Charset.US_ASCII), null, false);
+        HttpEntityEnclosingRequest request = new 
BasicHttpEntityEnclosingRequest("POST", REQUEST_URI);
+        HttpMessageUtils.setHeaderValue(request, AS2Header.SUBJECT, SUBJECT);
+        String httpdate = DATE_GENERATOR.getCurrentDate();
+        HttpMessageUtils.setHeaderValue(request, AS2Header.DATE, httpdate);
+        HttpMessageUtils.setHeaderValue(request, AS2Header.AS2_TO, AS2_NAME);
+        HttpMessageUtils.setHeaderValue(request, AS2Header.AS2_FROM, AS2_NAME);
+        String originalMessageId = Util.createMessageId(SERVER_FQDN);
+        HttpMessageUtils.setHeaderValue(request, AS2Header.MESSAGE_ID, 
originalMessageId);
+        HttpMessageUtils.setHeaderValue(request, 
AS2Header.DISPOSITION_NOTIFICATION_OPTIONS,
+                DISPOSITION_NOTIFICATION_OPTIONS);
+        EntityUtils.setMessageEntity(request, ediEntity);
+
+        // Create response for MDN creation.
+        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 
200, "OK");
+        httpdate = DATE_GENERATOR.getCurrentDate();
+        response.setHeader(AS2Header.DATE, httpdate);
+        response.setHeader(AS2Header.SERVER, REPORTING_UA);
+
+        // Create a receipt for edi message
+        Map<String, String> extensionFields = new HashMap<String, String>();
+        extensionFields.put("Original-Recipient", "rfc822;" + AS2_NAME);
+        AS2DispositionModifier dispositionModifier = 
AS2DispositionModifier.createWarning("AS2 is cool!");
+        String[] failureFields = new String[] {"failure-field-1"};
+        String[] errorFields = new String[] {"error-field-1"};
+        String[] warningFields = new String[] {"warning-field-1"};
+        DispositionNotificationMultipartReportEntity mdn = new 
DispositionNotificationMultipartReportEntity(request,
+                response, 
DispositionMode.AUTOMATIC_ACTION_MDN_SENT_AUTOMATICALLY, 
AS2DispositionType.PROCESSED,
+                dispositionModifier, failureFields, errorFields, 
warningFields, extensionFields, null, "boundary",
+                true);
+
+        // Send MDN
+        @SuppressWarnings("unused")
+        HttpCoreContext httpContext = mdnManager.send(mdn, 
RECIPIENT_DELIVERY_ADDRESS);
+        
+    }
+    
     @BeforeClass
     public static void setupTest() throws Exception {
         setupServerKeysAndCertificates();
@@ -373,8 +437,17 @@ public void handle(HttpRequest request, HttpResponse 
response, HttpContext conte
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() {
+                Processor proc = new Processor() {
+                    public void process(org.apache.camel.Exchange exchange) 
throws Exception {
+                        HttpMessage message = 
exchange.getIn(HttpMessage.class);
+                        @SuppressWarnings("unused")
+                        String body = message.getBody(String.class);
+                    }
+                };
                 // test route for send
                 from("direct://SEND").to("as2://" + PATH_PREFIX + 
"/send?inBody=ediMessage");
+                
+                from("jetty:http://localhost:"; + MDN_TARGET_PORT + 
"/handle-receipts").process(proc);
 
             }
         };
@@ -411,7 +484,7 @@ private static void setupServerKeysAndCertificates() throws 
Exception {
 
     private static void receiveTestMessages() throws IOException {
         serverConnection = new AS2ServerConnection(AS2_VERSION, 
ORIGIN_SERVER_NAME,
-                "server.example.com", 8888, serverCertList.toArray(new 
Certificate[0]), serverSigningKP.getPrivate());
+                SERVER_FQDN, PARTNER_TARGET_PORT, serverCertList.toArray(new 
Certificate[0]), serverSigningKP.getPrivate());
         serverConnection.listen("/", new RequestHandler());
     }
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Provide AS2 component to support Business Data Interchange Using HTTP
> ---------------------------------------------------------------------
>
>                 Key: CAMEL-11257
>                 URL: https://issues.apache.org/jira/browse/CAMEL-11257
>             Project: Camel
>          Issue Type: New Feature
>    Affects Versions: 2.19.1
>            Reporter: William Collins
>            Assignee: William Collins
>            Priority: Major
>             Fix For: 2.22.0
>
>
> AS2 Camel component should provide MIME-Based Secure Peer-to-Peer Business 
> Data Interchange Using HTTP as per RFC4120



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to