Search in sources :

Example 6 with SSLContextParameters

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;
}
Also used : KeyManagersParameters(org.apache.camel.util.jsse.KeyManagersParameters) KeyStoreParameters(org.apache.camel.util.jsse.KeyStoreParameters) SSLContextParameters(org.apache.camel.util.jsse.SSLContextParameters)

Example 7 with 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;
}
Also used : KeyManagersParameters(org.apache.camel.util.jsse.KeyManagersParameters) JndiRegistry(org.apache.camel.impl.JndiRegistry) TrustManagersParameters(org.apache.camel.util.jsse.TrustManagersParameters) KeyStoreParameters(org.apache.camel.util.jsse.KeyStoreParameters) SSLContextServerParameters(org.apache.camel.util.jsse.SSLContextServerParameters) SSLContextParameters(org.apache.camel.util.jsse.SSLContextParameters)

Example 8 with SSLContextParameters

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;
}
Also used : SSLContextParameters(org.apache.camel.util.jsse.SSLContextParameters)

Example 9 with SSLContextParameters

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);
}
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 10 with SSLContextParameters

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();
    }
}
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)

Aggregations

SSLContextParameters (org.apache.camel.util.jsse.SSLContextParameters)59 KeyStoreParameters (org.apache.camel.util.jsse.KeyStoreParameters)35 KeyManagersParameters (org.apache.camel.util.jsse.KeyManagersParameters)28 TrustManagersParameters (org.apache.camel.util.jsse.TrustManagersParameters)27 JndiRegistry (org.apache.camel.impl.JndiRegistry)19 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)8 IOException (java.io.IOException)7 GeneralSecurityException (java.security.GeneralSecurityException)7 SSLContextServerParameters (org.apache.camel.util.jsse.SSLContextServerParameters)7 RouteBuilder (org.apache.camel.builder.RouteBuilder)6 SSLContext (javax.net.ssl.SSLContext)5 Test (org.junit.Test)4 URI (java.net.URI)3 SalesforceException (org.apache.camel.component.salesforce.api.SalesforceException)3 SalesforceSession (org.apache.camel.component.salesforce.internal.SalesforceSession)3 HttpClient (org.eclipse.jetty.client.HttpClient)3 JdkSslContext (io.netty.handler.ssl.JdkSslContext)2 URISyntaxException (java.net.URISyntaxException)2 CertificateException (java.security.cert.CertificateException)2 X509Certificate (java.security.cert.X509Certificate)2