camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From forstho...@apache.org
Subject camel git commit: CAMEL-11438 spring tests added to crypto-cms
Date Fri, 28 Jul 2017 14:25:02 GMT
Repository: camel
Updated Branches:
  refs/heads/master 8781be036 -> cf9cd31e7


CAMEL-11438 spring tests added to crypto-cms

Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/cf9cd31e
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/cf9cd31e
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/cf9cd31e

Branch: refs/heads/master
Commit: cf9cd31e705628588c774751150422c2bfdd9193
Parents: 8781be0
Author: Franz Forsthofer <franz.forsthofer@sap.com>
Authored: Fri Jul 28 16:21:32 2017 +0200
Committer: Franz Forsthofer <franz.forsthofer@sap.com>
Committed: Fri Jul 28 16:21:32 2017 +0200

----------------------------------------------------------------------
 .../common/DefaultCryptoCmsConfiguration.java   |   2 +-
 .../crypto/cms/sig/DefaultSignerInfo.java       |   4 +-
 .../component/crypto/cms/ComponentTest.java     |   7 +-
 .../crypto/cms/SpringComponentTest.java         |  34 +++++
 .../component/crypto/cms/util/KeystoreUtil.java |   2 +-
 .../src/test/resources/SpringCryptoCmsTests.xml | 123 +++++++++++++++++++
 .../src/test/resources/keystore/system.jks      | Bin 5697 -> 5697 bytes
 7 files changed, 163 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/cf9cd31e/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/common/DefaultCryptoCmsConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/common/DefaultCryptoCmsConfiguration.java
