directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r280210 - in /directory: apacheds/trunk/main/src/test/org/apache/ldap/server/ protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/
Date Sun, 11 Sep 2005 23:18:28 GMT
Author: akarasulu
Date: Sun Sep 11 16:18:16 2005
New Revision: 280210

URL: http://svn.apache.org/viewcvs?rev=280210&view=rev
Log:
changes ...

 o added test to reproduce DIREVE-239
 o DisableAnonBindTest renamed to MiscTest so more tests can be put into it
 o fixed protocol provider problem for DIREVE-239 here:

     http://issues.apache.org/jira/browse/DIREVE-239


Added:
    directory/apacheds/trunk/main/src/test/org/apache/ldap/server/MiscTest.java
      - copied, changed from r280052, directory/apacheds/trunk/main/src/test/org/apache/ldap/server/DisableAnonBindTest.java
Removed:
    directory/apacheds/trunk/main/src/test/org/apache/ldap/server/DisableAnonBindTest.java
Modified:
    directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/AbandonHandler.java
    directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/SessionRegistry.java

Copied: directory/apacheds/trunk/main/src/test/org/apache/ldap/server/MiscTest.java (from
r280052, directory/apacheds/trunk/main/src/test/org/apache/ldap/server/DisableAnonBindTest.java)
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/main/src/test/org/apache/ldap/server/MiscTest.java?p2=directory/apacheds/trunk/main/src/test/org/apache/ldap/server/MiscTest.java&p1=directory/apacheds/trunk/main/src/test/org/apache/ldap/server/DisableAnonBindTest.java&r1=280052&r2=280210&rev=280210&view=diff
==============================================================================
--- directory/apacheds/trunk/main/src/test/org/apache/ldap/server/DisableAnonBindTest.java
(original)
+++ directory/apacheds/trunk/main/src/test/org/apache/ldap/server/MiscTest.java Sun Sep 11
16:18:16 2005
@@ -22,21 +22,22 @@
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NoPermissionException;
+import javax.naming.NamingEnumeration;
+import javax.naming.directory.*;
 
 
 /**
- * A set of simple tests to make sure simple authentication is working as it
- * should.
+ * A set of miscellanous tests.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class DisableAnonBindTest extends AbstractServerTest
+public class MiscTest extends AbstractServerTest
 {
     /**
      * Cleans up old database files on creation.
      */
-    public DisableAnonBindTest()
+    public MiscTest()
     {
     }
 
@@ -48,7 +49,10 @@
      */
     public void setUp() throws Exception
     {
-        configuration.setAllowAnonymousAccess( false );
+        if ( this.getName().equals( "testDisableAnonymousBinds" ) )
+        {
+            configuration.setAllowAnonymousAccess( false );
+        }
         super.setUp();
     }
 
@@ -77,5 +81,40 @@
         catch ( NoPermissionException e )
         {
         }
+    }
+
+
+    /**
+     * Reproduces the problem with
+     * <a href="http://issues.apache.org/jira/browse/DIREVE-239">DIREVE-239</a>.
+     *
+     * @throws Exception if anything goes wrong
+     */
+    public void testAdminAccessBug() throws Exception
+    {
+        // Use the SUN JNDI provider to hit server port and bind as anonymous
+
+        final Hashtable env = new Hashtable();
+
+        env.put( Context.PROVIDER_URL, "ldap://localhost:" + port );
+        env.put("java.naming.ldap.version", "3");
+        env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
+
+        Attributes attributes = new BasicAttributes();
+        Attribute objectClass = new BasicAttribute( "objectClass" );
+        objectClass.add( "top" );
+        objectClass.add( "organizationalUnit" );
+        attributes.put( objectClass );
+        attributes.put( "ou", "blah" );
+        InitialDirContext ctx = new InitialDirContext( env );
+        ctx.createSubcontext( "ou=blah,ou=system", attributes );
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.OBJECT_SCOPE );
+        controls.setReturningAttributes( new String[] { "+" } );
+        NamingEnumeration list = ctx.search( "ou=blah,ou=system", "(objectClass=*)", controls
);
+        SearchResult result = ( SearchResult ) list.next();
+        list.close();
+        Attribute creatorsName = result.getAttributes().get( "creatorsName" );
+        assertEquals( "", creatorsName.get() );
     }
 }

Modified: directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/AbandonHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/AbandonHandler.java?rev=280210&r1=280209&r2=280210&view=diff
==============================================================================
--- directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/AbandonHandler.java
(original)
+++ directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/AbandonHandler.java
Sun Sep 11 16:18:16 2005
@@ -21,6 +21,8 @@
 import org.apache.ldap.common.message.AbandonRequest;
 import org.apache.mina.protocol.ProtocolSession;
 import org.apache.mina.protocol.handler.MessageHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -31,6 +33,8 @@
  */
 public class AbandonHandler implements MessageHandler
 {
+    private static final Logger log = LoggerFactory.getLogger( AbandonHandler.class );
+
     public void messageReceived( ProtocolSession session, Object request )
     {
         AbandonRequest req = ( AbandonRequest ) request;
@@ -41,6 +45,6 @@
             return;
         }
         
-        throw new NotImplementedException( "don't know how to do this just yet" );
+        log.warn( "Got abandon request from client but I don't know how to do this just yet"
);
     }
 }

Modified: directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/SessionRegistry.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/SessionRegistry.java?rev=280210&r1=280209&r2=280210&view=diff
==============================================================================
--- directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/SessionRegistry.java
(original)
+++ directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/SessionRegistry.java
Sun Sep 11 16:18:16 2005
@@ -141,8 +141,6 @@
                 throw new LdapNoPermissionException( "Anonymous binds have been disabled!"
);
             }
 
-            Hashtable cloned = ( Hashtable ) env.clone();
-
             if ( env.containsKey( "server.use.factory.instance" ) )
             {
                 InitialContextFactory factory = ( InitialContextFactory ) env.get( "server.use.factory.instance"
);
@@ -156,6 +154,10 @@
             }
             else
             {
+                Hashtable cloned = ( Hashtable ) env.clone();
+                cloned.put( Context.SECURITY_AUTHENTICATION, "none" );
+                cloned.remove( Context.SECURITY_PRINCIPAL );
+                cloned.remove( Context.SECURITY_CREDENTIALS );
                 ctx = new InitialLdapContext( cloned, connCtls );
             }
         }



Mime
View raw message