Search in sources :

Example 41 with KeyStoreParameters

use of org.apache.camel.util.jsse.KeyStoreParameters in project camel by apache.

the class XMLSecurityDataFormatTest method testAsymmetricEncryptionAlgorithmPartialPayloadElement.

@Test
public void testAsymmetricEncryptionAlgorithmPartialPayloadElement() throws Exception {
    final KeyStoreParameters tsParameters = new KeyStoreParameters();
    tsParameters.setPassword("password");
    tsParameters.setResource("sender.ts");
    final KeyStoreParameters ksParameters = new KeyStoreParameters();
    ksParameters.setPassword("password");
    ksParameters.setResource("recipient.ks");
    // RSA v1.5 is not allowed unless explicitly configured
    context.addRoutes(new RouteBuilder() {

        public void configure() {
            from("direct:start").marshal().secureXML("//cheesesites/france/cheese", false, "recipient", testCypherAlgorithm, XMLCipher.RSA_v1dot5, tsParameters).to("mock:encrypted").unmarshal().secureXML("//cheesesites/france", false, "recipient", testCypherAlgorithm, XMLCipher.RSA_OAEP, ksParameters).to("mock:decrypted");
        }
    });
    MockEndpoint resultEndpoint = context.getEndpoint("mock:decrypted", MockEndpoint.class);
    resultEndpoint.setExpectedMessageCount(0);
    // verify that the message was encrypted before checking that it is decrypted
    xmlsecTestHelper.testEncryption(TestHelper.XML_FRAGMENT, context);
    resultEndpoint.assertIsSatisfied(100);
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) KeyStoreParameters(org.apache.camel.util.jsse.KeyStoreParameters) Test(org.junit.Test)

Example 42 with KeyStoreParameters

use of org.apache.camel.util.jsse.KeyStoreParameters in project camel by apache.

the class WebsocketSSLContextInUriRouteExampleTest method createRegistry.

@Override
protected JndiRegistry createRegistry() throws Exception {
    KeyStoreParameters ksp = new KeyStoreParameters();
    ksp.setResource("jsse/localhost.ks");
    ksp.setPassword(pwd);
    KeyManagersParameters kmp = new KeyManagersParameters();
    kmp.setKeyPassword(pwd);
    kmp.setKeyStore(ksp);
    TrustManagersParameters tmp = new TrustManagersParameters();
    tmp.setKeyStore(ksp);
    // NOTE: Needed since the client uses a loose trust configuration when no ssl context
    // is provided.  We turn on WANT client-auth to prefer using authentication
    SSLContextServerParameters scsp = new SSLContextServerParameters();
    SSLContextParameters sslContextParameters = new SSLContextParameters();
    sslContextParameters.setKeyManagers(kmp);
    sslContextParameters.setTrustManagers(tmp);
    sslContextParameters.setServerParameters(scsp);
    JndiRegistry registry = super.createRegistry();
    registry.bind("sslContextParameters", sslContextParameters);
    return registry;
}
Also used : KeyManagersParameters(org.apache.camel.util.jsse.KeyManagersParameters) JndiRegistry(org.apache.camel.impl.JndiRegistry) TrustManagersParameters(org.apache.camel.util.jsse.TrustManagersParameters) KeyStoreParameters(org.apache.camel.util.jsse.KeyStoreParameters) SSLContextServerParameters(org.apache.camel.util.jsse.SSLContextServerParameters) SSLContextParameters(org.apache.camel.util.jsse.SSLContextParameters)

Example 43 with KeyStoreParameters

use of org.apache.camel.util.jsse.KeyStoreParameters in project camel by apache.

the class WebsocketSSLRouteExampleTest method defineSSLContextParameters.

protected SSLContextParameters defineSSLContextParameters() {
    KeyStoreParameters ksp = new KeyStoreParameters();
    // ksp.setResource(this.getClass().getClassLoader().getResource("jsse/localhost.ks").toString());
    ksp.setResource("jsse/localhost.ks");
    ksp.setPassword(pwd);
    KeyManagersParameters kmp = new KeyManagersParameters();
    kmp.setKeyPassword(pwd);
    kmp.setKeyStore(ksp);
    TrustManagersParameters tmp = new TrustManagersParameters();
    tmp.setKeyStore(ksp);
    // NOTE: Needed since the client uses a loose trust configuration when no ssl context
    // is provided.  We turn on WANT client-auth to prefer using authentication
    SSLContextServerParameters scsp = new SSLContextServerParameters();
    SSLContextParameters sslContextParameters = new SSLContextParameters();
    sslContextParameters.setKeyManagers(kmp);
    sslContextParameters.setTrustManagers(tmp);
    sslContextParameters.setServerParameters(scsp);
    return sslContextParameters;
}
Also used : KeyManagersParameters(org.apache.camel.util.jsse.KeyManagersParameters) TrustManagersParameters(org.apache.camel.util.jsse.TrustManagersParameters) KeyStoreParameters(org.apache.camel.util.jsse.KeyStoreParameters) SSLContextServerParameters(org.apache.camel.util.jsse.SSLContextServerParameters) SSLContextParameters(org.apache.camel.util.jsse.SSLContextParameters)

