use of org.apache.camel.util.jsse.SSLContextParameters in project camel by apache.
the class StompBaseTest method getSSLContextParameters.
private SSLContextParameters getSSLContextParameters(String path, String password) {
KeyStoreParameters ksp = new KeyStoreParameters();
ksp.setResource(path);
ksp.setPassword(password);
KeyManagersParameters kmp = new KeyManagersParameters();
kmp.setKeyPassword(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 HttpsSslContextParametersGetTest method createRegistry.
@Override
protected JndiRegistry createRegistry() throws Exception {
JndiRegistry registry = super.createRegistry();
registry.bind("sslContextParameters", new SSLContextParameters());
return registry;
}
use of org.apache.camel.util.jsse.SSLContextParameters in project camel by apache.
the class HttpsTwoDifferentSslContextParametersGetTest 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());
return registry;
}
use of org.apache.camel.util.jsse.SSLContextParameters in project camel by apache.
the class HttpsRouteAliasTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() throws URISyntaxException {
JettyHttpComponent jetty = context.getComponent("jetty", JettyHttpComponent.class);
KeyStoreParameters ksp = new KeyStoreParameters();
ksp.setResource(this.getClass().getClassLoader().getResource("jsse/localhost-alias.ks").toString());
ksp.setPassword(pwd);
KeyManagersParameters kmp = new KeyManagersParameters();
kmp.setKeyPassword(pwd);
kmp.setKeyStore(ksp);
SSLContextParameters sslContextParameters = new SSLContextParameters();
sslContextParameters.setKeyManagers(kmp);
// Specify "server" cert alias
sslContextParameters.setCertAlias("server");
jetty.setSslContextParameters(sslContextParameters);
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");
}
};
}
use of org.apache.camel.util.jsse.SSLContextParameters in project camel by apache.
the class CamelSalesforceMojo method createHttpClient.
protected SalesforceHttpClient createHttpClient() throws MojoExecutionException {
final SalesforceHttpClient httpClient;
// set ssl context parameters
try {
final SSLContextParameters contextParameters = sslContextParameters != null ? sslContextParameters : new SSLContextParameters();
final SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setSslContext(contextParameters.createSSLContext());
httpClient = new SalesforceHttpClient(sslContextFactory);
} catch (GeneralSecurityException e) {
throw new MojoExecutionException("Error creating default SSL context: " + e.getMessage(), e);
} catch (IOException e) {
throw new MojoExecutionException("Error creating default SSL context: " + e.getMessage(), e);
}
// default settings
httpClient.setConnectTimeout(DEFAULT_TIMEOUT);
httpClient.setTimeout(DEFAULT_TIMEOUT);
// enable redirects, no need for a RedirectListener class in Jetty 9
httpClient.setFollowRedirects(true);
// set HTTP client parameters
if (httpClientProperties != null && !httpClientProperties.isEmpty()) {
try {
IntrospectionSupport.setProperties(httpClient, new HashMap<String, Object>(httpClientProperties));
} catch (Exception e) {
throw new MojoExecutionException("Error setting HTTP client properties: " + e.getMessage(), e);
}
}
// wait for 1 second longer than the HTTP client response timeout
responseTimeout = httpClient.getTimeout() + 1000L;
// set HTTP proxy settings
if (this.httpProxyHost != null && httpProxyPort != null) {
Origin.Address proxyAddress = new Origin.Address(this.httpProxyHost, this.httpProxyPort);
ProxyConfiguration.Proxy proxy;
if (isHttpProxySocks4) {
proxy = new Socks4Proxy(proxyAddress, isHttpProxySecure);
} else {
proxy = new HttpProxy(proxyAddress, isHttpProxySecure);
}
if (httpProxyIncludedAddresses != null && !httpProxyIncludedAddresses.isEmpty()) {
proxy.getIncludedAddresses().addAll(httpProxyIncludedAddresses);
}
if (httpProxyExcludedAddresses != null && !httpProxyExcludedAddresses.isEmpty()) {
proxy.getExcludedAddresses().addAll(httpProxyExcludedAddresses);
}
httpClient.getProxyConfiguration().getProxies().add(proxy);
}
if (this.httpProxyUsername != null && httpProxyPassword != null) {
ObjectHelper.notEmpty(httpProxyAuthUri, "httpProxyAuthUri");
ObjectHelper.notEmpty(httpProxyRealm, "httpProxyRealm");
final Authentication authentication;
if (httpProxyUseDigestAuth) {
authentication = new DigestAuthentication(URI.create(httpProxyAuthUri), httpProxyRealm, httpProxyUsername, httpProxyPassword);
} else {
authentication = new BasicAuthentication(URI.create(httpProxyAuthUri), httpProxyRealm, httpProxyUsername, httpProxyPassword);
}
httpClient.getAuthenticationStore().addAuthentication(authentication);
}
// set session before calling start()
final SalesforceSession session = new SalesforceSession(new DefaultCamelContext(), httpClient, httpClient.getTimeout(), new SalesforceLoginConfig(loginUrl, clientId, clientSecret, userName, password, false));
httpClient.setSession(session);
try {
httpClient.start();
} catch (Exception e) {
throw new MojoExecutionException("Error creating HTTP client: " + e.getMessage(), e);
}
return httpClient;
}
Aggregations