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

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

oscerd closed pull request #2526: [CAMEL-12605] Updated client integration tests
URL: https://github.com/apache/camel/pull/2526
 
 
   

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/AS2ClientManager.java
 
b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ClientManager.java
index c8eb044acb1..c99f3413c74 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
@@ -194,9 +194,9 @@ public AS2ClientManager(AS2ClientConnection 
as2ClientConnection) {
      * @param signingPrivateKey - the private key used to sign EDI message
      * @param dispositionNotificationTo - an RFC2822 address to request a 
receipt or <code>null</code> if no receipt requested
      * @param signedReceiptMicAlgorithms - the senders list of signing 
algorithms for signing receipt, in preferred order,  or <code>null</code> if 
requesting an unsigned receipt.
-     * @param encryptionAlgorithm - the algorithm used to encrypt the message 
or <code>null</code> if sending EDI message unencrypted
-     * @param encryptionCertificateChain - the chain of certificates used to 
encrypt the message or <code>null</code> if sending EDI message unencrypted
-     * @param encryptionPrivateKey - the private key used to encrypt EDI 
message
+     * @param encryptingAlgorithm - the algorithm used to encrypt the message 
or <code>null</code> if sending EDI message unencrypted
+     * @param encryptingCertificateChain - the chain of certificates used to 
encrypt the message or <code>null</code> if sending EDI message unencrypted
+     * @param encryptingPrivateKey - the private key used to encrypt EDI 
message
      * @return {@link HttpCoreContext} containing request and response used to 
send EDI message
      * @throws HttpException when things go wrong.
      */
@@ -213,9 +213,9 @@ public HttpCoreContext send(String ediMessage,
                                 PrivateKey signingPrivateKey,
                                 String dispositionNotificationTo,
                                 String[] signedReceiptMicAlgorithms,
-                                AS2EncryptionAlgorithm encryptionAlgorithm,
-                                Certificate[] encryptionCertificateChain,
-                                PrivateKey encryptionPrivateKey)
+                                AS2EncryptionAlgorithm encryptingAlgorithm,
+                                Certificate[] encryptingCertificateChain,
+                                PrivateKey encryptingPrivateKey)
             throws HttpException {
 
         Args.notNull(ediMessage, "EDI Message");
@@ -237,9 +237,9 @@ public HttpCoreContext send(String ediMessage,
         httpContext.setAttribute(AS2ClientManager.SIGNING_PRIVATE_KEY, 
signingPrivateKey);
         httpContext.setAttribute(AS2ClientManager.DISPOSITION_NOTIFICATION_TO, 
dispositionNotificationTo);
         
httpContext.setAttribute(AS2ClientManager.SIGNED_RECEIPT_MIC_ALGORITHMS, 
signedReceiptMicAlgorithms);
-        httpContext.setAttribute(AS2ClientManager.ENCRYPTING_ALGORITHM, 
encryptionAlgorithm);
-        
httpContext.setAttribute(AS2ClientManager.ENCRYPTING_CERTIFICATE_CHAIN, 
encryptionCertificateChain);
-        httpContext.setAttribute(AS2ClientManager.ENCRYPTING_PRIVATE_KEY, 
encryptionPrivateKey);
+        httpContext.setAttribute(AS2ClientManager.ENCRYPTING_ALGORITHM, 
encryptingAlgorithm);
+        
httpContext.setAttribute(AS2ClientManager.ENCRYPTING_CERTIFICATE_CHAIN, 
encryptingCertificateChain);
+        httpContext.setAttribute(AS2ClientManager.ENCRYPTING_PRIVATE_KEY, 
encryptingPrivateKey);
 
         BasicHttpEntityEnclosingRequest request = new 
BasicHttpEntityEnclosingRequest("POST", requestUri);
         httpContext.setAttribute(HTTP_REQUEST, request);
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 b2c3f46f1d7..60cee0682d0 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
@@ -40,11 +40,13 @@
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpException;
 import org.apache.http.HttpMessage;
+import org.apache.http.NameValuePair;
 import org.apache.http.ParseException;
 import org.apache.http.entity.ContentType;
 import org.apache.http.impl.io.AbstractMessageParser;
 import org.apache.http.impl.io.HttpTransportMetricsImpl;
 import org.apache.http.message.BasicLineParser;
+import org.apache.http.message.BasicNameValuePair;
 import org.apache.http.message.LineParser;
 import org.apache.http.message.ParserCursor;
 import org.apache.http.util.Args;
@@ -276,12 +278,18 @@ public static void parseMultipartSignedEntity(HttpMessage 
message)
             inbuffer.bind(entity.getContent());
 
             // Get Boundary Value
-            String boundary = 
HttpMessageUtils.getBoundaryParameterValue(message, AS2Header.CONTENT_TYPE);
+            String boundary = HttpMessageUtils.getParameterValue(message, 
AS2Header.CONTENT_TYPE, "boundary");
             if (boundary == null) {
-                throw new HttpException("Failed to retrive boundary value");
+                throw new HttpException("Failed to retrieve 'boundary' 
parameter from content type header");
+            }
+            
+            // Get Micalg Value
+            String micalg = HttpMessageUtils.getParameterValue(message, 
AS2Header.CONTENT_TYPE, "micalg");
+            if (micalg == null) {
+                throw new HttpException("Failed to retrieve 'micalg' parameter 
from content type header");
             }
 
-            multipartSignedEntity = parseMultipartSignedEntityBody(inbuffer, 
boundary, charsetName, contentTransferEncoding);
+            multipartSignedEntity = parseMultipartSignedEntityBody(inbuffer, 
boundary, micalg, charsetName, contentTransferEncoding);
             multipartSignedEntity.setMainBody(true);
 
             EntityUtils.setMessageEntity(message, multipartSignedEntity);
@@ -370,7 +378,7 @@ public static void 
parseMessageDispositionNotificationReportEntity(HttpMessage m
             inbuffer.bind(entity.getContent());
 
             // Get Boundary Value
-            String boundary = 
HttpMessageUtils.getBoundaryParameterValue(message, AS2Header.CONTENT_TYPE);
+            String boundary = HttpMessageUtils.getParameterValue(message, 
AS2Header.CONTENT_TYPE, "boundary");
             if (boundary == null) {
                 throw new HttpException("Failed to retrive boundary value");
             }
@@ -420,6 +428,7 @@ public static void parseAS2MessageEntity(HttpMessage 
message) throws HttpExcepti
 
     public static MultipartSignedEntity 
parseMultipartSignedEntityBody(AS2SessionInputBuffer inbuffer,
                                                                        String 
boundary,
+                                                                       String 
micalg,
                                                                        String 
charsetName,
                                                                        String 
contentTransferEncoding)
             throws ParseException {
@@ -514,7 +523,11 @@ public static MultipartSignedEntity 
parseMultipartSignedEntityBody(AS2SessionInp
             //
             // End Signature Body Part
 
-            ContentType contentType = 
ContentType.create(AS2MimeType.MULTIPART_SIGNED, charset);
+            NameValuePair[] parameters = new NameValuePair[] {
+                    new BasicNameValuePair("protocol", 
AS2MimeType.APPLICATION_PKCS7_SIGNATURE),
+                    new BasicNameValuePair("boundary", boundary), new 
BasicNameValuePair("micalg", micalg),
+                    new BasicNameValuePair("charset", charsetName)};
+            ContentType contentType = 
ContentType.create(AS2MimeType.MULTIPART_SIGNED, parameters);
             multipartSignedEntity.setContentType(contentType);
             
multipartSignedEntity.setContentTransferEncoding(contentTransferEncoding);
             return multipartSignedEntity;
@@ -731,9 +744,10 @@ public static MimeEntity 
parseEntityBody(AS2SessionInputBuffer inbuffer,
                 entity = parseEDIEntityBody(inbuffer, boundary, 
entityContentType, contentTransferEncoding);
                 break;
             case AS2MimeType.MULTIPART_SIGNED:
-                String multipartSignedBoundary = 
AS2HeaderUtils.getBoundaryParameterValue(headers,
-                        AS2Header.CONTENT_TYPE);
-                entity = parseMultipartSignedEntityBody(inbuffer, 
multipartSignedBoundary, charset.name(),
+                String multipartSignedBoundary = 
AS2HeaderUtils.getParameterValue(headers,
+                        AS2Header.CONTENT_TYPE, "boundary");
+                String micalg = AS2HeaderUtils.getParameterValue(headers, 
AS2Header.CONTENT_TYPE, "micalg");
+                entity = parseMultipartSignedEntityBody(inbuffer, 
multipartSignedBoundary, micalg, charset.name(),
                         contentTransferEncoding);
                 skipToBoundary(inbuffer, boundary);
                 break;
@@ -742,8 +756,8 @@ public static MimeEntity 
parseEntityBody(AS2SessionInputBuffer inbuffer,
                         contentTransferEncoding);
                 break;
             case AS2MimeType.MULTIPART_REPORT:
-                String multipartReportBoundary = 
AS2HeaderUtils.getBoundaryParameterValue(headers,
-                        AS2Header.CONTENT_TYPE);
+                String multipartReportBoundary = 
AS2HeaderUtils.getParameterValue(headers,
+                        AS2Header.CONTENT_TYPE, "boundary");
                 entity = parseMultipartReportEntityBody(inbuffer, 
multipartReportBoundary, charset.name(),
                         contentTransferEncoding);
                 skipToBoundary(inbuffer, boundary);
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 213183b5fd1..db589d566e8 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
@@ -145,14 +145,14 @@ public static Parameter parseParameter(final 
CharArrayBuffer buffer, final Parse
         return new Parameter(name, importance, values.toArray(new 
String[values.size()]));
     }
 
-    public static String getBoundaryParameterValue(Header[] headers, String 
headerName) {
+    public static String getParameterValue(Header[] headers, String 
headerName, String parameterName) {
         Args.notNull(headers, "headers");
         Args.notNull(headerName, "headerName");
         for (Header header : headers) {
             if (header.getName().equalsIgnoreCase(headerName)) {
                 for (HeaderElement headerElement : header.getElements()) {
                     for (NameValuePair nameValuePair : 
headerElement.getParameters()) {
-                        if 
(nameValuePair.getName().equalsIgnoreCase("boundary")) {
+                        if 
(nameValuePair.getName().equalsIgnoreCase(parameterName)) {
                             return nameValuePair.getValue();
                         }
                     }
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 1563c7ac8f0..0bf49629032 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
@@ -96,16 +96,17 @@ public static String 
parseBodyPartContent(SessionInputBuffer inBuffer, String bo
         }
     }
 
-    public static String getBoundaryParameterValue(HttpMessage message, String 
headerName) {
+    public static String getParameterValue(HttpMessage message, String 
headerName, String parameterName) {
         Args.notNull(message, "message");
         Args.notNull(headerName, "headerName");
+        Args.notNull(parameterName, "parameterName");
         Header header = message.getFirstHeader(headerName);
         if (header == null) {
             return null;
         }
         for (HeaderElement headerElement : header.getElements()) {
             for (NameValuePair nameValuePair : headerElement.getParameters()) {
-                if (nameValuePair.getName().equalsIgnoreCase("boundary")) {
+                if (nameValuePair.getName().equalsIgnoreCase(parameterName)) {
                     return nameValuePair.getValue();
                 }
             }
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 6a6705b7595..d4a4e2a6889 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
@@ -84,7 +84,7 @@ with the following path and query parameters:
 | *dispositionNotificationTo* (common) | The value of the 
Disposition-Notification-To header. Assigning a value to this parameter 
requests a message disposition notification (MDN) for the AS2 message. |  | 
String
 | *ediMessageTransferEncoding* (common) | The transfer encoding of EDI 
message. |  | String
 | *ediMessageType* (common) | The content type of EDI message. One of 
application/edifact, application/edi-x12, application/edi-consent |  | 
ContentType
-| *encryptingAlgorithmName* (common) | The name of algorithm used to encrypt 
EDI message. |  | String
+| *encryptingAlgorithm* (common) | The algorithm used to encrypt EDI message. 
|  | AS2EncryptionAlgorithm
 | *encryptingCertificateChain* (common) | The chain of certificates used to 
encrypt EDI message. |  | Certificate[]
 | *encryptingPrivateKey* (common) | The key used to encrypt the EDI message. | 
 | PrivateKey
 | *from* (common) | The value of the From header of AS2 message. |  | String
@@ -128,7 +128,7 @@ The component supports 28 options, which are listed below.
 | *camel.component.as2.configuration.disposition-notification-to* | The value 
of the Disposition-Notification-To header. Assigning a value to this parameter 
requests a message disposition notification (MDN) for the AS2 message. |  | 
String
 | *camel.component.as2.configuration.edi-message-transfer-encoding* | The 
transfer encoding of EDI message. |  | String
 | *camel.component.as2.configuration.edi-message-type* | The content type of 
EDI message. One of application/edifact, application/edi-x12, 
application/edi-consent |  | ContentType
-| *camel.component.as2.configuration.encrypting-algorithm-name* | The name of 
algorithm used to encrypt EDI message. |  | String
+| *camel.component.as2.configuration.encrypting-algorithm* | The algorithm 
used to encrypt EDI message. |  | AS2EncryptionAlgorithm
 | *camel.component.as2.configuration.encrypting-certificate-chain* | The chain 
of certificates used to encrypt EDI message. |  | Certificate[]
 | *camel.component.as2.configuration.encrypting-private-key* | The key used to 
encrypt the EDI message. |  | PrivateKey
 | *camel.component.as2.configuration.from* | The value of the From header of 
AS2 message. |  | String
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 b819c5a2041..73bc0fe086a 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
@@ -20,6 +20,7 @@
 import java.security.cert.Certificate;
 
 import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.component.as2.api.AS2EncryptionAlgorithm;
 import org.apache.camel.component.as2.api.AS2MessageStructure;
 import org.apache.camel.component.as2.internal.AS2ApiName;
 import org.apache.camel.spi.Metadata;
@@ -106,7 +107,7 @@
     private String[] signedReceiptMicAlgorithms;
 
     @UriParam
-    private String encryptingAlgorithmName;
+    private AS2EncryptionAlgorithm encryptingAlgorithm;
 
     @UriParam
     private Certificate[] encryptingCertificateChain;
@@ -413,15 +414,15 @@ public void setSignedReceiptMicAlgorithms(String[] 
signedReceiptMicAlgorithms) {
         this.signedReceiptMicAlgorithms = signedReceiptMicAlgorithms;
     }
 
-    public String getEncryptingingAlgorithmName() {
-        return signingAlgorithmName;
+    public AS2EncryptionAlgorithm getEncryptingingAlgorithm() {
+        return encryptingAlgorithm;
     }
 
     /**
-     * The name of algorithm used to encrypt EDI message.
+     * The algorithm used to encrypt EDI message.
      */
-    public void setEncryptingAlgorithmName(String signingAlgorithmName) {
-        this.encryptingAlgorithmName = signingAlgorithmName;
+    public void setEncryptingAlgorithm(AS2EncryptionAlgorithm 
encryptingAlgorithm) {
+        this.encryptingAlgorithm = encryptingAlgorithm;
     }
 
     public Certificate[] getEncryptingCertificateChain() {
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 75b1e102d90..58ad2757ace 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
@@ -32,6 +32,7 @@
 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.AS2EncryptionAlgorithm;
 import org.apache.camel.component.as2.api.AS2Header;
 import org.apache.camel.component.as2.api.AS2MediaType;
 import org.apache.camel.component.as2.api.AS2MessageStructure;
@@ -43,6 +44,7 @@
 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;
+import org.apache.camel.component.as2.api.entity.ApplicationPkcs7MimeEntity;
 import 
org.apache.camel.component.as2.api.entity.ApplicationPkcs7SignatureEntity;
 import org.apache.camel.component.as2.api.entity.DispositionMode;
 import 
org.apache.camel.component.as2.api.entity.DispositionNotificationMultipartReportEntity;
@@ -227,6 +229,12 @@ public void plainMessageSendTest() throws Exception {
         headers.put("CamelAS2.dispositionNotificationTo", "mr...@example.com");
         // parameter type is String[]
         headers.put("CamelAS2.signedReceiptMicAlgorithms", null);
+        // parameter type is 
org.apache.camel.component.as2.api.AS2EncryptionAlgorithm
+        headers.put("CamelAS2.encryptingAlgorithm", null);
+        // parameter type is java.security.cert.Certificate[]
+        headers.put("CamelAS2.encryptingCertificateChain", null);
+        // parameter type is java.security.PrivateKey
+        headers.put("CamelAS2.encryptingPrivateKey", null);
 
         final org.apache.http.protocol.HttpCoreContext result = 
requestBodyAndHeaders("direct://SEND", EDI_MESSAGE, headers);
 
@@ -274,6 +282,88 @@ public void plainMessageSendTest() throws Exception {
         
     }
 
+    @Test
+    public void envelopedMessageSendTest() throws Exception {
+        final Map<String, Object> headers = new HashMap<>();
+        // parameter type is String
+        headers.put("CamelAS2.requestUri", REQUEST_URI);
+        // parameter type is String
+        headers.put("CamelAS2.subject", SUBJECT);
+        // parameter type is String
+        headers.put("CamelAS2.from", FROM);
+        // parameter type is String
+        headers.put("CamelAS2.as2From", AS2_NAME);
+        // parameter type is String
+        headers.put("CamelAS2.as2To", AS2_NAME);
+        // parameter type is 
org.apache.camel.component.as2.api.AS2MessageStructure
+        headers.put("CamelAS2.as2MessageStructure", 
AS2MessageStructure.ENCRYPTED);
+        // parameter type is org.apache.http.entity.ContentType
+        headers.put("CamelAS2.ediMessageContentType", 
ContentType.create(AS2MediaType.APPLICATION_EDIFACT, AS2Charset.US_ASCII));
+        // parameter type is String
+        headers.put("CamelAS2.ediMessageTransferEncoding", 
EDI_MESSAGE_CONTENT_TRANSFER_ENCODING);
+        // parameter type is java.security.cert.Certificate[]
+        headers.put("CamelAS2.signingCertificateChain", null);
+        // parameter type is java.security.PrivateKey
+        headers.put("CamelAS2.signingPrivateKey", null);
+        // parameter type is String
+        headers.put("CamelAS2.dispositionNotificationTo", "mr...@example.com");
+        // parameter type is String[]
+        headers.put("CamelAS2.signedReceiptMicAlgorithms", null);
+        // parameter type is 
org.apache.camel.component.as2.api.AS2EncryptionAlgorithm
+        headers.put("CamelAS2.encryptingAlgorithm", 
AS2EncryptionAlgorithm.AES128_CBC);
+        // parameter type is java.security.cert.Certificate[]
+        headers.put("CamelAS2.encryptingCertificateChain", certList);
+        // parameter type is java.security.PrivateKey
+        headers.put("CamelAS2.encryptingPrivateKey", signingKP.getPrivate());
+
+        final org.apache.http.protocol.HttpCoreContext result = 
requestBodyAndHeaders("direct://SEND", EDI_MESSAGE, headers);
+
+        assertNotNull("send result", result);
+        LOG.debug("send: " + result);
+        HttpRequest request = result.getRequest();
+        assertNotNull("Request", request);
+        assertTrue("Request does not contain body", request instanceof 
HttpEntityEnclosingRequest);
+        HttpEntity entity = ((HttpEntityEnclosingRequest)request).getEntity();
+        assertNotNull("Request body", entity);
+        assertTrue("Request body does not contain ApplicationPkcs7Mime 
entity", entity instanceof ApplicationPkcs7MimeEntity);
+        MimeEntity envelopeEntity = 
((ApplicationPkcs7MimeEntity)entity).getEncryptedEntity(signingKP.getPrivate());
+        assertTrue("Enveloped entity is not an EDI entity", envelopeEntity 
instanceof ApplicationEDIEntity);
+        String ediMessage = 
((ApplicationEDIEntity)envelopeEntity).getEdiMessage();
+        assertEquals("EDI message is different", 
EDI_MESSAGE.replaceAll("[\n\r]", ""), ediMessage.replaceAll("[\n\r]", ""));
+
+        HttpResponse response = result.getResponse();
+        assertNotNull("Response", response);
+        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));
+        assertEquals("Unexpected MDN from", MDN_FROM, 
HttpMessageUtils.getHeaderValue(response, AS2Header.FROM));
+        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);
+        DispositionNotificationMultipartReportEntity reportEntity = 
(DispositionNotificationMultipartReportEntity)responseEntity;
+        assertEquals("Unexpected number of body parts in report", 2, 
reportEntity.getPartCount());
+        MimeEntity firstPart = reportEntity.getPart(0);
+        assertEquals("Unexpected content type in first body part of report", 
ContentType.create(AS2MimeType.TEXT_PLAIN, AS2Charset.US_ASCII).toString(), 
firstPart.getContentTypeValue());
+        MimeEntity secondPart = reportEntity.getPart(1);
+        assertEquals("Unexpected content type in second body part of report",
+                
ContentType.create(AS2MimeType.MESSAGE_DISPOSITION_NOTIFICATION, 
AS2Charset.US_ASCII).toString(),
+                secondPart.getContentTypeValue());
+        
+        assertTrue("", secondPart instanceof 
AS2MessageDispositionNotificationEntity);
+        AS2MessageDispositionNotificationEntity 
messageDispositionNotificationEntity = 
(AS2MessageDispositionNotificationEntity) secondPart;
+        assertEquals("Unexpected value for reporting UA", ORIGIN_SERVER_NAME, 
messageDispositionNotificationEntity.getReportingUA());
+        assertEquals("Unexpected value for final recipient", AS2_NAME, 
messageDispositionNotificationEntity.getFinalRecipient());
+        assertEquals("Unexpected value for original message ID", 
HttpMessageUtils.getHeaderValue(request, AS2Header.MESSAGE_ID), 
messageDispositionNotificationEntity.getOriginalMessageId());
+        assertEquals("Unexpected value for disposition mode", 
DispositionMode.AUTOMATIC_ACTION_MDN_SENT_AUTOMATICALLY, 
messageDispositionNotificationEntity.getDispositionMode());
+        assertEquals("Unexpected value for disposition type", 
AS2DispositionType.PROCESSED, 
messageDispositionNotificationEntity.getDispositionType());
+        
+    }
+
     @Test
     public void multipartSignedMessageTest() throws Exception {
         final Map<String, Object> headers = new HashMap<>();
@@ -301,6 +391,12 @@ public void multipartSignedMessageTest() throws Exception {
         headers.put("CamelAS2.dispositionNotificationTo", "mr...@example.com");
         // parameter type is String[]
         headers.put("CamelAS2.signedReceiptMicAlgorithms", 
SIGNED_RECEIPT_MIC_ALGORITHMS);
+        // parameter type is 
org.apache.camel.component.as2.api.AS2EncryptionAlgorithm
+        headers.put("CamelAS2.encryptingAlgorithm", null);
+        // parameter type is java.security.cert.Certificate[]
+        headers.put("CamelAS2.encryptingCertificateChain", null);
+        // parameter type is java.security.PrivateKey
+        headers.put("CamelAS2.encryptingPrivateKey", null);
 
         final org.apache.http.protocol.HttpCoreContext result = 
requestBodyAndHeaders("direct://SEND", EDI_MESSAGE, headers);
 
diff --git 
a/platforms/spring-boot/components-starter/camel-as2-starter/src/main/java/org/apache/camel/component/as2/springboot/AS2ComponentConfiguration.java
 
b/platforms/spring-boot/components-starter/camel-as2-starter/src/main/java/org/apache/camel/component/as2/springboot/AS2ComponentConfiguration.java
index 27ddc9ba898..0f65e1bc7b3 100644
--- 
a/platforms/spring-boot/components-starter/camel-as2-starter/src/main/java/org/apache/camel/component/as2/springboot/AS2ComponentConfiguration.java
+++ 
b/platforms/spring-boot/components-starter/camel-as2-starter/src/main/java/org/apache/camel/component/as2/springboot/AS2ComponentConfiguration.java
@@ -19,6 +19,7 @@
 import java.security.PrivateKey;
 import java.security.cert.Certificate;
 import javax.annotation.Generated;
+import org.apache.camel.component.as2.api.AS2EncryptionAlgorithm;
 import org.apache.camel.component.as2.api.AS2MessageStructure;
 import org.apache.camel.component.as2.internal.AS2ApiName;
 import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon;
@@ -177,9 +178,9 @@ public void setResolvePropertyPlaceholders(
          */
         private String[] signedReceiptMicAlgorithms;
         /**
-         * The name of algorithm used to encrypt EDI message.
+         * The algorithm used to encrypt EDI message.
          */
-        private String encryptingAlgorithmName;
+        private AS2EncryptionAlgorithm encryptingAlgorithm;
         /**
          * The chain of certificates used to encrypt EDI message.
          */
@@ -378,12 +379,13 @@ public void setSignedReceiptMicAlgorithms(
             this.signedReceiptMicAlgorithms = signedReceiptMicAlgorithms;
         }
 
-        public String getEncryptingAlgorithmName() {
-            return encryptingAlgorithmName;
+        public AS2EncryptionAlgorithm getEncryptingAlgorithm() {
+            return encryptingAlgorithm;
         }
 
-        public void setEncryptingAlgorithmName(String encryptingAlgorithmName) 
{
-            this.encryptingAlgorithmName = encryptingAlgorithmName;
+        public void setEncryptingAlgorithm(
+                AS2EncryptionAlgorithm encryptingAlgorithm) {
+            this.encryptingAlgorithm = encryptingAlgorithm;
         }
 
         public Certificate[] getEncryptingCertificateChain() {


 

----------------------------------------------------------------
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:
us...@infra.apache.org


> Enhance the AS2 Component to send and receive encrypted AS2 messages
> --------------------------------------------------------------------
>
>                 Key: CAMEL-12605
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12605
>             Project: Camel
>          Issue Type: Improvement
>    Affects Versions: 2.23.0
>            Reporter: William Collins
>            Assignee: William Collins
>            Priority: Major
>
> Enhance the AS2 Component to support encrypted AS2 messages per RFC4130



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

Reply via email to