use of org.apache.camel.util.jsse.SSLContextParameters in project camel by apache.
the class WebsocketComponent method createEndpoint.
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
// TODO cmueller: remove the "sslContextParametersRef" look up in Camel 3.0
SSLContextParameters sslContextParameters = resolveAndRemoveReferenceParameter(parameters, "sslContextParametersRef", SSLContextParameters.class);
if (sslContextParameters == null) {
sslContextParameters = resolveAndRemoveReferenceParameter(parameters, "sslContextParameters", SSLContextParameters.class);
}
Boolean enableJmx = getAndRemoveParameter(parameters, "enableJmx", Boolean.class);
String staticResources = getAndRemoveParameter(parameters, "staticResources", String.class);
int port = extractPortNumber(remaining);
String host = extractHostName(remaining);
WebsocketEndpoint endpoint = new WebsocketEndpoint(this, uri, remaining, parameters);
if (enableJmx != null) {
endpoint.setEnableJmx(enableJmx);
} else {
endpoint.setEnableJmx(isEnableJmx());
}
// prefer to use endpoint configured over component configured
if (sslContextParameters == null) {
// fallback to component configured
sslContextParameters = getSslContextParameters();
}
if (sslContextParameters != null) {
endpoint.setSslContextParameters(sslContextParameters);
}
// prefer to use endpoint configured over component configured
if (staticResources == null) {
// fallback to component configured
staticResources = getStaticResources();
}
if (staticResources != null) {
endpoint.setStaticResources(staticResources);
}
endpoint.setSslContextParameters(sslContextParameters);
endpoint.setPort(port);
endpoint.setHost(host);
setProperties(endpoint, parameters);
return endpoint;
}
use of org.apache.camel.util.jsse.SSLContextParameters in project camel by apache.
the class WebsocketSSLContextInUriRouteExampleTest method createAsyncHttpSSLClient.
protected AsyncHttpClient createAsyncHttpSSLClient() throws IOException, GeneralSecurityException {
AsyncHttpClient c;
AsyncHttpClientConfig config;
DefaultAsyncHttpClientConfig.Builder builder = new DefaultAsyncHttpClientConfig.Builder();
SSLContext sslContext = new SSLContextParameters().createSSLContext(context());
JdkSslContext ssl = new JdkSslContext(sslContext, true, ClientAuth.REQUIRE);
builder.setSslContext(ssl);
builder.setAcceptAnyCertificate(true);
config = builder.build();
c = new DefaultAsyncHttpClient(config);
return c;
}
use of org.apache.camel.util.jsse.SSLContextParameters in project camel by apache.
the class WebsocketSSLRouteExampleTest method createAsyncHttpSSLClient.
protected AsyncHttpClient createAsyncHttpSSLClient() throws IOException, GeneralSecurityException {
AsyncHttpClient c;
AsyncHttpClientConfig config;
DefaultAsyncHttpClientConfig.Builder builder = new DefaultAsyncHttpClientConfig.Builder();
SSLContext sslContext = new SSLContextParameters().createSSLContext(context());
JdkSslContext ssl = new JdkSslContext(sslContext, true, ClientAuth.REQUIRE);
builder.setSslContext(ssl);
builder.setAcceptAnyCertificate(true);
config = builder.build();
c = new DefaultAsyncHttpClient(config);
return c;
}
use of org.apache.camel.util.jsse.SSLContextParameters in project camel by apache.
the class SalesforceComponentVerifier method verifyConnectivity.
// *********************************
// Connectivity validation
// *********************************
@Override
protected Result verifyConnectivity(Map<String, Object> parameters) {
// Default is success
ResultBuilder builder = ResultBuilder.withStatusAndScope(Result.Status.OK, Scope.CONNECTIVITY);
try {
SalesforceEndpointConfig configuration = new SalesforceEndpointConfig();
setProperties(configuration, parameters);
SalesforceLoginConfig loginConfig = new SalesforceLoginConfig();
setProperties(loginConfig, parameters);
// Create a dummy SslContextFactory which is needed by SalesforceHttpClient
// or the underlying jetty client fails with a NPE
SSLContextParameters contextParameters = new SSLContextParameters();
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setSslContext(contextParameters.createSSLContext(getCamelContext()));
SalesforceHttpClient httpClient = new SalesforceHttpClient(sslContextFactory);
httpClient.setConnectTimeout(SalesforceComponent.CONNECTION_TIMEOUT);
configureHttpProxy(httpClient, parameters);
SalesforceSession session = new SalesforceSession(getCamelContext(), httpClient, httpClient.getTimeout(), loginConfig);
DefaultRestClient client = new DefaultRestClient(httpClient, configuration.getApiVersion(), configuration.getFormat(), session);
httpClient.setSession(session);
httpClient.start();
// For authentication check is is enough to use
session.start();
client.start();
client.getVersions((response, exception) -> processSalesforceException(builder, Optional.ofNullable(exception)));
client.stop();
session.stop();
httpClient.stop();
httpClient.destroy();
} catch (NoSuchOptionException e) {
builder.error(ResultErrorBuilder.withMissingOption(e.getOptionName()).build());
} catch (SalesforceException e) {
processSalesforceException(builder, Optional.of(e));
} catch (Exception e) {
builder.error(ResultErrorBuilder.withException(e).build());
throw new RuntimeException(e);
}
return builder.build();
}
use of org.apache.camel.util.jsse.SSLContextParameters in project camel by apache.
the class HttpsTwoComponentsSslContextParametersGetTest method createRegistry.
@Override
protected JndiRegistry createRegistry() throws Exception {
JndiRegistry registry = super.createRegistry();
registry.bind("x509HostnameVerifier", new AllowAllHostnameVerifier());
registry.bind("sslContextParameters", new SSLContextParameters());
registry.bind("sslContextParameters2", new SSLContextParameters());
registry.bind("http4s-foo", new HttpComponent());
registry.bind("http4s-bar", new HttpComponent());
return registry;
}
Aggregations