Repository: camel Updated Branches: refs/heads/master 007403ac4 -> bc5bfe46a
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/3db68c5a Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3db68c5a Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3db68c5a Branch: refs/heads/master Commit: 3db68c5af3567191e3f0cf632f19e79628de2c3c Parents: 608c99c Author: Dhiraj Bokde <[email protected]> Authored: Fri Oct 24 13:27:09 2014 -0700 Committer: Dhiraj Bokde <[email protected]> Committed: Fri Oct 24 14:43:15 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/3db68c5a/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/3db68c5a/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/3db68c5a/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) {
