cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r738536 - in /cxf/branches/2.0.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 Wed, 28 Jan 2009 16:55:18 GMT
Author: dkulp
Date: Wed Jan 28 16:55:17 2009
New Revision: 738536

URL: http://svn.apache.org/viewvc?rev=738536&view=rev
Log:
Merged revisions 737729 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.1.x-fixes

................
  r737729 | dkulp | 2009-01-26 11:28:25 -0500 (Mon, 26 Jan 2009) | 9 lines
  
  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.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/DigestAuthSupplier.java
      - copied unchanged from r737729, cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/DigestAuthSupplier.java
    cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpAuthSupplier.java
      - copied unchanged from r737729, cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpAuthSupplier.java
    cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/HttpAuthSupplierBeanDefinitionParser.java
      - copied unchanged from r737729, cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/HttpAuthSupplierBeanDefinitionParser.java
Removed:
    cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpBasicAuthSupplier.java
    cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/HttpBasicAuthSupplierBeanDefinitionParser.java
Modified:
    cxf/branches/2.0.x-fixes/   (props changed)
    cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
    cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/HttpConduitBeanDefinitionParser.java
    cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/NamespaceHandler.java
    cxf/branches/2.0.x-fixes/rt/transports/http/src/main/resources/schemas/configuration/http-conf.xsd
    cxf/branches/2.0.x-fixes/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitTest.java
    cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java

Propchange: cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jan 28 16:55:17 2009
@@ -1,3 +1,3 @@
-/cxf/branches/2.1.x-fixes:673548,674485,674547,674551,674562,674601,674649,674764,674887,675644,675653,677048,677385,678004,678009,678559,678629,678808,678852,678891,678893,679248,679597,680435,681060,681165,681813,681816,682902,682951,683089,683290,683318,684099,684790-684793,684842,684862,684895-684918,685205,685253,686237,686283,686299,686333-686364,686765,686827,687097,687464-687465,689109,689112,689122,691316,691357,691491,691711,691715,691745,692162-692163,692468,692500,694466-694469,694472,694717,694748-694749,694870,695503,695509,695553,695555,695563,695875-695877,695940,695980,696436,696455,696721,697086,698129,701526,701634,702275,702443,702527,702582,702604,702610,702642-702643,702649,702760,702870,702873,702959,703193,703242,703523,704303,704587,704738,704998,705153,705280-705449,705455,709357,709641,709644,710177,710184,711736,712199,712225,712275,712600,712896,713083,713410,713413,713594,713599,713808,713901,714169-714171,718622,718929,719211,719221-719223,7192
 96,719300-719301,719303,719308,719332,719356,719363,719369-719383,719650,719695,720124,723545,724403-724404,724421,724448,724451,724486-724487,724714,725367,725371,725763,725774,726045,726048,726106,726123,726745-726746,726749,726754,726756-726758,726995,727794,727797-727798,727800,731676,731684,731686-731688,731690,733587,733873,733876,733884,733891,733893,733915,735132,735136,735789,736451,736453,736456,736761,736765,736771,736827,736853,737126,737706,737714,737716,737726
-/cxf/trunk:651669-686342,686344-686363,686764,686820,687096,687387,687463,688086,688102,688735,691271,691355,691488,691602,691706,691728,692116,692157,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694869,695396,695484,695537,695552,695561,695619,695684,695835,695935,695977,696094,696433,696720,697085,698128,700261,700602,701783,701830,701862,702267,702580,702602,702609,702616,702656,702957,703191,703239,703501,704584,704997,705150,705274,705340,705446,708550,708554,709353-709354,709425,710150,712194,712198,712272,712312,712670,712893,713082,713584,713597,713804,713899,714167-714168,718281,718565,718620,718640,718665,719017,719210,719215-719218,719222,719273,719327-719354,719362,719368,719382,719649,719680,720119-720217,723338,723717-723791,724334-724371,724433-724438,724449,724481,724485,724668,724782,724795,725754,725773,725799,725839,726342,726524,726631,726637,726639,726692,726724,726992,727445,727692,727754,727792,730139,731598,731604,731615,73163
 1,731635,732320,732363,732411,732710,732827,733582,734666,734836,735734,736332,736343,736352,736408,736423,736491,736738,736766,736825,736852,737032,737069,737124
+/cxf/branches/2.1.x-fixes:673548,674485,674547,674551,674562,674601,674649,674764,674887,675644,675653,677048,677385,678004,678009,678559,678629,678808,678852,678891,678893,679248,679597,680435,681060,681165,681813,681816,682902,682951,683089,683290,683318,684099,684790-684793,684842,684862,684895-684918,685205,685253,686237,686283,686299,686333-686364,686765,686827,687097,687464-687465,689109,689112,689122,691316,691357,691491,691711,691715,691745,692162-692163,692468,692500,694466-694469,694472,694717,694748-694749,694870,695503,695509,695553,695555,695563,695875-695877,695940,695980,696436,696455,696721,697086,698129,701526,701634,702275,702443,702527,702582,702604,702610,702642-702643,702649,702760,702870,702873,702959,703193,703242,703523,704303,704587,704738,704998,705153,705280-705449,705455,709357,709641,709644,710177,710184,711736,712199,712225,712275,712600,712896,713083,713410,713413,713594,713599,713808,713901,714169-714171,718622,718929,719211,719221-719223,7192
 96,719300-719301,719303,719308,719332,719356,719363,719369-719383,719650,719695,720124,723545,724403-724404,724421,724448,724451,724486-724487,724714,725367,725371,725763,725774,726045,726048,726106,726123,726745-726746,726749,726754,726756-726758,726995,727794,727797-727798,727800,731676,731684,731686-731688,731690,733587,733873,733876,733884,733891,733893,733915,735132,735136,735789,736451,736453,736456,736761,736765,736771,736827,736853,737126,737706,737714,737716,737726,737729
