Search in sources :

Example 1 with SSLContextParameters

use of org.apache.camel.util.jsse.SSLContextParameters 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 SSLContextParameters

use of org.apache.camel.util.jsse.SSLContextParameters 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 SSLContextParameters

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

the class Olingo2Component method createOlingo2App.

private Olingo2AppWrapper createOlingo2App(Olingo2Configuration configuration) {
    Object clientBuilder = configuration.getHttpAsyncClientBuilder();
    if (clientBuilder == null) {
        HttpAsyncClientBuilder asyncClientBuilder = HttpAsyncClientBuilder.create();
        // apply simple configuration properties
        final RequestConfig.Builder requestConfigBuilder = RequestConfig.custom();
        requestConfigBuilder.setConnectTimeout(configuration.getConnectTimeout());
        requestConfigBuilder.setSocketTimeout(configuration.getSocketTimeout());
        final HttpHost proxy = configuration.getProxy();
        if (proxy != null) {
            requestConfigBuilder.setProxy(proxy);
        }
        // set default request config
        asyncClientBuilder.setDefaultRequestConfig(requestConfigBuilder.build());
        SSLContextParameters sslContextParameters = configuration.getSslContextParameters();
        if (sslContextParameters == null) {
            // use defaults if not specified
            sslContextParameters = new SSLContextParameters();
        }
        try {
            asyncClientBuilder.setSSLContext(sslContextParameters.createSSLContext(getCamelContext()));
        } catch (GeneralSecurityException e) {
            throw ObjectHelper.wrapRuntimeCamelException(e);
        } catch (IOException e) {
            throw ObjectHelper.wrapRuntimeCamelException(e);
        }
    }
    Olingo2AppImpl olingo2App;
    if (clientBuilder == null || clientBuilder instanceof HttpAsyncClientBuilder) {
        olingo2App = new Olingo2AppImpl(configuration.getServiceUri(), (HttpAsyncClientBuilder) clientBuilder);
    } else {
        olingo2App = new Olingo2AppImpl(configuration.getServiceUri(), (HttpClientBuilder) clientBuilder);
    }
    apiProxy = new Olingo2AppWrapper(olingo2App);
    apiProxy.getOlingo2App().setContentType(configuration.getContentType());
    apiProxy.getOlingo2App().setHttpHeaders(configuration.getHttpHeaders());
    return apiProxy;
}
Also used : RequestConfig(org.apache.http.client.config.RequestConfig) Olingo2AppImpl(org.apache.camel.component.olingo2.api.impl.Olingo2AppImpl) HttpHost(org.apache.http.HttpHost) GeneralSecurityException(java.security.GeneralSecurityException) IOException(java.io.IOException) HttpClientBuilder(org.apache.http.impl.client.HttpClientBuilder) HttpAsyncClientBuilder(org.apache.http.impl.nio.client.HttpAsyncClientBuilder) SSLContextParameters(org.apache.camel.util.jsse.SSLContextParameters)

Example 4 with SSLContextParameters

use of org.apache.camel.util.jsse.SSLContextParameters 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 5 with SSLContextParameters

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

the class ServiceNowClient method configureTls.

private static void configureTls(CamelContext camelContext, ServiceNowConfiguration configuration, WebClient client) throws Exception {
    SSLContextParameters sslContextParams = configuration.getSslContextParameters();
    if (sslContextParams != null) {
        HTTPConduit conduit = WebClient.getConfig(client).getHttpConduit();
        TLSClientParameters tlsClientParams = conduit.getTlsClientParameters();
        if (tlsClientParams == null) {
            tlsClientParams = new TLSClientParameters();
        }
        SSLContext sslContext = sslContextParams.createSSLContext(camelContext);
        tlsClientParams.setSSLSocketFactory(sslContext.getSocketFactory());
        conduit.setTlsClientParameters(tlsClientParams);
    }
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) TLSClientParameters(org.apache.cxf.configuration.jsse.TLSClientParameters) SSLContext(javax.net.ssl.SSLContext) 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