cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r737729 - in /cxf/branches/2.1.x-fixes: ./ rt/transports/http/src/main/java/org/apache/cxf/transport/http/ rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/ rt/transports/http/src/main/resources/schemas/configuration/ r...
Date Mon, 26 Jan 2009 16:28:25 GMT
Author: dkulp
Date: Mon Jan 26 16:28:25 2009
New Revision: 737729

URL: http://svn.apache.org/viewvc?rev=737729&view=rev
Log:
Merged revisions 737237 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r737237 | dkulp | 2009-01-23 18:06:21 -0500 (Fri, 23 Jan 2009) | 2 lines
  
  Support for digest auth.  Changes API's a bit, will add to migration guide.
........

Added:
    cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/DigestAuthSupplier.java
      - copied unchanged from r737237, cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/DigestAuthSupplier.java
    cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpAuthSupplier.java
      - copied unchanged from r737237, cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpAuthSupplier.java
    cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/HttpAuthSupplierBeanDefinitionParser.java
      - copied unchanged from r737237, cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/HttpAuthSupplierBeanDefinitionParser.java
Removed:
    cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpBasicAuthSupplier.java
    cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/HttpBasicAuthSupplierBeanDefinitionParser.java
Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
    cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/HttpConduitBeanDefinitionParser.java
    cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/NamespaceHandler.java
    cxf/branches/2.1.x-fixes/rt/transports/http/src/main/resources/schemas/configuration/http-conf.xsd
    cxf/branches/2.1.x-fixes/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitTest.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan 26 16:28:25 2009
@@ -1 +1 @@
-/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691338,691355,691488,691602,691646,691706,691728,692116,692157,692310,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694795,694869,694981,694987,694993,695041,695096,695396,695484,695537,695552,695561,695619,695684,695835,695840,695868,695935,695977,696016,696094,696433,696720,697085,697868,698128,699289,700261,700507,700602,700981,701316,701783,701830,701862,702187,702205-702248,702267,702547,702561,702580,702602,702609,702616,702653,702656,702957,703191,703239,703309,703501,703513,703548,704584,704937,704997,705150,705235,705274,705340,705446,705548,705614,705692,705708,706482,706631,706675,706900,706909,707034,707089,707100,707902,708035,708044,708074,708410,708417,708550,708554,709353-709354,709425,710076,710150,71015
 4,711193,711388,711410,711490,711635,711949,711975,712194,712198,712238,712272,712299,712312,712670,712893,713082,713095-713096,713099,713584,713597,713737,713804,713899,714167-714168,714245,714255,717937-717961,718281-718448,718565,718620,718640,718665,718970,719017,719210,719215-719218,719222-719273,719305,719327-719680,720053,720119-720218,720238,720293-720316,720497,721221,721241,721501,722117,722129,722412,722988,723024,723338,723378,723716-723791,724333-724372,724433-724438,724449,724481,724485,724668,724780,724782,724785,724793,724795,724940,725071,725316,725332,725335,725348,725364,725418,725425-725426,725455,725506,725554,725562,725651,725671,725688,725754,725773,725799,725839,726342,726524,726631,726634,726637,726639,726692,726724,726769,726992,727096,727445,727521,727568,727692,727754,727781,727792,728070,728087,728696,728897,729051,729430,729449,729460,729863,730082,730139,730889,730891,731598,731604,731615,731631,731635,732036,732050,732320,732363,732411,732450,
 732710,732827,733512,733582,733901,734367,734462,734666,734762,734772,734812,734836,734965,735113,735252,735722-735723,735729,735734,735751,735782,735787,735987,736332,736343,736352,736358-736362,736408,736423,736448,736491,736621,736726,736736,736738-736739,736766,736825,736852,737032,737046,737061,737069,737124,737246
