camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [camel] branch master updated: [CAMEL-12605] Refactored encryption algorithms and added tests for all supported algorithms.
Date Wed, 19 Sep 2018 06:13:24 GMT
This is an automated email from the ASF dual-hosted git repository.

acosentino 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 9c237f0  [CAMEL-12605] Refactored encryption algorithms and added tests for all supported
algorithms.
9c237f0 is described below

commit 9c237f09ca96da1f7ae345b25ef76942142c0e09
Author: William Collins <punkhornsw@gmail.com>
AuthorDate: Tue Sep 18 22:01:28 2018 -0400

    [CAMEL-12605] Refactored encryption algorithms and added tests for all supported algorithms.
---
 .../camel/component/as2/api/AS2Algorithm.java      | 346 ---------------------
 .../camel/component/as2/api/AS2ClientManager.java  |  16 +-
 .../component/as2/api/AS2EncryptionAlgorithm.java  |  62 ++++
 .../component/as2/api/util/EncryptingUtils.java    |  10 +-
 .../camel/component/as2/api/AS2MessageTest.java    | 107 ++++++-
 5 files changed, 179 insertions(+), 362 deletions(-)

diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2Algorithm.java
b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2Algorithm.java
deleted file mode 100644
index 8e71f47..0000000
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2Algorithm.java
+++ /dev/null
@@ -1,346 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.as2.api;
-
-import org.bouncycastle.asn1.ASN1ObjectIdentifier;
-import org.bouncycastle.cms.CMSAlgorithm;
-
-interface AS2AlgorithmConstants {
-    static final String DES_CBC = "DES_CBC";
-    static final String DES_EDE3_CBC = "DES_EDE3_CBC";
-    static final String RC2_CBC = "RC2_CBC";
-    static final String IDEA_CBC = "IDEA_CBC";
-    static final String CAST5_CBC = "CAST5_CBC";
-    static final String AES128_CBC = "AES128_CBC";
-    static final String AES192_CBC = "AES192_CBC";
-    static final String AES256_CBC = "AES256_CBC";
-    static final String AES128_CCM = "AES128_CCM";
-    static final String AES192_CCM = "AES192_CCM";
-    static final String AES256_CCM = "AES256_CCM";
-    static final String AES128_GCM = "AES128_GCM";
-    static final String AES192_GCM = "AES192_GCM";
-    static final String AES256_GCM = "AES256_GCM";
-    static final String CAMELLIA128_CBC = "CAMELLIA128_CBC";
-    static final String CAMELLIA192_CBC = "CAMELLIA192_CBC";
-    static final String CAMELLIA256_CBC = "CAMELLIA256_CBC";
-    static final String GOST28147_GCFB = "GOST28147_GCFB";
-    static final String SEED_CBC = "SEED_CBC";
-    static final String DES_EDE3_WRAP = "DES_EDE3_WRAP";
-    static final String AES128_WRAP = "AES128_WRAP";
-    static final String AES192_WRAP = "AES192_WRAP";
-    static final String AES256_WRAP = "AES256_WRAP";
-    static final String CAMELLIA128_WRAP = "CAMELLIA128_WRAP";
-    static final String CAMELLIA192_WRAP = "CAMELLIA192_WRAP";
-    static final String CAMELLIA256_WRAP = "CAMELLIA256_WRAP";
-    static final String SEED_WRAP = "SEED_WRAP";
-    static final String GOST28147_WRAP = "GOST28147_WRAP";
-    static final String GOST28147_CRYPTOPRO_WRAP = "GOST28147_CRYPTOPRO_WRAP";
-    static final String ECDH_SHA1KDF = "ECDH_SHA1KDF";
-    static final String ECCDH_SHA1KDF = "ECCDH_SHA1KDF";
-    static final String ECMQV_SHA1KDF = "ECMQV_SHA1KDF";
-    static final String ECDH_SHA224KDF = "ECDH_SHA224KDF";
-    static final String ECCDH_SHA224KDF = "ECCDH_SHA224KDF";
-    static final String ECMQV_SHA224KDF = "ECMQV_SHA224KDF";
-    static final String ECDH_SHA256KDF = "ECDH_SHA256KDF";
-    static final String ECCDH_SHA256KDF = "ECCDH_SHA256KDF";
-    static final String ECMQV_SHA256KDF = "ECMQV_SHA256KDF";
-    static final String ECDH_SHA384KDF = "ECDH_SHA384KDF";
-    static final String ECCDH_SHA384KDF = "ECCDH_SHA384KDF";
-    static final String ECMQV_SHA384KDF = "ECMQV_SHA384KDF";
-    static final String ECDH_SHA512KDF = "ECDH_SHA512KDF";
-    static final String ECCDH_SHA512KDF = "ECCDH_SHA512KDF";
-    static final String ECMQV_SHA512KDF = "ECMQV_SHA512KDF";
-    static final String ECDHGOST3410_2001 = "ECDHGOST3410_2001";
-    static final String ECDHGOST3410_2012_256 = "ECDHGOST3410_2012_256";
-    static final String ECDHGOST3410_2012_512 = "ECDHGOST3410_2012_512";
-    static final String SHA1 = "SHA1";
-    static final String SHA224 = "SHA224";
-    static final String SHA256 = "SHA256";
-    static final String SHA384 = "SHA384";
-    static final String SHA512 = "SHA512";
-    static final String MD5 = "MD5";
-    static final String GOST3411 = "GOST3411";
-    static final String GOST3411_2012_256 = "GOST3411_2012_256";
-    static final String GOST3411_2012_512 = "GOST3411_2012_512";
-    static final String RIPEMD128 = "RIPEMD128";
-    static final String RIPEMD160 = "RIPEMD160";
-    static final String RIPEMD256 = "RIPEMD256";
-}
-
-public enum AS2Algorithm {
-    DES_CBC(AS2AlgorithmConstants.DES_CBC, CMSAlgorithm.DES_CBC),
-    DES_EDE3_CBC(AS2AlgorithmConstants.DES_EDE3_CBC, CMSAlgorithm.DES_EDE3_CBC),
-    RC2_CBC(AS2AlgorithmConstants.RC2_CBC, CMSAlgorithm.RC2_CBC),
-    IDEA_CBC(AS2AlgorithmConstants.IDEA_CBC, CMSAlgorithm.IDEA_CBC),
-    CAST5_CBC(AS2AlgorithmConstants.CAST5_CBC, CMSAlgorithm.CAST5_CBC),
-    AES128_CBC(AS2AlgorithmConstants.AES128_CBC, CMSAlgorithm.AES128_CBC),
-    AES192_CBC(AS2AlgorithmConstants.AES192_CBC, CMSAlgorithm.AES192_CBC),
-    AES256_CBC(AS2AlgorithmConstants.AES256_CBC, CMSAlgorithm.AES256_CBC),
-    AES128_CCM(AS2AlgorithmConstants.AES128_CCM, CMSAlgorithm.AES128_CCM),
-    AES192_CCM(AS2AlgorithmConstants.AES192_CCM, CMSAlgorithm.AES192_CCM),
-    AES256_CCM(AS2AlgorithmConstants.AES256_CCM, CMSAlgorithm.AES256_CCM),
-    AES128_GCM(AS2AlgorithmConstants.AES128_GCM, CMSAlgorithm.AES128_GCM),
-    AES192_GCM(AS2AlgorithmConstants.AES192_GCM, CMSAlgorithm.AES192_GCM),
-    AES256_GCM(AS2AlgorithmConstants.AES256_GCM, CMSAlgorithm.AES256_GCM),
-    CAMELLIA128_CBC(AS2AlgorithmConstants.CAMELLIA128_CBC, CMSAlgorithm.CAMELLIA128_CBC),
-    CAMELLIA192_CBC(AS2AlgorithmConstants.CAMELLIA192_CBC, CMSAlgorithm.CAMELLIA192_CBC),
-    CAMELLIA256_CBC(AS2AlgorithmConstants.CAMELLIA256_CBC, CMSAlgorithm.CAMELLIA256_CBC),
-    GOST28147_GCFB(AS2AlgorithmConstants.GOST28147_GCFB, CMSAlgorithm.GOST28147_GCFB),
-    SEED_CBC(AS2AlgorithmConstants.SEED_CBC, CMSAlgorithm.SEED_CBC),
-    DES_EDE3_WRAP(AS2AlgorithmConstants.DES_EDE3_WRAP, CMSAlgorithm.DES_EDE3_WRAP),
-    AES128_WRAP(AS2AlgorithmConstants.AES128_WRAP, CMSAlgorithm.AES128_WRAP),
-    AES192_WRAP(AS2AlgorithmConstants.AES192_WRAP, CMSAlgorithm.AES192_WRAP),
-    AES256_WRAP(AS2AlgorithmConstants.AES256_WRAP, CMSAlgorithm.AES256_WRAP),
-    CAMELLIA128_WRAP(AS2AlgorithmConstants.CAMELLIA128_WRAP, CMSAlgorithm.CAMELLIA128_WRAP),
-    CAMELLIA192_WRAP(AS2AlgorithmConstants.CAMELLIA192_WRAP, CMSAlgorithm.CAMELLIA192_WRAP),
-    CAMELLIA256_WRAP(AS2AlgorithmConstants.CAMELLIA256_WRAP, CMSAlgorithm.CAMELLIA256_WRAP),
-    SEED_WRAP(AS2AlgorithmConstants.SEED_WRAP, CMSAlgorithm.SEED_WRAP),
-    GOST28147_WRAP(AS2AlgorithmConstants.GOST28147_WRAP, CMSAlgorithm.GOST28147_WRAP),
-    GOST28147_CRYPTOPRO_WRAP(AS2AlgorithmConstants.GOST28147_CRYPTOPRO_WRAP, CMSAlgorithm.GOST28147_CRYPTOPRO_WRAP),
-    ECDH_SHA1KDF(AS2AlgorithmConstants.ECDH_SHA1KDF, CMSAlgorithm.ECDH_SHA1KDF),
-    ECCDH_SHA1KDF(AS2AlgorithmConstants.ECCDH_SHA1KDF, CMSAlgorithm.ECCDH_SHA1KDF),
-    ECMQV_SHA1KDF(AS2AlgorithmConstants.ECMQV_SHA1KDF, CMSAlgorithm.ECMQV_SHA1KDF),
-    ECDH_SHA224KDF(AS2AlgorithmConstants.ECDH_SHA224KDF, CMSAlgorithm.ECDH_SHA224KDF),
-    ECCDH_SHA224KDF(AS2AlgorithmConstants.ECCDH_SHA224KDF, CMSAlgorithm.ECCDH_SHA224KDF),
-    ECMQV_SHA224KDF(AS2AlgorithmConstants.ECMQV_SHA224KDF, CMSAlgorithm.ECMQV_SHA224KDF),
-    ECDH_SHA256KDF(AS2AlgorithmConstants.ECDH_SHA256KDF, CMSAlgorithm.ECDH_SHA256KDF),
-    ECCDH_SHA256KDF(AS2AlgorithmConstants.ECCDH_SHA256KDF, CMSAlgorithm.ECCDH_SHA256KDF),
-    ECMQV_SHA256KDF(AS2AlgorithmConstants.ECMQV_SHA256KDF, CMSAlgorithm.ECMQV_SHA256KDF),
-    ECDH_SHA384KDF(AS2AlgorithmConstants.ECDH_SHA384KDF, CMSAlgorithm.ECDH_SHA384KDF),
-    ECCDH_SHA384KDF(AS2AlgorithmConstants.ECCDH_SHA384KDF, CMSAlgorithm.ECCDH_SHA384KDF),
-    ECMQV_SHA384KDF(AS2AlgorithmConstants.ECMQV_SHA384KDF, CMSAlgorithm.ECMQV_SHA384KDF),
-    ECDH_SHA512KDF(AS2AlgorithmConstants.ECDH_SHA512KDF, CMSAlgorithm.ECDH_SHA512KDF),
-    ECCDH_SHA512KDF(AS2AlgorithmConstants.ECCDH_SHA512KDF, CMSAlgorithm.ECCDH_SHA512KDF),
-    ECMQV_SHA512KDF(AS2AlgorithmConstants.ECMQV_SHA512KDF, CMSAlgorithm.ECMQV_SHA512KDF),
-    ECDHGOST3410_2001(AS2AlgorithmConstants.ECDHGOST3410_2001, CMSAlgorithm.ECDHGOST3410_2001),
-    ECDHGOST3410_2012_256(AS2AlgorithmConstants.ECDHGOST3410_2012_256, CMSAlgorithm.ECDHGOST3410_2012_256),
-    ECDHGOST3410_2012_512(AS2AlgorithmConstants.ECDHGOST3410_2012_512, CMSAlgorithm.ECDHGOST3410_2012_512),
-    SHA1(AS2AlgorithmConstants.SHA1, CMSAlgorithm.SHA1),
-    SHA224(AS2AlgorithmConstants.SHA224, CMSAlgorithm.SHA224),
-    SHA256(AS2AlgorithmConstants.SHA256, CMSAlgorithm.SHA256),
-    SHA384(AS2AlgorithmConstants.SHA384, CMSAlgorithm.SHA384),
-    SHA512(AS2AlgorithmConstants.SHA512, CMSAlgorithm.SHA512),
-    MD5(AS2AlgorithmConstants.MD5, CMSAlgorithm.MD5),
-    GOST3411(AS2AlgorithmConstants.GOST3411, CMSAlgorithm.GOST3411),
-    GOST3411_2012_256(AS2AlgorithmConstants.GOST3411_2012_256, CMSAlgorithm.GOST3411_2012_256),
-    GOST3411_2012_512(AS2AlgorithmConstants.GOST3411_2012_512, CMSAlgorithm.GOST3411_2012_512),
-    RIPEMD128(AS2AlgorithmConstants.RIPEMD128, CMSAlgorithm.RIPEMD128),
-    RIPEMD160(AS2AlgorithmConstants.RIPEMD160, CMSAlgorithm.RIPEMD160),
-    RIPEMD256(AS2AlgorithmConstants.RIPEMD256, CMSAlgorithm.RIPEMD256);
-    
-    private String algorithmName;
-    private ASN1ObjectIdentifier algorithmOID;
-    
-    private AS2Algorithm(String algorithmName, ASN1ObjectIdentifier algorithmOID) {
-        this.algorithmName = algorithmName;
-        this.algorithmOID = algorithmOID;
-    }
-    public String getAlgorithmName() {
-        return algorithmName;
-    }
-    public ASN1ObjectIdentifier getAlgorithmOID() {
-        return algorithmOID;
-    }
-    
-    public static AS2Algorithm getAS2Algorithm(String algorithmName) {
-        AS2Algorithm as2Algorithm;
-        switch (algorithmName) {
-        case "DES_CBC":
-            as2Algorithm = DES_CBC;
-            break;
-        case "DES_EDE3_CBC":
-            as2Algorithm = DES_EDE3_CBC;
-            break;
-        case "RC2_CBC":
-            as2Algorithm = RC2_CBC;
-            break;
-        case "IDEA_CBC":
-            as2Algorithm = IDEA_CBC;
-            break;
-        case "CAST5_CBC":
-            as2Algorithm = CAST5_CBC;
-            break;
-        case "AES128_CBC":
-            as2Algorithm = AES128_CBC;
-            break;
-        case "AES192_CBC":
-            as2Algorithm = AES192_CBC;
-            break;
-        case "AES256_CBC":
-            as2Algorithm = AES256_CBC;
-            break;
-        case "AES128_CCM":
-            as2Algorithm = AES128_CCM;
-            break;
-        case "AES192_CCM":
-            as2Algorithm = AES192_CCM;
-            break;
-        case "AES256_CCM":
-            as2Algorithm = AES256_CCM;
-            break;
-        case "AES128_GCM":
-            as2Algorithm = AES128_GCM;
-            break;
-        case "AES192_GCM":
-            as2Algorithm = AES192_GCM;
-            break;
-        case "AES256_GCM":
-            as2Algorithm = AES256_GCM;
-            break;
-        case "CAMELLIA128_CBC":
-            as2Algorithm = CAMELLIA128_CBC;
-            break;
-        case "CAMELLIA192_CBC":
-            as2Algorithm = CAMELLIA192_CBC;
-            break;
-        case "CAMELLIA256_CBC":
-            as2Algorithm = CAMELLIA256_CBC;
-            break;
-        case "GOST28147_GCFB":
-            as2Algorithm = GOST28147_GCFB;
-            break;
-        case "SEED_CBC":
-            as2Algorithm = SEED_CBC;
-            break;
-        case "DES_EDE3_WRAP":
-            as2Algorithm = DES_EDE3_WRAP;
-            break;
-        case "AES128_WRAP":
-            as2Algorithm = AES128_WRAP;
-            break;
-        case "AES192_WRAP":
-            as2Algorithm = AES192_WRAP;
-            break;
-        case "AES256_WRAP":
-            as2Algorithm = AES256_WRAP;
-            break;
-        case "CAMELLIA128_WRAP":
-            as2Algorithm = CAMELLIA128_WRAP;
-            break;
-        case "CAMELLIA192_WRAP":
-            as2Algorithm = CAMELLIA192_WRAP;
-            break;
-        case "CAMELLIA256_WRAP":
-            as2Algorithm = CAMELLIA256_WRAP;
-            break;
-        case "SEED_WRAP":
-            as2Algorithm = SEED_WRAP;
-            break;
-        case "GOST28147_WRAP":
-            as2Algorithm = GOST28147_WRAP;
-            break;
-        case "GOST28147_CRYPTOPRO_WRAP":
-            as2Algorithm = GOST28147_CRYPTOPRO_WRAP;
-            break;
-        case "ECDH_SHA1KDF":
-            as2Algorithm = ECDH_SHA1KDF;
-            break;
-        case "ECCDH_SHA1KDF":
-            as2Algorithm = ECCDH_SHA1KDF;
-            break;
-        case "ECMQV_SHA1KDF":
-            as2Algorithm = ECMQV_SHA1KDF;
-            break;
-        case "ECDH_SHA224KDF":
-            as2Algorithm = ECDH_SHA224KDF;
-            break;
-        case "ECCDH_SHA224KDF":
-            as2Algorithm = ECCDH_SHA224KDF;
-            break;
-        case "ECMQV_SHA224KDF":
-            as2Algorithm = ECMQV_SHA224KDF;
-            break;
-        case "ECDH_SHA256KDF":
-            as2Algorithm = ECDH_SHA256KDF;
-            break;
-        case "ECCDH_SHA256KDF":
-            as2Algorithm = ECCDH_SHA256KDF;
-            break;
-        case "ECMQV_SHA256KDF":
-            as2Algorithm = ECMQV_SHA256KDF;
-            break;
-        case "ECDH_SHA384KDF":
-            as2Algorithm = ECDH_SHA384KDF;
-            break;
-        case "ECCDH_SHA384KDF":
-            as2Algorithm = ECCDH_SHA384KDF;
-            break;
-        case "ECMQV_SHA384KDF":
-            as2Algorithm = ECMQV_SHA384KDF;
-            break;
-        case "ECDH_SHA512KDF":
-            as2Algorithm = ECDH_SHA512KDF;
-            break;
-        case "ECCDH_SHA512KDF":
-            as2Algorithm = ECCDH_SHA512KDF;
-            break;
-        case "ECMQV_SHA512KDF":
-            as2Algorithm = ECMQV_SHA512KDF;
-            break;
-        case "ECDHGOST3410_2001":
-            as2Algorithm = ECDHGOST3410_2001;
-            break;
-        case "ECDHGOST3410_2012_256":
-            as2Algorithm = ECDHGOST3410_2012_256;
-            break;
-        case "ECDHGOST3410_2012_512":
-            as2Algorithm = ECDHGOST3410_2012_512;
-            break;
-        case "SHA1":
-            as2Algorithm = SHA1;
-            break;
-        case "SHA224":
-            as2Algorithm = SHA224;
-            break;
-        case "SHA256":
-            as2Algorithm = SHA256;
-            break;
-        case "SHA384":
-            as2Algorithm = SHA384;
-            break;
-        case "SHA512":
-            as2Algorithm = SHA512;
-            break;
-        case "MD5":
-            as2Algorithm = MD5;
-            break;
-        case "GOST3411":
-            as2Algorithm = GOST3411;
-            break;
-        case "GOST3411_2012_256":
-            as2Algorithm = GOST3411_2012_256;
-            break;
-        case "GOST3411_2012_512":
-            as2Algorithm = GOST3411_2012_512;
-            break;
-        case "RIPEMD128":
-            as2Algorithm = RIPEMD128;
-            break;
-        case "RIPEMD160":
-            as2Algorithm = RIPEMD160;
-            break;
-        case "RIPEMD256":
-            as2Algorithm = RIPEMD256;
-            break;
-
-        default:
-            throw new IllegalArgumentException("Unsupported algorithm '" + algorithmName
+ "'");
-        }
-        return as2Algorithm;
-    }
-    
-}
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 9c33d9a..c8eb044 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
@@ -142,7 +142,7 @@ public class AS2ClientManager {
      * The HTTP Context Attribute containing the algorithm name used to encrypt EDI
      * message
      */
-    public static final String ENCRYPTING_ALGORITHM_NAME = CAMEL_AS2_CLIENT_PREFIX + "encrypting-algorithm-name";
+    public static final String ENCRYPTING_ALGORITHM = CAMEL_AS2_CLIENT_PREFIX + "encrypting-algorithm-name";
 
     /**
      * The HTTP Context Attribute containing the certificate used to encrypt
@@ -194,7 +194,7 @@ public class AS2ClientManager {
      * @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 encryptionAlgorithmName - the name of the algorithm used to encrypt the message
or <code>null</code> if sending EDI message unencrypted
+     * @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
      * @return {@link HttpCoreContext} containing request and response used to send EDI message
@@ -213,7 +213,7 @@ public class AS2ClientManager {
                                 PrivateKey signingPrivateKey,
                                 String dispositionNotificationTo,
                                 String[] signedReceiptMicAlgorithms,
-                                String encryptionAlgorithmName,
+                                AS2EncryptionAlgorithm encryptionAlgorithm,
                                 Certificate[] encryptionCertificateChain,
                                 PrivateKey encryptionPrivateKey)
             throws HttpException {
@@ -237,7 +237,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);
-        httpContext.setAttribute(AS2ClientManager.ENCRYPTING_ALGORITHM_NAME, encryptionAlgorithmName);
+        httpContext.setAttribute(AS2ClientManager.ENCRYPTING_ALGORITHM, encryptionAlgorithm);
         httpContext.setAttribute(AS2ClientManager.ENCRYPTING_CERTIFICATE_CHAIN, encryptionCertificateChain);
         httpContext.setAttribute(AS2ClientManager.ENCRYPTING_PRIVATE_KEY, encryptionPrivateKey);
 
@@ -322,12 +322,12 @@ public class AS2ClientManager {
     
     public OutputEncryptor createEncryptor(HttpCoreContext httpContext) throws HttpException
{
         
-        String algorithmName = httpContext.getAttribute(ENCRYPTING_ALGORITHM_NAME, String.class);
-        if (algorithmName == null) {
-            throw new HttpException("Encrypting algorithm name missing");
+        AS2EncryptionAlgorithm encryptionAlgorithm = httpContext.getAttribute(ENCRYPTING_ALGORITHM,
AS2EncryptionAlgorithm.class);
+        if (encryptionAlgorithm == null) {
+            throw new HttpException("Encrypting algorithm missing");
         }
 
-        return EncryptingUtils.createEncryptor(algorithmName);
+        return EncryptingUtils.createEncryptor(encryptionAlgorithm);
     }
 
 }
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2EncryptionAlgorithm.java
b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2EncryptionAlgorithm.java
new file mode 100644
index 0000000..bb7c761
--- /dev/null
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2EncryptionAlgorithm.java
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.as2.api;
+
+import org.bouncycastle.asn1.ASN1ObjectIdentifier;
+import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
+import org.bouncycastle.cms.CMSAlgorithm;
+
+public enum AS2EncryptionAlgorithm {
+    AES128_CBC(CMSAlgorithm.AES128_CBC),
+    AES192_CBC(CMSAlgorithm.AES192_CBC),
+    AES256_CBC(CMSAlgorithm.AES256_CBC),
+    AES128_CCM(CMSAlgorithm.AES128_CCM),
+    AES192_CCM(CMSAlgorithm.AES192_CCM),
+    AES256_CCM(CMSAlgorithm.AES256_CCM),
+    AES128_GCM(CMSAlgorithm.AES128_GCM),
+    AES192_GCM(CMSAlgorithm.AES192_GCM),
+    AES256_GCM(CMSAlgorithm.AES256_GCM),
+    CAMELLIA128_CBC(CMSAlgorithm.CAMELLIA128_CBC),
+    CAMELLIA192_CBC(CMSAlgorithm.CAMELLIA192_CBC),
+    CAMELLIA256_CBC(CMSAlgorithm.CAMELLIA256_CBC),
+    CAST5_CBC(CMSAlgorithm.CAST5_CBC),
+    DES_CBC(CMSAlgorithm.DES_CBC),
+    DES_EDE3_CBC(CMSAlgorithm.DES_EDE3_CBC),
+    GOST28147_GCFB(CMSAlgorithm.GOST28147_GCFB),
+    IDEA_CBC(CMSAlgorithm.IDEA_CBC),
+    RC2_CBC(CMSAlgorithm.RC2_CBC),
+    RC4(PKCSObjectIdentifiers.rc4),
+    SEED_CBC(CMSAlgorithm.SEED_CBC);
+
+    
+    private ASN1ObjectIdentifier algorithmOID;
+    
+    private AS2EncryptionAlgorithm(ASN1ObjectIdentifier algorithmOID) {
+        this.algorithmOID = algorithmOID;
+    }
+    public String getAlgorithmName() {
+        return this.name();
+    }
+    public ASN1ObjectIdentifier getAlgorithmOID() {
+        return algorithmOID;
+    }
+    
+    public static AS2EncryptionAlgorithm getAS2Algorithm(String algorithmName) {
+        return AS2EncryptionAlgorithm.valueOf(algorithmName);
+    }
+    
+}
diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/util/EncryptingUtils.java
b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/util/EncryptingUtils.java
index 8e0c9b3..2be9680 100644
--- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/util/EncryptingUtils.java
+++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/util/EncryptingUtils.java
@@ -20,10 +20,9 @@ import java.security.cert.Certificate;
 import java.security.cert.CertificateEncodingException;
 import java.security.cert.X509Certificate;
 
-import org.apache.camel.component.as2.api.AS2Algorithm;
+import org.apache.camel.component.as2.api.AS2EncryptionAlgorithm;
 import org.apache.http.HttpException;
 import org.apache.http.util.Args;
-import org.bouncycastle.asn1.ASN1ObjectIdentifier;
 import org.bouncycastle.cms.CMSEnvelopedDataGenerator;
 import org.bouncycastle.cms.CMSException;
 import org.bouncycastle.cms.jcajce.JceCMSContentEncryptorBuilder;
@@ -55,11 +54,10 @@ public final class EncryptingUtils {
         }
     }
     
-    public static OutputEncryptor createEncryptor(String encryptionAlgorithmName) throws
HttpException {
-        Args.notNull(encryptionAlgorithmName, "encryptionAlgorithmName");
+    public static OutputEncryptor createEncryptor(AS2EncryptionAlgorithm encryptionAlgorithm)
throws HttpException {
+        Args.notNull(encryptionAlgorithm, "encryptionAlgorithmName");
         try {
-            ASN1ObjectIdentifier algorithmOID = AS2Algorithm.getAS2Algorithm(encryptionAlgorithmName).getAlgorithmOID();
-            return new JceCMSContentEncryptorBuilder(algorithmOID).build();
+            return new JceCMSContentEncryptorBuilder(encryptionAlgorithm.getAlgorithmOID()).build();
         } catch (CMSException e) {
             throw new HttpException("Failed to create encryptor ", e);
         }
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 c994037..d9d3338 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
@@ -365,15 +365,116 @@ public class AS2MessageTest {
     }
 
     @Test
-    public void envelopeddMessageTest() throws Exception {
+    public void aes128CbcEnvelopedMessageTest() throws Exception {
+        envelopeddMessageTest(AS2EncryptionAlgorithm.AES128_CBC);
+    }
+    
+    @Test
+    public void aes192CbcEnvelopedMessageTest() throws Exception {
+        envelopeddMessageTest(AS2EncryptionAlgorithm.AES192_CBC);
+    }
+    
+    @Test
+    public void aes256CbcEnvelopedMessageTest() throws Exception {
+        envelopeddMessageTest(AS2EncryptionAlgorithm.AES256_CBC);
+    }
+    
+    @Test
+    public void aes128CcmEnvelopedMessageTest() throws Exception {
+        envelopeddMessageTest(AS2EncryptionAlgorithm.AES128_CCM);
+    }
+    
+    @Test
+    public void aes192CcmEnvelopedMessageTest() throws Exception {
+        envelopeddMessageTest(AS2EncryptionAlgorithm.AES192_CCM);
+    }
+    
+    @Test
+    public void aes256CcmEnvelopedMessageTest() throws Exception {
+        envelopeddMessageTest(AS2EncryptionAlgorithm.AES256_CCM);
+    }
+    
+    @Test
+    public void aes128GcmEnvelopedMessageTest() throws Exception {
+        envelopeddMessageTest(AS2EncryptionAlgorithm.AES128_GCM);
+    }
+    
+    @Test
+    public void aes192GcmEnvelopedMessageTest() throws Exception {
+        envelopeddMessageTest(AS2EncryptionAlgorithm.AES192_GCM);
+    }
+    
+    @Test
+    public void aes256GcmEnvelopedMessageTest() throws Exception {
+        envelopeddMessageTest(AS2EncryptionAlgorithm.AES256_GCM);
+    }
+    
+    @Test
+    public void camellia128CbcEnvelopedMessageTest() throws Exception {
+        envelopeddMessageTest(AS2EncryptionAlgorithm.CAMELLIA128_CBC);
+    }
+    
+    @Test
+    public void camellia192CbcEnvelopedMessageTest() throws Exception {
+        envelopeddMessageTest(AS2EncryptionAlgorithm.CAMELLIA192_CBC);
+    }
+    
+    @Test
+    public void camellia256CbcEnvelopedMessageTest() throws Exception {
+        envelopeddMessageTest(AS2EncryptionAlgorithm.CAMELLIA256_CBC);
+    }
+    
+    @Test
+    public void cast5CbcEnvelopedMessageTest() throws Exception {
+        envelopeddMessageTest(AS2EncryptionAlgorithm.CAST5_CBC);
+    }
+    
+    @Test
+    public void desCbcEnvelopedMessageTest() throws Exception {
+        envelopeddMessageTest(AS2EncryptionAlgorithm.DES_CBC);
+    }
+    
+    @Test
+    public void desEde3CbcEnvelopedMessageTest() throws Exception {
+        envelopeddMessageTest(AS2EncryptionAlgorithm.DES_EDE3_CBC);
+    }
+    
+    @Test
+    public void cost28147GcfbEnvelopedMessageTest() throws Exception {
+        envelopeddMessageTest(AS2EncryptionAlgorithm.GOST28147_GCFB);
+    }
+    
+    @Test
+    public void ideaCbcEnvelopedMessageTest() throws Exception {
+        envelopeddMessageTest(AS2EncryptionAlgorithm.IDEA_CBC);
+    }
+    
+    @Test
+    public void rc2CbcEnvelopedMessageTest() throws Exception {
+        envelopeddMessageTest(AS2EncryptionAlgorithm.RC2_CBC);
+    }
+    
+    @Test
+    public void rc4EnvelopedMessageTest() throws Exception {
+        envelopeddMessageTest(AS2EncryptionAlgorithm.RC4);
+    }
+    
+    @Test
+    public void seedCbcEnvelopedMessageTest() throws Exception {
+        envelopeddMessageTest(AS2EncryptionAlgorithm.SEED_CBC);
+    }
+
+    public void envelopeddMessageTest(AS2EncryptionAlgorithm encryptionAlgorithm) throws
Exception {
         AS2ClientConnection clientConnection = new AS2ClientConnection(AS2_VERSION, USER_AGENT,
CLIENT_FQDN,
                 TARGET_HOST, TARGET_PORT);
         AS2ClientManager clientManager = new AS2ClientManager(clientConnection);
+        
+        LOG.info("Key Algoritm: " + signingKP.getPrivate().getAlgorithm());
 
         HttpCoreContext httpContext = clientManager.send(EDI_MESSAGE, REQUEST_URI, SUBJECT,
FROM, AS2_NAME, AS2_NAME,
                 AS2MessageStructure.ENCRYPTED, ContentType.create(AS2MediaType.APPLICATION_EDIFACT,
AS2Charset.US_ASCII),
                 null, certList.toArray(new Certificate[0]), signingKP.getPrivate(), DISPOSITION_NOTIFICATION_TO,
-                SIGNED_RECEIPT_MIC_ALGORITHMS, AS2AlgorithmConstants.AES128_CCM, certList.toArray(new
Certificate[0]),
+                SIGNED_RECEIPT_MIC_ALGORITHMS, encryptionAlgorithm, certList.toArray(new
Certificate[0]),
                 signingKP.getPrivate());
 
         HttpRequest request = httpContext.getRequest();
@@ -413,6 +514,8 @@ public class AS2MessageTest {
         assertTrue("Unexpected content type for enveloped mime part",
                 ediEntity.getContentType().getValue().startsWith(AS2MediaType.APPLICATION_EDIFACT));
         assertFalse("Enveloped mime type set as main body of request", ediEntity.isMainBody());
+        assertEquals("Unexpected content for enveloped mime part", EDI_MESSAGE.replaceAll("[\n\r]",
""),
+                ediEntity.getEdiMessage().replaceAll("[\n\r]", ""));
 
     }
 


Mime
View raw message