Example 44 with KeyStoreParameters

use of org.apache.camel.util.jsse.KeyStoreParameters in project camel by apache.

the class StompBaseTest method getSSLContextParameters.

private SSLContextParameters getSSLContextParameters(String path, String password) {
    KeyStoreParameters ksp = new KeyStoreParameters();
    ksp.setResource(path);
    ksp.setPassword(password);
    KeyManagersParameters kmp = new KeyManagersParameters();
    kmp.setKeyPassword(password);
    kmp.setKeyStore(ksp);
    TrustManagersParameters tmp = new TrustManagersParameters();
    tmp.setKeyStore(ksp);
    SSLContextParameters sslContextParameters = new SSLContextParameters();
    sslContextParameters.setKeyManagers(kmp);
    sslContextParameters.setTrustManagers(tmp);
    return sslContextParameters;
}
Also used : KeyManagersParameters(org.apache.camel.util.jsse.KeyManagersParameters) TrustManagersParameters(org.apache.camel.util.jsse.TrustManagersParameters) KeyStoreParameters(org.apache.camel.util.jsse.KeyStoreParameters) SSLContextParameters(org.apache.camel.util.jsse.SSLContextParameters)

Example 45 with KeyStoreParameters

use of org.apache.camel.util.jsse.KeyStoreParameters in project camel by apache.

the class HttpsRouteAliasTest method createRouteBuilder.

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        public void configure() throws URISyntaxException {
            JettyHttpComponent jetty = context.getComponent("jetty", JettyHttpComponent.class);
            KeyStoreParameters ksp = new KeyStoreParameters();
            ksp.setResource(this.getClass().getClassLoader().getResource("jsse/localhost-alias.ks").toString());
            ksp.setPassword(pwd);
            KeyManagersParameters kmp = new KeyManagersParameters();
            kmp.setKeyPassword(pwd);
            kmp.setKeyStore(ksp);
            SSLContextParameters sslContextParameters = new SSLContextParameters();
            sslContextParameters.setKeyManagers(kmp);
            // Specify "server" cert alias
            sslContextParameters.setCertAlias("server");
            jetty.setSslContextParameters(sslContextParameters);
            setSSLProps(jetty, "", "asdfasdfasdfdasfs", "sadfasdfasdfas");
            from("jetty:https://localhost:" + port1 + "/test").to("mock:a");
            Processor proc = new Processor() {

                public void process(Exchange exchange) throws Exception {
                    exchange.getOut().setBody("<b>Hello World</b>");
                }
            };
            from("jetty:https://localhost:" + port1 + "/hello").process(proc);
            from("jetty:https://localhost:" + port2 + "/test").to("mock:b");
        }
    };
}
Also used : KeyManagersParameters(org.apache.camel.util.jsse.KeyManagersParameters) Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) RouteBuilder(org.apache.camel.builder.RouteBuilder) KeyStoreParameters(org.apache.camel.util.jsse.KeyStoreParameters) SSLContextParameters(org.apache.camel.util.jsse.SSLContextParameters)

Aggregations

KeyStoreParameters (org.apache.camel.util.jsse.KeyStoreParameters)57 SSLContextParameters (org.apache.camel.util.jsse.SSLContextParameters)31 KeyManagersParameters (org.apache.camel.util.jsse.KeyManagersParameters)25 RouteBuilder (org.apache.camel.builder.RouteBuilder)24 TrustManagersParameters (org.apache.camel.util.jsse.TrustManagersParameters)24 Test (org.junit.Test)21 JndiRegistry (org.apache.camel.impl.JndiRegistry)17 SSLContextServerParameters (org.apache.camel.util.jsse.SSLContextServerParameters)7 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)4 HashMap (java.util.HashMap)3 Exchange (org.apache.camel.Exchange)3 Processor (org.apache.camel.Processor)3 IOException (java.io.IOException)2 GeneralSecurityException (java.security.GeneralSecurityException)2 KeyStore (java.security.KeyStore)2 Document (org.w3c.dom.Document)2 NodeList (org.w3c.dom.NodeList)2 PrivateKey (java.security.PrivateKey)1 Signature (java.security.Signature)1 Certificate (java.security.cert.Certificate)1