Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id CDC1A200C53 for ; Tue, 11 Apr 2017 16:12:00 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id CC7C8160B89; Tue, 11 Apr 2017 14:12:00 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C6AE1160BAE for ; Tue, 11 Apr 2017 16:11:59 +0200 (CEST) Received: (qmail 90500 invoked by uid 500); 11 Apr 2017 14:11:58 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 90108 invoked by uid 99); 11 Apr 2017 14:11:58 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Apr 2017 14:11:58 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 07CB3DFCB3; Tue, 11 Apr 2017 14:11:58 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: nferraro@apache.org To: commits@camel.apache.org Date: Tue, 11 Apr 2017 14:12:07 -0000 Message-Id: In-Reply-To: <9bfa64da559c4f138d5ed55e1b6e8d5d@git.apache.org> References: <9bfa64da559c4f138d5ed55e1b6e8d5d@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [11/13] camel git commit: CAMEL-10650: putting flag to enable global SSL config in all components archived-at: Tue, 11 Apr 2017 14:12:01 -0000 http://git-wip-us.apache.org/repos/asf/camel/blob/d51aa65d/components/camel-stomp/src/main/java/org/apache/camel/component/stomp/StompComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-stomp/src/main/java/org/apache/camel/component/stomp/StompComponent.java b/components/camel-stomp/src/main/java/org/apache/camel/component/stomp/StompComponent.java index bed8ba4..3b6854d 100644 --- a/components/camel-stomp/src/main/java/org/apache/camel/component/stomp/StompComponent.java +++ b/components/camel-stomp/src/main/java/org/apache/camel/component/stomp/StompComponent.java @@ -33,6 +33,8 @@ public class StompComponent extends UriEndpointComponent implements SSLContextPa @Metadata(label = "security", secret = true) private String passcode; private String host; + @Metadata(label = "security", defaultValue = "false") + private boolean useGlobalSSLContextParameters; public StompComponent() { super(StompEndpoint.class); @@ -50,7 +52,7 @@ public class StompComponent extends UriEndpointComponent implements SSLContextPa StompEndpoint endpoint = new StompEndpoint(uri, this, config, destination); setProperties(endpoint, parameters); - if (config.isUseGlobalSslContextParameters() && config.getSslContextParameters() == null) { + if (config.getSslContextParameters() == null) { config.setSslContextParameters(getGlobalSSLContextParameters()); } @@ -96,4 +98,17 @@ public class StompComponent extends UriEndpointComponent implements SSLContextPa configuration.setHost(host); } + @Override + public boolean isUseGlobalSSLContextParameters() { + return this.useGlobalSSLContextParameters; + } + + /** + * Enable usage of global SSL context parameters. + */ + @Override + public void setUseGlobalSSLContextParameters(boolean useGlobalSSLContextParameters) { + this.useGlobalSSLContextParameters = useGlobalSSLContextParameters; + } + } http://git-wip-us.apache.org/repos/asf/camel/blob/d51aa65d/components/camel-stomp/src/main/java/org/apache/camel/component/stomp/StompConfiguration.java ---------------------------------------------------------------------- diff --git a/components/camel-stomp/src/main/java/org/apache/camel/component/stomp/StompConfiguration.java b/components/camel-stomp/src/main/java/org/apache/camel/component/stomp/StompConfiguration.java index f46a173..61ddd0d 100644 --- a/components/camel-stomp/src/main/java/org/apache/camel/component/stomp/StompConfiguration.java +++ b/components/camel-stomp/src/main/java/org/apache/camel/component/stomp/StompConfiguration.java @@ -35,8 +35,6 @@ public class StompConfiguration implements Cloneable { private String host; @UriParam(label = "security") private SSLContextParameters sslContextParameters; - @Metadata(label = "security", defaultValue = "false") - private boolean useGlobalSslContextParameters; /** * Returns a copy of this configuration @@ -105,14 +103,4 @@ public class StompConfiguration implements Cloneable { this.sslContextParameters = sslContextParameters; } - public boolean isUseGlobalSslContextParameters() { - return useGlobalSslContextParameters; - } - - /** - * Enable usage of Camel global SSL configuration - */ - public void setUseGlobalSslContextParameters(boolean useGlobalSslContextParameters) { - this.useGlobalSslContextParameters = useGlobalSslContextParameters; - } } http://git-wip-us.apache.org/repos/asf/camel/blob/d51aa65d/components/camel-stomp/src/test/java/org/apache/camel/component/stomp/StompGlobalSslConsumerTest.java ---------------------------------------------------------------------- diff --git a/components/camel-stomp/src/test/java/org/apache/camel/component/stomp/StompGlobalSslConsumerTest.java b/components/camel-stomp/src/test/java/org/apache/camel/component/stomp/StompGlobalSslConsumerTest.java index 99ce061..aa1d942 100644 --- a/components/camel-stomp/src/test/java/org/apache/camel/component/stomp/StompGlobalSslConsumerTest.java +++ b/components/camel-stomp/src/test/java/org/apache/camel/component/stomp/StompGlobalSslConsumerTest.java @@ -17,6 +17,7 @@ package org.apache.camel.component.stomp; import org.apache.camel.CamelContext; +import org.apache.camel.SSLContextParametersAware; import org.apache.camel.builder.RouteBuilder; public class StompGlobalSslConsumerTest extends StompConsumerTest { @@ -25,6 +26,8 @@ public class StompGlobalSslConsumerTest extends StompConsumerTest { protected CamelContext createCamelContext() throws Exception { CamelContext context = super.createCamelContext(); context.setSSLContextParameters(getClientSSLContextParameters()); + + ((SSLContextParametersAware) context.getComponent("stomp")).setUseGlobalSSLContextParameters(true); return context; } @@ -37,7 +40,7 @@ public class StompGlobalSslConsumerTest extends StompConsumerTest { protected RouteBuilder createRouteBuilder() { return new RouteBuilder() { public void configure() { - fromF("stomp:queue:test?brokerURL=ssl://localhost:%d&useGlobalSslContextParameters=true", getPort()) + fromF("stomp:queue:test?brokerURL=ssl://localhost:%d", getPort()) .transform(body().convertToString()) .to("mock:result"); } http://git-wip-us.apache.org/repos/asf/camel/blob/d51aa65d/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java index 1bc598c..3c57475 100644 --- a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java +++ b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java @@ -65,6 +65,8 @@ public class UndertowComponent extends DefaultComponent implements RestConsumerF private UndertowHttpBinding undertowHttpBinding; @Metadata(label = "security") private SSLContextParameters sslContextParameters; + @Metadata(label = "security", defaultValue = "false") + private boolean useGlobalSSLContextParameters; @Metadata(label = "advanced") private UndertowHostOptions hostOptions; @@ -331,6 +333,18 @@ public class UndertowComponent extends DefaultComponent implements RestConsumerF this.sslContextParameters = sslContextParameters; } + @Override + public boolean isUseGlobalSSLContextParameters() { + return this.useGlobalSSLContextParameters; + } + + /** + * Enable usage of global SSL context parameters. + */ + @Override + public void setUseGlobalSSLContextParameters(boolean useGlobalSSLContextParameters) { + this.useGlobalSSLContextParameters = useGlobalSSLContextParameters; + } public UndertowHostOptions getHostOptions() { return hostOptions; http://git-wip-us.apache.org/repos/asf/camel/blob/d51aa65d/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponent.java b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponent.java index c575960..d69706b 100644 --- a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponent.java +++ b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponent.java @@ -66,8 +66,8 @@ public class WebsocketComponent extends UriEndpointComponent implements SSLConte @Metadata(label = "security") protected SSLContextParameters sslContextParameters; - @Metadata(label = "security", defaultValue = "true") - protected boolean useGlobalSslContextParameters = true; + @Metadata(label = "security", defaultValue = "false") + protected boolean useGlobalSSLContextParameters; @Metadata(label = "advanced") protected ThreadPool threadPool; @Metadata(defaultValue = "9292") @@ -280,10 +280,7 @@ public class WebsocketComponent extends UriEndpointComponent implements SSLConte @Override protected Endpoint createEndpoint(String uri, String remaining, Map parameters) throws Exception { SSLContextParameters sslContextParameters = resolveAndRemoveReferenceParameter(parameters, "sslContextParameters", SSLContextParameters.class); - Boolean useGlobalSslContextParameters = getAndRemoveParameter(parameters, "useGlobalSslContextParameters", Boolean.class); - if (useGlobalSslContextParameters == null) { - useGlobalSslContextParameters = this.useGlobalSslContextParameters; - } + Boolean enableJmx = getAndRemoveParameter(parameters, "enableJmx", Boolean.class); String staticResources = getAndRemoveParameter(parameters, "staticResources", String.class); int port = extractPortNumber(remaining); @@ -302,7 +299,7 @@ public class WebsocketComponent extends UriEndpointComponent implements SSLConte // fallback to component configured sslContextParameters = getSslContextParameters(); } - if (useGlobalSslContextParameters && sslContextParameters == null) { + if (sslContextParameters == null) { sslContextParameters = getGlobalSSLContextParameters(); } @@ -319,7 +316,6 @@ public class WebsocketComponent extends UriEndpointComponent implements SSLConte endpoint.setSslContextParameters(sslContextParameters); endpoint.setPort(port); endpoint.setHost(host); - endpoint.setUseGlobalSslContextParameters(useGlobalSslContextParameters); setProperties(endpoint, parameters); return endpoint; @@ -738,15 +734,17 @@ public class WebsocketComponent extends UriEndpointComponent implements SSLConte this.sslContextParameters = sslContextParameters; } - public boolean isUseGlobalSslContextParameters() { - return useGlobalSslContextParameters; + @Override + public boolean isUseGlobalSSLContextParameters() { + return this.useGlobalSSLContextParameters; } /** - * Enable usage of Camel global SSL context parameters + * Enable usage of global SSL context parameters. */ - public void setUseGlobalSslContextParameters(boolean useGlobalSslContextParameters) { - this.useGlobalSslContextParameters = useGlobalSslContextParameters; + @Override + public void setUseGlobalSSLContextParameters(boolean useGlobalSSLContextParameters) { + this.useGlobalSSLContextParameters = useGlobalSSLContextParameters; } public Map getSocketFactory() { http://git-wip-us.apache.org/repos/asf/camel/blob/d51aa65d/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketEndpoint.java b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketEndpoint.java index 27427c8..cdd4cbf 100644 --- a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketEndpoint.java +++ b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketEndpoint.java @@ -64,8 +64,6 @@ public class WebsocketEndpoint extends DefaultEndpoint { private boolean crossOriginFilterOn; @UriParam(label = "security") private SSLContextParameters sslContextParameters; - @UriParam(label = "security", defaultValue = "true") - private boolean useGlobalSslContextParameters = true; @UriParam(label = "cors") private String allowedOrigins; @UriParam(label = "cors") @@ -297,17 +295,6 @@ public class WebsocketEndpoint extends DefaultEndpoint { this.sslContextParameters = sslContextParameters; } - public boolean isUseGlobalSslContextParameters() { - return useGlobalSslContextParameters; - } - - /** - * Enable usage of Camel global SSL context parameters - */ - public void setUseGlobalSslContextParameters(boolean useGlobalSslContextParameters) { - this.useGlobalSslContextParameters = useGlobalSslContextParameters; - } - public boolean isEnableJmx() { return this.enableJmx; } http://git-wip-us.apache.org/repos/asf/camel/blob/d51aa65d/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketSSLContextGlobalRouteExampleTest.java ---------------------------------------------------------------------- diff --git a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketSSLContextGlobalRouteExampleTest.java b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketSSLContextGlobalRouteExampleTest.java index 2ba350a..7dee865 100644 --- a/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketSSLContextGlobalRouteExampleTest.java +++ b/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketSSLContextGlobalRouteExampleTest.java @@ -30,6 +30,7 @@ import io.netty.handler.ssl.ClientAuth; import io.netty.handler.ssl.JdkSslContext; import org.apache.camel.CamelContext; +import org.apache.camel.SSLContextParametersAware; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.test.AvailablePortFinder; import org.apache.camel.test.junit4.CamelTestSupport; @@ -94,6 +95,8 @@ public class WebsocketSSLContextGlobalRouteExampleTest extends CamelTestSupport sslContextParameters.setTrustManagers(tmp); sslContextParameters.setServerParameters(scsp); context.setSSLContextParameters(sslContextParameters); + + ((SSLContextParametersAware) context.getComponent("websocket")).setUseGlobalSSLContextParameters(true); return context; } http://git-wip-us.apache.org/repos/asf/camel/blob/d51aa65d/platforms/spring-boot/components-starter/camel-http-starter/src/main/java/org/apache/camel/component/http/springboot/HttpComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-http-starter/src/main/java/org/apache/camel/component/http/springboot/HttpComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-http-starter/src/main/java/org/apache/camel/component/http/springboot/HttpComponentConfiguration.java index 619b34f..c0c7a25 100644 --- a/platforms/spring-boot/components-starter/camel-http-starter/src/main/java/org/apache/camel/component/http/springboot/HttpComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-http-starter/src/main/java/org/apache/camel/component/http/springboot/HttpComponentConfiguration.java @@ -63,6 +63,10 @@ public class HttpComponentConfiguration { */ private Boolean allowJavaSerializedObject = false; /** + * Enable usage of global SSL context parameters. + */ + private Boolean useGlobalSSLContextParameters = false; + /** * To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter * header to and from Camel message. */ @@ -117,6 +121,15 @@ public class HttpComponentConfiguration { this.allowJavaSerializedObject = allowJavaSerializedObject; } + public Boolean getUseGlobalSSLContextParameters() { + return useGlobalSSLContextParameters; + } + + public void setUseGlobalSSLContextParameters( + Boolean useGlobalSSLContextParameters) { + this.useGlobalSSLContextParameters = useGlobalSSLContextParameters; + } + public HeaderFilterStrategy getHeaderFilterStrategy() { return headerFilterStrategy; } http://git-wip-us.apache.org/repos/asf/camel/blob/d51aa65d/platforms/spring-boot/components-starter/camel-http-starter/src/main/java/org/apache/camel/component/http/springboot/HttpComponentSSLAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-http-starter/src/main/java/org/apache/camel/component/http/springboot/HttpComponentSSLAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-http-starter/src/main/java/org/apache/camel/component/http/springboot/HttpComponentSSLAutoConfiguration.java index d8d6988..40f4bca 100644 --- a/platforms/spring-boot/components-starter/camel-http-starter/src/main/java/org/apache/camel/component/http/springboot/HttpComponentSSLAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-http-starter/src/main/java/org/apache/camel/component/http/springboot/HttpComponentSSLAutoConfiguration.java @@ -30,48 +30,51 @@ import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** - * Generated by camel-package-maven-plugin - do not edit this file! + * Configuration of global SSL parameters. */ @Configuration -@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@ConditionalOnProperty(value = "camel.component.http.ssl.auto-configure", matchIfMissing = true) +@ConditionalOnBean(HttpComponentAutoConfiguration.class) +@AutoConfigureAfter(HttpComponentAutoConfiguration.class) public class HttpComponentSSLAutoConfiguration { private static final Logger LOG = LoggerFactory.getLogger(HttpComponentSSLAutoConfiguration.class); @Bean - public HttpSSLPostProcessor cacheAutoConfigurationValidatorPostProcessor(CamelContext context) { - return new HttpSSLPostProcessor(context); + public HttpSSLPostProcessor cacheAutoConfigurationValidatorPostProcessor(CamelContext context, HttpComponentConfiguration config) { + return new HttpSSLPostProcessor(context, config); } static class HttpSSLPostProcessor implements BeanFactoryPostProcessor { private CamelContext context; - HttpSSLPostProcessor(CamelContext context) { + private HttpComponentConfiguration config; + + HttpSSLPostProcessor(CamelContext context, HttpComponentConfiguration config) { this.context = context; + this.config = config; } @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { try { - SSLContextParameters globalSSLParams = context.getSSLContextParameters(); + if (config != null && config.getUseGlobalSSLContextParameters() != null && config.getUseGlobalSSLContextParameters()) { + SSLContextParameters globalSSLParams = context.getSSLContextParameters(); - if (globalSSLParams != null) { - ProtocolSocketFactory factory = - new SSLContextParametersSecureProtocolSocketFactory(globalSSLParams, context); + if (globalSSLParams != null) { + ProtocolSocketFactory factory = + new SSLContextParametersSecureProtocolSocketFactory(globalSSLParams, context); - Protocol.registerProtocol("https", - new Protocol( - "https", - factory, - 443)); + Protocol.registerProtocol("https", + new Protocol( + "https", + factory, + 443)); + } } } catch (NoUniqueBeanDefinitionException e) { http://git-wip-us.apache.org/repos/asf/camel/blob/d51aa65d/platforms/spring-boot/components-starter/camel-http-starter/src/main/java/org/apache/camel/component/http/springboot/HttpComponentSSLConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-http-starter/src/main/java/org/apache/camel/component/http/springboot/HttpComponentSSLConfiguration.java b/platforms/spring-boot/components-starter/camel-http-starter/src/main/java/org/apache/camel/component/http/springboot/HttpComponentSSLConfiguration.java deleted file mode 100644 index c1fc238..0000000 --- a/platforms/spring-boot/components-starter/camel-http-starter/src/main/java/org/apache/camel/component/http/springboot/HttpComponentSSLConfiguration.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.http.springboot; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * SSL related options - */ -@ConfigurationProperties(prefix = "camel.component.http.ssl") -public class HttpComponentSSLConfiguration { - - /** - * Auto-configure SSL from SSLContextParameters. - */ - private boolean autoConfigure = true; - - public HttpComponentSSLConfiguration() { - } - - public boolean isAutoConfigure() { - return autoConfigure; - } - - public void setAutoConfigure(boolean autoConfigure) { - this.autoConfigure = autoConfigure; - } - -} \ No newline at end of file