camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [3/3] git commit: CAMEL-7940 Fixed the test error with JDK6 and do not set the enabledProtocols if specify the SslContextParameter
Date Thu, 06 Nov 2014 09:48:37 GMT
CAMEL-7940 Fixed the test error with JDK6 and do not set the enabledProtocols if specify the
SslContextParameter


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

Branch: refs/heads/master
Commit: ea0f7f48f3ef77cf4af7303f50e2d5ce6eabcee8
Parents: 4c48e87
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Thu Nov 6 17:47:39 2014 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Thu Nov 6 17:48:15 2014 +0800

----------------------------------------------------------------------
 .../netty/http/HttpClientPipelineFactory.java      |  5 ++++-
 .../netty/http/HttpServerPipelineFactory.java      |  5 ++++-
 .../http/HttpServerSharedPipelineFactory.java      |  5 ++++-
 .../netty/DefaultClientPipelineFactory.java        |  5 ++++-
 .../netty/DefaultServerPipelineFactory.java        |  6 ++++--
 .../netty/NettyServerBootstrapConfiguration.java   | 16 ++++++++++++++--
 .../netty4/http/HttpClientInitializerFactory.java  |  5 ++++-
 .../netty4/http/HttpServerInitializerFactory.java  |  5 ++++-
 .../http/HttpServerSharedInitializerFactory.java   |  5 ++++-
 .../netty4/DefaultClientInitializerFactory.java    |  5 ++++-
 .../netty4/DefaultServerInitializerFactory.java    |  5 ++++-
 .../netty4/NettyServerBootstrapConfiguration.java  | 17 ++++++++++++++---
 12 files changed, 68 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ea0f7f48/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpClientPipelineFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpClientPipelineFactory.java
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpClientPipelineFactory.java
index 9c85c9d..ee77dce 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpClientPipelineFactory.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpClientPipelineFactory.java
@@ -174,7 +174,10 @@ public class HttpClientPipelineFactory extends ClientPipelineFactory
{
         } else if (sslContext != null) {
             SSLEngine engine = sslContext.createSSLEngine();
             engine.setUseClientMode(true);
-            engine.setEnabledProtocols(producer.getConfiguration().getEnabledProtocols().split(","));
+            if (producer.getConfiguration().getSslContextParameters() == null) {
+                // just set the enabledProtocols if the SslContextParameter doesn't set
+                engine.setEnabledProtocols(producer.getConfiguration().getEnabledProtocols().split(","));
+            }
             return new SslHandler(engine);
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/ea0f7f48/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
index 565534c..84a4eeb 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
@@ -184,7 +184,10 @@ public class HttpServerPipelineFactory extends ServerPipelineFactory
{
             SSLEngine engine = sslContext.createSSLEngine();
             engine.setUseClientMode(false);
             engine.setNeedClientAuth(consumer.getConfiguration().isNeedClientAuth());
-            engine.setEnabledProtocols(consumer.getConfiguration().getEnabledProtocols().split(","));
+            if (consumer.getConfiguration().getSslContextParameters() == null) {
+                // just set the enabledProtocols if the SslContextParameter doesn't set
+                engine.setEnabledProtocols(consumer.getConfiguration().getEnabledProtocols().split(","));
+            }
             return new SslHandler(engine);
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/ea0f7f48/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java
index c920fd4..f9b4cd0 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java
@@ -151,7 +151,10 @@ public class HttpServerSharedPipelineFactory extends HttpServerPipelineFactory
{
             SSLEngine engine = sslContext.createSSLEngine();
             engine.setUseClientMode(false);
             engine.setNeedClientAuth(configuration.isNeedClientAuth());
-            engine.setEnabledProtocols(configuration.getEnabledProtocols().split(","));
+            if (configuration.getSslContextParameters() == null) {
+                // just set the enabledProtocols if the SslContextParameter doesn't set
+                engine.setEnabledProtocols(configuration.getEnabledProtocols().split(","));
+            }
             return new SslHandler(engine);
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/ea0f7f48/components/camel-netty/src/main/java/org/apache/camel/component/netty/DefaultClientPipelineFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/DefaultClientPipelineFactory.java
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/DefaultClientPipelineFactory.java
index b997720..556ee98 100644
--- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/DefaultClientPipelineFactory.java
+++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/DefaultClientPipelineFactory.java
@@ -155,7 +155,10 @@ public class DefaultClientPipelineFactory extends ClientPipelineFactory
 {
             return producer.getConfiguration().getSslHandler();
         } else if (sslContext != null) {
             SSLEngine engine = sslContext.createSSLEngine();
-            engine.setEnabledProtocols(producer.getConfiguration().getEnabledProtocols().split(","));
+            if (producer.getConfiguration().getSslContextParameters() == null) {
+                // just set the enabledProtocols if the SslContextParameter doesn't set
+                engine.setEnabledProtocols(producer.getConfiguration().getEnabledProtocols().split(","));
+            }
             engine.setUseClientMode(true);
             return new SslHandler(engine);
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/ea0f7f48/components/camel-netty/src/main/java/org/apache/camel/component/netty/DefaultServerPipelineFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/DefaultServerPipelineFactory.java
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/DefaultServerPipelineFactory.java
index 33f264a..6e6ec9f 100644
--- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/DefaultServerPipelineFactory.java
+++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/DefaultServerPipelineFactory.java
@@ -174,8 +174,10 @@ public class DefaultServerPipelineFactory extends ServerPipelineFactory
{
             SSLEngine engine = sslContext.createSSLEngine();
             engine.setUseClientMode(false);            
             engine.setNeedClientAuth(consumer.getConfiguration().isNeedClientAuth());
-            engine.setEnabledProtocols(consumer.getConfiguration().getEnabledProtocols().split(","));
-
+            if (consumer.getConfiguration().getSslContextParameters() == null) {
+                // just set the enabledProtocols if the SslContextParameter doesn't set
+                engine.setEnabledProtocols(consumer.getConfiguration().getEnabledProtocols().split(","));
+            }
             return new SslHandler(engine);
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/ea0f7f48/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyServerBootstrapConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyServerBootstrapConfiguration.java
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyServerBootstrapConfiguration.java
index 647d4cc..3ecc7ed 100644
--- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyServerBootstrapConfiguration.java
+++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyServerBootstrapConfiguration.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.netty;
 
 import java.io.File;
+import java.util.Locale;
 import java.util.Map;
 
 import org.apache.camel.util.jsse.SSLContextParameters;
@@ -25,7 +26,7 @@ import org.jboss.netty.channel.socket.nio.WorkerPool;
 import org.jboss.netty.handler.ssl.SslHandler;
 
 public class NettyServerBootstrapConfiguration implements Cloneable {
-
+    private static String defaultEnabledProtocols;
     protected String protocol;
     protected String host;
     protected int port;
@@ -55,11 +56,22 @@ public class NettyServerBootstrapConfiguration implements Cloneable {
     protected String trustStoreResource;
     protected String keyStoreFormat = "JKS";
     protected String securityProvider = "SunX509";
-    protected String enabledProtocols = "TLSv1,TLSv1.1,TLSv1.2";
+    protected String enabledProtocols = defaultEnabledProtocols;
     protected String passphrase;
     protected BossPool bossPool;
     protected WorkerPool workerPool;
     protected String networkInterface;
+    
+    // setup the default value of TLS
+    static {
+        // JDK6 doesn't support TLSv1.1,TLSv1.2
+        String javaVersion = System.getProperty("java.version").toLowerCase(Locale.US);
+        if (javaVersion.startsWith("1.6")) {
+            defaultEnabledProtocols = "TLSv1";
+        } else {
+            defaultEnabledProtocols = "TLSv1,TLSv1.1,TLSv1.2";
+        }
+    }
 
     public String getAddress() {
         return host + ":" + port;

http://git-wip-us.apache.org/repos/asf/camel/blob/ea0f7f48/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpClientInitializerFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpClientInitializerFactory.java
b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpClientInitializerFactory.java
index 6bf8869..898068a 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpClientInitializerFactory.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpClientInitializerFactory.java
@@ -178,7 +178,10 @@ public class HttpClientInitializerFactory extends ClientInitializerFactory
{
         } else if (sslContext != null) {
             SSLEngine engine = sslContext.createSSLEngine();
             engine.setUseClientMode(true);
-            engine.setEnabledProtocols(producer.getConfiguration().getEnabledProtocols().split(","));
+            if (producer.getConfiguration().getSslContextParameters() == null) {
+                // just set the enabledProtocols if the SslContextParameter doesn't set
+                engine.setEnabledProtocols(producer.getConfiguration().getEnabledProtocols().split(","));
+            }
             return new SslHandler(engine);
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/ea0f7f48/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerInitializerFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerInitializerFactory.java
b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerInitializerFactory.java
index 833c5bc..94fc834 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerInitializerFactory.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerInitializerFactory.java
@@ -179,7 +179,10 @@ public class HttpServerInitializerFactory extends ServerInitializerFactory
{
             SSLEngine engine = sslContext.createSSLEngine();
             engine.setUseClientMode(false);
             engine.setNeedClientAuth(consumer.getConfiguration().isNeedClientAuth());
-            engine.setEnabledProtocols(consumer.getConfiguration().getEnabledProtocols().split(","));
+            if (consumer.getConfiguration().getSslContextParameters() == null) {
+                // just set the enabledProtocols if the SslContextParameter doesn't set
+                engine.setEnabledProtocols(consumer.getConfiguration().getEnabledProtocols().split(","));
+            }
             return new SslHandler(engine);
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/ea0f7f48/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
index c687641..3ed4397 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
@@ -150,7 +150,10 @@ public class HttpServerSharedInitializerFactory extends HttpServerInitializerFac
             SSLEngine engine = sslContext.createSSLEngine();
             engine.setUseClientMode(false);
             engine.setNeedClientAuth(configuration.isNeedClientAuth());
-            engine.setEnabledProtocols(configuration.getEnabledProtocols().split(","));
+            if (configuration.getSslContextParameters() == null) {
+                // just set the enabledProtocols if the SslContextParameter doesn't set
+                engine.setEnabledProtocols(configuration.getEnabledProtocols().split(","));
+            }
             return new SslHandler(engine);
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/ea0f7f48/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/DefaultClientInitializerFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/DefaultClientInitializerFactory.java
b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/DefaultClientInitializerFactory.java
index b35ba4e..ff7f50e 100644
--- a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/DefaultClientInitializerFactory.java
+++ b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/DefaultClientInitializerFactory.java
@@ -157,7 +157,10 @@ public class DefaultClientInitializerFactory extends ClientInitializerFactory
 {
         } else if (sslContext != null) {
             SSLEngine engine = sslContext.createSSLEngine();
             engine.setUseClientMode(true);
-            engine.setEnabledProtocols(producer.getConfiguration().getEnabledProtocols().split(","));
+            if (producer.getConfiguration().getSslContextParameters() == null) {
+                // just set the enabledProtocols if the SslContextParameter doesn't set
+                engine.setEnabledProtocols(producer.getConfiguration().getEnabledProtocols().split(","));
+            }
             return new SslHandler(engine);
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/ea0f7f48/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/DefaultServerInitializerFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/DefaultServerInitializerFactory.java
b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/DefaultServerInitializerFactory.java
index 0f080c6..6ec681c 100644
--- a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/DefaultServerInitializerFactory.java
+++ b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/DefaultServerInitializerFactory.java
@@ -177,7 +177,10 @@ public class DefaultServerInitializerFactory extends ServerInitializerFactory
{
             SSLEngine engine = sslContext.createSSLEngine();
             engine.setUseClientMode(false);
             engine.setNeedClientAuth(consumer.getConfiguration().isNeedClientAuth());
-            engine.setEnabledProtocols(consumer.getConfiguration().getEnabledProtocols().split(","));
+            if (consumer.getConfiguration().getSslContextParameters() == null) {
+                // just set the enabledProtocols if the SslContextParameter doesn't set
+                engine.setEnabledProtocols(consumer.getConfiguration().getEnabledProtocols().split(","));
+            }
             return new SslHandler(engine);
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/ea0f7f48/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyServerBootstrapConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyServerBootstrapConfiguration.java
b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyServerBootstrapConfiguration.java
index 20f1240..a0a6bcb 100644
--- a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyServerBootstrapConfiguration.java
+++ b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyServerBootstrapConfiguration.java
@@ -17,15 +17,15 @@
 package org.apache.camel.component.netty4;
 
 import java.io.File;
+import java.util.Locale;
 import java.util.Map;
 
 import io.netty.channel.EventLoopGroup;
 import io.netty.handler.ssl.SslHandler;
-
 import org.apache.camel.util.jsse.SSLContextParameters;
 
 public class NettyServerBootstrapConfiguration implements Cloneable {
-
+    private static String defaultEnabledProtocols;
     protected String protocol;
     protected String host;
     protected int port;
@@ -55,11 +55,22 @@ public class NettyServerBootstrapConfiguration implements Cloneable {
     protected String trustStoreResource;
     protected String keyStoreFormat;
     protected String securityProvider;
-    protected String enabledProtocols = "TLSv1,TLSv1.1,TLSv1.2";
+    protected String enabledProtocols = defaultEnabledProtocols;
     protected String passphrase;
     protected EventLoopGroup bossGroup;
     protected EventLoopGroup workerGroup;
     protected String networkInterface;
+    
+    // setup the default value of TLS
+    static {
+        // JDK6 doesn't support TLSv1.1,TLSv1.2
+        String javaVersion = System.getProperty("java.version").toLowerCase(Locale.US);
+        if (javaVersion.startsWith("1.6")) {
+            defaultEnabledProtocols = "TLSv1";
+        } else {
+            defaultEnabledProtocols = "TLSv1,TLSv1.1,TLSv1.2";
+        }
+    }
 
     public String getAddress() {
         return host + ":" + port;


Mime
View raw message