camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dhira...@apache.org
Subject [5/5] git commit: CAMEL-7956: Updated Camel-salesforce to support SSLContextParameters to configure HttpClient
Date Fri, 24 Oct 2014 21:43:02 GMT
CAMEL-7956: Updated Camel-salesforce to support SSLContextParameters to configure HttpClient


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/05cf33de
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/05cf33de
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/05cf33de

Branch: refs/heads/camel-2.14.x
Commit: 05cf33de4a8a2f8046b71f7cd271d8849fad3a00
Parents: 18e08c2
Author: Dhiraj Bokde <dhirajsb@yahoo.com>
Authored: Fri Oct 24 13:21:07 2014 -0700
Committer: Dhiraj Bokde <dhirajsb@yahoo.com>
Committed: Fri Oct 24 14:42:29 2014 -0700

----------------------------------------------------------------------
 .../component/salesforce/SalesforceComponent.java | 18 +++++++++++++++++-
 .../internal/SessionIntegrationTest.java          |  6 +++++-
 2 files changed, 22 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/05cf33de/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceComponent.java
b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceComponent.java
index 52dafa5..8a38bec 100644
--- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceComponent.java
+++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceComponent.java
@@ -41,8 +41,10 @@ import org.apache.camel.spi.EndpointCompleter;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.ReflectionHelper;
 import org.apache.camel.util.ServiceHelper;
+import org.apache.camel.util.jsse.SSLContextParameters;
 import org.eclipse.jetty.client.HttpClient;
 import org.eclipse.jetty.client.RedirectListener;
+import org.eclipse.jetty.util.ssl.SslContextFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -60,6 +62,8 @@ public class SalesforceComponent extends UriEndpointComponent implements
Endpoin
 
     private SalesforceLoginConfig loginConfig;
     private SalesforceEndpointConfig config;
+
+    private SSLContextParameters sslContextParameters;
     private String[] packages;
 
     // component state
@@ -136,7 +140,11 @@ public class SalesforceComponent extends UriEndpointComponent implements
Endpoin
             if (config != null && config.getHttpClient() != null) {
                 httpClient = config.getHttpClient();
             } else {
-                httpClient = new HttpClient();
+                final SslContextFactory sslContextFactory = new SslContextFactory();
+                final SSLContextParameters contextParameters =
+                    sslContextParameters != null ? sslContextParameters : new SSLContextParameters();
+                sslContextFactory.setSslContext(contextParameters.createSSLContext());
+                httpClient = new HttpClient(sslContextFactory);
                 httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
                 httpClient.setMaxConnectionsPerAddress(MAX_CONNECTIONS_PER_ADDRESS);
                 httpClient.setConnectTimeout(CONNECTION_TIMEOUT);
@@ -303,6 +311,14 @@ public class SalesforceComponent extends UriEndpointComponent implements
Endpoin
         this.config = config;
     }
 
+    public SSLContextParameters getSslContextParameters() {
+        return sslContextParameters;
+    }
+
+    public void setSslContextParameters(SSLContextParameters sslContextParameters) {
+        this.sslContextParameters = sslContextParameters;
+    }
+
     public String[] getPackages() {
         return packages;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/05cf33de/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/internal/SessionIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/internal/SessionIntegrationTest.java
b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/internal/SessionIntegrationTest.java
index ce55033..a25ad52 100644
--- a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/internal/SessionIntegrationTest.java
+++ b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/internal/SessionIntegrationTest.java
@@ -17,8 +17,10 @@
 package org.apache.camel.component.salesforce.internal;
 
 import org.apache.camel.component.salesforce.LoginConfigHelper;
+import org.apache.camel.util.jsse.SSLContextParameters;
 import org.eclipse.jetty.client.HttpClient;
 import org.eclipse.jetty.client.RedirectListener;
+import org.eclipse.jetty.util.ssl.SslContextFactory;
 import org.junit.Assert;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -37,7 +39,9 @@ public class SessionIntegrationTest extends Assert implements SalesforceSession.
     @Test
     public void testLogin() throws Exception {
 
-        final HttpClient httpClient = new HttpClient();
+        final SslContextFactory sslContextFactory = new SslContextFactory();
+        sslContextFactory.setSslContext(new SSLContextParameters().createSSLContext());
+        final HttpClient httpClient = new HttpClient(sslContextFactory);
         httpClient.setConnectTimeout(TIMEOUT);
         httpClient.setTimeout(TIMEOUT);
         httpClient.registerListener(RedirectListener.class.getName());


Mime
View raw message