You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by dl...@apache.org on 2005/11/06 04:41:24 UTC

svn commit: r331067 - in /portals/jetspeed-2/trunk/components/security: src/test/JETSPEED-INF/ldap/ src/test/org/apache/jetspeed/security/spi/ldap/ xdocs/

Author: dlestrat
Date: Sat Nov  5 19:41:19 2005
New Revision: 331067

URL: http://svn.apache.org/viewcvs?rev=331067&view=rev
Log:
http://issues.apache.org/jira/browse/JS2-188#action_12356329

Revisited the LDAP implementation.  Integrate Apache DS with J2.
All unit tests for LDAP are passing on Apache DS.  Leave them excluded for now.
Various quick fixes for serializable objects.  Add serialUID.

Documentation to come in the next few days.

Added:
    portals/jetspeed-2/trunk/components/security/src/test/JETSPEED-INF/ldap/ldap.properties
    portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/LdapDataHelper.java
Modified:
    portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/AbstractLdapTest.java
    portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapCredentialHandler.java
    portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapGroupSecurityHandler.java
    portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapSecurityMappingHandler.java
    portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapUserCredentialDao.java
    portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapUserSecurityDao.java
    portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapUserSecurityHandler.java
    portals/jetspeed-2/trunk/components/security/xdocs/ldap.xml

Added: portals/jetspeed-2/trunk/components/security/src/test/JETSPEED-INF/ldap/ldap.properties
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/security/src/test/JETSPEED-INF/ldap/ldap.properties?rev=331067&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/security/src/test/JETSPEED-INF/ldap/ldap.properties (added)
+++ portals/jetspeed-2/trunk/components/security/src/test/JETSPEED-INF/ldap/ldap.properties Sat Nov  5 19:41:19 2005
@@ -0,0 +1,10 @@
+# Ldap Configuration.
+org.apache.jetspeed.ldap.initialContextFactory=com.sun.jndi.ldap.LdapCtxFactory
+org.apache.jetspeed.ldap.ldapServerName=localhost
+org.apache.jetspeed.ldap.ldapServerPort=10389
+org.apache.jetspeed.ldap.rootDn=uid\=admin\,ou\=system
+org.apache.jetspeed.ldap.rootPassword=secret
+org.apache.jetspeed.ldap.rootContext=o\=sevenSeas
+org.apache.jetspeed.ldap.defaultDnSuffix=
+org.apache.jetspeed.ldap.ou.users=users
+org.apache.jetspeed.ldap.ou.groups=groups
\ No newline at end of file

Modified: portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/AbstractLdapTest.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/AbstractLdapTest.java?rev=331067&r1=331066&r2=331067&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/AbstractLdapTest.java (original)
+++ portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/AbstractLdapTest.java Sat Nov  5 19:41:19 2005
@@ -16,42 +16,34 @@
 
 import junit.framework.TestCase;
 
-import org.apache.jetspeed.security.GroupPrincipal;
-import org.apache.jetspeed.security.SecurityException;
-import org.apache.jetspeed.security.UserPrincipal;
-import org.apache.jetspeed.security.impl.GroupPrincipalImpl;
-import org.apache.jetspeed.security.impl.UserPrincipalImpl;
 import org.apache.jetspeed.security.spi.CredentialHandler;
 import org.apache.jetspeed.security.spi.GroupSecurityHandler;
+import org.apache.jetspeed.security.spi.SecurityMappingHandler;
 import org.apache.jetspeed.security.spi.UserSecurityHandler;
 import org.apache.jetspeed.security.spi.impl.LdapCredentialHandler;
 import org.apache.jetspeed.security.spi.impl.LdapGroupSecurityHandler;
+import org.apache.jetspeed.security.spi.impl.LdapSecurityMappingHandler;
 import org.apache.jetspeed.security.spi.impl.LdapUserSecurityHandler;
+import org.apache.jetspeed.security.spi.impl.ldap.LdapBindingConfig;
+import org.apache.jetspeed.security.spi.impl.ldap.LdapGroupDaoImpl;
 import org.apache.jetspeed.security.spi.impl.ldap.LdapPrincipalDao;
 import org.apache.jetspeed.security.spi.impl.ldap.LdapUserCredentialDao;
 import org.apache.jetspeed.security.spi.impl.ldap.LdapUserCredentialDaoImpl;
+import org.apache.jetspeed.security.spi.impl.ldap.LdapUserPrincipalDao;
 import org.apache.jetspeed.security.spi.impl.ldap.LdapUserPrincipalDaoImpl;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.Properties;
 import java.util.Random;
 
