directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r529082 - /directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java
Date Sun, 15 Apr 2007 22:19:38 GMT
Author: elecharny
Date: Sun Apr 15 15:19:33 2007
New Revision: 529082

URL: http://svn.apache.org/viewvc?view=rev&rev=529082
Log:
Applied the patch proposed by Chris to fix bug DIRSERVER-901

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

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java?view=diff&rev=529082&r1=529081&r2=529082
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java
Sun Apr 15 15:19:33 2007
@@ -184,6 +184,11 @@
         {
             // Found ! Are the password equals ?
             credentialsMatch = Arrays.equals( credentials, principal.getUserPassword() );
+            
+            if ( ! credentialsMatch )
+            {
+                credentialsMatch = authenticateHashedPassword(credentials, principal.getUserPassword());
+            }            
         }
         else
         {
@@ -205,24 +210,7 @@
     
             if ( ! credentialsMatch )
             {
-                // Check if password is stored as a message digest, i.e. one-way
-                // encrypted
-                String algorithm = getAlgorithmForHashedPassword( userPassword );
-                
-                if ( algorithm != null )
-                {
-                    try
-                    {
-                        // create a corresponding digested password from creds
-                        String digestedCredits = createDigestedPassword( algorithm, credentials
);
-        
-                        credentialsMatch = Arrays.equals( StringTools.getBytesUtf8( digestedCredits
), userPassword );
-                    }
-                    catch ( IllegalArgumentException e )
-                    {
-                        log.warn( "Exception during authentication", e.getMessage() );
-                    }
-                }
+                credentialsMatch = authenticateHashedPassword( credentials, userPassword
);
             }
             
             // Last, if we have found the credential, we have to store it in the cache
@@ -254,6 +242,32 @@
         }
     }
     
+    private boolean authenticateHashedPassword( byte[] credentials, byte[] storedPassword
) 
+    {
+        boolean credentialsMatch = false;
+        
+        // Check if password is stored as a message digest, i.e. one-way
+        // encrypted
+        String algorithm = getAlgorithmForHashedPassword( storedPassword );
+        
+        if ( algorithm != null )
+        {
+            try
+            {
+                // create a corresponding digested password from creds
+                String digestedCredits = createDigestedPassword( algorithm, credentials );
+                credentialsMatch = Arrays.equals( StringTools.getBytesUtf8( digestedCredits
), storedPassword );
+            }
+            catch ( IllegalArgumentException e )
+            {
+                log.warn( "Exception during authentication", e.getMessage() );
+            }
+        }
+        
+        return credentialsMatch;
+    }
+
+
     /**
      * Local function which request the password from the backend
      */



Mime
View raw message