directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r905478 - in /directory: apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/ apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ clients/ldap/trunk/ldap-client-test/src/test/java/org/a...
Date Tue, 02 Feb 2010 00:44:40 GMT
Author: elecharny
Date: Tue Feb  2 00:44:39 2010
New Revision: 905478

URL: http://svn.apache.org/viewvc?rev=905478&view=rev
Log:
o Fixing the ResultCode sent for the SimpleBind operation
o Added a test in the API Bind method

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/BindHandler.java
    directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientBindRequestTest.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java?rev=905478&r1=905477&r2=905478&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
Tue Feb  2 00:44:39 2010
@@ -430,7 +430,7 @@
             LOG.debug( "Operation Context: {}", opContext );
         }
 
-        if ( opContext.getSession() != null && opContext.getSession().getEffectivePrincipal()
!= null )
+        if ( ( opContext.getSession() != null ) && ( opContext.getSession().getEffectivePrincipal()
!= null ) )
         {
             // null out the credentials
             opContext.setCredentials( null );

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/BindHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/BindHandler.java?rev=905478&r1=905477&r2=905478&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/BindHandler.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/BindHandler.java
Tue Feb  2 00:44:39 2010
@@ -39,7 +39,8 @@
 import org.apache.directory.server.ldap.handlers.bind.SaslConstants;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.exception.LdapAuthenticationException;
-import org.apache.directory.shared.ldap.exception.LdapException;
+import org.apache.directory.shared.ldap.exception.LdapInvalidNameException;
+import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.message.internal.InternalBindRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalBindResponse;
@@ -103,7 +104,7 @@
         // create a new Bind context, with a null session, as we don't have 
         // any context yet.
         BindOperationContext opContext = new BindOperationContext( null );
-
+        
         // Stores the DN of the user to check, and its password
         opContext.setDn( bindRequest.getName() );
         opContext.setCredentials( bindRequest.getCredentials() );
@@ -185,18 +186,25 @@
         }
         catch ( Exception e )
         {
-            // Something went wrong. Write back an error message            
+            // Something went wrong. Write back an error message
+            // For BindRequest, it should be an InvalidCredentials, 
+            // no matter what kind of exception we got.
             ResultCodeEnum code = null;
             InternalLdapResult result = bindRequest.getResultResponse().getLdapResult();
 
-            if ( e instanceof LdapException )
+            if ( e instanceof LdapOperationNotSupportedException )
             {
-                code = ( ( LdapException ) e ).getResultCode();
+                code = ResultCodeEnum.UNWILLING_TO_PERFORM;
                 result.setResultCode( code );
             }
-            else
+            else if ( e instanceof LdapInvalidNameException )
+            {
+                code = ResultCodeEnum.INVALID_DN_SYNTAX;
+                result.setResultCode( code );
+            }
+            else 
             {
-                code = ResultCodeEnum.getBestEstimate( e, bindRequest.getType() );
+                code = ResultCodeEnum.INVALID_CREDENTIALS;
                 result.setResultCode( code );
             }
 

Modified: directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientBindRequestTest.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientBindRequestTest.java?rev=905478&r1=905477&r2=905478&view=diff
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientBindRequestTest.java
(original)
+++ directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientBindRequestTest.java
Tue Feb  2 00:44:39 2010
@@ -31,6 +31,7 @@
 import org.apache.directory.ldap.client.api.listener.BindListener;
 import org.apache.directory.ldap.client.api.message.BindRequest;
 import org.apache.directory.ldap.client.api.message.BindResponse;
+import org.apache.directory.ldap.client.api.message.LdapResult;
 import org.apache.directory.ldap.client.api.message.Response;
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.annotations.CreateTransport;
@@ -226,4 +227,24 @@
             fail();
         }
     }
+    
+    
+    /**
+     * A bind with no name and a password is invalid
+     */
+    @Test
+    public void testSimpleBindNoNamePassword() throws Exception
+    {
+        try
+        {
+            BindResponse response = connection.bind((String)null, "abc" );
+            LdapResult ldapResult = response.getLdapResult();
+            assertEquals( ResultCodeEnum.INVALID_CREDENTIALS, ldapResult.getResultCode()
);
+            assertEquals( 1, response.getMessageId() );
+        }
+        catch ( Exception le )
+        {
+            fail();
+        }
+    }
 }



Mime
View raw message