Search in sources :

Example 46 with SslContextFactory

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);
}
Also used : SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) ContentResponse(org.eclipse.jetty.client.api.ContentResponse) JobInfo(org.apache.camel.component.salesforce.api.dto.bulk.JobInfo) HttpClient(org.eclipse.jetty.client.HttpClient) Request(org.eclipse.jetty.client.api.Request) Merchandise__c(org.apache.camel.component.salesforce.dto.generated.Merchandise__c) SSLContextParameters(org.apache.camel.util.jsse.SSLContextParameters) Test(org.junit.Test)

Example 47 with SslContextFactory

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();
    }
}
Also used : SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) SalesforceHttpClient(org.apache.camel.component.salesforce.SalesforceHttpClient) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) SSLContextParameters(org.apache.camel.util.jsse.SSLContextParameters) Test(org.junit.Test)

Example 48 with SslContextFactory

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;
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory)

Example 49 with SslContextFactory

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;
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) ServerConnector(org.eclipse.jetty.server.ServerConnector) Connector(org.eclipse.jetty.server.Connector) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) SecureRequestCustomizer(org.eclipse.jetty.server.SecureRequestCustomizer) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration)

Example 50 with SslContextFactory

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;
}
Also used : SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) WebSocketClient(org.eclipse.jetty.websocket.client.WebSocketClient)

Aggregations

SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)139 ServerConnector (org.eclipse.jetty.server.ServerConnector)54 HttpConnectionFactory (org.eclipse.jetty.server.HttpConnectionFactory)44 Server (org.eclipse.jetty.server.Server)43 SslConnectionFactory (org.eclipse.jetty.server.SslConnectionFactory)43 Test (org.junit.Test)40 HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)37 SecureRequestCustomizer (org.eclipse.jetty.server.SecureRequestCustomizer)35 QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)23 InputStream (java.io.InputStream)18 IOException (java.io.IOException)17 File (java.io.File)15 SSLContext (javax.net.ssl.SSLContext)15 ServletException (javax.servlet.ServletException)15 OutputStream (java.io.OutputStream)14 HttpServletRequest (javax.servlet.http.HttpServletRequest)13 HttpServletResponse (javax.servlet.http.HttpServletResponse)13 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)13 AbstractHandler (org.eclipse.jetty.server.handler.AbstractHandler)11 InetSocketAddress (java.net.InetSocketAddress)10