directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r232227 - in /directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authn: AuthenticationService.java SimpleAuthenticator.java
Date Fri, 12 Aug 2005 07:49:38 GMT
Author: trustin
Date: Fri Aug 12 00:49:35 2005
New Revision: 232227

URL: http://svn.apache.org/viewcvs?rev=232227&view=rev
Log:
DIREVE-178
* Fixed SimpleAuthenticator not to throw LdapNameNotFoundExecption.
* Made AuthenticationService to log unexpected exceptions while authenticating.


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

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authn/AuthenticationService.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authn/AuthenticationService.java?rev=232227&r1=232226&r2=232227&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authn/AuthenticationService.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authn/AuthenticationService.java
Fri Aug 12 00:49:35 2005
@@ -44,6 +44,8 @@
 import org.apache.ldap.server.invocation.InvocationStack;
 import org.apache.ldap.server.jndi.ContextFactoryConfiguration;
 import org.apache.ldap.server.jndi.ServerContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -56,6 +58,8 @@
  */
 public class AuthenticationService extends BaseInterceptor
 {
+    private static final Logger log = LoggerFactory.getLogger( AuthenticationService.class
);
+    
     /** authenticators **/
     public Map authenticators = new HashMap();
 
@@ -356,26 +360,28 @@
         // try each authenticators
         for ( Iterator i = authenticators.iterator(); i.hasNext(); )
         {
+            Authenticator authenticator = ( Authenticator ) i.next();
+
             try
             {
-                Authenticator authenticator = ( Authenticator ) i.next();
-
                 // perform the authentication
-
                 LdapPrincipal authorizationId = authenticator.authenticate( ctx );
 
                 // authentication was successful
-
                 ctx.setPrincipal( new TrustedPrincipalWrapper( authorizationId ) );
 
                 // remove creds so there is no security risk
-
                 ctx.removeFromEnvironment( Context.SECURITY_CREDENTIALS );
                 return;
             }
-            catch ( LdapAuthenticationException e )
+            catch( LdapAuthenticationException e )
             {
                 // authentication failed, try the next authenticator
+            }
+            catch( Exception e )
+            {
+                // Log other exceptions than LdapAuthenticationException
+                log.warn( "Unexpected exception from " + authenticator.getClass(), e );
             }
         }
 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authn/SimpleAuthenticator.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authn/SimpleAuthenticator.java?rev=232227&r1=232226&r2=232227&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authn/SimpleAuthenticator.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authn/SimpleAuthenticator.java
Fri Aug 12 00:49:35 2005
@@ -23,7 +23,6 @@
 import javax.naming.directory.Attributes;
 
 import org.apache.ldap.common.exception.LdapAuthenticationException;
-import org.apache.ldap.common.exception.LdapNameNotFoundException;
 import org.apache.ldap.common.name.LdapName;
 import org.apache.ldap.common.util.ArrayUtils;
 import org.apache.ldap.server.jndi.ServerContext;
@@ -89,12 +88,21 @@
         LdapName principalDn = new LdapName( principal );
 
         ContextPartitionNexus nexus = getFactoryConfiguration().getPartitionNexus();
-        Attributes userEntry = nexus.lookup( principalDn );
-
-        if ( userEntry == null )
+        Attributes userEntry;
+        
+        try
+        {
+            userEntry = nexus.lookup( principalDn );
+            if ( userEntry == null )
+            {
+                throw new LdapAuthenticationException();
+            }
+        }
+        catch( Exception e )
         {
-            throw new LdapNameNotFoundException();
+            throw new LdapAuthenticationException();
         }
+
 
         Object userPassword;
 



Mime
View raw message