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

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

davsclaus closed pull request #2310: [CAMEL-11257] Fixed multipart parsing 
logic and updated tests
URL: https://github.com/apache/camel/pull/2310
 
 
   

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/entity/EntityParser.java
 
b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/entity/EntityParser.java
index 28d0715964b..8b884f121aa 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
@@ -446,7 +446,14 @@ public static MultipartSignedEntity 
parseMultipartSignedEntityBody(AS2SessionInp
             applicationPkcs7SignatureEntity.setHeaders(headers);
             multipartSignedEntity.addPart(applicationPkcs7SignatureEntity);
 
+            //
+            // End Signature Body Part
+
+            ContentType contentType = 
ContentType.create(AS2MimeType.MULTIPART_SIGNED, charset);
+            multipartSignedEntity.setContentType(contentType);
+            
multipartSignedEntity.setContentTransferEncoding(contentTransferEncoding);
             return multipartSignedEntity;
+            
         } catch (Exception e) {
             ParseException parseException = new ParseException("failed to 
parse text entity");
             parseException.initCause(e);
@@ -560,7 +567,10 @@ public static DispositionNotificationMultipartReportEntity 
parseMultipartReportE
 
             //
             // End Disposition Notification Body Part
-          
+            
+            ContentType contentType = 
ContentType.create(AS2MimeType.MULTIPART_REPORT, charset);
+            
dispositionNotificationMultipartReportEntity.setContentType(contentType);
+            
dispositionNotificationMultipartReportEntity.setContentTransferEncoding(contentTransferEncoding);
             return dispositionNotificationMultipartReportEntity;
         } catch (Exception e) {
             ParseException parseException = new ParseException("failed to 
parse text entity");
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 157d8cd79b0..6ae06874da4 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
@@ -32,6 +32,7 @@
 import org.apache.http.entity.ContentType;
 import org.apache.http.message.BasicHeader;
 import org.apache.http.message.HeaderGroup;
+import org.apache.http.protocol.HTTP;
 import org.apache.http.util.Args;
 
 public abstract class MimeEntity extends AbstractHttpEntity {
@@ -92,7 +93,11 @@ public void setContentType(ContentType contentType) {
     @Override
     public void setContentType(Header contentType) {
         super.setContentType(contentType);
-        addHeader(contentType);
+        if (contentType != null) {
+               addHeader(contentType);
+        } else {
+               removeHeaders(AS2Header.CONTENT_TYPE);
+        }
     }
     
     public String getContentEncodingValue() {
@@ -106,7 +111,11 @@ public String getContentEncodingValue() {
     @Override
     public void setContentEncoding(Header contentEncoding) {
         super.setContentEncoding(contentEncoding);
-        addHeader(contentEncoding);
+        if (contentEncoding != null) {
+               addHeader(contentEncoding);
+        } else {
+               removeHeaders(HTTP.CONTENT_ENCODING);
+        }
     }
 
     public String getContentTransferEncodingValue() {
@@ -133,12 +142,16 @@ public Header getContentTransferEncoding() {
      * The default implementation sets the value of the
      * {@link #contentTranferEncoding contentTransferEncoding} attribute.
      *
-     * @param contentEncoding   the new Content-Transfer-Encoding header, or
+     * @param contentTransferEncoding   the new Content-Transfer-Encoding 
header, or
      *                          {@code null} to unset
      */
-    public void setContentTranserEncoding(final Header contentEncoding) {
-        this.contentTransferEncoding = contentEncoding;
-        addHeader(contentTransferEncoding);
+    public void setContentTranserEncoding(final Header 
contentTransferEncoding) {
+        this.contentTransferEncoding = contentTransferEncoding;
+        if (contentTransferEncoding != null) {
+               addHeader(contentTransferEncoding);
+        } else {
+               removeHeaders(AS2Header.CONTENT_TRANSFER_ENCODING);
+        }
     }
 
     /**
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 af8e0985ca5..4d7c856d3ad 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
@@ -53,16 +53,16 @@ protected MultipartSignedEntity(String boundary, boolean 
isMainBody) {
     }
     
     public boolean isValid()  {
-        ApplicationEDIEntity applicationEDIEntity = getSignedDataEntity();
+       MimeEntity signedEntity = getSignedDataEntity();
         ApplicationPkcs7SignatureEntity applicationPkcs7SignatureEntity = 
getSignatureEntity();
         
-        if (applicationEDIEntity == null || applicationPkcs7SignatureEntity == 
null) {
+        if (signedEntity == null || applicationPkcs7SignatureEntity == null) {
             return false;
         }
         
         try {
             ByteArrayOutputStream outstream = new ByteArrayOutputStream();
-            applicationEDIEntity.writeTo(outstream);
+            signedEntity.writeTo(outstream);
             CMSProcessable signedContent = new 
CMSProcessableByteArray(outstream.toByteArray());
 
             byte[] signature = applicationPkcs7SignatureEntity.getSignature();
@@ -90,9 +90,9 @@ public boolean isValid()  {
         return true;
     }
     
-    public ApplicationEDIEntity getSignedDataEntity() {
-        if (getPartCount() > 0 && getPart(0) instanceof ApplicationEDIEntity) {
-            return (ApplicationEDIEntity)  getPart(0);
+    public MimeEntity getSignedDataEntity() {
+        if (getPartCount() > 0) {
+            return getPart(0);
         }
         
         return null;
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 34307dbbdf6..19eb0efcbc9 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,6 +16,11 @@
  */
 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;
@@ -29,6 +34,7 @@
 import org.apache.camel.component.as2.api.entity.ApplicationEDIEntity;
 import org.apache.camel.component.as2.api.entity.ApplicationEDIFACTEntity;
 import 
org.apache.camel.component.as2.api.entity.ApplicationPkcs7SignatureEntity;
+import org.apache.camel.component.as2.api.entity.MimeEntity;
 import org.apache.camel.component.as2.api.entity.MultipartSignedEntity;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpException;
@@ -58,11 +64,6 @@
 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"
@@ -340,14 +341,16 @@ public void signatureVerificationTest() throws Exception {
         HttpEntity entity = 
((BasicHttpEntityEnclosingRequest)request).getEntity();
         assertNotNull("Request does not contain entity", entity);
         assertTrue("Unexpected request entity type", entity instanceof 
MultipartSignedEntity);
-        MultipartSignedEntity signedEntity = (MultipartSignedEntity)entity;
-        ApplicationEDIEntity ediMessageEntity = 
signedEntity.getSignedDataEntity();
+        MultipartSignedEntity multipartSignedEntity = 
(MultipartSignedEntity)entity;
+        MimeEntity signedEntity = multipartSignedEntity.getSignedDataEntity();
+        assertTrue("Signed entity wrong type", signedEntity instanceof 
ApplicationEDIEntity);
+        ApplicationEDIEntity ediMessageEntity = (ApplicationEDIEntity) 
signedEntity;
         assertNotNull("Multipart signed entity does not contain EDI message 
entity", ediMessageEntity);
-        ApplicationPkcs7SignatureEntity signatureEntity = 
signedEntity.getSignatureEntity();
+        ApplicationPkcs7SignatureEntity signatureEntity = 
multipartSignedEntity.getSignatureEntity();
         assertNotNull("Multipart signed entity does not contain signature 
entity", signatureEntity);
         
         // Validate Signature
-        assertTrue("Signature is invalid", signedEntity.isValid());
+        assertTrue("Signature is invalid", multipartSignedEntity.isValid());
 
     }
     
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 a685145e5fd..e4074bc0468 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
@@ -17,7 +17,15 @@
 package org.apache.camel.component.as2;
 
 import java.io.IOException;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.SecureRandom;
+import java.security.Security;
+import java.security.cert.Certificate;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.camel.builder.RouteBuilder;
@@ -29,9 +37,12 @@
 import org.apache.camel.component.as2.api.AS2MimeType;
 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.entity.ApplicationEDIEntity;
+import 
org.apache.camel.component.as2.api.entity.ApplicationPkcs7SignatureEntity;
 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.HttpMessageUtils;
 import org.apache.camel.component.as2.internal.AS2ApiCollection;
 import org.apache.camel.component.as2.internal.AS2ClientManagerApiMethod;
@@ -43,7 +54,19 @@
 import org.apache.http.entity.ContentType;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpRequestHandler;
+import org.bouncycastle.asn1.ASN1EncodableVector;
+import org.bouncycastle.asn1.cms.AttributeTable;
+import org.bouncycastle.asn1.cms.IssuerAndSerialNumber;
+import org.bouncycastle.asn1.smime.SMIMECapabilitiesAttribute;
+import org.bouncycastle.asn1.smime.SMIMECapability;
+import org.bouncycastle.asn1.smime.SMIMECapabilityVector;
+import org.bouncycastle.asn1.smime.SMIMEEncryptionKeyPreferenceAttribute;
+import org.bouncycastle.asn1.x500.X500Name;
+import org.bouncycastle.cert.jcajce.JcaCertStore;
+import org.bouncycastle.cms.jcajce.JcaSimpleSignerInfoGeneratorBuilder;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
 import org.junit.AfterClass;
+import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -95,15 +118,65 @@
     
     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;
+
+    private KeyPair issueKP;
+    private X509Certificate issueCert;
+
+    private KeyPair signingKP;
+    private X509Certificate signingCert;
+    private List<X509Certificate> certList;
+    private AS2SignedDataGenerator gen;
+
+    @Before
+    public void setUp() throws Exception {
+       super.setUp();
+        Security.addProvider(new BouncyCastleProvider());
+        
+        setupKeysAndCertificates();
+        
+        // Create and populate certificate store.
+        JcaCertStore certs = new JcaCertStore(certList);
+
+        // Create capabilities vector
+        SMIMECapabilityVector capabilities = new SMIMECapabilityVector();
+        capabilities.addCapability(SMIMECapability.dES_EDE3_CBC);
+        capabilities.addCapability(SMIMECapability.rC2_CBC, 128);
+        capabilities.addCapability(SMIMECapability.dES_CBC);
+
+        // Create signing attributes
+        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 {
+                this.gen = new AS2SignedDataGenerator();
+                this.gen.addSignerInfoGenerator(new 
JcaSimpleSignerInfoGeneratorBuilder().setProvider("BC")
+                        .setSignedAttributeGenerator(new 
AttributeTable(attributes))
+                        .build(signingAlgorithmName, signingKP.getPrivate(), 
signingCert));
+                this.gen.addCertificates(certs);
+                break;
+            } catch (Exception e) {
+                this.gen = null;
+                continue;
+            }
+        }
+        
+        if (this.gen == null) {
+            throw new Exception("failed to create signing generator");
+        }
+    }
 
     @Test
     public void plainMessageSendTest() throws Exception {
         final Map<String, Object> headers = new HashMap<String, Object>();
         // parameter type is String
-        headers.put("CamelAS2.ediMessage", EDI_MESSAGE);
-        // parameter type is String
         headers.put("CamelAS2.requestUri", REQUEST_URI);
         // parameter type is String
         headers.put("CamelAS2.subject", SUBJECT);
@@ -119,8 +192,6 @@ public void plainMessageSendTest() throws Exception {
         headers.put("CamelAS2.ediMessageContentType", 
ContentType.create(AS2MediaType.APPLICATION_EDIFACT, AS2Charset.US_ASCII));
         // parameter type is String
         headers.put("CamelAS2.ediMessageTransferEncoding", null);
-        // parameter type is String
-        headers.put("CamelAS2.signingAlgorithmName", null);
         // parameter type is java.security.cert.Certificate[]
         headers.put("CamelAS2.signingCertificateChain", null);
         // parameter type is java.security.PrivateKey
@@ -130,7 +201,7 @@ public void plainMessageSendTest() throws Exception {
         // parameter type is String[]
         headers.put("CamelAS2.signedReceiptMicAlgorithms", null);
 
-        final org.apache.http.protocol.HttpCoreContext result = 
requestBodyAndHeaders("direct://SEND", null, headers);
+        final org.apache.http.protocol.HttpCoreContext result = 
requestBodyAndHeaders("direct://SEND", EDI_MESSAGE, headers);
 
         assertNotNull("send result", result);
         LOG.debug("send: " + result);
@@ -167,8 +238,85 @@ public void plainMessageSendTest() throws Exception {
                 secondPart.getContentTypeValue());
     }
 
+    @Test
+    public void multipartSignedMessageTest() throws Exception {
+        final Map<String, Object> headers = new HashMap<String, Object>();
+        // 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.SIGNED);
+        // 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", null);
+        // parameter type is java.security.cert.Certificate[]
+        headers.put("CamelAS2.signingCertificateChain", certList.toArray(new 
Certificate[0]));
+        // parameter type is java.security.PrivateKey
+        headers.put("CamelAS2.signingPrivateKey", signingKP.getPrivate());
+        // parameter type is String
+        headers.put("CamelAS2.dispositionNotificationTo", "[email protected]");
+        // parameter type is String[]
+        headers.put("CamelAS2.signedReceiptMicAlgorithms", 
SIGNED_RECEIPT_MIC_ALGORITHMS);
+
+        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 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);
+        ContentType responseContentType = 
ContentType.parse(contentTypeHeaderValue);
+        assertEquals("Unexpected response type", AS2MimeType.MULTIPART_SIGNED, 
responseContentType.getMimeType());
+        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 MultipartSignedEntity);
+        MultipartSignedEntity responseSignedEntity = (MultipartSignedEntity) 
responseEntity;
+        MimeEntity responseSignedDataEntity = 
responseSignedEntity.getSignedDataEntity();
+        assertTrue("Signed entity wrong type", responseSignedDataEntity 
instanceof DispositionNotificationMultipartReportEntity);
+        DispositionNotificationMultipartReportEntity reportEntity = 
(DispositionNotificationMultipartReportEntity)responseSignedDataEntity;
+        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());
+        ApplicationPkcs7SignatureEntity signatureEntity = 
responseSignedEntity.getSignatureEntity();
+        assertNotNull("Signature Entity", signatureEntity);
+    }
+
     @BeforeClass
     public static void setupTest() throws Exception {
+       setupServerKeysAndCertificates();
         receiveTestMessages();
     }
     
@@ -196,15 +344,72 @@ protected RouteBuilder createRouteBuilder() throws 
Exception {
         return new RouteBuilder() {
             public void configure() {
                 // test route for send
-                from("direct://SEND").to("as2://" + PATH_PREFIX + "/send");
+                from("direct://SEND").to("as2://" + PATH_PREFIX + 
"/send?inBody=ediMessage");
 
             }
         };
     }
+    
+    private static void setupServerKeysAndCertificates() throws Exception {
+        Security.addProvider(new BouncyCastleProvider());
+        
+        //
+        // set up our certificates
+        //
+        KeyPairGenerator    kpg  = KeyPairGenerator.getInstance("RSA", "BC");
+
+        kpg.initialize(1024, new SecureRandom());
+
+        String issueDN = "O=Punkhorn Software, C=US";
+        KeyPair issueKP = kpg.generateKeyPair();
+        X509Certificate issueCert = Utils.makeCertificate(
+                                        issueKP, issueDN, issueKP, issueDN);
+        
+        //
+        // certificate we sign against
+        //
+        String signingDN = "CN=William J. Collins, [email protected], 
O=Punkhorn Software, C=US";
+        serverSigningKP = kpg.generateKeyPair();
+        X509Certificate signingCert = Utils.makeCertificate(
+                       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, null, null);
+                "server.example.com", 8888, serverCertList.toArray(new 
Certificate[0]), serverSigningKP.getPrivate());
         serverConnection.listen("/", new RequestHandler());
     }
+
+    private void setupKeysAndCertificates() throws Exception {
+        //
+        // set up our certificates
+        //
+        KeyPairGenerator    kpg  = KeyPairGenerator.getInstance("RSA", "BC");
+
+        kpg.initialize(1024, new SecureRandom());
+
+        String issueDN = "O=Punkhorn Software, C=US";
+        issueKP = kpg.generateKeyPair();
+        issueCert = Utils.makeCertificate(
+                                        issueKP, issueDN, issueKP, issueDN);
+        
+        //
+        // certificate we sign against
+        //
+        String signingDN = "CN=William J. Collins, [email protected], 
O=Punkhorn Software, C=US";
+        signingKP = kpg.generateKeyPair();
+        signingCert = Utils.makeCertificate(
+                                        signingKP, signingDN, issueKP, 
issueDN);
+        
+        certList = new ArrayList<X509Certificate>();
+
+        certList.add(signingCert);
+        certList.add(issueCert);
+
+    }
 }


 

----------------------------------------------------------------
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