Search in sources :

Example 16 with SSLContextParameters

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

the class JettyHttpComponent method createConnector.

protected Connector createConnector(Server server, JettyHttpEndpoint endpoint) {
    // now we just use the SelectChannelConnector as the default connector
    SslContextFactory sslcf = null;
    // Note that this was set on the endpoint when it was constructed.  It was
    // either explicitly set at the component or on the endpoint, but either way,
    // the value is already set.  We therefore do not need to look at the component
    // level SSLContextParameters again in this method.
    SSLContextParameters endpointSslContextParameters = endpoint.getSslContextParameters();
    if (endpointSslContextParameters != null) {
        try {
            sslcf = createSslContextFactory(endpointSslContextParameters);
        } catch (Exception e) {
            throw new RuntimeCamelException(e);
        }
    } else if ("https".equals(endpoint.getProtocol())) {
        sslcf = new SslContextFactory();
        String keystoreProperty = System.getProperty(JETTY_SSL_KEYSTORE);
        if (keystoreProperty != null) {
            sslcf.setKeyStorePath(keystoreProperty);
        } else if (sslKeystore != null) {
            sslcf.setKeyStorePath(sslKeystore);
        }
        String keystorePassword = System.getProperty(JETTY_SSL_KEYPASSWORD);
        if (keystorePassword != null) {
            sslcf.setKeyManagerPassword(keystorePassword);
        } else if (sslKeyPassword != null) {
            sslcf.setKeyManagerPassword(sslKeyPassword);
        }
        String password = System.getProperty(JETTY_SSL_PASSWORD);
        if (password != null) {
            sslcf.setKeyStorePassword(password);
        } else if (sslPassword != null) {
            sslcf.setKeyStorePassword(sslPassword);
        }
    }
    return createConnectorJettyInternal(server, endpoint, sslcf);
}
Also used : SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) RuntimeCamelException(org.apache.camel.RuntimeCamelException) URISyntaxException(java.net.URISyntaxException) GeneralSecurityException(java.security.GeneralSecurityException) RuntimeCamelException(org.apache.camel.RuntimeCamelException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) SSLContextParameters(org.apache.camel.util.jsse.SSLContextParameters)

Example 17 with SSLContextParameters

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

the class ExplicitHttpsSslContextParametersRouteTest method createSslSocketConnector.

// START SNIPPET: e2
private Connector createSslSocketConnector(CamelContext context, int port) throws Exception {
    KeyStoreParameters ksp = new KeyStoreParameters();
    ksp.setResource(this.getClass().getClassLoader().getResource("jsse/localhost.ks").toString());
    ksp.setPassword(pwd);
    KeyManagersParameters kmp = new KeyManagersParameters();
    kmp.setKeyPassword(pwd);
    kmp.setKeyStore(ksp);
    SSLContextParameters sslContextParameters = new SSLContextParameters();
    sslContextParameters.setKeyManagers(kmp);
    //return sslSocketConnector;
    return null;
}
Also used : KeyManagersParameters(org.apache.camel.util.jsse.KeyManagersParameters) KeyStoreParameters(org.apache.camel.util.jsse.KeyStoreParameters) SSLContextParameters(org.apache.camel.util.jsse.SSLContextParameters)

Example 18 with SSLContextParameters

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

the class HttpsRouteSslContextParametersInComponentTest method createRouteBuilder.

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

        public void configure() throws URISyntaxException {
            JettyHttpComponent jetty = getContext().getComponent("jetty", JettyHttpComponent.class);
            KeyStoreParameters ksp = new KeyStoreParameters();
            ksp.setResource(this.getClass().getClassLoader().getResource("jsse/localhost.ks").toString());
            ksp.setPassword(pwd);
            KeyManagersParameters kmp = new KeyManagersParameters();
            kmp.setKeyPassword(pwd);
            kmp.setKeyStore(ksp);
            SSLContextParameters sslContextParameters = new SSLContextParameters();
            sslContextParameters.setKeyManagers(kmp);
            jetty.setSslContextParameters(sslContextParameters);
            // NOTE: These are here to check that they are properly ignored.
            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)

Example 19 with SSLContextParameters

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

the class HttpsRouteSslContextParametersInUriTest method createRegistry.

@Override
protected JndiRegistry createRegistry() throws Exception {
    KeyStoreParameters ksp = new KeyStoreParameters();
    ksp.setResource(this.getClass().getClassLoader().getResource("jsse/localhost.ks").toString());
    ksp.setPassword(pwd);
    KeyManagersParameters kmp = new KeyManagersParameters();
    kmp.setKeyPassword(pwd);
    kmp.setKeyStore(ksp);
    SSLContextParameters sslContextParameters = new SSLContextParameters();
    sslContextParameters.setKeyManagers(kmp);
    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) KeyStoreParameters(org.apache.camel.util.jsse.KeyStoreParameters) SSLContextParameters(org.apache.camel.util.jsse.SSLContextParameters)

Example 20 with SSLContextParameters

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

the class FileToFtpsExplicitSSLWithoutClientAuthAndSSLContextParametersTest method createRegistry.

@Override
protected JndiRegistry createRegistry() throws Exception {
    KeyStoreParameters ksp = new KeyStoreParameters();
    ksp.setResource("server.jks");
    ksp.setPassword("password");
    TrustManagersParameters tmp = new TrustManagersParameters();
    tmp.setKeyStore(ksp);
    SSLContextParameters sslContextParameters = new SSLContextParameters();
    sslContextParameters.setSecureSocketProtocol("SSL");
    sslContextParameters.setTrustManagers(tmp);
    JndiRegistry registry = super.createRegistry();
    registry.bind("sslContextParameters", sslContextParameters);
    return registry;
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) TrustManagersParameters(org.apache.camel.util.jsse.TrustManagersParameters) KeyStoreParameters(org.apache.camel.util.jsse.KeyStoreParameters) SSLContextParameters(org.apache.camel.util.jsse.SSLContextParameters)

Aggregations

SSLContextParameters (org.apache.camel.util.jsse.SSLContextParameters)59 KeyStoreParameters (org.apache.camel.util.jsse.KeyStoreParameters)35 KeyManagersParameters (org.apache.camel.util.jsse.KeyManagersParameters)28 TrustManagersParameters (org.apache.camel.util.jsse.TrustManagersParameters)27 JndiRegistry (org.apache.camel.impl.JndiRegistry)19 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)8 IOException (java.io.IOException)7 GeneralSecurityException (java.security.GeneralSecurityException)7 SSLContextServerParameters (org.apache.camel.util.jsse.SSLContextServerParameters)7 RouteBuilder (org.apache.camel.builder.RouteBuilder)6 SSLContext (javax.net.ssl.SSLContext)5 Test (org.junit.Test)4 URI (java.net.URI)3 SalesforceException (org.apache.camel.component.salesforce.api.SalesforceException)3 SalesforceSession (org.apache.camel.component.salesforce.internal.SalesforceSession)3 HttpClient (org.eclipse.jetty.client.HttpClient)3 JdkSslContext (io.netty.handler.ssl.JdkSslContext)2 URISyntaxException (java.net.URISyntaxException)2 CertificateException (java.security.cert.CertificateException)2 X509Certificate (java.security.cert.X509Certificate)2