cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject cxf git commit: [CXF-6188] Add ability to configure the builder and provide a Registry of AuthSchemeProviders
Date Fri, 09 Jan 2015 17:27:30 GMT
Repository: cxf
Updated Branches:
  refs/heads/master d5b502a60 -> eb82c4c12


[CXF-6188] Add ability to configure the builder and provide a Registry of AuthSchemeProviders


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

Branch: refs/heads/master
Commit: eb82c4c12f2613379dafa48763a30ccd5efc4861
Parents: d5b502a
Author: Daniel Kulp <dkulp@apache.org>
Authored: Fri Jan 9 12:26:38 2015 -0500
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Fri Jan 9 12:26:38 2015 -0500

----------------------------------------------------------------------
 .../transport/http/asyncclient/AsyncHTTPConduit.java  |  8 ++++++++
 .../http/asyncclient/AsyncHTTPConduitFactory.java     | 14 +++++++++++---
 2 files changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/eb82c4c1/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
b/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
index 56a677b..77815fa 100644
--- a/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
+++ b/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
@@ -72,6 +72,7 @@ import org.apache.cxf.ws.addressing.EndpointReferenceType;
 import org.apache.http.Header;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpResponse;
+import org.apache.http.auth.AuthSchemeProvider;
 import org.apache.http.auth.AuthScope;
 import org.apache.http.auth.Credentials;
 import org.apache.http.auth.UsernamePasswordCredentials;
@@ -79,6 +80,7 @@ import org.apache.http.client.config.RequestConfig;
 import org.apache.http.client.protocol.HttpClientContext;
 import org.apache.http.concurrent.BasicFuture;
 import org.apache.http.concurrent.FutureCallback;
+import org.apache.http.config.Registry;
 import org.apache.http.config.RegistryBuilder;
 import org.apache.http.entity.BasicHttpEntity;
 import org.apache.http.impl.client.BasicCredentialsProvider;
@@ -550,6 +552,12 @@ public class AsyncHTTPConduit extends URLConnectionHTTPConduit {
                 credsProvider.setCredentials(AuthScope.ANY, creds);
                 ctx.setUserToken(creds.getUserPrincipal());
             }
+            @SuppressWarnings("unchecked")
+            Registry<AuthSchemeProvider> asp = (Registry<AuthSchemeProvider>)outMessage
+                .getContextualProperty(AuthSchemeProvider.class.getName());
+            if (asp != null) {              
+                ctx.setAuthSchemeRegistry(asp);
+            }
 
             c.execute(new CXFHttpAsyncRequestProducer(entity, outbuf),
                       new CXFHttpAsyncResponseConsumer(this, inbuf, responseCallback),

http://git-wip-us.apache.org/repos/asf/cxf/blob/eb82c4c1/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitFactory.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitFactory.java
b/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitFactory.java
index c8411c9..6158d44 100644
--- a/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitFactory.java
+++ b/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitFactory.java
@@ -47,6 +47,7 @@ import org.apache.http.impl.client.BasicCookieStore;
 import org.apache.http.impl.conn.DefaultSchemePortResolver;
 import org.apache.http.impl.conn.SystemDefaultDnsResolver;
 import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
+import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
 import org.apache.http.impl.nio.client.HttpAsyncClients;
 import org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionFactory;
 import org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager;
@@ -349,19 +350,26 @@ public class AsyncHTTPConduitFactory implements HTTPConduitFactory {
             }
         };
 
-        client = HttpAsyncClients.custom()
+        HttpAsyncClientBuilder httpAsyncClientBuilder = HttpAsyncClients.custom()
             .setConnectionManager(connectionManager)
             .setRedirectStrategy(redirectStrategy)
             .setDefaultCookieStore(new BasicCookieStore() {
                 private static final long serialVersionUID = 1L;
                 public void addCookie(Cookie cookie) {
                 }
-            })
-            .build();
+            });
+        
+        adaptClientBuilder(httpAsyncClientBuilder);
+        
+        client = httpAsyncClientBuilder.build();
         // Start the client thread
         client.start();
     }
 
+    //provide a hook to customize the builder
+    protected void adaptClientBuilder(HttpAsyncClientBuilder httpAsyncClientBuilder) {  
 
+    }
+    
     public CloseableHttpAsyncClient createClient(final AsyncHTTPConduit c) throws IOException
{
         if (client == null) {
             setupNIOClient(c.getClient());


Mime
View raw message