-import javax.naming.NamingException;
-
 /**
  * <p>
  * Abstract test case for LDAP providers.
  * </p>
  * 
- * @author <a href="mailto:mike.long@dataline.com">Mike Long </a>
+ * @author <a href="mailto:mike.long@dataline.com">Mike Long </a>, <a href="mailto:dlestrat@apache.org">David Le Strat</a>
+ * 
  */
 public abstract class AbstractLdapTest extends TestCase
 {
-    /** The ldap properties. */
-    private static Properties props = null;
-
     /** The {@link UserSecurityHandler}. */
     UserSecurityHandler userHandler;
 
@@ -60,32 +52,32 @@
 
     /** The {@link GroupSecurityHandler}. */
     GroupSecurityHandler grHandler;
+    
+    /** The {@link SecurityMappingHandler}. */
+    SecurityMappingHandler secHandler;
+    
+    /** The {@link LdapUserPrincipalDao}. */
+    LdapUserPrincipalDao ldapPrincipalDao;
+    
+    /** The {@link LdapUserCredentialDao}. */
+    LdapUserCredentialDao ldapCredDao;
+    
+    /** The {@link LdapGroupDao}. */
+    LdapPrincipalDao ldapGroupDao;
 
     /** Random seed. */
     Random rand = new Random(System.currentTimeMillis());
 
-    /** Group principal.*/
-    GroupPrincipal gp1;
-
-    /** Group principal.*/
-    GroupPrincipal gp2;
-
-    /** User principal.*/
-    UserPrincipal up1;
-
-    /** User principal.*/
-    UserPrincipal up2;
-
-    /** Group uid.*/
+    /** Group uid. */
     protected String gpUid1;
 
-    /** Group uid.*/
+    /** Group uid. */
     protected String gpUid2;
 
-    /** User uid.*/
+    /** User uid. */
     protected String uid1;
 
-    /** User uid.*/
+    /** User uid. */
     protected String uid2;
 
     /** The test password. */
@@ -97,32 +89,24 @@
     protected void setUp() throws Exception
     {
         super.setUp();
-        initializeConfiguration();
-        LdapUserCredentialDao credDao = new LdapUserCredentialDaoImpl(props
-                .getProperty("org.apache.jetspeed.ldap.ldapServerName"), props
-                .getProperty("org.apache.jetspeed.ldap.rootDn"), props
-                .getProperty("org.apache.jetspeed.ldap.rootPassword"), props
-                .getProperty("org.apache.jetspeed.ldap.rootContext"), props
-                .getProperty("org.apache.jetspeed.ldap.defaultDnSuffix"));
-
-        LdapPrincipalDao userPrincDao = new LdapUserPrincipalDaoImpl(props
-                .getProperty("org.apache.jetspeed.ldap.ldapServerName"), props
-                .getProperty("org.apache.jetspeed.ldap.rootDn"), props
-                .getProperty("org.apache.jetspeed.ldap.rootPassword"), props
-                .getProperty("org.apache.jetspeed.ldap.rootContext"), props
-                .getProperty("org.apache.jetspeed.ldap.defaultDnSuffix"));
-
-        userHandler = new LdapUserSecurityHandler(userPrincDao);
-        crHandler = new LdapCredentialHandler(credDao);
+        LdapBindingConfig ldapConfig = new LdapBindingConfig();
+        ldapCredDao = new LdapUserCredentialDaoImpl(ldapConfig);
+        ldapPrincipalDao = new LdapUserPrincipalDaoImpl(ldapConfig);
+
+        userHandler = new LdapUserSecurityHandler(ldapPrincipalDao);
+        crHandler = new LdapCredentialHandler(ldapCredDao);
+        LdapDataHelper.setUserSecurityHandler(userHandler);
+        LdapDataHelper.setCredentialHandler(crHandler);
         uid1 = Integer.toString(rand.nextInt());
         uid2 = Integer.toString(rand.nextInt());
-        up1 = new UserPrincipalImpl(uid1);
-        userHandler.addUserPrincipal(up1);
-        crHandler.setPassword(uid1, "", password);
-        up2 = new UserPrincipalImpl(uid2);
-        userHandler.addUserPrincipal(up2);
-        crHandler.setPassword(uid2, "", password);
-        createGroupPrincipals();
+        
+        ldapGroupDao = new LdapGroupDaoImpl(ldapConfig);
+        grHandler = new LdapGroupSecurityHandler(ldapGroupDao);
+        LdapDataHelper.setGroupSecurityHandler(grHandler);
+        gpUid1 = Integer.toString(rand.nextInt());
+        gpUid2 = Integer.toString(rand.nextInt());
+        
+        secHandler = new LdapSecurityMappingHandler(ldapPrincipalDao, ldapGroupDao);
     }
 
     /**
@@ -131,62 +115,6 @@
     protected void tearDown() throws Exception
     {
         super.tearDown();
-
-        if (up1 != null)
-        {
-            userHandler.removeUserPrincipal(up1);
-        }
-        if (up2 != null)
-        {
-            userHandler.removeUserPrincipal(up2);
-        }
-        if (gp1 != null)
-        {
-            grHandler.removeGroupPrincipal(gp1);
-        }
-        if (gp2 != null)
-        {
-            grHandler.removeGroupPrincipal(gp2);
-        }
     }
 
-    /**
-     * <p>
-     * Init ldap config.
-     * </p>
-     */
-    protected static void initializeConfiguration()
-    {
-        String testPropsPath = "./etc/ldap.properties";
-        try
-        {
-            File testFile = new File(testPropsPath);
-            if (testFile.exists())
-            {
-                FileInputStream is = new FileInputStream(testPropsPath);
-                props = new Properties();
-                props.load(is);
-            }
-        }
-        catch (IOException e)
-        {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * @throws NamingException A {@link NamingException}.
-     * @throws SecurityException A {@link SecurityException}.
-     */
-    private void createGroupPrincipals() throws SecurityException, NamingException
-    {
-        grHandler = new LdapGroupSecurityHandler();
-        gpUid1 = Integer.toString(rand.nextInt());
-        gp1 = new GroupPrincipalImpl(gpUid1);
-        grHandler.setGroupPrincipal(gp1);
-
-        gpUid2 = Integer.toString(rand.nextInt());
-        gp2 = new GroupPrincipalImpl(gpUid2);
-        grHandler.setGroupPrincipal(gp2);
-    }
 }

Added: portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/LdapDataHelper.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/LdapDataHelper.java?rev=331067&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/LdapDataHelper.java (added)
+++ portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/LdapDataHelper.java Sat Nov  5 19:41:19 2005
@@ -0,0 +1,82 @@
+/* Copyright 2004 Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.security.spi.ldap;
+
+import org.apache.jetspeed.security.GroupPrincipal;
+import org.apache.jetspeed.security.UserPrincipal;
+import org.apache.jetspeed.security.impl.GroupPrincipalImpl;
+import org.apache.jetspeed.security.impl.UserPrincipalImpl;
+import org.apache.jetspeed.security.spi.CredentialHandler;
+import org.apache.jetspeed.security.spi.GroupSecurityHandler;
+import org.apache.jetspeed.security.spi.UserSecurityHandler;
+
+/**
+ * <p>
+ * Utility class for LDAP test data.
+ * </p>
+ * 
+ * @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
+ */
+public class LdapDataHelper
+{
+    /** The {@link UserSecurityHandler}. */
+    private static UserSecurityHandler userHandler;
+
+    /** The {@link CredentialHandler}. */
+    private static CredentialHandler crHandler;
+
+    /** The {@link GroupSecurityHandler}. */
+    private static GroupSecurityHandler grHandler;
+    
+    public static void seedUserData(String uid, String password) throws Exception
+    {
+        UserPrincipal up = new UserPrincipalImpl(uid);
+        userHandler.addUserPrincipal(up);
+        crHandler.setPassword(uid, "", password);
+    }
+    
+    public static void seedGroupData(String gpUid) throws Exception
+    {
+        GroupPrincipal gp = new GroupPrincipalImpl(gpUid);
+        grHandler.setGroupPrincipal(gp);
+    }
+    
+    public static void removeUserData(String uid) throws Exception
+    {
+        UserPrincipal up = new UserPrincipalImpl(uid);
+        userHandler.removeUserPrincipal(up);
+    }
+    
+    public static void removeGroupData(String gpUid) throws Exception
+    {
+        GroupPrincipal gp = new GroupPrincipalImpl(gpUid);
+        grHandler.removeGroupPrincipal(gp);
+    }
+    
+    public static void setUserSecurityHandler(UserSecurityHandler userHandlerVar)
+    {
+        userHandler = userHandlerVar;
+    }
+    
+    public static void setCredentialHandler(CredentialHandler crHandlerVar)
+    {
+        crHandler = crHandlerVar;
+    }
+    
+    public static void setGroupSecurityHandler(GroupSecurityHandler grHandlerVar)
+    {
+        grHandler = grHandlerVar;
+    }
+}

Modified: portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapCredentialHandler.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapCredentialHandler.java?rev=331067&r1=331066&r2=331067&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapCredentialHandler.java (original)
+++ portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapCredentialHandler.java Sat Nov  5 19:41:19 2005
@@ -15,8 +15,6 @@
  */
 package org.apache.jetspeed.security.spi.ldap;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.jetspeed.security.PasswordCredential;
 import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.spi.impl.LdapCredentialHandler;
@@ -33,16 +31,23 @@
  */
 public class TestLdapCredentialHandler extends AbstractLdapTest
 {
-    /** The logger. */
-    private static final Log log = LogFactory.getLog(TestLdapCredentialHandler.class);
 
     /**
-     * @see junit.framework.TestCase#setUp()
+     * @see org.apache.jetspeed.security.spi.ldap.AbstractLdapTest#setUp()
      */
     protected void setUp() throws Exception
     {
         super.setUp();
-        crHandler = new LdapCredentialHandler();
+        LdapDataHelper.seedUserData(uid1, password);
+    }
+    
+    /**
+     * @see org.apache.jetspeed.security.spi.ldap.AbstractLdapTest#tearDown()
+     */
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+        LdapDataHelper.removeUserData(uid1);
     }
 
     /**
@@ -50,9 +55,9 @@
      * Test <code>getPrivateCredentials</code>
      * </p>
      * 
-     * @throws SecurityException A {@link SecurityException}.
+     * @throws Exception An {@link Exception}.
      */
-    public void testGetPrivateCredentials() throws SecurityException
+    public void testGetPrivateCredentials() throws Exception
     {
         Set credentials = crHandler.getPrivateCredentials(uid1);
 
@@ -68,9 +73,9 @@
      * Test <code>getPrivateCredentials</code> for a user that does not exist.
      * </p>
      * 
-     * @throws SecurityException A {@link SecurityException}.
+     * @throws Exception An {@link Exception}.
      */
-    public void testGetPrivateCredentialsForNonExistantUser() throws SecurityException
+    public void testGetPrivateCredentialsForNonExistantUser() throws Exception
     {
         String nonExistantUser = Integer.toString(rand.nextInt());
         Set credentials = crHandler.getPrivateCredentials(nonExistantUser);
@@ -84,9 +89,9 @@
      * Test <code>setPassword</code>.
      * </p>
      * 
-     * @throws SecurityException A {@link SecurityException}.
+     * @throws Exception An {@link Exception}.
      */
-    public void testSetPassword() throws SecurityException
+    public void testSetPassword() throws Exception
     {
         crHandler.setPassword(uid1, password, "freddie");
         assertTrue("Failed to change the password.", crHandler.authenticate(uid1, "freddie"));
@@ -98,9 +103,9 @@
      * Test <code>setPassword</code> with null password.
      * </p>
      * 
-     * @throws SecurityException A {@link SecurityException}.
+     * @throws Exception An {@link Exception}.
      */
-    public void testVerifyNullSetPassword() throws SecurityException
+    public void testVerifyNullSetPassword() throws Exception
     {
         crHandler.setPassword(uid1, null, password);
     }
@@ -110,9 +115,9 @@
      * Test <code>authenticate</code> with correct login.
      * </p>
      * 
-     * @throws SecurityException A {@link SecurityException}.
+     * @throws Exception An {@link Exception}.
      */
-    public void testGoodLogin() throws SecurityException
+    public void testGoodLogin() throws Exception
     {
         assertTrue("The login failed for user.", crHandler.authenticate(uid1, password));
     }
@@ -122,9 +127,9 @@
      * Test <code>authenticate</code> with no password.
      * </p>
      * 
-     * @throws SecurityException A {@link SecurityException}.
+     * @throws Exception An {@link Exception}.
      */
-    public void testCannotAuthenticateWithNoPassword()
+    public void testCannotAuthenticateWithNoPassword() throws Exception
     {
         try
         {
@@ -142,9 +147,9 @@
      * Test <code>authenticate</code> with bad uid.
      * </p>
      * 
-     * @throws SecurityException A {@link SecurityException}.
+     * @throws Exception An {@link Exception}.
      */
-    public void testBadUID() throws SecurityException
+    public void testBadUID() throws Exception
     {
         String nonExistantUser = Integer.toString(rand.nextInt());
 
@@ -165,9 +170,9 @@
      * Test <code>authenticate</code> with bad password.
      * </p>
      * 
-     * @throws SecurityException A {@link SecurityException}.
+     * @throws Exception An {@link Exception}.
      */
-    public void testBadPassword() throws SecurityException
+    public void testBadPassword() throws Exception
     {
         assertFalse("Should not have authenticated with a bad password.", crHandler
                 .authenticate(uid1, password + "123"));

Modified: portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapGroupSecurityHandler.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapGroupSecurityHandler.java?rev=331067&r1=331066&r2=331067&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapGroupSecurityHandler.java (original)
+++ portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapGroupSecurityHandler.java Sat Nov  5 19:41:19 2005
@@ -17,37 +17,65 @@
 
 import java.util.List;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.jetspeed.security.GroupPrincipal;
-import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.impl.GroupPrincipalImpl;
 
 /**
- * @author <a href="mailto:mike.long@dataline.com">Mike Long </a> 
+ * @author <a href="mailto:mike.long@dataline.com">Mike Long </a>, <a
+ *         href="mailto:dlestrat@apache.org">David Le Strat</a>
  */
 public class TestLdapGroupSecurityHandler extends AbstractLdapTest
 {
-    /** The logger. */
-    private static final Log log = LogFactory.getLog(TestLdapGroupSecurityHandler.class);
 
-    public void testGetGroupPrincipal()
+    /**
+     * @see org.apache.jetspeed.security.spi.ldap.AbstractLdapTest#setUp()
+     */
+    protected void setUp() throws Exception
     {
-        assertNotNull("Group was not found.", grHandler.getGroupPrincipal(gp1.getFullPath()));
+        super.setUp();
+        LdapDataHelper.seedGroupData(gpUid1);
     }
 
-    public void testAddDuplicateGroupPrincipal() throws SecurityException
+    /**
+     * @see org.apache.jetspeed.security.spi.ldap.AbstractLdapTest#tearDown()
+     */
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+        LdapDataHelper.removeGroupData(gpUid1);
+    }
+
+    /**
+     * @throws Exception
+     */
+    public void testGetGroupPrincipal() throws Exception
+    {
+        String fullPath = (new GroupPrincipalImpl(gpUid1)).getFullPath();
+        assertNotNull("Group was not found.", grHandler.getGroupPrincipal(fullPath));
+    }
+
+    /**
+     * @throws Exception
+     */
+    public void testAddDuplicateGroupPrincipal() throws Exception
     {
         grHandler.setGroupPrincipal(new GroupPrincipalImpl(gpUid1));
     }
 
-    public void testRemoveExistantUserPrincipal() throws SecurityException
+    /**
+     * @throws Exception
+     */
+    public void testRemoveExistantUserPrincipal() throws Exception
     {
-        grHandler.removeGroupPrincipal((gp1));
-        assertNull("Group was found and should have been removed.", grHandler.getGroupPrincipal(gp1.getFullPath()));
+        GroupPrincipal gp = new GroupPrincipalImpl(gpUid1);
+        grHandler.removeGroupPrincipal(gp);
+        assertNull("Group was found and should have been removed.", grHandler.getGroupPrincipal(gp.getFullPath()));
     }
 
-    public void testRemoveNonExistantUserPrincipal() throws SecurityException
+    /**
+     * @throws Exception
+     */
+    public void testRemoveNonExistantUserPrincipal() throws Exception
     {
         String localUid = Integer.toString(rand.nextInt()).toString();
         GroupPrincipal localPrin = new GroupPrincipalImpl(localUid);
@@ -55,20 +83,30 @@
         grHandler.removeGroupPrincipal(localPrin);
     }
 
-    public void testGetGroupPrincipals() throws SecurityException
+    /**
+     * @throws Exception
+     */
+    public void testGetGroupPrincipals() throws Exception
     {
-        assertTrue("getUserPrincipals should have returned more than one user.", grHandler.getGroupPrincipals("*")
-                .size() > 1);
-
-        List groups = grHandler.getGroupPrincipals(gp1.getFullPath());
-
-        assertTrue("getGroupPrincipals should have returned one group.", groups.size() == 1);
-        assertTrue("List should have consisted of GroupPrincipal objects.", groups.get(0) instanceof GroupPrincipal);
-
-        String localUid = Integer.toString(rand.nextInt()).toString();
-
-        assertTrue("getGroupPrincipals should not have found any groups with the specified filter.", grHandler
-                .getGroupPrincipals(new GroupPrincipalImpl(localUid).getFullPath()).isEmpty());
+        try
+        {
+            LdapDataHelper.seedGroupData(gpUid2);
+            assertTrue("getUserPrincipals should have returned more than one user.", grHandler.getGroupPrincipals("*")
+                    .size() > 1);
+
+            String fullPath = (new GroupPrincipalImpl(gpUid1)).getFullPath();
+            List groups = grHandler.getGroupPrincipals(fullPath);
+            assertTrue("getGroupPrincipals should have returned one group.", groups.size() == 1);
+            assertTrue("List should have consisted of GroupPrincipal objects.", groups.get(0) instanceof GroupPrincipal);
+
+            String localUid = Integer.toString(rand.nextInt()).toString();
+            assertTrue("getGroupPrincipals should not have found any groups with the specified filter.", grHandler
+                    .getGroupPrincipals(new GroupPrincipalImpl(localUid).getFullPath()).isEmpty());
+        }
+        finally
+        {
+            LdapDataHelper.removeGroupData(gpUid2);
+        }
     }
 
 }

Modified: portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapSecurityMappingHandler.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapSecurityMappingHandler.java?rev=331067&r1=331066&r2=331067&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapSecurityMappingHandler.java (original)
+++ portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapSecurityMappingHandler.java Sat Nov  5 19:41:19 2005
@@ -15,48 +15,75 @@
  */
 package org.apache.jetspeed.security.spi.ldap;
 
-import javax.naming.NamingException;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.security.GroupPrincipal;
 import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.impl.GroupPrincipalImpl;
-import org.apache.jetspeed.security.spi.SecurityMappingHandler;
-import org.apache.jetspeed.security.spi.impl.LdapSecurityMappingHandler;
 
 /**
- * @author <a href="mailto:mike.long@dataline.com">Mike Long </a>
- *  
+ * <p>
+ * Test the LDAP implementation for the {@link SecurityMappingHandler}.
+ * </p>
+ * 
+ * @author <a href="mailto:mike.long@dataline.com">Mike Long </a>, <a href="dlestrat@apache.org">David Le Strat</a>  
  */
 public class TestLdapSecurityMappingHandler extends AbstractLdapTest
 {
     /** The logger. */
-    private static final Log LOG = LogFactory.getLog(TestLdapSecurityMappingHandler.class);
+    private static final Log logger = LogFactory.getLog(TestLdapSecurityMappingHandler.class);
 
-    /** The {@link SecurityMappingHandler}. */
-    private SecurityMappingHandler secHandler;
+    /** The group principal for gpUid1. */
+    private GroupPrincipal gp1;
+    
+    /** The group principal for gpUid2. */
+    private GroupPrincipal gp2;
 
     /**
-     * @throws NamingException A {@link NamingException}.
-     * @throws SecurityException A {@link SecurityException}.
+     * @see org.apache.jetspeed.security.spi.ldap.AbstractLdapTest#setUp()
      */
-    public TestLdapSecurityMappingHandler() throws SecurityException, NamingException
+    protected void setUp() throws Exception
     {
-        this.secHandler = new LdapSecurityMappingHandler();
+        super.setUp();
+        gp1 = new GroupPrincipalImpl(gpUid1);
+        gp2 = new GroupPrincipalImpl(gpUid2);
+        LdapDataHelper.seedGroupData(gpUid1);
+        LdapDataHelper.seedGroupData(gpUid2);
+        LdapDataHelper.seedUserData(uid1, password);
+        LdapDataHelper.seedUserData(uid2, password);
     }
 
-    public void testGetUserPrincipalsInGroup() throws SecurityException
+    /**
+     * @see org.apache.jetspeed.security.spi.ldap.AbstractLdapTest#tearDown()
+     */
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+        LdapDataHelper.removeGroupData(gpUid1);
+        LdapDataHelper.removeGroupData(gpUid2);
+        LdapDataHelper.removeUserData(uid1);
+        LdapDataHelper.removeUserData(uid2);
+    }
+
+    /**
+     * @throws Exception
+     */
+    public void testGetUserPrincipalsInGroup() throws Exception
     {
         secHandler.setUserPrincipalInGroup(uid1, gp1.getFullPath());
         secHandler.setUserPrincipalInGroup(uid2, gp1.getFullPath());
 
         String fullPathName = new GroupPrincipalImpl(gpUid1).getFullPath();
-        LOG.debug("Group full path name from testGetUserPrincipalsInGroup()[" + fullPathName + "]");
+        logger.debug("Group full path name from testGetUserPrincipalsInGroup()[" + fullPathName + "]");
         assertEquals("The user should have been in two groups.", 2, secHandler.getUserPrincipalsInGroup(fullPathName)
                 .size());
     }
 
-    public void testSetUserPrincipalInGroup() throws SecurityException
+    /**
+     * @throws Exception
+     */
+    public void testSetUserPrincipalInGroup() throws Exception
     {
         secHandler.setUserPrincipalInGroup(uid1, gp1.getFullPath());
         secHandler.setUserPrincipalInGroup(uid1, gp2.getFullPath());
@@ -64,7 +91,10 @@
         assertEquals("The user should have been in two groups.", 2, secHandler.getGroupPrincipals(uid1).size());
     }
 
-    public void testRemoveUserPrincipalInGroup() throws SecurityException
+    /**
+     * @throws Exception
+     */
+    public void testRemoveUserPrincipalInGroup() throws Exception
     {
         secHandler.setUserPrincipalInGroup(uid1, gp1.getFullPath());
         secHandler.setUserPrincipalInGroup(uid1, gp2.getFullPath());
@@ -78,7 +108,10 @@
         assertEquals("The user should have been in two groups.", 0, secHandler.getGroupPrincipals(uid1).size());
     }
 
-    public void testSetUserPrincipalInGroupForNonExistantUser() throws SecurityException
+    /**
+     * @throws Exception
+     */
+    public void testSetUserPrincipalInGroupForNonExistantUser() throws Exception
     {
         try
         {
@@ -93,7 +126,10 @@
         }
     }
 
-    public void testSetUserPrincipalInGroupForNonExistantGroup() throws SecurityException
+    /**
+     * @throws Exception
+     */
+    public void testSetUserPrincipalInGroupForNonExistantGroup() throws Exception
     {
         try
         {

Modified: portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapUserCredentialDao.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapUserCredentialDao.java?rev=331067&r1=331066&r2=331067&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapUserCredentialDao.java (original)
+++ portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapUserCredentialDao.java Sat Nov  5 19:41:19 2005
@@ -25,14 +25,13 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.spi.impl.ldap.LdapUserCredentialDao;
-import org.apache.jetspeed.security.spi.impl.ldap.LdapUserCredentialDaoImpl;
 
 /**
  * <p>
  * Test the {@link LdapUserCredentialDao}.
  * </p>
  * 
- * @author <a href="mailto:mike.long@dataline.com">Mike Long </a>
+ * @author <a href="mailto:mike.long@dataline.com">Mike Long </a>, <a href="mailto:dlestrat@apache.org">David Le Strat</a>
  *  
  */
 public class TestLdapUserCredentialDao extends AbstractLdapTest
@@ -49,16 +48,22 @@
     /** The logger. */
     private static final Log log = LogFactory.getLog(TestLdapUserCredentialDao.class);
 
-    /** The {@link LdapUserCredentialDao}. */
-    private LdapUserCredentialDao ldap;
-
     /**
-     * @see junit.framework.TestCase#setUp()
+     * @see org.apache.jetspeed.security.spi.ldap.AbstractLdapTest#setUp()
      */
     protected void setUp() throws Exception
     {
         super.setUp();
-        ldap = new LdapUserCredentialDaoImpl();
+        LdapDataHelper.seedUserData(uid1, password);
+    }
+    
+    /**
+     * @see org.apache.jetspeed.security.spi.ldap.AbstractLdapTest#tearDown()
+     */
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+        LdapDataHelper.removeUserData(uid1);
     }
 
     /**
@@ -66,11 +71,49 @@
      * Test <code>authenticate</code> with correct login.
      * </p>
      * 
-     * @throws SecurityException A {@link SecurityException}.
+     * @throws Exception An {@link Exception}.
+     */
+    public void testGoodLogin() throws Exception
+    {
+        assertTrue("The login failed for user.", ldapCredDao.authenticate(uid1, password));
+    }
+    
+    /**
+     * <p>
+     * Test regular expression to match any of the following characters: ([{\^$|)?*+.
+     * </p>
+     * 
+     * @throws Exception
      */
-    public void testGoodLogin() throws SecurityException
+    public void testRegexForValidateUid() throws Exception
     {
-        assertTrue("The login failed for user.", ldap.authenticate(uid1, password));
+        String pattern = ".*\\(.*|.*\\[.*|.*\\{.*|.*\\\\.*|.*\\^.*|.*\\$.*|.*\\|.*|.*\\).*|.*\\?.*|.*\\*.*|.*\\+.*|.*\\..*";
+        String s = "abcde";
+        assertFalse(s.matches(pattern));
+        s = "ba(cde";
+        assertTrue(s.matches(pattern));
+        s = "ba[cde";
+        assertTrue(s.matches(pattern));
+        s = "ba{cde";
+        assertTrue(s.matches(pattern));
+        s = "ba\\cde";
+        assertTrue(s.matches(pattern));
+        s = "ba^cde";
+        assertTrue(s.matches(pattern));
+        s = "ba$cde";
+        assertTrue(s.matches(pattern));
+        s = "ba|cde";
+        assertTrue(s.matches(pattern));
+        s = "ba)cde";
+        assertTrue(s.matches(pattern));
+        s = "ba?cde";
+        assertTrue(s.matches(pattern));
+        s = "ba*cde";
+        assertTrue(s.matches(pattern));
+        s = "ba+cde";
+        assertTrue(s.matches(pattern));
+        s = "ba.cde";
+        assertTrue(s.matches(pattern));
     }
 
     /**
@@ -78,8 +121,10 @@
      * Test that the uid does not contain any of the following character:
      * <code>([{\^$|)?*+.</code>
      * </p>
+     * 
+     * @throws Exception An {@link Exception}.
      */
-    public void testRegularExpessionInUid()
+    public void testRegularExpessionInUid() throws Exception
     {
         // ([{\^$|)?*+.
         verifyRegularExpressionFails("(");
@@ -100,19 +145,21 @@
      * <p>
      * Test <code>authenticate</code> with incorrect character in uid.
      * </p>
+     * 
+     * @throws Exception An {@link Exception}.
      */
-    private void verifyRegularExpressionFails(String metaCharacter)
+    private void verifyRegularExpressionFails(String metaCharacter) throws Exception
     {
         try
         {
-            ldap.authenticate(uid1 + metaCharacter, password);
-            fail("Should have thrown an IllegalArgumentException because the uid contained a regular expression meta-character.");
+            ldapCredDao.authenticate(uid1 + metaCharacter, password);
+            fail("Should have thrown an SecurityException because the uid contained a regular expression meta-character.");
         }
         catch (Exception e)
         {
             assertTrue(
-                    "Should have thrown an IllegalArgumentException  because the uid contained a regular expression meta-character.",
-                    e instanceof IllegalArgumentException);
+                    "Should have thrown an SecurityException  because the uid contained a regular expression meta-character.",
+                    e instanceof SecurityException);
         }
     }
 
@@ -120,12 +167,14 @@
      * <p>
      * Test <code>authenticate</code> with no password.
      * </p>
+     * 
+     * @throws Exception An {@link Exception}.
      */
-    public void testCannotAuthenticateWithNoPassword()
+    public void testCannotAuthenticateWithNoPassword() throws Exception
     {
         try
         {
-            ldap.authenticate(uid1, "");
+            ldapCredDao.authenticate(uid1, "");
             fail("Should have thrown an SecurityException.");
         }
         catch (Exception e)
@@ -137,7 +186,7 @@
 
         try
         {
-            ldap.authenticate(uid1, null);
+            ldapCredDao.authenticate(uid1, null);
             fail("Should have thrown an SecurityException.");
         }
         catch (Exception e)
@@ -151,14 +200,14 @@
      * Test <code>authenticate</code> with bad uid.
      * </p>
      * 
-     * @throws SecurityException A {@link SecurityException}.
+     * @throws Exception An {@link Exception}.
      */
-    public void testBadUID() throws SecurityException
+    public void testBadUID() throws Exception
     {
 
         try
         {
-            ldap.authenticate(uid1 + "123", password);
+            ldapCredDao.authenticate(uid1 + "123", password);
             fail("Should have thrown an exception for a non-existant user.");
         }
         catch (Exception e)
@@ -174,11 +223,11 @@
      * Test <code>authenticate</code> with bad password.
      * </p>
      * 
-     * @throws NamingException A {@link NamingException}.
+     * @throws Exception An {@link Exception}.
      */
-    public void testBadPassword() throws SecurityException
+    public void testBadPassword() throws Exception
     {
-        assertFalse("Should not have authenticated with bad password.", ldap.authenticate(uid1, password + "123"));
+        assertFalse("Should not have authenticated with bad password.", ldapCredDao.authenticate(uid1, password + "123"));
     }
 
     /**
@@ -186,9 +235,9 @@
      * Test <code>authenticate</code> with concurrent logins.
      * </p>
      * 
-     * @throws InterruptedException A {@link InterruptedException}.
+     * @throws Exception An {@link Exception}.
      */
-    public void testConcurrentLogins() throws InterruptedException, SecurityException, NamingException
+    public void testConcurrentLogins() throws Exception
     {
         for (int i = 0; i < NUMBER_OF_LOGIN_THREADS; i++)
         {
@@ -265,7 +314,7 @@
 
         public LoginThread() throws NamingException, SecurityException
         {
-            threadLdap = new LdapUserCredentialDaoImpl();
+            threadLdap = ldapCredDao;
         }
 
         /**

Modified: portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapUserSecurityDao.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapUserSecurityDao.java?rev=331067&r1=331066&r2=331067&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapUserSecurityDao.java (original)
+++ portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapUserSecurityDao.java Sat Nov  5 19:41:19 2005
@@ -16,34 +16,34 @@
 package org.apache.jetspeed.security.spi.ldap;
 
 import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.jetspeed.security.SecurityException;
-import org.apache.jetspeed.security.spi.impl.ldap.LdapPrincipalDao;
-import org.apache.jetspeed.security.spi.impl.ldap.LdapUserPrincipalDaoImpl;
 
 /**
  * <p>
  * Test the {@link LdapUserSecurityDao}.
  * </p>
  * 
- * @author <a href="mailto:mike.long@dataline.com">Mike Long </a>
+ * @author <a href="mailto:mike.long@dataline.com">Mike Long </a>, <a href="mailto:dlestrat@apache.org">David Le Strat</a>
  */
 public class TestLdapUserSecurityDao extends AbstractLdapTest
 {
-    /** The logger. */
-    private static final Log log = LogFactory.getLog(TestLdapUserSecurityDao.class);
-
-    /** The {@link LdapUserSecurityDao}. */
-    private LdapPrincipalDao ldap;
 
     /**
-     * @see junit.framework.TestCase#setUp()
+     * @see org.apache.jetspeed.security.spi.ldap.AbstractLdapTest#setUp()
      */
     protected void setUp() throws Exception
     {
         super.setUp();
-        ldap = new LdapUserPrincipalDaoImpl();
+        LdapDataHelper.seedUserData(uid1, password);
+    }
+    
+    /**
+     * @see org.apache.jetspeed.security.spi.ldap.AbstractLdapTest#tearDown()
+     */
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+        LdapDataHelper.removeUserData(uid1);
     }
 
     /**
@@ -55,7 +55,7 @@
      */
     public void testLookupByGoodUID() throws SecurityException
     {
-        assertFalse("The loookup failed for user.", StringUtils.isEmpty(ldap.lookupByUid(uid1)));
+        assertFalse("The loookup failed for user.", StringUtils.isEmpty(ldapPrincipalDao.lookupByUid(uid1)));
     }
 
     /**
@@ -67,7 +67,7 @@
      */
     public void testLookupByBadUID() throws SecurityException
     {
-        assertTrue("The lookup should have failed for user:" + uid1 + "123", StringUtils.isEmpty(ldap.lookupByUid(uid1
+        assertTrue("The lookup should have failed for user:" + uid1 + "123", StringUtils.isEmpty(ldapPrincipalDao.lookupByUid(uid1
                 + "123")));
     }
 }

Modified: portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapUserSecurityHandler.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapUserSecurityHandler.java?rev=331067&r1=331066&r2=331067&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapUserSecurityHandler.java (original)
+++ portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/ldap/TestLdapUserSecurityHandler.java Sat Nov  5 19:41:19 2005
@@ -15,8 +15,6 @@
  */
 package org.apache.jetspeed.security.spi.ldap;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.UserPrincipal;
 import org.apache.jetspeed.security.impl.UserPrincipalImpl;
@@ -27,31 +25,54 @@
 
 /**
  * <p>
- * LdapServerTest - This class tests the LdapServer. It assumes that the
- * following three inetOrgPerson objects exist:
- * 
- * uid:cbrewton password:maddie uid:dlong, password: uid:mlong, password:maddie
+ * LdapServerTest - This class tests the LdapServer. It assumes that the following three
+ * inetOrgPerson objects exist: uid:cbrewton password:maddie uid:dlong, password: uid:mlong,
+ * password:maddie
  * </p>
  * 
  * @author <a href="mailto:mike.long@dataline.com">Mike Long </a>
  */
 public class TestLdapUserSecurityHandler extends AbstractLdapTest
 {
-    /** The logger. */
-    private static final Log log = LogFactory.getLog(TestLdapUserSecurityHandler.class);
+    /**
+     * @see org.apache.jetspeed.security.spi.ldap.AbstractLdapTest#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        LdapDataHelper.seedUserData(uid1, password);
+    }
 
-    public void testUserIsPrincipal()
+    /**
+     * @see org.apache.jetspeed.security.spi.ldap.AbstractLdapTest#tearDown()
+     */
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+        LdapDataHelper.removeUserData(uid1);
+    }
+
+    /**
+     * @throws Exception
+     */
+    public void testUserIsPrincipal() throws Exception
     {
         assertTrue("User is not principal.", userHandler.isUserPrincipal(uid1));
     }
 
-    public void testUserIsNotPrincipal()
+    /**
+     * @throws Exception
+     */
+    public void testUserIsNotPrincipal() throws Exception
     {
         assertFalse("User is principal and should not be.", userHandler.isUserPrincipal(Integer
                 .toString(rand.nextInt()).toString()));
     }
 
-    public void testAddDuplicateUserPrincipal()
+    /**
+     * @throws Exception
+     */
+    public void testAddDuplicateUserPrincipal() throws Exception
     {
         try
         {
@@ -65,18 +86,28 @@
         }
     }
 
-    public void testAddUserPrincipal() throws SecurityException
+    /**
+     * @throws Exception
+     */
+    public void testAddUserPrincipal() throws Exception
     {
         assertTrue("User not found.", userHandler.getUserPrincipal(uid1) != null);
     }
 
-    public void testRemoveExistantUserPrincipal() throws SecurityException
+    /**
+     * @throws Exception
+     */
+    public void testRemoveExistantUserPrincipal() throws Exception
     {
-        userHandler.removeUserPrincipal(up1);
+        UserPrincipal up = new UserPrincipalImpl(uid1);
+        userHandler.removeUserPrincipal(up);
         assertTrue("User was found and should have been removed.", userHandler.getUserPrincipal(uid1) == null);
     }
 
-    public void testRemoveNonExistantUserPrincipal() throws SecurityException
+    /**
+     * @throws Exception
+     */
+    public void testRemoveNonExistantUserPrincipal() throws Exception
     {
         String localUid = Integer.toString(rand.nextInt()).toString();
         UserPrincipal localPrin = new UserPrincipalImpl(localUid);
@@ -84,19 +115,36 @@
         userHandler.removeUserPrincipal(localPrin);
     }
 
-    public void testGetUserPrincipals() throws SecurityException
+    /**
+     * @throws Exception
+     */
+    public void testGetUserPrincipals() throws Exception
     {
-        assertTrue("getUserPrincipals should have returned more than one user.", userHandler.getUserPrincipals("*")
-                .size() > 1);
-
-        List users = userHandler.getUserPrincipals(uid1);
+        try
+        {
+            LdapDataHelper.seedUserData(uid2, password);
+            // With wild card search
+            assertTrue("getUserPrincipals should have returned more than one user.", userHandler.getUserPrincipals("*")
+                    .size() > 1);
+            
+            // With empty string search
+            assertTrue("getUserPrincipals should have returned more than one user.", userHandler.getUserPrincipals("")
+                    .size() > 1);
+
+            // With specific uid.
+            List users = userHandler.getUserPrincipals(uid1);
 
-        assertTrue("getUserPrincipals should have returned one user.", users.size() == 1);
-        assertTrue("List should have consisted of Principal objects.", users.get(0) instanceof Principal);
+            assertTrue("getUserPrincipals should have returned one user.", users.size() == 1);
+            assertTrue("List should have consisted of Principal objects.", users.get(0) instanceof Principal);
 
-        String localUid = Integer.toString(rand.nextInt()).toString();
+            String localUid = Integer.toString(rand.nextInt()).toString();
 
-        assertTrue("getUserPrincipals should not have found any users with the specified filter.", userHandler
-                .getUserPrincipals(localUid).isEmpty());
+            assertTrue("getUserPrincipals should not have found any users with the specified filter.", userHandler
+                    .getUserPrincipals(localUid).isEmpty());
+        }
+        finally
+        {
+            LdapDataHelper.removeUserData(uid2);
+        }
     }
 }

Modified: portals/jetspeed-2/trunk/components/security/xdocs/ldap.xml
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/security/xdocs/ldap.xml?rev=331067&r1=331066&r2=331067&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/security/xdocs/ldap.xml (original)
+++ portals/jetspeed-2/trunk/components/security/xdocs/ldap.xml Sat Nov  5 19:41:19 2005
@@ -34,9 +34,9 @@
                 . below.
             </p>
             <p>
-                Jetspeed 2
-                <b>does not currently provide an embedded LDAP directory</b>
-                . A external LDAP directory must be configured in order to leverage this functionality.
+                Jetspeed 2 provides an embedded LDAP configuration through the <a
+                href="http://directory.apache.org/subprojects/apacheds/index.html">Apache Directory Server</a>
+                . A external LDAP directory can also be onfigured in order to leverage the LDAP security functionality.
             </p>
             <p>
                 <i>security-spi-atn.xml</i>
@@ -49,13 +49,16 @@
             <p>
                 The
                 <i>security-spi-ldap-atn.xml</i>
-                preforms the same functions as the
+                peeforms the same functions as the
                 <i>security-spi-atn.xml</i>
                 described above. It replaces the default implementation for
                 <i>CredentialHandler</i>
                 and
                 <i>UserSecurityHandler</i>
                 with an LDAP specific implementation.
+            </p>
+            <p>
+            <u>The sections below are outdated.  Update to come soon...</u>
             </p>
             <p>
                 Additionally,



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org