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 2011/04/13 09:56:08 UTC

svn commit: r1091679 - in /directory/apacheds/trunk: ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/ protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/bind/plain/

Author: elecharny
Date: Wed Apr 13 07:56:07 2011
New Revision: 1091679

URL: http://svn.apache.org/viewvc?rev=1091679&view=rev
Log:
o Added a tests for a simple bind request and an (ignored atm) anonymous bind request. The Anonymous bind fails because we have a NPE in the BindRequest encoder when the name is null.

Modified:
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/bind/plain/PlainSaslServer.java

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java?rev=1091679&r1=1091678&r2=1091679&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java Wed Apr 13 07:56:07 2011
@@ -48,6 +48,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -137,6 +138,41 @@ public class SimpleBindRequestTest exten
 
 
     /**
+     * Test a successful simple bind request.
+     */
+    @Test
+    public void testSimpleBindRequest() throws Exception
+    {
+        BindRequest bindRequest = new BindRequestImpl();
+        bindRequest.setName( new Dn( "uid=admin,ou=system" ) );
+        bindRequest.setCredentials( "secret" );
+
+        BindResponse bindResponse = connection.bind( bindRequest );
+
+        assertNotNull( bindResponse );
+        assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
+        assertTrue( connection.isAuthenticated() );
+    }
+
+
+    /**
+     * Test a successful anonymous bind request.
+     */
+    @Test
+    @Ignore // TODO : FIXME ! We get a NPE low in the code because the name is null
+    public void testAnonymousBindRequest() throws Exception
+    {
+        BindRequest bindRequest = new BindRequestImpl();
+
+        BindResponse bindResponse = connection.bind( bindRequest );
+
+        assertNotNull( bindResponse );
+        assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
+        assertTrue( connection.isAuthenticated() );
+    }
+
+
+    /**
      * Test an Anonymous BindRequest
      */
     @Test

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/bind/plain/PlainSaslServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/bind/plain/PlainSaslServer.java?rev=1091679&r1=1091678&r2=1091679&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/bind/plain/PlainSaslServer.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/bind/plain/PlainSaslServer.java Wed Apr 13 07:56:07 2011
@@ -22,6 +22,9 @@ package org.apache.directory.server.ldap
 
 import java.io.IOException;
 
+import javax.naming.InvalidNameException;
+import javax.security.sasl.SaslException;
+
 import org.apache.directory.server.core.CoreSession;
 import org.apache.directory.server.core.interceptor.context.BindOperationContext;
 import org.apache.directory.server.i18n.I18n;
@@ -34,9 +37,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.util.StringConstants;
 import org.apache.directory.shared.util.Strings;
 
-import javax.naming.InvalidNameException;
-import javax.security.sasl.SaslException;
-
 
 /**
  * A SaslServer implementation for PLAIN based SASL mechanism.  This is
@@ -126,6 +126,11 @@ public class PlainSaslServer extends Abs
             // - the optional authzId
             // - the authId
             // - the password
+            // The message should have this structure :
+            // message   = [authzid] '0x00' authcid '0x00' passwd
+            // authzid   = 1*SAFE ; MUST accept up to 255 octets
+            // authcid   = 1*SAFE ; MUST accept up to 255 octets
+            // passwd    = 1*SAFE ; MUST accept up to 255 octets
             InitialResponse element = InitialResponse.AUTHZID_EXPECTED;
             String authzId = null;
             String authcId = null;