You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2019/07/30 08:03:50 UTC
[camel] branch master updated (f5f968c -> e2397c8)
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.
from f5f968c CAMEL-13797: Move @InvokeOnHeader/@InvokeOnHeaders to org.apache.camel.spi package
new dc2390f Camel-Crypto: Use BindToRegistry annotation wherever possible
new e2397c8 Removed unused imports
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../camel/component/crypto/SignatureTest.java | 54 ++++++++++++----------
.../component/crypto/SpringSignatureTest.java | 10 +---
2 files changed, 31 insertions(+), 33 deletions(-)
[camel] 01/02: Camel-Crypto: Use BindToRegistry annotation wherever
possible
Posted by ac...@apache.org.
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
commit dc2390f85cb4a82655cbdac937dc927deb303ae1
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Jul 29 16:35:37 2019 +0200
Camel-Crypto: Use BindToRegistry annotation wherever possible
---
.../camel/component/crypto/SignatureTest.java | 53 ++++++++++++----------
.../component/crypto/SpringSignatureTest.java | 9 +---
2 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/SignatureTest.java b/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/SignatureTest.java
index 76ec31e..69483ba 100644
--- a/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/SignatureTest.java
+++ b/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/SignatureTest.java
@@ -28,6 +28,7 @@ import java.security.cert.Certificate;
import java.util.Collections;
import java.util.Map;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
@@ -50,22 +51,8 @@ public class SignatureTest extends CamelTestSupport {
private KeyPair keyPair;
private String payload = "Dear Alice, Rest assured it's me, signed Bob";
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry registry = super.createRegistry();
- KeyStore keystore = loadKeystore();
- Certificate cert = keystore.getCertificate("bob");
- KeyStoreParameters keystoreParameters = new KeyStoreParameters();
- keystoreParameters.setPassword("letmein");
- keystoreParameters.setResource("./ks.keystore");
- registry.bind("signatureParams", keystoreParameters);
- registry.bind("keystore", keystore);
- registry.bind("myPublicKey", cert.getPublicKey());
- registry.bind("myCert", cert);
- registry.bind("myPrivateKey", keystore.getKey("bob", "letmein".toCharArray()));
- registry.bind("someRandom", new SecureRandom());
- return registry;
- }
+ @BindToRegistry("someRandom")
+ private SecureRandom random = new SecureRandom();
@Override
protected RouteBuilder[] createRouteBuilders() throws Exception {
@@ -117,13 +104,15 @@ public class SignatureTest extends CamelTestSupport {
}, new RouteBuilder() {
public void configure() throws Exception {
// START SNIPPET: buffersize
- from("direct:buffersize").to("crypto:sign:buffer?privateKey=#myPrivateKey&buffersize=1024", "crypto:verify:buffer?publicKey=#myPublicKey&buffersize=1024", "mock:result");
+ from("direct:buffersize").to("crypto:sign:buffer?privateKey=#myPrivateKey&buffersize=1024", "crypto:verify:buffer?publicKey=#myPublicKey&buffersize=1024",
+ "mock:result");
// END SNIPPET: buffersize
}
}, new RouteBuilder() {
public void configure() throws Exception {
// START SNIPPET: provider
- from("direct:provider").to("crypto:sign:provider?privateKey=#myPrivateKey&provider=SUN", "crypto:verify:provider?publicKey=#myPublicKey&provider=SUN", "mock:result");
+ from("direct:provider").to("crypto:sign:provider?privateKey=#myPrivateKey&provider=SUN", "crypto:verify:provider?publicKey=#myPublicKey&provider=SUN",
+ "mock:result");
// END SNIPPET: provider
}
}, new RouteBuilder() {
@@ -135,14 +124,15 @@ public class SignatureTest extends CamelTestSupport {
}, new RouteBuilder() {
public void configure() throws Exception {
// START SNIPPET: keystore
- from("direct:keystore").to("crypto:sign:keystore?keystore=#keystore&alias=bob&password=letmein", "crypto:verify:keystore?keystore=#keystore&alias=bob", "mock:result");
+ from("direct:keystore").to("crypto:sign:keystore?keystore=#keystore&alias=bob&password=letmein", "crypto:verify:keystore?keystore=#keystore&alias=bob",
+ "mock:result");
// END SNIPPET: keystore
}
}, new RouteBuilder() {
public void configure() throws Exception {
// START SNIPPET: keystore
from("direct:keystoreParameters").to("crypto:sign:keyStoreParameters?keyStoreParameters=#signatureParams&alias=bob&password=letmein",
- "crypto:verify:keyStoreParameters?keyStoreParameters=#signatureParams&alias=bob", "mock:result");
+ "crypto:verify:keyStoreParameters?keyStoreParameters=#signatureParams&alias=bob", "mock:result");
// END SNIPPET: keystore
}
}, new RouteBuilder() {
@@ -155,8 +145,8 @@ public class SignatureTest extends CamelTestSupport {
}, new RouteBuilder() {
public void configure() throws Exception {
// START SNIPPET: random
- from("direct:random").to("crypto:sign:another?privateKey=#myPrivateKey&secureRandom=#someRandom", "crypto:verify:another?publicKey=#myPublicKey&secureRandom=#someRandom",
- "mock:result");
+ from("direct:random").to("crypto:sign:another?privateKey=#myPrivateKey&secureRandom=#someRandom",
+ "crypto:verify:another?publicKey=#myPublicKey&secureRandom=#someRandom", "mock:result");
// END SNIPPET: random
}
}, new RouteBuilder() {
@@ -358,7 +348,7 @@ public class SignatureTest extends CamelTestSupport {
}
public Exchange doTestSignatureRoute(RouteBuilder builder) throws Exception {
- return doSignatureRouteTest(builder, null, Collections.<String, Object>emptyMap());
+ return doSignatureRouteTest(builder, null, Collections.<String, Object> emptyMap());
}
public Exchange doSignatureRouteTest(RouteBuilder builder, Exchange e, Map<String, Object> headers) throws Exception {
@@ -400,6 +390,7 @@ public class SignatureTest extends CamelTestSupport {
return keyGen.generateKeyPair();
}
+ @BindToRegistry("keystore")
public static KeyStore loadKeystore() throws Exception {
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
InputStream in = SignatureTest.class.getResourceAsStream("/ks.keystore");
@@ -407,13 +398,29 @@ public class SignatureTest extends CamelTestSupport {
return keystore;
}
+ @BindToRegistry("myCert")
public Certificate getCertificateFromKeyStore() throws Exception {
Certificate c = loadKeystore().getCertificate("bob");
return c;
}
+ @BindToRegistry("myPublicKey")
+ public PublicKey getPublicKey() throws Exception {
+ Certificate c = loadKeystore().getCertificate("bob");
+ return c.getPublicKey();
+ }
+
+ @BindToRegistry("myPrivateKey")
public PrivateKey getKeyFromKeystore() throws Exception {
return (PrivateKey)loadKeystore().getKey("bob", "letmein".toCharArray());
}
+ @BindToRegistry("signatureParams")
+ public KeyStoreParameters getParams() {
+ KeyStoreParameters keystoreParameters = new KeyStoreParameters();
+ keystoreParameters.setPassword("letmein");
+ keystoreParameters.setResource("./ks.keystore");
+ return keystoreParameters;
+ }
+
}
diff --git a/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/SpringSignatureTest.java b/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/SpringSignatureTest.java
index 5ac05dd..ce88e62 100644
--- a/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/SpringSignatureTest.java
+++ b/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/SpringSignatureTest.java
@@ -29,15 +29,13 @@ import org.apache.camel.impl.JndiRegistry;
import org.apache.camel.spring.SpringCamelContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
-
public class SpringSignatureTest extends SignatureTest {
private static KeyPair rsaPair;
protected CamelContext createCamelContext() throws Exception {
rsaPair = getKeyPair("RSA");
- return SpringCamelContext.springCamelContext(
- new ClassPathXmlApplicationContext("org/apache/camel/component/crypto/SpringSignatureTest.xml"), true);
+ return SpringCamelContext.springCamelContext(new ClassPathXmlApplicationContext("org/apache/camel/component/crypto/SpringSignatureTest.xml"), true);
}
public static KeyStore keystore() throws Exception {
@@ -77,11 +75,6 @@ public class SpringSignatureTest extends SignatureTest {
}
@Override
- protected JndiRegistry createRegistry() throws Exception {
- return super.createRegistry();
- }
-
- @Override
protected RouteBuilder[] createRouteBuilders() throws Exception {
return new RouteBuilder[] {};
}
[camel] 02/02: Removed unused imports
Posted by ac...@apache.org.
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
commit e2397c86c279ec25c2694770ce65fa8bb840611d
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Jul 30 10:02:49 2019 +0200
Removed unused imports
---
.../src/test/java/org/apache/camel/component/crypto/SignatureTest.java | 1 -
.../test/java/org/apache/camel/component/crypto/SpringSignatureTest.java | 1 -
2 files changed, 2 deletions(-)
diff --git a/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/SignatureTest.java b/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/SignatureTest.java
index 69483ba..e3743e9 100644
--- a/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/SignatureTest.java
+++ b/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/SignatureTest.java
@@ -36,7 +36,6 @@ import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.impl.JndiRegistry;
import org.apache.camel.support.jsse.KeyStoreParameters;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Before;
diff --git a/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/SpringSignatureTest.java b/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/SpringSignatureTest.java
index ce88e62..4522074 100644
--- a/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/SpringSignatureTest.java
+++ b/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/SpringSignatureTest.java
@@ -25,7 +25,6 @@ import java.security.cert.Certificate;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.impl.JndiRegistry;
import org.apache.camel.spring.SpringCamelContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;