cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1393019 - in /cxf/trunk: rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/JettyDigestAuthTest.java
Date Tue, 02 Oct 2012 16:35:55 GMT
Author: dkulp
Date: Tue Oct  2 16:35:55 2012
New Revision: 1393019

URL: http://svn.apache.org/viewvc?rev=1393019&view=rev
Log:
[CXF-4525] Make it easier to set credentials so that it can be done via spring/blueprint config

Modified:
    cxf/trunk/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
    cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/JettyDigestAuthTest.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=1393019&r1=1393018&r2=1393019&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
Tue Oct  2 16:35:55 2012
@@ -468,10 +468,15 @@ public class AsyncHTTPConduit extends UR
             }
             ctx.setAttribute(ClientContext.SCHEME_REGISTRY, reg);
             connectionFuture = new BasicFuture<Boolean>(callback);
-            getHttpAsyncClient().execute(new CXFHttpAsyncRequestProducer(entity, outbuf),
-                                         new CXFHttpAsyncResponseConsumer(inbuf, responseCallback),
-                                         ctx,
-                                         callback);
+            DefaultHttpAsyncClient c = getHttpAsyncClient();
+            Credentials creds = (Credentials)outMessage.getContextualProperty(Credentials.class.getName());
+            if (creds != null) {
+                c.getCredentialsProvider().setCredentials(AuthScope.ANY, creds);
+            }
+            c.execute(new CXFHttpAsyncRequestProducer(entity, outbuf),
+                      new CXFHttpAsyncResponseConsumer(inbuf, responseCallback),
+                      ctx,
+                      callback);
         }
         
         protected synchronized void setHttpResponse(HttpResponse r) {

Modified: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/JettyDigestAuthTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/JettyDigestAuthTest.java?rev=1393019&r1=1393018&r2=1393019&view=diff
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/JettyDigestAuthTest.java
(original)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/JettyDigestAuthTest.java
Tue Oct  2 16:35:55 2012
@@ -45,7 +45,7 @@ import org.apache.cxf.transport.http.aut
 import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
 import org.apache.hello_world_soap_http.Greeter;
 import org.apache.hello_world_soap_http.SOAPService;
-import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.Credentials;
 import org.apache.http.auth.UsernamePasswordCredentials;
 
 import org.junit.BeforeClass;
@@ -109,12 +109,10 @@ public class JettyDigestAuthTest extends
         cond.setClient(client);
         if (async) {
             if (cond instanceof AsyncHTTPConduit) {
-                AsyncHTTPConduit acond = (AsyncHTTPConduit)cond;
-                acond.getClient().setAllowChunking(false);
-                acond.getClient().setAutoRedirect(true);
-                bp.getRequestContext().put(AsyncHTTPConduit.USE_ASYNC, Boolean.TRUE);
                 UsernamePasswordCredentials creds = new UsernamePasswordCredentials("ffang",
"pswd");
-                acond.getHttpAsyncClient().getCredentialsProvider().setCredentials(AuthScope.ANY,
creds);
+                bp.getRequestContext().put(Credentials.class.getName(), creds);
+                bp.getRequestContext().put(AsyncHTTPConduit.USE_ASYNC, Boolean.TRUE);
+                client.setAutoRedirect(true);
             } else {
                 fail("Not an async conduit");
             }
@@ -151,16 +149,15 @@ public class JettyDigestAuthTest extends
     }
     
     private void doTest(boolean async) throws Exception {
-        HTTPConduit cond = setupClient(async);
+        setupClient(async);
         assertEquals("Hello Alice", greeter.greetMe("Alice"));
         assertEquals("Hello Bob", greeter.greetMe("Bob"));
 
         try {
             BindingProvider bp = (BindingProvider)greeter;
             if (async) {
-                AsyncHTTPConduit acond = (AsyncHTTPConduit)cond;
                 UsernamePasswordCredentials creds = new UsernamePasswordCredentials("blah",
"foo");
-                acond.getHttpAsyncClient().getCredentialsProvider().setCredentials(AuthScope.ANY,
creds);
+                bp.getRequestContext().put(Credentials.class.getName(), creds);
             } else {
                 bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "blah");
                 bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "foo");



Mime
View raw message