svn commit: r740393 - /lenya/branches/BRANCH_2_0_X/src/modules-core/ac/java/src/org/apache/lenya/ac/impl/UserAuthenticator.java

[email protected]
Newsgroups gmane.comp.cms.lenya.cvs
Message-ID <[email protected]>
Author: andreas
Date: Tue Feb  3 19:40:41 2009
New Revision: 740393

URL: http://svn.apache.org/viewvc?rev=740393&view=rev
Log:
Consider the Authorization header only if the authorization is basic. Fixes bug 43823.

Modified:
    lenya/branches/BRANCH_2_0_X/src/modules-core/ac/java/src/org/apache/lenya/ac/impl/UserAuthenticator.java

Modified: lenya/branches/BRANCH_2_0_X/src/modules-core/ac/java/src/org/apache/lenya/ac/impl/UserAuthenticator.java
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_0_X/src/modules-core/ac/java/src/org/apache/lenya/ac/impl/UserAuthenticator.java?rev=740393&r1=740392&r2=740393&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_0_X/src/modules-core/ac/java/src/org/apache/lenya/ac/impl/UserAuthenticator.java (original)
+++ lenya/branches/BRANCH_2_0_X/src/modules-core/ac/java/src/org/apache/lenya/ac/impl/UserAuthenticator.java Tue Feb  3 19:40:41 2009
@@ -41,24 +41,28 @@
     public boolean authenticate(AccreditableManager accreditableManager, Request request)
             throws AccessControlException {
 
-        String encoded = "";
-        String unencoded = "";
-        String username = "";
-        String password = "";
+        String username = null;
+        String password = null;
+        
+        boolean useHeader = false;
         if (request.getHeader("Authorization") != null) {
-            encoded = request.getHeader("Authorization");
-        }
-        if (encoded.indexOf("Basic") > -1) {
-            encoded = encoded.trim();
-            encoded = encoded.substring(encoded.indexOf(' ') + 1);
-            unencoded = new String(Base64.decodeBase64(encoded.getBytes()));
-        }
-        if (unencoded.indexOf(":") - 1 > -1) {
-            username = unencoded.substring(0, unencoded.indexOf(":"));
-            password = unencoded.substring(unencoded.indexOf(":") + 1);
-        }
+            String encoded = request.getHeader("Authorization");
 
-        if (encoded.length() == 0 && request.getParameter("username") != null) {
+            if (encoded.indexOf("Basic") > -1) {
+                encoded = encoded.trim();
+                encoded = encoded.substring(encoded.indexOf(' ') + 1);
+                String unencoded = new String(Base64.decodeBase64(encoded.getBytes()));
+
+                if (unencoded.indexOf(":") - 1 > -1) {
+                    useHeader = true;
+                    username = unencoded.substring(0, unencoded.indexOf(":"));
+                    password = unencoded.substring(unencoded.indexOf(":") + 1);
+                }
+
+            }
+        }
+        
+        if (!useHeader && request.getParameter("username") != null) {
             username = request.getParameter("username").toLowerCase();
             password = request.getParameter("password");
         }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.