+/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691338,691355,691488,691602,691646,691706,691728,692116,692157,692310,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694795,694869,694981,694987,694993,695041,695096,695396,695484,695537,695552,695561,695619,695684,695835,695840,695868,695935,695977,696016,696094,696433,696720,697085,697868,698128,699289,700261,700507,700602,700981,701316,701783,701830,701862,702187,702205-702248,702267,702547,702561,702580,702602,702609,702616,702653,702656,702957,703191,703239,703309,703501,703513,703548,704584,704937,704997,705150,705235,705274,705340,705446,705548,705614,705692,705708,706482,706631,706675,706900,706909,707034,707089,707100,707902,708035,708044,708074,708410,708417,708550,708554,709353-709354,709425,710076,710150,71015
 4,711193,711388,711410,711490,711635,711949,711975,712194,712198,712238,712272,712299,712312,712670,712893,713082,713095-713096,713099,713584,713597,713737,713804,713899,714167-714168,714245,714255,717937-717961,718281-718448,718565,718620,718640,718665,718970,719017,719210,719215-719218,719222-719273,719305,719327-719680,720053,720119-720218,720238,720293-720316,720497,721221,721241,721501,722117,722129,722412,722988,723024,723338,723378,723716-723791,724333-724372,724433-724438,724449,724481,724485,724668,724780,724782,724785,724793,724795,724940,725071,725316,725332,725335,725348,725364,725418,725425-725426,725455,725506,725554,725562,725651,725671,725688,725754,725773,725799,725839,726342,726524,726631,726634,726637,726639,726692,726724,726769,726992,727096,727445,727521,727568,727692,727754,727781,727792,728070,728087,728696,728897,729051,729430,729449,729460,729863,730082,730139,730889,730891,731598,731604,731615,731631,731635,732036,732050,732320,732363,732411,732450,
 732710,732827,733512,733582,733901,734367,734462,734666,734762,734772,734812,734836,734965,735113,735252,735722-735723,735729,735734,735751,735782,735787,735987,736332,736343,736352,736358-736362,736408,736423,736448,736491,736621,736726,736736,736738-736739,736766,736825,736852,737032,737046,737061,737069,737124,737237,737246

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java?rev=737729&r1=737728&r2=737729&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
Mon Jan 26 16:28:25 2009
@@ -241,9 +241,9 @@
     private MessageTrustDecider trustDecider;
     
     /**
-     * This field contains the HttpBasicAuthSupplier.
+     * This field contains the HttpAuthSupplier.
      */
