camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dhira...@apache.org
Subject [4/5] git commit: CAMEL-7955: Updated Camel-linkedin to use SSLContextParameters to configure HtmlUnit for OAuth
Date Fri, 24 Oct 2014 21:43:01 GMT
CAMEL-7955: Updated Camel-linkedin to use SSLContextParameters to configure HtmlUnit for OAuth


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

Branch: refs/heads/camel-2.14.x
Commit: 18e08c2e0079c564c72f5141a8a9a3b845f3f1b0
Parents: bfa2388
Author: Dhiraj Bokde <dhirajsb@yahoo.com>
Authored: Fri Oct 24 13:27:09 2014 -0700
Committer: Dhiraj Bokde <dhirajsb@yahoo.com>
Committed: Fri Oct 24 14:42:28 2014 -0700

----------------------------------------------------------------------
 .../linkedin/api/LinkedInOAuthRequestFilter.java  |  4 +++-
 .../api/AbstractResourceIntegrationTest.java      |  4 ++--
 .../component/linkedin/LinkedInComponent.java     | 18 +++++++++++++++++-
 3 files changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/18e08c2e/components/camel-linkedin/camel-linkedin-api/src/main/java/org/apache/camel/component/linkedin/api/LinkedInOAuthRequestFilter.java
----------------------------------------------------------------------
diff --git a/components/camel-linkedin/camel-linkedin-api/src/main/java/org/apache/camel/component/linkedin/api/LinkedInOAuthRequestFilter.java
b/components/camel-linkedin/camel-linkedin-api/src/main/java/org/apache/camel/component/linkedin/api/LinkedInOAuthRequestFilter.java
index 4fd7194..ed11944 100644
--- a/components/camel-linkedin/camel-linkedin-api/src/main/java/org/apache/camel/component/linkedin/api/LinkedInOAuthRequestFilter.java
+++ b/components/camel-linkedin/camel-linkedin-api/src/main/java/org/apache/camel/component/linkedin/api/LinkedInOAuthRequestFilter.java
@@ -47,6 +47,7 @@ import com.gargoylesoftware.htmlunit.html.HtmlPage;
 import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput;
 import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
 import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
+
 import org.apache.http.HttpHost;
 import org.apache.http.HttpStatus;
 import org.apache.http.conn.params.ConnRoutePNames;
@@ -82,7 +83,7 @@ public final class LinkedInOAuthRequestFilter implements ClientRequestFilter
{
 
     @SuppressWarnings("deprecation")
     public LinkedInOAuthRequestFilter(OAuthParams oAuthParams, Map<String, Object>
httpParams,
-                                      boolean lazyAuth) {
+                                      boolean lazyAuth, String[] enabledProtocols) {
 
         this.oAuthParams = oAuthParams;
         this.oAuthToken = null;
@@ -95,6 +96,7 @@ public final class LinkedInOAuthRequestFilter implements ClientRequestFilter
{
         options.setThrowExceptionOnFailingStatusCode(true);
         options.setThrowExceptionOnScriptError(true);
         options.setPrintContentOnFailingStatusCode(LOG.isDebugEnabled());
+        options.setSSLClientProtocols(enabledProtocols);
 
         // add HTTP proxy if set
         if (httpParams != null && httpParams.get(ConnRoutePNames.DEFAULT_PROXY) !=
null) {

http://git-wip-us.apache.org/repos/asf/camel/blob/18e08c2e/components/camel-linkedin/camel-linkedin-api/src/test/java/org/apache/camel/component/linkedin/api/AbstractResourceIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-linkedin/camel-linkedin-api/src/test/java/org/apache/camel/component/linkedin/api/AbstractResourceIntegrationTest.java
b/components/camel-linkedin/camel-linkedin-api/src/test/java/org/apache/camel/component/linkedin/api/AbstractResourceIntegrationTest.java
index d8f474e..b0f3ad8 100644
--- a/components/camel-linkedin/camel-linkedin-api/src/test/java/org/apache/camel/component/linkedin/api/AbstractResourceIntegrationTest.java
+++ b/components/camel-linkedin/camel-linkedin-api/src/test/java/org/apache/camel/component/linkedin/api/AbstractResourceIntegrationTest.java
@@ -48,7 +48,7 @@ public class AbstractResourceIntegrationTest extends Assert {
     @BeforeClass
     public static void beforeClass() throws Exception {
         properties = new Properties();
-        properties.load(PeopleResourceIntegrationTest.class.getResourceAsStream("/test-options.properties"));
+        properties.load(AbstractResourceIntegrationTest.class.getResourceAsStream("/test-options.properties"));
 
         requestFilter = createOAuthHelper();
     }
@@ -82,7 +82,7 @@ public class AbstractResourceIntegrationTest extends Assert {
 
         final OAuthParams oAuthParams = new OAuthParams(userName, userPassword, secureStorage,
             clientId, clientSecret, redirectUri, scopes);
-        return new LinkedInOAuthRequestFilter(oAuthParams, null, false);
+        return new LinkedInOAuthRequestFilter(oAuthParams, null, false, null);
     }
 
     @AfterClass

http://git-wip-us.apache.org/repos/asf/camel/blob/18e08c2e/components/camel-linkedin/camel-linkedin-component/src/main/java/org/apache/camel/component/linkedin/LinkedInComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-linkedin/camel-linkedin-component/src/main/java/org/apache/camel/component/linkedin/LinkedInComponent.java
b/components/camel-linkedin/camel-linkedin-component/src/main/java/org/apache/camel/component/linkedin/LinkedInComponent.java
index 4434f8c..a45a300 100644
--- a/components/camel-linkedin/camel-linkedin-component/src/main/java/org/apache/camel/component/linkedin/LinkedInComponent.java
+++ b/components/camel-linkedin/camel-linkedin-component/src/main/java/org/apache/camel/component/linkedin/LinkedInComponent.java
@@ -16,6 +16,10 @@
  */
 package org.apache.camel.component.linkedin;
 
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import javax.net.ssl.SSLContext;
+
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
 import org.apache.camel.component.linkedin.api.LinkedInOAuthRequestFilter;
@@ -24,7 +28,9 @@ import org.apache.camel.component.linkedin.internal.CachingOAuthSecureStorage;
 import org.apache.camel.component.linkedin.internal.LinkedInApiCollection;
 import org.apache.camel.component.linkedin.internal.LinkedInApiName;
 import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.component.AbstractApiComponent;
+import org.apache.camel.util.jsse.SSLContextParameters;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -72,8 +78,18 @@ public class LinkedInComponent extends AbstractApiComponent<LinkedInApiName,
Lin
         // validate configuration
         configuration.validate();
 
+        final String[] enabledProtocols;
+        try {
+            // use default SSP to create supported non-SSL protocols list
+            final SSLContext sslContext = new SSLContextParameters().createSSLContext();
+            enabledProtocols = sslContext.createSSLEngine().getEnabledProtocols();
+        } catch (GeneralSecurityException e) {
+            throw ObjectHelper.wrapRuntimeCamelException(e);
+        } catch (IOException e) {
+            throw ObjectHelper.wrapRuntimeCamelException(e);
+        }
         return new LinkedInOAuthRequestFilter(getOAuthParams(configuration),
-            configuration.getHttpParams(), configuration.isLazyAuth());
+            configuration.getHttpParams(), configuration.isLazyAuth(), enabledProtocols);
     }
 
     private static OAuthParams getOAuthParams(LinkedInConfiguration configuration) {


Mime
View raw message