Search in sources :

Example 1 with KeyStoreParameters

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

the class MailTestHelper method createSslContextParameters.

public static SSLContextParameters createSslContextParameters() {
    KeyStoreParameters ksp = new KeyStoreParameters();
    ksp.setResource(MailTestHelper.class.getClassLoader().getResource("jsse/localhost.ks").toString());
    ksp.setPassword(KEY_STORE_PASSWORD);
    KeyManagersParameters kmp = new KeyManagersParameters();
    kmp.setKeyPassword(KEY_STORE_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 2 with KeyStoreParameters

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

the class BaseMina2Test method addSslContextParametersToRegistry.

protected void addSslContextParametersToRegistry(JndiRegistry registry) {
    KeyStoreParameters ksp = new KeyStoreParameters();
    ksp.setResource(this.getClass().getClassLoader().getResource("jsse/localhost.ks").toString());
    ksp.setPassword(KEY_STORE_PASSWORD);
    KeyManagersParameters kmp = new KeyManagersParameters();
    kmp.setKeyPassword(KEY_STORE_PASSWORD);
    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();
    scsp.setClientAuthentication(ClientAuthentication.WANT.name());
    SSLContextParameters sslContextParameters = new SSLContextParameters();
    sslContextParameters.setKeyManagers(kmp);
    sslContextParameters.setTrustManagers(tmp);
    sslContextParameters.setServerParameters(scsp);
    registry.bind("sslContextParameters", 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 3 with KeyStoreParameters

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

the class RestletHttpsWithSSLContextParametersTest method createRegistry.

@Override
protected JndiRegistry createRegistry() throws Exception {
    KeyStoreParameters ksp = new KeyStoreParameters();
    ksp.setResource(this.getClass().getClassLoader().getResource("jsse/localhost.ks").getPath().toString());
    ksp.setPassword("changeit");
    KeyManagersParameters kmp = new KeyManagersParameters();
    kmp.setKeyPassword("changeit");
    kmp.setKeyStore(ksp);
    SSLContextParameters sslContextParameters = new SSLContextParameters();
    sslContextParameters.setKeyManagers(kmp);
    JndiRegistry registry = super.createRegistry();
    registry.bind("mySSLContextParameters", 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 4 with KeyStoreParameters

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

the class NatsProducerTLSTest method createSSLContextParameters.

private SSLContextParameters createSSLContextParameters() {
    SSLContextParameters sslContextParameters = new SSLContextParameters();
    KeyManagersParameters keyManagersParameters = new KeyManagersParameters();
    KeyStoreParameters keyStore = new KeyStoreParameters();
    keyStore.setPassword("password");
    keyStore.setResource("org/apache/camel/component/nats/keystore.jks");
    keyManagersParameters.setKeyPassword("password");
    keyManagersParameters.setKeyStore(keyStore);
    sslContextParameters.setKeyManagers(keyManagersParameters);
    return sslContextParameters;
}
Also used : KeyManagersParameters(org.apache.camel.util.jsse.KeyManagersParameters) KeyStoreParameters(org.apache.camel.util.jsse.KeyStoreParameters) SSLContextParameters(org.apache.camel.util.jsse.SSLContextParameters)

Example 5 with KeyStoreParameters

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

the class NettySSLContextParametersTest method createRegistry.

@Override
protected JndiRegistry createRegistry() throws Exception {
    KeyStoreParameters ksp = new KeyStoreParameters();
    ksp.setResource(this.getClass().getClassLoader().getResource("keystore.jks").toString());
    ksp.setPassword("changeit");
    KeyManagersParameters kmp = new KeyManagersParameters();
    kmp.setKeyPassword("changeit");
    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();
    scsp.setClientAuthentication(ClientAuthentication.WANT.name());
    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)

Aggregations

KeyStoreParameters (org.apache.camel.util.jsse.KeyStoreParameters)64 SSLContextParameters (org.apache.camel.util.jsse.SSLContextParameters)35 KeyManagersParameters (org.apache.camel.util.jsse.KeyManagersParameters)29 TrustManagersParameters (org.apache.camel.util.jsse.TrustManagersParameters)28 RouteBuilder (org.apache.camel.builder.RouteBuilder)26 Test (org.junit.Test)23 JndiRegistry (org.apache.camel.impl.JndiRegistry)17 SSLContextServerParameters (org.apache.camel.util.jsse.SSLContextServerParameters)7 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)6 IOException (java.io.IOException)3 GeneralSecurityException (java.security.GeneralSecurityException)3 KeyStore (java.security.KeyStore)3 HashMap (java.util.HashMap)3 CamelContext (org.apache.camel.CamelContext)3 Exchange (org.apache.camel.Exchange)3 Processor (org.apache.camel.Processor)3 Certificate (java.security.cert.Certificate)2 CertificateException (java.security.cert.CertificateException)2 X509Certificate (java.security.cert.X509Certificate)2 X509TrustManager (javax.net.ssl.X509TrustManager)2