-    private HttpBasicAuthSupplier basicAuthSupplier;
+    private HttpAuthSupplier authSupplier;
 
     /**
      * This boolean signfies that that finalizeConfig is called, which is
@@ -360,9 +360,9 @@
             trustDecider = endpointInfo.getTraversedExtensor(
                     null, MessageTrustDecider.class);
         }
-        if (this.basicAuthSupplier == null) {
-            basicAuthSupplier = endpointInfo.getTraversedExtensor(
-                    null, HttpBasicAuthSupplier.class);
+        if (this.authSupplier == null) {
+            authSupplier = endpointInfo.getTraversedExtensor(
+                    null, HttpAuthSupplier.class);
         }
         if (trustDecider == null) {
             if (LOG.isLoggable(Level.FINE)) {
@@ -381,18 +381,18 @@
                     + "'");
             }
         }
-        if (basicAuthSupplier == null) {
+        if (authSupplier == null) {
             if (LOG.isLoggable(Level.FINE)) {
                 LOG.log(Level.FINE,
-                    "No Basic Auth Supplier configured for Conduit '"
+                    "No Auth Supplier configured for Conduit '"
                     + getConduitName() + "'");
             }
         } else {
             if (LOG.isLoggable(Level.FINE)) {
-                LOG.log(Level.FINE, "HttpBasicAuthSupplier of class '" 
-                    + basicAuthSupplier.getClass().getName()
+                LOG.log(Level.FINE, "HttpAuthSupplier of class '" 
+                    + authSupplier.getClass().getName()
                     + "' with logical name of '"
-                    + basicAuthSupplier.getLogicalName()
+                    + authSupplier.getLogicalName()
                     + "' has been configured for Conduit '" 
                     + getConduitName()
                     + "'");
@@ -477,8 +477,6 @@
         // with the Conduit.
         URL currentURL = setupURL(message);       
         
-        HttpBasicAuthSupplier.UserPass userPass = null;
-        
         // The need to cache the request is off by default
         boolean needToCacheRequest = false;
         
@@ -519,13 +517,16 @@
         int chunkThreshold = 0;
         // We must cache the request if we have basic auth supplier
         // without preemptive basic auth.
-        if (basicAuthSupplier != null) {
-            userPass = basicAuthSupplier.getPreemptiveUserPass(
-                    getConduitName(), currentURL, message);
-            needToCacheRequest = userPass == null;
-            LOG.log(Level.INFO,
-                "Basic Auth Supplier, but no Premeptive User Pass." 
-                + " We must cache request.");
+        if (authSupplier != null) {
+            String auth = authSupplier.getPreemptiveAuthorization(
+                    this, currentURL, message);
+            if (auth == null) {
+                needToCacheRequest = true;
+                isChunking = false;
+                LOG.log(Level.INFO,
+                        "Auth Supplier, but no Premeptive User Pass." 
+                        + " We must cache request.");
+            }
         }
         if (getClient().isAutoRedirect()) {
             needToCacheRequest = true;
@@ -1061,7 +1062,7 @@
      * <p>
      * The precedence is as follows:
      * 1. AuthorizationPolicy that is set on the Message, if exists.
-     * 2. Preemptive UserPass from BasicAuthSupplier, if exists.
+     * 2. Authorization from AuthSupplier, if exists.
      * 3. AuthorizationPolicy set/configured for conduit.
      * 
      * REVISIT: Since the AuthorizationPolicy is set on the message by class, then
@@ -1077,25 +1078,28 @@
             Map<String, List<String>> headers
     ) {
         AuthorizationPolicy authPolicy = getAuthorization();
+        AuthorizationPolicy newPolicy = message.get(AuthorizationPolicy.class);
         
-        HttpBasicAuthSupplier.UserPass userpass = null;
-        if (basicAuthSupplier != null) {
-            userpass = basicAuthSupplier.getPreemptiveUserPass(
-                    getConduitName(), url, message);
+        String authString = null;
+        if (authSupplier != null 
+            && (newPolicy == null
+                || (!"Basic".equals(newPolicy.getAuthorizationType())
+                    && newPolicy.getAuthorization() == null))) {
+            authString = authSupplier.getPreemptiveAuthorization(
+                    this, url, message);
+            if (authString != null) {
+                headers.put("Authorization",
+                            createMutableList(authString));
+                return;
+            }
         }
-        
-        AuthorizationPolicy newPolicy = message.get(AuthorizationPolicy.class);
         String userName = null;
         String passwd = null;
         if (null != newPolicy) {
             userName = newPolicy.getUserName();
             passwd = newPolicy.getPassword();
         }
-        if (userName == null
-            && userpass != null) {
-            userName = userpass.getUserid();
-            passwd   = userpass.getPassword();
-        }
+
         if (userName == null 
             && authPolicy != null && authPolicy.isSetUserName()) {
             userName = authPolicy.getUserName();
@@ -1336,21 +1340,16 @@
     }
 
     /**
-     * This method gets the Basic Auth Supplier that was set/configured for this 
+     * This method gets the Auth Supplier that was set/configured for this 
      * HTTPConduit.
-     * @return The Basic Auth Supplier or null.
+     * @return The Auth Supplier or null.
      */
