use of org.eclipse.jetty.util.ssl.SslContextFactory 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.eclipse.jetty.util.ssl.SslContextFactory 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();
}
}
use of org.eclipse.jetty.util.ssl.SslContextFactory in project camel by apache.
the class WebsocketComponent method getSslSocketConnector.
private ServerConnector getSslSocketConnector(Server server, SSLContextParameters sslContextParameters) throws Exception {
ServerConnector sslSocketConnector = null;
if (sslContextParameters != null) {
SslContextFactory sslContextFactory = new WebSocketComponentSslContextFactory();
sslContextFactory.setSslContext(sslContextParameters.createSSLContext(getCamelContext()));
sslSocketConnector = new ServerConnector(server, sslContextFactory);
} else {
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStorePassword(sslKeyPassword);
sslContextFactory.setKeyManagerPassword(sslPassword);
if (sslKeystore != null) {
sslContextFactory.setKeyStorePath(sslKeystore);
}
sslSocketConnector = new ServerConnector(server, sslContextFactory);
}
return sslSocketConnector;
}
use of org.eclipse.jetty.util.ssl.SslContextFactory in project rest.li by linkedin.
the class HttpsJettyServer method getConnectors.
@Override
protected Connector[] getConnectors(Server server) {
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStorePath(_keyStore);
sslContextFactory.setKeyStorePassword(_keyStorePassword);
sslContextFactory.setTrustStorePath(_keyStore);
sslContextFactory.setTrustStorePassword(_keyStorePassword);
HttpConfiguration configuration = new HttpConfiguration();
configuration.addCustomizer(new SecureRequestCustomizer());
ServerConnector sslConnector = new ServerConnector(server, sslContextFactory, new HttpConnectionFactory(configuration, HttpCompliance.RFC2616));
sslConnector.setPort(_sslPort);
Connector[] httpConnectors = super.getConnectors(server);
Connector[] connectors = new Connector[httpConnectors.length + 1];
int i = 0;
for (Connector c : httpConnectors) {
connectors[i++] = c;
}
connectors[i++] = sslConnector;
return connectors;
}
use of org.eclipse.jetty.util.ssl.SslContextFactory in project gocd by gocd.
the class GoAgentServerWebSocketClientBuilder method build.
@Override
public WebSocketClient build() throws Exception {
SslContextFactory sslContextFactory = sslVerificationMode == SslVerificationMode.NONE ? new TrustAllSSLContextFactory() : new SslContextFactory();
sslContextFactory.setNeedClientAuth(true);
sslContextFactory.setKeyStore(agentKeystore());
sslContextFactory.setKeyStorePassword(keystorePassword());
sslContextFactory.setKeyManagerPassword(keystorePassword());
if (rootCertFile != null) {
sslContextFactory.setTrustStore(agentTruststore());
sslContextFactory.setTrustStorePassword(keystorePassword());
}
if (sslVerificationMode == SslVerificationMode.NO_VERIFY_HOST) {
sslContextFactory.setEndpointIdentificationAlgorithm(null);
}
WebSocketClient client = new WebSocketClient(sslContextFactory);
client.setMaxIdleTimeout(systemEnvironment.getWebsocketMaxIdleTime());
return client;
}
Aggregations