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 2007/04/16 00:19:38 UTC
svn commit: r529082 -
/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java
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
*/