cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1050075 - in /cxf/trunk/rt/transports/http/src: main/java/org/apache/cxf/transport/http/HttpAuthHeader.java test/java/org/apache/cxf/transport/http/DigestAuthSupplierTest.java test/java/org/apache/cxf/transport/http/HttpAuthHeaderTest.java
Date Thu, 16 Dec 2010 17:49:46 GMT
Author: cschneider
Date: Thu Dec 16 17:49:45 2010
New Revision: 1050075

URL: http://svn.apache.org/viewvc?rev=1050075&view=rev
Log:
CXF-3123 Some refactorings of the http auth code to make it easier to add new auth mechanisms

Added:
    cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HttpAuthHeaderTest.java
Modified:
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpAuthHeader.java
    cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/DigestAuthSupplierTest.java

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpAuthHeader.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpAuthHeader.java?rev=1050075&r1=1050074&r2=1050075&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpAuthHeader.java
(original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpAuthHeader.java
Thu Dec 16 17:49:45 2010
@@ -85,9 +85,6 @@ public final class HttpAuthHeader {
                     return map;
                 }
                 String value = tok.sval;
-                if (value.charAt(0) == '"') {
-                    value = value.substring(1, value.length() - 1);
-                }
                 map.put(key, value);
             }
         } catch (IOException ex) {

Modified: cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/DigestAuthSupplierTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/DigestAuthSupplierTest.java?rev=1050075&r1=1050074&r2=1050075&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/DigestAuthSupplierTest.java
(original)
+++ cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/DigestAuthSupplierTest.java
Thu Dec 16 17:49:45 2010
@@ -21,6 +21,7 @@ package org.apache.cxf.transport.http;
 import java.io.UnsupportedEncodingException;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.cxf.configuration.security.AuthorizationPolicy;
@@ -81,11 +82,19 @@ public class DigestAuthSupplierTest {
         control.replay();
         String authToken = authSupplier
             .getAuthorizationForRealm(conduit, url, message, "myRealm", fullHeader);
-        assertEquals("Digest response=\"28e616b6868f60aaf9b19bb5b172f076\", " 
-                     + "cnonce=\"27db039b76362f3d55da10652baee38c\", " 
-                     + "username=\"testUser\", nc=\"00000001\", " 
-                     + "nonce=\"MTI0ODg3OTc5NzE2OTplZGUyYTg0Yzk2NTFkY2YyNjc1Y2JjZjU2MTUzZmQyYw==\",
"
-                     + "realm=\"MyCompany realm.\", qop=\"auth\", uri=\"\"", authToken);
+        HttpAuthHeader authHeader = new HttpAuthHeader(authToken);
+        assertEquals("Digest", authHeader.getAuthType());
+        Map<String, String> params = authHeader.getParams();
+        Map<String, String> expectedParams = new HashMap<String, String>();
+        expectedParams.put("response", "28e616b6868f60aaf9b19bb5b172f076");
+        expectedParams.put("cnonce", "27db039b76362f3d55da10652baee38c");
+        expectedParams.put("username", "testUser");
+        expectedParams.put("nc", "00000001");
+        expectedParams.put("nonce", "MTI0ODg3OTc5NzE2OTplZGUyYTg0Yzk2NTFkY2YyNjc1Y2JjZjU2MTUzZmQyYw==");
+        expectedParams.put("realm", "MyCompany realm.");
+        expectedParams.put("qop", "auth");
+        expectedParams.put("uri", "");
+        assertEquals(expectedParams, params);
         control.verify();
     }
 }

Added: cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HttpAuthHeaderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HttpAuthHeaderTest.java?rev=1050075&view=auto
==============================================================================
--- cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HttpAuthHeaderTest.java
(added)
+++ cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HttpAuthHeaderTest.java
Thu Dec 16 17:49:45 2010
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.transport.http;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class HttpAuthHeaderTest {
+
+    @Test
+    public void testParse() {
+        HttpAuthHeader authHeader = new HttpAuthHeader("Digest nonce=\"TUzZmQyYw==\", username=\"testUser\"");
+        assertEquals("Digest", authHeader.getAuthType());
+        Map<String, String> params = authHeader.getParams();
+        Map<String, String> expectedParams = new HashMap<String, String>();
+        expectedParams.put("username", "testUser");
+        expectedParams.put("nonce", "TUzZmQyYw==");
+        assertEquals(expectedParams, params);
+    }
+}



Mime
View raw message