+/cxf/trunk:651669-686342,686344-686363,686764,686820,687096,687387,687463,688086,688102,688735,691271,691355,691488,691602,691706,691728,692116,692157,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694869,695396,695484,695537,695552,695561,695619,695684,695835,695935,695977,696094,696433,696720,697085,698128,700261,700602,701783,701830,701862,702267,702580,702602,702609,702616,702656,702957,703191,703239,703501,704584,704997,705150,705274,705340,705446,708550,708554,709353-709354,709425,710150,712194,712198,712272,712312,712670,712893,713082,713584,713597,713804,713899,714167-714168,718281,718565,718620,718640,718665,719017,719210,719215-719218,719222,719273,719327-719354,719362,719368,719382,719649,719680,720119-720217,723338,723717-723791,724334-724371,724433-724438,724449,724481,724485,724668,724782,724795,725754,725773,725799,725839,726342,726524,726631,726637,726639,726692,726724,726992,727445,727692,727754,727792,730139,731598,731604,731615,73163
 1,731635,732320,732363,732411,732710,732827,733582,734666,734836,735734,736332,736343,736352,736408,736423,736491,736738,736766,736825,736852,737032,737069,737124,737237
 /incubator/cxf/trunk:434594-651668

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

Modified: cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java?rev=738536&r1=738535&r2=738536&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
(original)
+++ cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
Wed Jan 28 16:55:17 2009
@@ -240,9 +240,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
@@ -359,9 +359,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)) {
@@ -380,18 +380,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()
                     + "'");
@@ -473,8 +473,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;
         
@@ -514,13 +512,16 @@
         boolean isChunking = false;
         // 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()) {
             // If the AutoRedirect property is set then we cannot
@@ -1044,7 +1045,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
@@ -1060,25 +1061,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();
@@ -1319,21 +1323,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;
     }
     
     /**
@@ -1497,8 +1496,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();
@@ -1525,9 +1529,9 @@
             return connection;
         }
         
-        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) {
@@ -1538,9 +1542,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);
     }
@@ -1637,8 +1640,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.0.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.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/HttpConduitBeanDefinitionParser.java?rev=738536&r1=738535&r2=738536&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/HttpConduitBeanDefinitionParser.java
(original)
+++ cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/HttpConduitBeanDefinitionParser.java
Wed Jan 28 16:55:17 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.0.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.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/NamespaceHandler.java?rev=738536&r1=738535&r2=738536&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/NamespaceHandler.java
(original)
+++ cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/NamespaceHandler.java
Wed Jan 28 16:55:17 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.0.x-fixes/rt/transports/http/src/main/resources/schemas/configuration/http-conf.xsd
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/resources/schemas/configuration/http-conf.xsd?rev=738536&r1=738535&r2=738536&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/transports/http/src/main/resources/schemas/configuration/http-conf.xsd
(original)
+++ cxf/branches/2.0.x-fixes/rt/transports/http/src/main/resources/schemas/configuration/http-conf.xsd
Wed Jan 28 16:55:17 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.0.x-fixes/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitTest.java?rev=738536&r1=738535&r2=738536&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitTest.java
(original)
+++ cxf/branches/2.0.x-fixes/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitTest.java
Wed Jan 28 16:55:17 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.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java?rev=738536&r1=738535&r2=738536&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java
(original)
+++ cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java
Wed Jan 28 16:55:17 2009
@@ -41,6 +41,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;
@@ -50,7 +51,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;
@@ -731,7 +732,7 @@
         
     }
 
-    public class MyBasicAuthSupplier extends HttpBasicAuthSupplier {
+    public class MyBasicAuthSupplier extends HttpAuthSupplier {
 
         String realm;
         String user;
@@ -749,8 +750,8 @@
             pass  = p;
         }
         @Override
-        public UserPass getPreemptiveUserPass(
-                String  conduitName,
+        public String getPreemptiveAuthorization(
+                HTTPConduit  conduit,
                 URL     currentURL,
                 Message message
         ) {
@@ -762,11 +763,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);
@@ -786,6 +788,12 @@
             return null;
         }
 
+        private String createUserPass(String usr, String pwd) {
+            String userpass = usr + ":" + pwd;
+            String token = Base64Utility.encode(userpass.getBytes());
+            return "Basic " + token;
+        }
+
     }
 
     /**
@@ -827,7 +835,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
@@ -836,9 +844,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