use of org.apache.camel.util.jsse.SSLContextParameters 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;
}
use of org.apache.camel.util.jsse.SSLContextParameters 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;
}
use of org.apache.camel.util.jsse.SSLContextParameters in project camel by apache.
the class HttpProxyMojoIntegrationTest method createMojo.
@Override
protected CamelSalesforceMojo createMojo() throws IOException {
final CamelSalesforceMojo mojo = super.createMojo();
// SSL context parameters
mojo.sslContextParameters = new SSLContextParameters();
// HTTP proxy properties
mojo.httpProxyHost = HTTP_PROXY_HOST;
mojo.httpProxyPort = httpProxyPort;
mojo.httpProxyUsername = HTTP_PROXY_USER_NAME;
mojo.httpProxyPassword = HTTP_PROXY_PASSWORD;
mojo.httpProxyRealm = HTTP_PROXY_REALM;
mojo.httpProxyAuthUri = String.format("https://%s:%s", HTTP_PROXY_HOST, httpProxyPort);
// HTTP client properties
mojo.httpClientProperties = new HashMap<String, Object>();
mojo.httpClientProperties.put("timeout", "60000");
mojo.httpClientProperties.put("removeIdleDestinations", "true");
return mojo;
}
use of org.apache.camel.util.jsse.SSLContextParameters in project camel by apache.
the class BulkApiIntegrationTest method testRetry.
@Test
public void testRetry() throws Exception {
final SalesforceComponent sf = context().getComponent("salesforce", SalesforceComponent.class);
final String accessToken = sf.getSession().getAccessToken();
final SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setSslContext(new SSLContextParameters().createSSLContext(context));
final HttpClient httpClient = new HttpClient(sslContextFactory);
httpClient.setConnectTimeout(60000);
httpClient.start();
final String uri = sf.getLoginConfig().getLoginUrl() + "/services/oauth2/revoke?token=" + accessToken;
final Request logoutGet = httpClient.newRequest(uri).method(HttpMethod.GET).timeout(1, TimeUnit.MINUTES);
final ContentResponse response = logoutGet.send();
assertEquals(HttpStatus.OK_200, response.getStatus());
final JobInfo jobInfo = new JobInfo();
jobInfo.setOperation(OperationEnum.INSERT);
jobInfo.setContentType(ContentType.CSV);
jobInfo.setObject(Merchandise__c.class.getSimpleName());
createJob(jobInfo);
}
use of org.apache.camel.util.jsse.SSLContextParameters in project camel by apache.
the class SessionIntegrationTest method testLogin.
@Test
public void testLogin() throws Exception {
final SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setSslContext(new SSLContextParameters().createSSLContext());
final SalesforceHttpClient httpClient = new SalesforceHttpClient(sslContextFactory);
httpClient.setConnectTimeout(TIMEOUT);
final SalesforceSession session = new SalesforceSession(new DefaultCamelContext(), httpClient, TIMEOUT, LoginConfigHelper.getLoginConfig());
session.addListener(this);
httpClient.setSession(session);
httpClient.start();
try {
String loginToken = session.login(session.getAccessToken());
LOG.info("First token " + loginToken);
assertTrue("SalesforceSessionListener onLogin NOT called", onLoginTriggered);
onLoginTriggered = false;
// refresh token, also causes logout
loginToken = session.login(loginToken);
LOG.info("Refreshed token " + loginToken);
assertTrue("SalesforceSessionListener onLogout NOT called", onLogoutTriggered);
assertTrue("SalesforceSessionListener onLogin NOT called", onLoginTriggered);
} finally {
// logout finally
session.logout();
}
}
Aggregations