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;
}
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);
}
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;
}
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;
}
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);
}
}
Aggregations