-    public HttpBasicAuthSupplier getBasicAuthSupplier() {
-        return this.basicAuthSupplier;
+    public HttpAuthSupplier getAuthSupplier() {
+        return this.authSupplier;
     }
     
-    /**
-     * This method sets the Trust Decider for this HTTP Conduit.
-     * Using this method overrides any trust decider configured for this 
-     * HTTPConduit.
-     */
-    public void setBasicAuthSupplier(HttpBasicAuthSupplier supplier) {
-        this.basicAuthSupplier = supplier;
+    public void setAuthSupplier(HttpAuthSupplier supplier) {
+        this.authSupplier = supplier;
     }
     
     /**
@@ -1518,8 +1517,13 @@
 
         // If we don't have a dynamic supply of user pass, then
         // we don't retransmit. We just die with a Http 401 response.
-        if (basicAuthSupplier == null) {
-            return connection;
+        if (authSupplier == null) {
+            String auth = connection.getHeaderField("WWW-Authenticate");
+            if (auth.startsWith("Digest ")) {
+                authSupplier = new DigestAuthSupplier();
+            } else {
+                return connection;
+            }
         }
         
         URL currentURL = connection.getURL();
@@ -1551,9 +1555,9 @@
                                   + "\"");
         }
         
-        HttpBasicAuthSupplier.UserPass up = 
-            basicAuthSupplier.getUserPassForRealm(
-                getConduitName(), currentURL, message, realm);
+        String up = 
+            authSupplier.getAuthorizationForRealm(
+                this, currentURL, message, realm, connection.getHeaderField("WWW-Authenticate"));
         
         // No user pass combination. We give up.
         if (up == null) {
@@ -1564,9 +1568,8 @@
         authURLs.add(currentURL.toString() + realm);
         
         Map<String, List<String>> headers = getSetProtocolHeaders(message);
-        
-        setBasicAuthHeader(up.getUserid(), up.getPassword(), headers);
-        
+        headers.put("Authorization",
+                    createMutableList(up));
         return retransmit(
                 connection, currentURL, message, cachedStream);
     }
@@ -1670,8 +1673,15 @@
         List<String> auth = headers.get("WWW-Authenticate");
         if (auth != null) {
             for (String a : auth) {
-                if (a.startsWith("Basic realm=")) {
-                    return a.substring(a.indexOf("=") + 1);
+                int idx = a.indexOf("realm=");
+                if (idx != -1) {
+                    a = a.substring(idx + 6);
+                    if (a.charAt(0) == '"') {
+                        a = a.substring(1, a.indexOf('"', 1));
+                    } else if (a.contains(",")) {
+                        a = a.substring(0, a.indexOf(','));
+                    }
+                    return a;
                 }
             }
         }

Modified: cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/HttpConduitBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/HttpConduitBeanDefinitionParser.java?rev=737729&r1=737728&r2=737729&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/HttpConduitBeanDefinitionParser.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/HttpConduitBeanDefinitionParser.java
Mon Jan 26 16:28:25 2009
@@ -34,7 +34,7 @@
 import org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser;
 import org.apache.cxf.staxutils.StaxUtils;
 import org.apache.cxf.transport.http.HTTPConduit;
-import org.apache.cxf.transport.http.HttpBasicAuthSupplier;
+import org.apache.cxf.transport.http.HttpAuthSupplier;
 import org.apache.cxf.transport.http.MessageTrustDecider;
 import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
@@ -86,7 +86,7 @@
             if ("trustDecider".equals(elementName)) {                
                 mapBeanOrClassElement((Element)n, bean, MessageTrustDecider.class);
             } else if ("basicAuthSupplier".equals(elementName)) {
-                mapBeanOrClassElement((Element)n, bean, HttpBasicAuthSupplier.class);
+                mapBeanOrClassElement((Element)n, bean, HttpAuthSupplier.class);
             } else if ("tlsClientParameters".equals(elementName)) {
                 mapTLSClientParameters((Element)n, bean);
             }          

Modified: cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/NamespaceHandler.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/NamespaceHandler.java?rev=737729&r1=737728&r2=737729&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/NamespaceHandler.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/NamespaceHandler.java
Mon Jan 26 16:28:25 2009
@@ -26,8 +26,8 @@
                 new HttpConduitBeanDefinitionParser());        
         registerBeanDefinitionParser("trustDecider", 
                 new MessageTrustDeciderBeanDefinitionParser());        
-        registerBeanDefinitionParser("basicAuthSupplier", 
-                new HttpBasicAuthSupplierBeanDefinitionParser()); 
+        registerBeanDefinitionParser("authSupplier", 
+                new HttpAuthSupplierBeanDefinitionParser()); 
         registerBeanDefinitionParser("destination", 
                 new HttpDestinationBeanDefinitionParser());        
     }

Modified: cxf/branches/2.1.x-fixes/rt/transports/http/src/main/resources/schemas/configuration/http-conf.xsd
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/http/src/main/resources/schemas/configuration/http-conf.xsd?rev=737729&r1=737728&r2=737729&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/http/src/main/resources/schemas/configuration/http-conf.xsd
(original)
+++ cxf/branches/2.1.x-fixes/rt/transports/http/src/main/resources/schemas/configuration/http-conf.xsd
Mon Jan 26 16:28:25 2009
@@ -48,7 +48,7 @@
     <xs:element name="proxyAuthorization"  type="sec:ProxyAuthorizationPolicy"/>
     <xs:element name="tlsClientParameters" type="sec:TLSClientParametersType"/>
     <xs:element name="trustDecider"        type="cxf-beans:ClassOrBeanType"/>
-    <xs:element name="basicAuthSupplier"   type="cxf-beans:ClassOrBeanType"/>
+    <xs:element name="authSupplier"        type="cxf-beans:ClassOrBeanType"/>
     
     
     <xs:element name="conduit">
@@ -92,15 +92,15 @@
                      </xs:documentation>
                    </xs:annotation>
                 </xs:element>
-                <xs:element ref="http-conf:basicAuthSupplier" 
+                <xs:element ref="http-conf:authSupplier" 
                 			minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                      <xs:documentation>
                        Holds the bean reference or class name
-                       of an object that supplies Basic Auth information
+                       of an object that supplies Auth information
                        both preemptively and in response to a 401 HTTP
                        Challenge. This class must extend the abstract class 
-                       org.apache.cxf.transport.http.BasicAuthSupplier.
+                       org.apache.cxf.transport.http.HttpAuthSupplier.
                      </xs:documentation>
                    </xs:annotation>
                 </xs:element>

Modified: cxf/branches/2.1.x-fixes/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitTest.java?rev=737729&r1=737728&r2=737729&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitTest.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitTest.java
Mon Jan 26 16:28:25 2009
@@ -82,13 +82,15 @@
      * This test class is a Basic Auth Supplier with a
      * preemptive UserPass.
      */
-    class BasicAuthSupplier extends HttpBasicAuthSupplier {
-        public UserPass getPreemptiveUserPass(
-                String conduitName, URL url, Message m) {
-            return createUserPass("Gandalf", "staff");
+    class BasicAuthSupplier extends HttpAuthSupplier {
+        public String getPreemptiveAuthorization(
+                HTTPConduit conduit, URL url, Message m) {
+            String userpass = "Gandalf:staff";
+            String token = Base64Utility.encode(userpass.getBytes());
+            return "Basic " + token;
         }
-        public UserPass getUserPassForRealm(
-                String conduitName, URL url, Message m, String r) {
+        public String getAuthorizationForRealm(
+                HTTPConduit conduit, URL url, Message m, String r, String fh) {
             return null;
         }
     }
@@ -207,7 +209,7 @@
                 headers.get("Authorization").get(0));
 
         // Setting a Basic Auth User Pass should override
-        conduit.setBasicAuthSupplier(new BasicAuthSupplier());
+        conduit.setAuthSupplier(new BasicAuthSupplier());
         message = getNewMessage();
 
         // Test Call
@@ -216,14 +218,17 @@
         headers =
             CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS));
 
-        assertEquals("Unexpected Authorization Token",
+        String head = headers.get("Authorization").get(0);
+        assertEquals("Unexpected Authorization Token: " 
+                     + new String(Base64Utility.decode(head.substring(6))),
                 "Basic " + Base64Utility.encode("Gandalf:staff".getBytes()),
-                headers.get("Authorization").get(0));
+                head);
 
         // Setting authorization policy on the message should override all.
         AuthorizationPolicy authPolicy = new AuthorizationPolicy();
         authPolicy.setUserName("Hello");
         authPolicy.setPassword("world");
+        authPolicy.setAuthorizationType("Basic");
         message = getNewMessage();
         message.put(AuthorizationPolicy.class, authPolicy);
 

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java?rev=737729&r1=737728&r2=737729&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java
(original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java
Mon Jan 26 16:28:25 2009
@@ -42,6 +42,7 @@
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.spring.BusApplicationContext;
 import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.common.util.Base64Utility;
 import org.apache.cxf.configuration.jsse.TLSClientParameters;
 import org.apache.cxf.configuration.security.AuthorizationPolicy;
 import org.apache.cxf.configuration.security.FiltersType;
@@ -51,7 +52,7 @@
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 
 import org.apache.cxf.transport.http.HTTPConduit;
-import org.apache.cxf.transport.http.HttpBasicAuthSupplier;
+import org.apache.cxf.transport.http.HttpAuthSupplier;
 import org.apache.cxf.transport.http.MessageTrustDecider;
 import org.apache.cxf.transport.http.URLConnectionInfo;
 import org.apache.cxf.transport.http.UntrustedURLConnectionIOException;
@@ -722,7 +723,7 @@
         
     }
 
-    public class MyBasicAuthSupplier extends HttpBasicAuthSupplier {
+    public class MyBasicAuthSupplier extends HttpAuthSupplier {
 
         String realm;
         String user;
@@ -740,8 +741,8 @@
             pass  = p;
         }
         @Override
-        public UserPass getPreemptiveUserPass(
-                String  conduitName,
+        public String getPreemptiveAuthorization(
+                HTTPConduit  conduit,
                 URL     currentURL,
                 Message message
         ) {
@@ -753,11 +754,12 @@
          * through the realms.
          */
         @Override
-        public UserPass getUserPassForRealm(
-                String  conduitName, 
+        public String getAuthorizationForRealm(
+                HTTPConduit  conduit, 
                 URL     currentURL,
                 Message message, 
-                String  reqestedRealm
+                String  reqestedRealm,
+                String fullHeader
         ) {
             if (realm != null && realm.equals(reqestedRealm)) {
                 return createUserPass(user, pass);
@@ -777,6 +779,12 @@
             return null;
         }
 
+        private String createUserPass(String usr, String pwd) {
+            String userpass = usr + ":" + pwd;
+            String token = Base64Utility.encode(userpass.getBytes());
+            return "Basic " + token;
+        }
+
     }
 
     /**
@@ -818,7 +826,7 @@
         // 401 for realm Cronus. If we supply any name other
         // than Edward, George, or Mary, with the pass of "password"
         // we should succeed.
-        http.setBasicAuthSupplier(
+        http.setAuthSupplier(
                 new MyBasicAuthSupplier("Cronus", "Betty", "password"));
         
         // We actually get our answer from Bethal at the end of the
@@ -827,9 +835,9 @@
         assertTrue("Unexpected answer: " + answer, 
                 "Bonjour from Bethal".equals(answer));
         
-        // Uhe loop auth supplier, 
+        // The loop auth supplier, 
         // We should die with looping realms.
-        http.setBasicAuthSupplier(new MyBasicAuthSupplier());
+        http.setAuthSupplier(new MyBasicAuthSupplier());
         
         try {
             answer = gordy.sayHi();



Mime
View raw message