b/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/common/DefaultCryptoCmsConfiguration.java
index 120ee22..7331aa5 100644
--- a/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/common/DefaultCryptoCmsConfiguration.java
+++ b/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/common/DefaultCryptoCmsConfiguration.java
@@ -35,7 +35,7 @@ public abstract class DefaultCryptoCmsConfiguration {
     private KeyStore keyStore;
 
     /**
-     * Keystore containing signer private keys verifier public keys, encryptor
+     * Keystore containing signer private keys, verifier public keys, encryptor
      * public keys, decryptor private keys depending on the operation. Use
      * either this parameter or the parameter 'keystore'.
      */

http://git-wip-us.apache.org/repos/asf/camel/blob/cf9cd31e/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/sig/DefaultSignerInfo.java
----------------------------------------------------------------------
diff --git a/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/sig/DefaultSignerInfo.java
b/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/sig/DefaultSignerInfo.java
index 0a02a03..19480ee 100644
--- a/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/sig/DefaultSignerInfo.java
+++ b/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/sig/DefaultSignerInfo.java
@@ -50,10 +50,10 @@ public class DefaultSignerInfo extends DefaultCryptoCmsConfiguration implements
     @UriParam(label = "sign", defaultValue = "true")
     private boolean includeCertificates = true;
 
-    @UriParam(label = "sign,advanced")
+    @UriParam(label = "sign")
     private CMSAttributeTableGenerator signedAttributeGenerator = new DefaultSignedAttributeTableGenerator();
 
-    @UriParam(label = "sign,advanced", defaultValue = "null")
+    @UriParam(label = "sign", defaultValue = "null")
     private CMSAttributeTableGenerator unsignedAttributeGenerator;
 
     /**

http://git-wip-us.apache.org/repos/asf/camel/blob/cf9cd31e/components/camel-crypto-cms/src/test/java/org/apache/camel/component/crypto/cms/ComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-crypto-cms/src/test/java/org/apache/camel/component/crypto/cms/ComponentTest.java
b/components/camel-crypto-cms/src/test/java/org/apache/camel/component/crypto/cms/ComponentTest.java
index 497aa70..2e7d8c9 100644
--- a/components/camel-crypto-cms/src/test/java/org/apache/camel/component/crypto/cms/ComponentTest.java
+++ b/components/camel-crypto-cms/src/test/java/org/apache/camel/component/crypto/cms/ComponentTest.java
@@ -110,9 +110,8 @@ public class ComponentTest extends CamelTestSupport {
                 recipient.setKeyStoreParameters(keystore);
 
                 DefaultSignerInfo signerInfo = new DefaultSignerInfo();
-                signerInfo.setIncludeCertificates(true); // optional default
-                                                         // value is true
-                signerInfo.setSignatureAlgorithm("SHA256withRSA"); // mandatory
+                signerInfo.setIncludeCertificates(true); 
+                signerInfo.setSignatureAlgorithm("SHA256withRSA"); 
                 signerInfo.setPrivateKeyAlias("rsa");
                 signerInfo.setKeyStoreParameters(keystore);
 
@@ -121,8 +120,6 @@ public class ComponentTest extends CamelTestSupport {
                 signerInfo2.setPrivateKeyAlias("dsa");
                 signerInfo2.setKeyStoreParameters(keystore);
 
-                getContext().addComponent("crypto-cms", new CryptoCmsComponent(getContext()));
-
                 simpleReg.put("keyStoreParameters", keystore);
                 simpleReg.put("signer1", signerInfo);
                 simpleReg.put("signer2", signerInfo2);

http://git-wip-us.apache.org/repos/asf/camel/blob/cf9cd31e/components/camel-crypto-cms/src/test/java/org/apache/camel/component/crypto/cms/SpringComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-crypto-cms/src/test/java/org/apache/camel/component/crypto/cms/SpringComponentTest.java
b/components/camel-crypto-cms/src/test/java/org/apache/camel/component/crypto/cms/SpringComponentTest.java
new file mode 100644
index 0000000..d8ecd70
--- /dev/null
+++ b/components/camel-crypto-cms/src/test/java/org/apache/camel/component/crypto/cms/SpringComponentTest.java
@@ -0,0 +1,34 @@
+package org.apache.camel.component.crypto.cms;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.spring.SpringCamelContext;
+
+public class SpringComponentTest extends ComponentTest {
+
+    protected CamelContext createCamelContext() throws Exception {
+
+        return SpringCamelContext.springCamelContext("SpringCryptoCmsTests.xml");
+    }
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        return super.createRegistry();
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+                // no routes added by default
+            }
+        };
+    }
+
+    @Override
+    protected RouteBuilder[] createRouteBuilders() throws Exception {
+        return new RouteBuilder[] {};
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/cf9cd31e/components/camel-crypto-cms/src/test/java/org/apache/camel/component/crypto/cms/util/KeystoreUtil.java
----------------------------------------------------------------------
diff --git a/components/camel-crypto-cms/src/test/java/org/apache/camel/component/crypto/cms/util/KeystoreUtil.java
b/components/camel-crypto-cms/src/test/java/org/apache/camel/component/crypto/cms/util/KeystoreUtil.java
index 4381229..0798cac 100644
--- a/components/camel-crypto-cms/src/test/java/org/apache/camel/component/crypto/cms/util/KeystoreUtil.java
+++ b/components/camel-crypto-cms/src/test/java/org/apache/camel/component/crypto/cms/util/KeystoreUtil.java
@@ -32,7 +32,7 @@ public final class KeystoreUtil {
         if (keystoreName.startsWith("test")) {
             pw = "abcd1234";
         } else {
-            pw = "";
+            pw = "Abcd1234";
         }
         keystorePas.setPassword(pw);
         return keystorePas;

http://git-wip-us.apache.org/repos/asf/camel/blob/cf9cd31e/components/camel-crypto-cms/src/test/resources/SpringCryptoCmsTests.xml
----------------------------------------------------------------------
diff --git a/components/camel-crypto-cms/src/test/resources/SpringCryptoCmsTests.xml b/components/camel-crypto-cms/src/test/resources/SpringCryptoCmsTests.xml
new file mode 100644
index 0000000..69ac433
--- /dev/null
+++ b/components/camel-crypto-cms/src/test/resources/SpringCryptoCmsTests.xml
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 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. -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+    <camelContext id="camel"
+        xmlns="http://camel.apache.org/schema/spring">
+        <onException>
+            <exception>org.apache.camel.component.crypto.cms.exception.CryptoCmsVerifierCertificateNotValidException
+            </exception>
+            <handled>
+                <constant>false</constant>
+            </handled>
+            <to uri="mock:exception" />
+        </onException>
+
+        <!-- START SNIPPET: two-signer -->
+        <route>
+            <from uri="direct:start" />
+            <to
+                uri="crypto-cms:sign://testsign?signer=#signer1&amp;signer=#signer2&amp;includeContent=true"
/>
+            <to
+                uri="crypto-cms:encrypt://testencrpyt?toBase64=true&amp;recipient=#recipient1&amp;contentEncryptionAlgorithm=DESede/CBC/PKCS5Padding&amp;secretKeyLength=128"
/>
+            <to
+                uri="crypto-cms:decrypt://testdecrypt?fromBase64=true&amp;keyStoreParameters=#keyStoreParameters1"
/>
+            <to
+                uri="crypto-cms:verify://testverify?keyStoreParameters=#keyStoreParameters1"
/>
+            <to uri="mock:result" />
+        </route>
+        <!-- END SNIPPET: two-signer -->
+
+
+        <!-- START SNIPPET: outdated -->
+        <route>
+            <from uri="direct:outdated" />
+            <to
+                uri="crypto-cms:sign://outdated?signer=#signerOutdated&amp;includeContent=true"
/>
+            <to
+                uri="crypto-cms:verify://testverify?keyStoreParameters=#keyStoreParameters1"
/>
+            <to uri="mock:result" />
+        </route>
+        <!-- END SNIPPET: outdated -->
+
+        <!-- START SNIPPET: decryptAndVerify -->
+        <route>
+            <from uri="direct:decryptAndVerify" />
+            <to
+                uri="crypto-cms:decrypt://testdecrypt?fromBase64=true&amp;keyStoreParameters=#keyStoreParameters1"
/>
+            <to
+                uri="crypto-cms:verify://testverify?keyStoreParameters=#keyStoreParameters1"
/>
+            <to uri="mock:result" />
+        </route>
+        <!-- END SNIPPET: decryptAndVerify -->
+
+        <!-- START SNIPPET: encryptDecryptOriginatorAttributes -->
+        <route>
+            <from uri="direct:encryptDecryptOriginatorAttributes" />
+            <to
+                uri="crypto-cms:encrypt://testencrpyt?toBase64=true&amp;recipient=#recipient1&amp;contentEncryptionAlgorithm=DESede/CBC/PKCS5Padding&amp;secretKeyLength=128&amp;originatorInformationProvider=#originatorInformationProvider1&amp;unprotectedAttributesGeneratorProvider=#attributesGeneratorProvider1"
/>
+            <to
+                uri="crypto-cms:decrypt://testdecrypt?fromBase64=true&amp;keyStoreParameters=#keyStoreParameters1"
/>
+            <to uri="mock:result" />
+        </route>
+        <!-- END SNIPPET: encryptDecryptOriginatorAttributes -->
+
+
+    </camelContext>
+
+    <keyStoreParameters xmlns="http://camel.apache.org/schema/spring"
+        id="keyStoreParameters1" resource="./keystore/system.jks"
+        password="Abcd1234" type="JCEKS" />
+
+    <bean id="recipient1"
+        class="org.apache.camel.component.crypto.cms.crypt.DefaultKeyTransRecipientInfo">
+        <property name="keyStoreParameters" ref="keyStoreParameters1" />
+        <property name="certificateAlias" value="rsa" />
+    </bean>
+
+    <bean id="signer1"
+        class="org.apache.camel.component.crypto.cms.sig.DefaultSignerInfo">
+        <property name="keyStoreParameters" ref="keyStoreParameters1" />
+        <property name="privateKeyAlias" value="rsa" />
+        <property name="signatureAlgorithm" value="SHA256withRSA" />
+        <property name="includeCertificates" value="true" />
+    </bean>
+
+    <bean id="signer2"
+        class="org.apache.camel.component.crypto.cms.sig.DefaultSignerInfo">
+        <property name="keyStoreParameters" ref="keyStoreParameters1" />
+        <property name="privateKeyAlias" value="dsa" />
+        <property name="signatureAlgorithm" value="SHA256withDSA" />
+    </bean>
+
+    <bean id="signerOutdated"
+        class="org.apache.camel.component.crypto.cms.sig.DefaultSignerInfo">
+        <property name="keyStoreParameters" ref="keyStoreParameters1" />
+        <property name="privateKeyAlias" value="outdated" />
+        <property name="signatureAlgorithm" value="SHA1withRSA" />
+        <property name="includeCertificates" value="false" />
+    </bean>
+
+    <bean id="originatorInformationProvider1"
+        class="org.apache.camel.component.crypto.cms.util.TestOriginatorInformationProvider"
/>
+
+    <bean id="attributesGeneratorProvider1"
+        class="org.apache.camel.component.crypto.cms.util.TestAttributesGeneratorProvider"
/>
+
+
+
+</beans>

http://git-wip-us.apache.org/repos/asf/camel/blob/cf9cd31e/components/camel-crypto-cms/src/test/resources/keystore/system.jks
----------------------------------------------------------------------
diff --git a/components/camel-crypto-cms/src/test/resources/keystore/system.jks b/components/camel-crypto-cms/src/test/resources/keystore/system.jks
index c9f894e..510c3a2 100644
Binary files a/components/camel-crypto-cms/src/test/resources/keystore/system.jks and b/components/camel-crypto-cms/src/test/resources/keystore/system.jks
differ


Mime
View raw message