You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2015/01/09 18:28:16 UTC
[2/2] cxf git commit: [CXF-6188] Add ability to configure the builder
and provide a Registry of AuthSchemeProviders
[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/09346fdf
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/09346fdf
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/09346fdf
Branch: refs/heads/3.0.x-fixes
Commit: 09346fdf83be3ad213a96670cf97e9b64bbea086
Parents: 53049ab
Author: Daniel Kulp <dk...@apache.org>
Authored: Fri Jan 9 12:26:38 2015 -0500
Committer: Daniel Kulp <dk...@apache.org>
Committed: Fri Jan 9 12:28:08 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/09346fdf/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/09346fdf/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());