You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2013/09/16 11:40:14 UTC

[1/2] git commit: Skip test if cannot run on platform due security provider not supporting ECDSA.

Updated Branches:
  refs/heads/camel-2.12.x 075422229 -> 4db3d9e12
  refs/heads/master bdb3faff2 -> 89c61cacc


Skip test if cannot run on platform due security provider not supporting ECDSA.


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

Branch: refs/heads/master
Commit: 89c61caccc6f2138c1b20e4ff3d92daa8acee613
Parents: bdb3faf
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Sep 16 11:39:41 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Sep 16 11:39:41 2013 +0200

----------------------------------------------------------------------
 .../component/crypto/ECDSASignatureTest.java    | 40 ++++++++++++++------
 1 file changed, 28 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/89c61cac/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/ECDSASignatureTest.java
----------------------------------------------------------------------
diff --git a/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/ECDSASignatureTest.java b/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/ECDSASignatureTest.java
index 4f8760f..b24988c 100644
--- a/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/ECDSASignatureTest.java
+++ b/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/ECDSASignatureTest.java
@@ -40,12 +40,15 @@ public class ECDSASignatureTest extends CamelTestSupport {
 
     private String payload = "Dear Alice, Rest assured it's me, signed Bob";
     private boolean ibmJDK;
+    private PrivateKey privateKey;
+    private X509Certificate x509;
+    private boolean canRun = true;
 
     public ECDSASignatureTest() throws Exception {
         // BouncyCastle is required for ECDSA support for JDK 1.6
         if (isJava16()
             && Security.getProvider("BC") == null) {
-            Constructor<?> cons = null;
+            Constructor<?> cons;
             Class<?> c = Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider");
             cons = c.getConstructor(new Class[] {});
             
@@ -57,28 +60,40 @@ public class ECDSASignatureTest extends CamelTestSupport {
         if (isJavaVendor("IBM")) {
             ibmJDK = true;
         }
+
+        // see if we can load the keystore et all
+        try {
+            KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
+            InputStream in = ECDSASignatureTest.class.getResourceAsStream("/org/apache/camel/component/crypto/ecdsa.jks");
+            keyStore.load(in, "security".toCharArray());
+            privateKey = (PrivateKey) keyStore.getKey("ECDSA", "security".toCharArray());
+            x509 = (X509Certificate)keyStore.getCertificate("ECDSA");
+        } catch (Throwable e) {
+            log.warn("Cannot setup keystore for running this test due " + e.getMessage() + ". This test is skipped.", e);
+            canRun = false;
+        }
     }
     
     @Override
     protected RouteBuilder[] createRouteBuilders() throws Exception {
-        if (ibmJDK) {
+        if (ibmJDK || !canRun) {
             return new RouteBuilder[] {};
         }
 
         return new RouteBuilder[]{new RouteBuilder() {
             public void configure() throws Exception {
                 // START SNIPPET: ecdsa-sha1
-                KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
-                InputStream in = ECDSASignatureTest.class.getResourceAsStream("/org/apache/camel/component/crypto/ecdsa.jks");
-                keyStore.load(in, "security".toCharArray());
-                PrivateKey privateKey = 
-                    (PrivateKey)keyStore.getKey("ECDSA", "security".toCharArray());
-                X509Certificate x509 = (X509Certificate)keyStore.getCertificate("ECDSA");
 
                 // we can set the keys explicitly on the endpoint instances.
-                context.getEndpoint("crypto:sign://ecdsa-sha1?algorithm=SHA1withECDSA", DigitalSignatureEndpoint.class).setPrivateKey(privateKey);
-                context.getEndpoint("crypto:verify://ecdsa-sha1?algorithm=SHA1withECDSA", DigitalSignatureEndpoint.class).setPublicKey(x509.getPublicKey());
-                from("direct:ecdsa-sha1").to("crypto:sign://ecdsa-sha1?algorithm=SHA1withECDSA", "crypto:verify://ecdsa-sha1?algorithm=SHA1withECDSA", "mock:result");
+                context.getEndpoint("crypto:sign://ecdsa-sha1?algorithm=SHA1withECDSA", DigitalSignatureEndpoint.class)
+                        .setPrivateKey(privateKey);
+                context.getEndpoint("crypto:verify://ecdsa-sha1?algorithm=SHA1withECDSA", DigitalSignatureEndpoint.class)
+                        .setPublicKey(x509.getPublicKey());
+
+                from("direct:ecdsa-sha1")
+                    .to("crypto:sign://ecdsa-sha1?algorithm=SHA1withECDSA")
+                    .to("crypto:verify://ecdsa-sha1?algorithm=SHA1withECDSA")
+                    .to("mock:result");
                 // END SNIPPET: ecdsa-sha1
             }
         }};
@@ -86,9 +101,10 @@ public class ECDSASignatureTest extends CamelTestSupport {
 
     @Test
     public void testECDSASHA1() throws Exception {
-        if (ibmJDK) {
+        if (ibmJDK || !canRun) {
             return;
         }
+
         setupMock();
         sendBody("direct:ecdsa-sha1", payload);
         assertMockEndpointsSatisfied();


[2/2] git commit: Skip test if cannot run on platform due security provider not supporting ECDSA.

Posted by da...@apache.org.
Skip test if cannot run on platform due security provider not supporting ECDSA.


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

Branch: refs/heads/camel-2.12.x
Commit: 4db3d9e12dd74c4ecef68ddcbfc5b29dc713bc3b
Parents: 0754222
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Sep 16 11:39:41 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Sep 16 11:39:57 2013 +0200

----------------------------------------------------------------------
 .../component/crypto/ECDSASignatureTest.java    | 40 ++++++++++++++------
 1 file changed, 28 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/4db3d9e1/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/ECDSASignatureTest.java
----------------------------------------------------------------------
diff --git a/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/ECDSASignatureTest.java b/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/ECDSASignatureTest.java
index 4f8760f..b24988c 100644
--- a/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/ECDSASignatureTest.java
+++ b/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/ECDSASignatureTest.java
@@ -40,12 +40,15 @@ public class ECDSASignatureTest extends CamelTestSupport {
 
     private String payload = "Dear Alice, Rest assured it's me, signed Bob";
     private boolean ibmJDK;
+    private PrivateKey privateKey;
+    private X509Certificate x509;
+    private boolean canRun = true;
 
     public ECDSASignatureTest() throws Exception {
         // BouncyCastle is required for ECDSA support for JDK 1.6
         if (isJava16()
             && Security.getProvider("BC") == null) {
-            Constructor<?> cons = null;
+            Constructor<?> cons;
             Class<?> c = Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider");
             cons = c.getConstructor(new Class[] {});
             
@@ -57,28 +60,40 @@ public class ECDSASignatureTest extends CamelTestSupport {
         if (isJavaVendor("IBM")) {
             ibmJDK = true;
         }
+
+        // see if we can load the keystore et all
+        try {
+            KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
+            InputStream in = ECDSASignatureTest.class.getResourceAsStream("/org/apache/camel/component/crypto/ecdsa.jks");
+            keyStore.load(in, "security".toCharArray());
+            privateKey = (PrivateKey) keyStore.getKey("ECDSA", "security".toCharArray());
+            x509 = (X509Certificate)keyStore.getCertificate("ECDSA");
+        } catch (Throwable e) {
+            log.warn("Cannot setup keystore for running this test due " + e.getMessage() + ". This test is skipped.", e);
+            canRun = false;
+        }
     }
     
     @Override
     protected RouteBuilder[] createRouteBuilders() throws Exception {
-        if (ibmJDK) {
+        if (ibmJDK || !canRun) {
             return new RouteBuilder[] {};
         }
 
         return new RouteBuilder[]{new RouteBuilder() {
             public void configure() throws Exception {
                 // START SNIPPET: ecdsa-sha1
-                KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
-                InputStream in = ECDSASignatureTest.class.getResourceAsStream("/org/apache/camel/component/crypto/ecdsa.jks");
-                keyStore.load(in, "security".toCharArray());
-                PrivateKey privateKey = 
-                    (PrivateKey)keyStore.getKey("ECDSA", "security".toCharArray());
-                X509Certificate x509 = (X509Certificate)keyStore.getCertificate("ECDSA");
 
                 // we can set the keys explicitly on the endpoint instances.
-                context.getEndpoint("crypto:sign://ecdsa-sha1?algorithm=SHA1withECDSA", DigitalSignatureEndpoint.class).setPrivateKey(privateKey);
-                context.getEndpoint("crypto:verify://ecdsa-sha1?algorithm=SHA1withECDSA", DigitalSignatureEndpoint.class).setPublicKey(x509.getPublicKey());
-                from("direct:ecdsa-sha1").to("crypto:sign://ecdsa-sha1?algorithm=SHA1withECDSA", "crypto:verify://ecdsa-sha1?algorithm=SHA1withECDSA", "mock:result");
+                context.getEndpoint("crypto:sign://ecdsa-sha1?algorithm=SHA1withECDSA", DigitalSignatureEndpoint.class)
+                        .setPrivateKey(privateKey);
+                context.getEndpoint("crypto:verify://ecdsa-sha1?algorithm=SHA1withECDSA", DigitalSignatureEndpoint.class)
+                        .setPublicKey(x509.getPublicKey());
+
+                from("direct:ecdsa-sha1")
+                    .to("crypto:sign://ecdsa-sha1?algorithm=SHA1withECDSA")
+                    .to("crypto:verify://ecdsa-sha1?algorithm=SHA1withECDSA")
+                    .to("mock:result");
                 // END SNIPPET: ecdsa-sha1
             }
         }};
@@ -86,9 +101,10 @@ public class ECDSASignatureTest extends CamelTestSupport {
 
     @Test
     public void testECDSASHA1() throws Exception {
-        if (ibmJDK) {
+        if (ibmJDK || !canRun) {
             return;
         }
+
         setupMock();
         sendBody("direct:ecdsa-sha1", payload);
         assertMockEndpointsSatisfied();