cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1535671 - in /cxf/trunk/rt/transports: http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/ http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/ http/src/main/java/org/apache/cxf/transport/http/
Date Fri, 25 Oct 2013 10:02:05 GMT
Author: ningjiang
Date: Fri Oct 25 10:02:05 2013
New Revision: 1535671

URL: http://svn.apache.org/r1535671
Log:
CXF-5333 Supported to set the TLSClientParameters dynamically

Modified:
    cxf/trunk/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
    cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpClientPipelineFactory.java
    cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduit.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/URLConnectionHTTPConduit.java

Modified: cxf/trunk/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java?rev=1535671&r1=1535670&r2=1535671&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
(original)
+++ cxf/trunk/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
Fri Oct 25 10:02:05 2013
@@ -159,10 +159,15 @@ public class AsyncHTTPConduit extends UR
                 break;
             }
             
-        } 
+        }
+        // check tlsClientParameters from message header
+        TLSClientParameters clientParameters = message.get(TLSClientParameters.class);
+        if (clientParameters == null) {
+            clientParameters = tlsClientParameters;
+        }
         if (uri.getScheme().equals("https") 
-            && tlsClientParameters != null
-            && tlsClientParameters.getSSLSocketFactory() != null) {
+            && clientParameters != null
+            && clientParameters.getSSLSocketFactory() != null) {
             //if they configured in an SSLSocketFactory, we cannot do anything
             //with it as the NIO based transport cannot use socket created from
             //the SSLSocketFactory.
@@ -488,8 +493,11 @@ public class AsyncHTTPConduit extends UR
                         = RegistryBuilder.<SchemeIOSessionStrategy>create()
                             .register("http", NoopIOSessionStrategy.INSTANCE);
                     
-                   
-                    TLSClientParameters tlsClientParameters = getTlsClientParameters();
+                    // check tlsClientParameters from message header
+                    TLSClientParameters tlsClientParameters = outMessage.get(TLSClientParameters.class);
+                    if (tlsClientParameters == null) {
+                        tlsClientParameters = getTlsClientParameters();
+                    }
                     if (tlsClientParameters == null) {
                         tlsClientParameters = new TLSClientParameters();
                     }

Modified: cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpClientPipelineFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpClientPipelineFactory.java?rev=1535671&r1=1535670&r2=1535671&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpClientPipelineFactory.java
(original)
+++ cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpClientPipelineFactory.java
Fri Oct 25 10:02:05 2013
@@ -25,6 +25,7 @@ import java.util.logging.Logger;
 import javax.net.ssl.SSLEngine;
 
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.configuration.jsse.TLSClientParameters;
 import org.apache.cxf.transport.https.SSLUtils;
 
 import io.netty.channel.Channel;
@@ -41,10 +42,10 @@ public class NettyHttpClientPipelineFact
     
     private static final Logger LOG =
         LogUtils.getL7dLogger(NettyHttpClientPipelineFactory.class);
-    private final NettyHttpConduit httpConduit;
+    private final TLSClientParameters tlsClientParameters;
     
-    public NettyHttpClientPipelineFactory(NettyHttpConduit httpConduit) {
-        this.httpConduit = httpConduit;
+    public NettyHttpClientPipelineFactory(TLSClientParameters clientParameters) {
+        this.tlsClientParameters = clientParameters;
     }
     
     @Override
@@ -69,8 +70,8 @@ public class NettyHttpClientPipelineFact
     }
     
     private SslHandler configureClientSSLOnDemand() throws Exception {
-        if (httpConduit.getTlsClientParameters() != null) {
-            SSLEngine sslEngine = SSLUtils.createClientSSLEngine(httpConduit.getTlsClientParameters());
+        if (tlsClientParameters != null) {
+            SSLEngine sslEngine = SSLUtils.createClientSSLEngine(tlsClientParameters);
             return new SslHandler(sslEngine);
         } else {
             return null;

Modified: cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduit.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduit.java?rev=1535671&r1=1535670&r2=1535671&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduit.java
(original)
+++ cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduit.java
Fri Oct 25 10:02:05 2013
@@ -42,6 +42,7 @@ import javax.net.ssl.SSLSession;
 import org.apache.cxf.Bus;
 import org.apache.cxf.buslifecycle.BusLifeCycleListener;
 import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.configuration.jsse.TLSClientParameters;
 import org.apache.cxf.helpers.HttpHeaderHelper;
 import org.apache.cxf.io.CacheAndWriteOutputStream;
 import org.apache.cxf.message.Message;
@@ -85,7 +86,6 @@ public class NettyHttpConduit extends UR
         bootstrap = new Bootstrap();
         bootstrap.group(group);
         bootstrap.channel(NioSocketChannel.class);
-        bootstrap.handler(new NettyHttpClientPipelineFactory(this));
     }
     
     public NettyHttpConduitFactory getNettyHttpConduitFactory() {
@@ -281,7 +281,18 @@ public class NettyHttpConduit extends UR
         }
 
         protected void connect(boolean output) {
-
+            if (url.getScheme().equals("https")) {
+                TLSClientParameters clientParameters = outMessage.get(TLSClientParameters.class);
+                if (clientParameters == null) {
+                    clientParameters = getTlsClientParameters();
+                }
+                if (clientParameters == null) {
+                    clientParameters = new TLSClientParameters();
+                }
+                bootstrap.handler(new NettyHttpClientPipelineFactory(clientParameters));
+            } else {
+                bootstrap.handler(new NettyHttpClientPipelineFactory(null));
+            }
             ChannelFuture connFuture = 
                 bootstrap.connect(new InetSocketAddress(url.getHost(), url.getPort()));
 

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/URLConnectionHTTPConduit.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/URLConnectionHTTPConduit.java?rev=1535671&r1=1535670&r2=1535671&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/URLConnectionHTTPConduit.java
(original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/URLConnectionHTTPConduit.java
Fri Oct 25 10:02:05 2013
@@ -32,6 +32,7 @@ import java.net.URLConnection;
 import java.util.logging.Level;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.configuration.jsse.TLSClientParameters;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.io.CacheAndWriteOutputStream;
 import org.apache.cxf.message.Message;
@@ -91,7 +92,12 @@ public class URLConnectionHTTPConduit ex
         URL url = uri.toURL();
         Proxy proxy = proxyFactory.createProxy(csPolicy , uri);
         message.put("http.scheme", uri.getScheme());
-        return connectionFactory.createConnection(tlsClientParameters, proxy, url);
+        // check tlsClientParameters from message header
+        TLSClientParameters clientParameters = message.get(TLSClientParameters.class);
+        if (clientParameters == null) {
+            clientParameters = tlsClientParameters;
+        }
+        return connectionFactory.createConnection(clientParameters, proxy, url);
     }
     protected void setupConnection(Message message, URI currentURL, HTTPClientPolicy csPolicy)
throws IOException {
         HttpURLConnection connection = createConnection(message, currentURL, csPolicy);



Mime
View raw message