You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2008/05/24 01:11:34 UTC

svn commit: r659709 - /directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java

Author: elecharny
Date: Fri May 23 16:11:32 2008
New Revision: 659709

URL: http://svn.apache.org/viewvc?rev=659709&view=rev
Log:
Reverted to a previously working revision

Modified:
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java?rev=659709&r1=659708&r2=659709&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java Fri May 23 16:11:32 2008
@@ -188,25 +188,45 @@
      * @return A byte array which can be empty if the password was not found
      * @throws NamingException If we have a problem during the lookup operation
      */
-    private byte[] getStoredPassword( Registries registries, LdapDN principalDN ) throws NamingException
+    private LdapPrincipal getStoredPassword( Registries registries, LdapDN principalDN ) throws NamingException
     {
-        byte[] storedPassword;
+        LdapPrincipal principal;
+        String principalNorm = principalDN.getNormName();
         
-        // Not found in the cache
-        // Get the user password from the backend
-        storedPassword = lookupUserPassword( registries, principalDN );
+        synchronized( credentialCache )
+        {
+            principal = (LdapPrincipal)credentialCache.get( principalNorm );
+        }
         
+        byte[] storedPassword;
         
-        // Deal with the special case where the user didn't enter a password
-        // We will compare the empty array with the credentials. Sometime,
-        // a user does not set a password. This is bad, but there is nothing
-        // we can do against that, except education ...
-        if ( storedPassword == null )
+        if ( principal == null )
         {
-            storedPassword = ArrayUtils.EMPTY_BYTE_ARRAY;
-        }
+            // Not found in the cache
+            // Get the user password from the backend
+            storedPassword = lookupUserPassword( registries, principalDN );
+            
+            
+            // Deal with the special case where the user didn't enter a password
+            // We will compare the empty array with the credentials. Sometime,
+            // a user does not set a password. This is bad, but there is nothing
+            // we can do against that, except education ...
+            if ( storedPassword == null )
+            {
+                storedPassword = ArrayUtils.EMPTY_BYTE_ARRAY;
+            }
 
-        return storedPassword;
+            // Create the new principal before storing it in the cache
+            principal = new LdapPrincipal( principalDN, AuthenticationLevel.SIMPLE, storedPassword );
+            
+            // Now, update the local cache.
+            synchronized( credentialCache )
+            {
+                credentialCache.put( principalDN.getNormName(), principal );
+            }
+        }
+        
+        return principal;
     }
 
     /**
@@ -287,28 +307,10 @@
         // ---- extract password from JNDI environment
         byte[] credentials = getCredentials( ctx );
         
-        LdapPrincipal principal;
-        String principalNorm = principalDn.getNormName();
-        
-        synchronized( credentialCache )
-        {
-            principal = (LdapPrincipal)credentialCache.get( principalNorm );
-        }
-        
-        byte[] storedPassword = getStoredPassword( getDirectoryService().getRegistries(), principalDn );
-
-        if ( principal == null )
-        {
-            // Create the new principal before storing it in the cache
-            principal = new LdapPrincipal( principalDn, AuthenticationLevel.SIMPLE );
-            
-            // Now, update the local cache.
-            synchronized( credentialCache )
-            {
-                credentialCache.put( principalDn.getNormName(), principal );
-            }
-        }
+        LdapPrincipal principal = getStoredPassword( getDirectoryService().getRegistries(), principalDn );
         
+        // Get the stored password, either from cache or from backend
+        byte[] storedPassword = principal.getUserPassword();
         
         // Short circuit for PLAIN TEXT passwords : we compare the byte array directly
         // Are the passwords equal ?