[jboss-svn-commits] JBoss Portal SVN: r5521 - in trunk: identity identity/src/main/org/jboss/portal/identity2 identity/src/main/org/jboss/portal/identity2/ldap identity/src/main/org/jboss/portal/identity2/ldap/helper identity/src/main/org/jboss/portal/test/identity identity/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc test/src/etc test/src/etc/ldap/ldif test/src/main/org/jboss/portal/test/framework/embedded

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Oct 30 20:06:39 EST 2006


Author: bdaw
Date: 2006-10-30 20:06:03 -0500 (Mon, 30 Oct 2006)
New Revision: 5521

Added:
   trunk/identity/src/main/org/jboss/portal/identity2/IdentityContext.java
   trunk/identity/src/main/org/jboss/portal/identity2/IdentityContextImpl.java
   trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPStaticGroupMembershipModuleImpl.java
   trunk/identity/src/main/org/jboss/portal/identity2/ldap/helper/
   trunk/identity/src/main/org/jboss/portal/identity2/ldap/helper/LDAPTools.java
   trunk/identity/src/main/org/jboss/portal/test/identity/LDAPMembershipModuleTestCase.java
   trunk/identity/src/main/org/jboss/portal/test/identity/LDAPStaticGroupMembershipModuleTestCase.java
Removed:
   trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPMembershipModuleImpl.java
   trunk/identity/src/main/org/jboss/portal/identity2/ldap/StaticGroupLDAPMembershipStrategyImpl.java
   trunk/identity/src/main/org/jboss/portal/identity2/ldap/StaticRoleLDAPMembershipStrategyImpl.java
   trunk/identity/src/main/org/jboss/portal/test/identity/LDAPMembershipStrategyTestCase.java
   trunk/identity/src/main/org/jboss/portal/test/identity/LDAPStaticGroupStrategyTestCase.java
   trunk/identity/src/main/org/jboss/portal/test/identity/LDAPStaticRoleStrategyTestCase.java
Modified:
   trunk/identity/build.xml
   trunk/identity/src/main/org/jboss/portal/identity2/MembershipModule.java
   trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPConnectionContext.java
   trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleImpl.java
   trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModuleImpl.java
   trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserImpl.java
   trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserModuleImpl.java
   trunk/identity/src/main/org/jboss/portal/test/identity/LDAPSimpleRoleModuleTestCase.java
   trunk/identity/src/main/org/jboss/portal/test/identity/LDAPSimpleUserModuleTestCase.java
   trunk/identity/src/main/org/jboss/portal/test/identity/LDAPTestCase.java
   trunk/identity/src/main/org/jboss/portal/test/identity/MembershipStrategyTest.java
   trunk/identity/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity/ldap-beans.xml
   trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/Log4JTestCase.java
   trunk/test/src/etc/directories.xml
   trunk/test/src/etc/ldap/ldif/example1.ldif
   trunk/test/src/main/org/jboss/portal/test/framework/embedded/DSConfig.java
Log:
- syncing up after mess from merge with test framework changes
- some improvements in testing

Modified: trunk/identity/build.xml
===================================================================
--- trunk/identity/build.xml	2006-10-30 23:46:58 UTC (rev 5520)
+++ trunk/identity/build.xml	2006-10-31 01:06:03 UTC (rev 5521)
@@ -223,11 +223,13 @@
 
       <execute-tests>
 <!--
+
          <x-sysproperty>
             <jvmarg value="-Xdebug"/>
             <jvmarg value="-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y"/>
          </x-sysproperty>
 -->
+
          <x-test>
             <test todir="${test.reports}" name="org.jboss.portal.test.identity.DBUserTestCase"/>
          </x-test>
@@ -267,9 +269,10 @@
       <!--<execute-tests>
          <x-test>
 
-            <test todir="${test.reports}"  name="org.jboss.portal.test.identity.LDAPStaticRoleStrategyTestCase"/>
-            <test todir="${test.reports}"  name="org.jboss.portal.test.identity.LDAPStaticGroupStrategyTestCase"/>
+
+            <test todir="${test.reports}"  name="org.jboss.portal.test.identity.LDAPStaticGroupMembershipModuleTestCase"/>
             <test todir="${test.reports}"  name="org.jboss.portal.test.identity.LDAPSimpleUserModuleTestCase"/>
+            <test todir="${test.reports}"  name="org.jboss.portal.test.identity.LDAPSimpleRoleModuleTestCase"/>
          </x-test>
          <x-classpath>
             <pathelement location="${build.lib}/portal-identity-lib.jar"/>
@@ -300,10 +303,10 @@
             <path refid="jboss.portal-test.classpath"/>
             <path refid="jboss.portal-common.classpath"/>
             <path refid="jboss.portal-jems.classpath"/>
-            <path refid="sleepycat.sleepycat.classpath"/>
+            --><!--<path refid="sleepycat.sleepycat.classpath"/>--><!--
             <path refid="sun.jaf.classpath"/>
          </x-classpath>
-      </execute-tests>-->
-   </target>
+      </execute-tests>
+   </target>-->
 
 </project>

Added: trunk/identity/src/main/org/jboss/portal/identity2/IdentityContext.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/IdentityContext.java	2006-10-30 23:46:58 UTC (rev 5520)
+++ trunk/identity/src/main/org/jboss/portal/identity2/IdentityContext.java	2006-10-31 01:06:03 UTC (rev 5521)
@@ -0,0 +1,49 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity2;
+
+import org.jboss.portal.identity.IdentityException;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public interface IdentityContext
+{
+   public static final String USER_MODULE = "user_module";
+
+   public static final String ROLE_MODULE = "role_module";
+
+   public static final String MEMBERSHIP_MODULE = "membership_module";
+
+   public static final String USER_PROFILE_MODULE = "user_profile_module";
+
+   public static final String CONNECTION_CONTEXT = "connection_context";
+
+
+
+   public void register(Object object, String name) throws IdentityException;
+
+   public void unregister(String name);
+
+   public Object getObject(String name) throws IdentityException;
+}

Added: trunk/identity/src/main/org/jboss/portal/identity2/IdentityContextImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/IdentityContextImpl.java	2006-10-30 23:46:58 UTC (rev 5520)
+++ trunk/identity/src/main/org/jboss/portal/identity2/IdentityContextImpl.java	2006-10-31 01:06:03 UTC (rev 5521)
@@ -0,0 +1,101 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity2;
+
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.identity.IdentityException;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * Keeps references to all identity related modules to enable them interactions
+ *
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class IdentityContextImpl extends AbstractJBossService implements IdentityContext
+{
+   private Map registry;
+
+   public IdentityContextImpl()
+   {
+      registry = new HashMap();
+   }
+
+   public void register(Object object, String name) throws IdentityException
+   {
+      if (object == null)
+      {
+         throw new IllegalArgumentException("Cannot register null reference");
+      }
+      if (name == null)
+      {
+         throw new IllegalArgumentException("Cannot register object with null name");
+      }
+
+      synchronized(this)
+      {
+         if (registry.containsKey(name))
+         {
+            throw new IdentityException("Name: " + name + " already registered.");
+         }
+         registry.put(name, object);
+      }
+   }
+
+   public void unregister(String name)
+   {
+      if (name == null)
+      {
+         throw new IllegalArgumentException("Name cannot be null");
+      }
+      synchronized(this)
+      {
+         if(!registry.containsKey(name))
+         {
+            registry.remove(name);
+         }
+      }
+   }
+
+   public Object getObject(String name) throws IdentityException
+   {
+      if (name == null)
+      {
+         throw new IllegalArgumentException("Name cannot be null");
+      }
+
+      //TODO:
+      synchronized(this)
+      {
+         if (registry.containsKey(name))
+         {
+            return registry.get(name);
+         }
+         else
+         {
+            throw new IdentityException("No such mapping");
+         }
+      }
+   }
+}

Modified: trunk/identity/src/main/org/jboss/portal/identity2/MembershipModule.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/MembershipModule.java	2006-10-30 23:46:58 UTC (rev 5520)
+++ trunk/identity/src/main/org/jboss/portal/identity2/MembershipModule.java	2006-10-31 01:06:03 UTC (rev 5521)
@@ -25,6 +25,7 @@
 
 import org.jboss.portal.identity.IdentityException;
 import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.Role;
 
 import java.util.Set;
 

Modified: trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPConnectionContext.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPConnectionContext.java	2006-10-30 23:46:58 UTC (rev 5520)
+++ trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPConnectionContext.java	2006-10-31 01:06:03 UTC (rev 5521)
@@ -23,6 +23,9 @@
 package org.jboss.portal.identity2.ldap;
 
 import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.identity2.IdentityContext;
+import org.jboss.portal.common.util.JNDI;
+import org.jboss.portal.identity.IdentityException;
 
 import javax.naming.Context;
 import javax.naming.NamingException;
@@ -38,7 +41,33 @@
 public class LDAPConnectionContext extends AbstractJBossService
 {
 
+   private IdentityContext identityContext;
 
+   protected void startService() throws Exception
+   {
+      if (identityContext == null)
+      {
+         log.error("Cannot register module in context - missing reference");
+      }
+
+      identityContext.register(this, IdentityContext.CONNECTION_CONTEXT);
+
+
+   }
+
+
+   protected void stopService() throws Exception
+   {
+
+      if (identityContext == null)
+      {
+         log.error("Cannot unregister module in context - missing reference");
+      }
+
+      identityContext.unregister(IdentityContext.CONNECTION_CONTEXT);
+
+   }
+
    private String name;
 
    private String providerUrl;
@@ -71,7 +100,7 @@
    }
 
 
-   public InitialLdapContext createInitialContext()
+   public InitialLdapContext createInitialContext() throws IdentityException
    {
       try
       {
@@ -85,8 +114,8 @@
       }
       catch (NamingException e)
       {
-         log.info("Unable to create InitialLdapContext using: " + this, e);
-         return null;
+         throw new IdentityException("Unable to create InitialLdapContext using: " + this, e);
+         //return null;
       }
    }
 
@@ -177,5 +206,15 @@
       this.authentication = authentication;
    }
 
+   public IdentityContext getIdentityContext()
+   {
+      return identityContext;
+   }
 
+   public void setIdentityContext(IdentityContext identityContext)
+   {
+      this.identityContext = identityContext;
+   }
+
+
 }

Deleted: trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPMembershipModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPMembershipModuleImpl.java	2006-10-30 23:46:58 UTC (rev 5520)
+++ trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPMembershipModuleImpl.java	2006-10-31 01:06:03 UTC (rev 5521)
@@ -1,159 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat                                               *
- * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
- * contributors as indicated by the @authors tag. See the                     *
- * copyright.txt in the distribution for a full listing of                    *
- * individual contributors.                                                   *
- *                                                                            *
- * This is free software; you can redistribute it and/or modify it            *
- * under the terms of the GNU Lesser General Public License as                *
- * published by the Free Software Foundation; either version 2.1 of           *
- * the License, or (at your option) any later version.                        *
- *                                                                            *
- * This software is distributed in the hope that it will be useful,           *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
- * Lesser General Public License for more details.                            *
- *                                                                            *
- * You should have received a copy of the GNU Lesser General Public           *
- * License along with this software; if not, write to the Free                *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
- ******************************************************************************/
-package org.jboss.portal.identity2.ldap;
-
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity.User;
-import org.jboss.portal.identity2.LDAPMembershipStrategy;
-import org.jboss.portal.identity2.MembershipModule;
-import org.jboss.portal.identity2.Role;
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-
-import java.util.Set;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class LDAPMembershipModuleImpl extends AbstractJBossService implements MembershipModule
-{
-
-   private LDAPConnectionContext connectionContext;
-
-   private LDAPMembershipStrategy membershipStrategy;
-
-   public Set getRoles(User user) throws IdentityException
-   {
-      if (user == null)
-      {
-         throw new IllegalArgumentException("User cannot be null");
-      }
-
-      LDAPUserImpl ldapUser = null;
-
-      if (user instanceof LDAPUserImpl)
-      {
-         ldapUser = (LDAPUserImpl)user;
-      }
-      else
-      {
-         throw new IllegalArgumentException("UserMembershipModuleImpl supports only LDAPUserImpl objects");
-      }
-
-      return membershipStrategy.getRoles(ldapUser);
-
-   }
-
-   public Set getUsers(Role role) throws IdentityException
-   {
-      if (role == null)
-      {
-         throw new IllegalArgumentException("Role cannot be null");
-      }
-
-      LDAPRoleImpl ldapRole = null;
-
-      if (role instanceof LDAPRoleImpl)
-      {
-         ldapRole = (LDAPRoleImpl)role;
-      }
-      else
-      {
-         throw new IllegalArgumentException("UserMembershipModuleImpl supports only LDAPRoleImpl objects");
-      }
-
-      return membershipStrategy.getUsers(ldapRole);
-   }
-
-   public void assignUsers(Role role, Set users) throws IdentityException
-   {
-      if (role == null)
-      {
-         throw new IllegalArgumentException("Role cannot be null");
-      }
-
-      LDAPRoleImpl ldapRole = null;
-
-      if (role instanceof LDAPRoleImpl)
-      {
-         ldapRole = (LDAPRoleImpl)role;
-      }
-      else
-      {
-         throw new IllegalArgumentException("UserMembershipModuleImpl supports only LDAPRoleImpl objects");
-      }
-
-      membershipStrategy.assignUsers(ldapRole, users);
-   }
-
-   public void assignRoles(User user, Set roles) throws IdentityException
-   {
-      if (user == null)
-      {
-         throw new IllegalArgumentException("User cannot be null");
-      }
-
-      LDAPUserImpl ldapUser = null;
-
-      if (user instanceof LDAPUserImpl)
-      {
-         ldapUser = (LDAPUserImpl)user;
-      }
-      else
-      {
-         throw new IllegalArgumentException("UserMembershipModuleImpl supports only LDAPUserImpl objects");
-      }
-
-      membershipStrategy.assignRoles(ldapUser, roles);
-   }
-
-   //TODO:don't forget to add this....
-   public Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter) throws IdentityException
-   {
-      throw new UnsupportedOperationException("Not yet implemented");
-   }
-
-   //************************************
-   //******* Getters and Setters ********
-   //************************************
-
-   public LDAPConnectionContext getConnectionContext()
-   {
-      return connectionContext;
-   }
-
-   public void setConnectionContext(LDAPConnectionContext connectionContext)
-   {
-      this.connectionContext = connectionContext;
-   }
-
-   public LDAPMembershipStrategy getMembershipStrategy()
-   {
-      return membershipStrategy;
-   }
-
-   public void setMembershipStrategy(LDAPMembershipStrategy membershipStrategy)
-   {
-      this.membershipStrategy = membershipStrategy;
-   }
-}

Modified: trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleImpl.java	2006-10-30 23:46:58 UTC (rev 5520)
+++ trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleImpl.java	2006-10-31 01:06:03 UTC (rev 5521)
@@ -23,6 +23,9 @@
 package org.jboss.portal.identity2.ldap;
 
 import org.jboss.portal.identity.Role;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity2.IdentityContext;
+import org.jboss.portal.identity2.MembershipModule;
 
 import java.util.Set;
 
@@ -32,7 +35,11 @@
  */
 public class LDAPRoleImpl implements Role
 {
+   private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPRoleImpl.class);
 
+   //TODO:only to make a fasade for implementing old Role interface
+   private IdentityContext identityContext;
+
    private String dn;
 
    private String id;
@@ -44,9 +51,19 @@
 
    }
 
-   public LDAPRoleImpl(String dn)
+   public LDAPRoleImpl(String dn, IdentityContext context) 
    {
+      if (dn == null)
+      {
+         throw new IllegalArgumentException("LDAPRoleImpl need to be aware of its DN");
+      }
       this.dn = dn;
+
+      if (context == null)
+      {
+         throw new IllegalArgumentException("IdentityContext can't be null");
+      }
+      this.identityContext = context;
    }
 
    public String getName()
@@ -64,10 +81,19 @@
       this.displayName = name;
    }
 
-   //TODO: fasade to MembershipModule.getUsers() method call
+   //TODO: fasade to MembershipModule.getUsers() method call - change this
    public Set getUsers()
    {
-      throw new UnsupportedOperationException("Not yet implemented");
+      try
+      {
+         MembershipModule mm = (MembershipModule)identityContext.getObject(IdentityContext.MEMBERSHIP_MODULE);
+         return mm.getUsers(this);
+      }
+      catch (IdentityException e)
+      {
+         log.error("Unable to delegate method to MembershipModule: ", e);
+      }
+      return null;
    }
 
 

Modified: trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModuleImpl.java	2006-10-30 23:46:58 UTC (rev 5520)
+++ trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModuleImpl.java	2006-10-31 01:06:03 UTC (rev 5521)
@@ -23,9 +23,13 @@
 package org.jboss.portal.identity2.ldap;
 
 import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.common.util.JNDI;
 import org.jboss.portal.identity.IdentityException;
 import org.jboss.portal.identity.Role;
-import org.jboss.portal.identity2.RoleModule;
+import org.jboss.portal.identity.RoleModule;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity2.IdentityContext;
+import org.jboss.portal.identity2.MembershipModule;
 import org.jboss.portal.jems.as.system.AbstractJBossService;
 
 import javax.naming.NamingEnumeration;
@@ -40,6 +44,7 @@
 import java.util.List;
 import java.util.NoSuchElementException;
 import java.util.Set;
+import java.util.HashSet;
 
 /**
  * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
@@ -49,12 +54,61 @@
 {
    private LDAPConnectionContext connectionContext;
 
+   private String jndiName;
+
+   private IdentityContext identityContext;
+
    private String ridAttributeID;
 
    private String containerDN;
 
    private String displayNameAttributeID;
 
+      protected JNDI.Binding jndiBinding;
+
+
+   protected void startService() throws Exception
+   {
+
+      //
+      if (jndiName != null)
+      {
+         jndiBinding = new JNDI.Binding(jndiName, this);
+         jndiBinding.bind();
+      }
+
+      if (identityContext == null)
+      {
+         throw new IdentityException("Cannot register module in context - missing reference");
+      }
+      else
+      {
+         identityContext.register(this, IdentityContext.ROLE_MODULE);
+      }
+
+
+   }
+
+
+   protected void stopService() throws Exception
+   {
+      if (jndiBinding != null)
+      {
+         jndiBinding.unbind();
+         jndiBinding = null;
+      }
+
+      if (identityContext == null)
+      {
+         log.error("Cannot unregister module in context - missing reference");
+      }
+      else
+      {
+         identityContext.unregister(IdentityContext.ROLE_MODULE);
+      }
+
+   }
+
    public Role findRoleByName(String name) throws IdentityException, IllegalArgumentException
    {
       try
@@ -223,10 +277,82 @@
 
    public Set findRoles() throws IdentityException
    {
-      throw new UnsupportedOperationException("Not yet implemented");
+      Set rf = new HashSet();
+      try
+      {
+         SearchControls controls = new SearchControls();
+         controls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
+
+         //search all entries containing "cn" attribute
+         String filter = getRidAttributeID().concat("=").concat("*");
+         log.debug("Search filter: " + filter);
+
+
+         NamingEnumeration results = getConnectionContext().createInitialContext().search(getContainerDN(), filter, controls);
+         while (results.hasMoreElements())
+         {
+            SearchResult res = (SearchResult)results.nextElement();
+            rf.add(createRoleInstance(res));
+         }
+
+      }
+      catch (NoSuchElementException e)
+      {
+         log.debug("No roles found", e);
+      }
+      catch (Exception e)
+      {
+         throw new IdentityException("Role search failed.", e);
+      }
+      return rf;
    }
 
+   //TODO:remove this - it's only a fasade to make this implementation compatible with old RoleModule interface
+   public Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter) throws IdentityException
+   {
+      try
+      {
+         MembershipModule mm = (MembershipModule)getIdentityContext().getObject(IdentityContext.MEMBERSHIP_MODULE);
+         return mm.findRoleMembers(roleName, offset, limit, userNameFilter);
+      }
+         catch (IdentityException e)
+      {
+         throw new IdentityException("Unable to delegate method to MembershipModule: ", e);
+      }
 
+   }
+
+   //TODO:remove this - it's only a fasade to make this implementation compatible with old RoleModule interface
+   public void setRoles(User user, Set roles) throws IdentityException
+   {
+      try
+      {
+         MembershipModule mm = (MembershipModule)getIdentityContext().getObject(IdentityContext.MEMBERSHIP_MODULE);
+         mm.assignRoles(user,roles);
+      }
+         catch (IdentityException e)
+      {
+         throw new IdentityException("Unable to delegate method to MembershipModule: ", e);
+      }
+
+   }
+
+   //TODO:remove this - it's only a fasade to make this implementation compatible with old RoleModule interface
+   public Set getRoles(User user) throws IdentityException
+   {
+      try
+      {
+         MembershipModule mm = (MembershipModule)getIdentityContext().getObject(IdentityContext.MEMBERSHIP_MODULE);
+         return mm.getRoles(user);
+      }
+         catch (IdentityException e)
+      {
+         throw new IdentityException("Unable to delegate method to MembershipModule: ", e);
+      }
+
+   }
+
+
    protected LDAPRoleImpl createRoleInstance(SearchResult sr) throws IdentityException
    {
       LDAPRoleImpl ldapr = null;
@@ -245,7 +371,7 @@
          {
             throw new IdentityException("LDAP entry doesn't contain proper attribute:" + getRidAttributeID());
          }
-         ldapr = new LDAPRoleImpl(uida.getID().concat("=").concat((String)uida.get()) + "," + getContainerDN());
+         ldapr = new LDAPRoleImpl(uida.getID().concat("=").concat((String)uida.get()) + "," + getContainerDN(), identityContext);
          ldapr.setId((String)uida.get());
 
          Attribute display = attrs.get(getDisplayNameAttributeID());
@@ -287,15 +413,20 @@
       this.ridAttributeID = ridAttributeID;
    }
 
-   public LDAPConnectionContext getConnectionContext()
+
+   public LDAPConnectionContext getConnectionContext() throws IdentityException
    {
+      if (connectionContext == null)
+      {
+         this.connectionContext = (LDAPConnectionContext)identityContext.getObject(IdentityContext.CONNECTION_CONTEXT);
+      }
       return connectionContext;
    }
 
-   public void setConnectionContext(LDAPConnectionContext connectionContext)
+   /*public void setConnectionContext(LDAPConnectionContext connectionContext)
    {
       this.connectionContext = connectionContext;
-   }
+   }*/
 
    public String getContainerDN()
    {
@@ -320,4 +451,25 @@
    {
       this.displayNameAttributeID = displayNameAttributeID;
    }
+
+   public IdentityContext getIdentityContext()
+   {
+      return identityContext;
+   }
+
+   public void setIdentityContext(IdentityContext identityContext)
+   {
+      this.identityContext = identityContext;
+   }
+
+   public String getJndiName()
+   {
+      return jndiName;
+   }
+
+   public void setJndiName(String jndiName)
+   {
+      this.jndiName = jndiName;
+   }
+
 }

Copied: trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPStaticGroupMembershipModuleImpl.java (from rev 5472, trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPMembershipModuleImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPMembershipModuleImpl.java	2006-10-17 00:12:37 UTC (rev 5472)
+++ trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPStaticGroupMembershipModuleImpl.java	2006-10-31 01:06:03 UTC (rev 5521)
@@ -0,0 +1,369 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * This is free software; you can redistribute it and/or modify it            *
+ * under the terms of the GNU Lesser General Public License as                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+package org.jboss.portal.identity2.ldap;
+
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity2.LDAPMembershipStrategy;
+import org.jboss.portal.identity2.MembershipModule;
+import org.jboss.portal.identity.Role;
+import org.jboss.portal.identity.UserModule;
+import org.jboss.portal.identity.RoleModule;
+import org.jboss.portal.identity2.IdentityContext;
+import org.jboss.portal.identity2.ldap.helper.LDAPTools;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.common.util.JNDI;
+import org.jboss.portal.common.util.Tools;
+
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
+import java.util.Set;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.HashSet;
+import java.util.MissingResourceException;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class LDAPStaticGroupMembershipModuleImpl extends AbstractJBossService implements MembershipModule
+{
+
+   private LDAPConnectionContext connectionContext;
+
+   private UserModule userModule;
+
+   private RoleModule roleModule;
+
+   private IdentityContext identityContext;
+
+
+   //private LDAPMembershipStrategy membershipStrategy;
+
+   private String jndiName;
+
+   protected JNDI.Binding jndiBinding;
+
+
+   /** DN under which roles should be searched. Used only when obtaining roles having only User DN. */
+   /*private String roleCtxDN;*/
+
+
+
+   /** Name of attribute in role entry that point to belonging user */
+   private String uidAttributeID;
+
+
+   /** If the uidAttributeID in Role entry keeps full DN of a user or just a name */
+   private boolean uidAttributeIsDN;
+
+
+   protected void startService() throws Exception
+   {
+
+      //
+      if (jndiName != null)
+      {
+         jndiBinding = new JNDI.Binding(jndiName, this);
+         jndiBinding.bind();
+      }
+
+      if (identityContext == null)
+      {
+         throw new IdentityException("Cannot register module in context - missing reference");
+      }
+      else
+      {
+         identityContext.register(this, IdentityContext.MEMBERSHIP_MODULE);
+      }
+
+
+
+   }
+
+
+   protected void stopService() throws Exception
+   {
+      if (jndiBinding != null)
+      {
+         jndiBinding.unbind();
+         jndiBinding = null;
+      }
+
+      if (identityContext == null)
+      {
+         log.error("Cannot unregister module in context - missing reference");
+      }
+      else
+      {
+         identityContext.unregister(IdentityContext.MEMBERSHIP_MODULE);
+      }
+
+   }
+
+   public Set getRoles(User user) throws IdentityException
+   {
+      if (user == null)
+      {
+         throw new IllegalArgumentException("User cannot be null");
+      }
+
+      LDAPUserImpl ldapUser = null;
+
+      if (user instanceof LDAPUserImpl)
+      {
+         ldapUser = (LDAPUserImpl)user;
+      }
+      else
+      {
+         throw new IllegalArgumentException("UserMembershipModuleImpl supports only LDAPUserImpl objects");
+      }
+
+      throw new UnsupportedOperationException("Not yet implemented");
+
+   }
+
+   public Set getUsers(Role role) throws IdentityException
+   {
+      if (role == null)
+      {
+         throw new IllegalArgumentException("Role cannot be null");
+      }
+
+      LDAPRoleImpl ldapRole = null;
+
+      if (role instanceof LDAPRoleImpl)
+      {
+         ldapRole = (LDAPRoleImpl)role;
+      }
+      else
+      {
+         throw new IllegalArgumentException("UserMembershipModuleImpl supports only LDAPRoleImpl objects");
+      }
+
+      //throw new UnsupportedOperationException("Not yet implemented");
+
+      Set users = new HashSet();
+
+      try
+      {
+         log.debug("findUsers(): role = " + ldapRole.getDn());
+
+         if (ldapRole.getName() == null)
+         {
+            throw new IdentityException("Role name canot be null");
+         }
+
+         //obtain Role entry attributes from directory
+         Attributes attrs = getConnectionContext().createInitialContext().getAttributes(ldapRole.getDn());
+
+         if (attrs == null )
+         {
+            throw new IdentityException("Cannot find Role with DN: " + ldapRole.getDn());
+         }
+
+         //iterate over user names belonging to this role
+         NamingEnumeration values = attrs.get(getUidAttributeID()).getAll();
+         while (values.hasMoreElements())
+         {
+            String value = values.nextElement().toString();
+            String name = value;
+
+            //if user is pointed as DN get only it's name
+            if (isUidAttributeIsDN())
+            {
+               name = LDAPTools.stripDnToName(name);
+            }
+
+            try
+            {
+               users.add(getUserModule().findUserByUserName(name));
+            }
+            catch(IdentityException ie)
+            {
+               log.error("Failed to find user: " + name + "/" + value, ie);
+
+            }
+         }
+      }
+      catch (NamingException e)
+      {
+         throw new IdentityException("Resolving Role Users failed.", e);
+      }
+
+      return users;
+
+   }
+
+   public void assignUsers(Role role, Set users) throws IdentityException
+   {
+      if (role == null)
+      {
+         throw new IllegalArgumentException("Role cannot be null");
+      }
+
+      LDAPRoleImpl ldapRole = null;
+
+      if (role instanceof LDAPRoleImpl)
+      {
+         ldapRole = (LDAPRoleImpl)role;
+      }
+      else
+      {
+         throw new IllegalArgumentException("UserMembershipModuleImpl supports only LDAPRoleImpl objects");
+      }
+
+      throw new UnsupportedOperationException("Not yet implemented");
+   }
+
+   public void assignRoles(User user, Set roles) throws IdentityException
+   {
+      if (user == null)
+      {
+         throw new IllegalArgumentException("User cannot be null");
+      }
+
+      LDAPUserImpl ldapUser = null;
+
+      if (user instanceof LDAPUserImpl)
+      {
+         ldapUser = (LDAPUserImpl)user;
+      }
+      else
+      {
+         throw new IllegalArgumentException("UserMembershipModuleImpl supports only LDAPUserImpl objects");
+      }
+
+
+      throw new UnsupportedOperationException("Not yet implemented");
+   }
+
+   //TODO:don't forget to add this....
+   public Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter) throws IdentityException
+   {
+      throw new UnsupportedOperationException("Not yet implemented");
+   }
+
+
+   //************************************
+   //******* Getters and Setters ********
+   //************************************
+
+   public LDAPConnectionContext getConnectionContext() throws IdentityException
+   {
+
+      if (connectionContext == null)
+      {
+         try
+         {
+            this.connectionContext = (LDAPConnectionContext)identityContext.getObject(IdentityContext.CONNECTION_CONTEXT);
+         }
+         catch (ClassCastException e)
+         {
+            throw new IdentityException("Not supported object as part of the context", e);
+         }
+      }
+      return connectionContext;
+   }
+
+   public UserModule getUserModule() throws IdentityException
+   {
+
+      if (userModule == null)
+      {
+         try
+         {
+            this.userModule = (UserModule)identityContext.getObject(IdentityContext.USER_MODULE);
+         }
+         catch (ClassCastException e)
+         {
+            throw new IdentityException("Not supported object as part of the context", e);
+         }
+      }
+      return userModule;
+   }
+
+   public RoleModule getRoleModule() throws IdentityException
+   {
+
+      if (roleModule == null)
+      {
+         try
+         {
+            this.roleModule = (RoleModule)identityContext.getObject(IdentityContext.ROLE_MODULE);
+         }
+         catch (ClassCastException e)
+         {
+            throw new IdentityException("Not supported object as part of the context", e);
+         }
+      }
+      return roleModule;
+   }
+
+   public IdentityContext getIdentityContext()
+   {
+      return identityContext;
+   }
+
+   public void setIdentityContext(IdentityContext identityContext)
+   {
+      this.identityContext = identityContext;
+   }
+
+   public String getJndiName()
+   {
+      return jndiName;
+   }
+
+   public void setJndiName(String jndiName)
+   {
+      this.jndiName = jndiName;
+   }
+
+   public String getUidAttributeID()
+   {
+      return uidAttributeID;
+   }
+
+   public void setUidAttributeID(String uidAttributeID)
+   {
+      this.uidAttributeID = uidAttributeID;
+   }
+
+   public boolean isUidAttributeIsDN()
+   {
+      return uidAttributeIsDN;
+   }
+
+   public void setUidAttributeIsDN(boolean uidAttributeIsDN)
+   {
+      this.uidAttributeIsDN = uidAttributeIsDN;
+   }
+}

Modified: trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserImpl.java	2006-10-30 23:46:58 UTC (rev 5520)
+++ trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserImpl.java	2006-10-31 01:06:03 UTC (rev 5521)
@@ -26,6 +26,7 @@
 import org.jboss.portal.identity.ProfileMap;
 import org.jboss.portal.identity.User;
 import org.jboss.portal.identity2.UserProfileModule;
+import org.jboss.portal.identity2.IdentityContext;
 
 import java.util.Date;
 import java.util.Locale;
@@ -36,6 +37,8 @@
  */
 public class LDAPUserImpl implements User
 {
+   //TODO:this is just to make a fasade and implement old User interface
+   IdentityContext identityContext;
 
    //TODO:validatePassowrd method to handle different enc.
 
@@ -53,13 +56,19 @@
 
    }
 
-   public LDAPUserImpl(String dn) throws IdentityException
+   public LDAPUserImpl(String dn, IdentityContext context) throws IdentityException
    {
       if (dn == null)
       {
          throw new IdentityException("Cannot create LDAPUserImpl without DN");
       }
       this.dn = dn;
+
+      if (context == null)
+      {
+         throw new IllegalArgumentException("IdentityContext can't be null");
+      }
+      this.identityContext = context;
    }
 
    public boolean getEnabled()

Modified: trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserModuleImpl.java	2006-10-30 23:46:58 UTC (rev 5520)
+++ trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserModuleImpl.java	2006-10-31 01:06:03 UTC (rev 5521)
@@ -23,11 +23,14 @@
 package org.jboss.portal.identity2.ldap;
 
 import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.common.util.JNDI;
 import org.jboss.portal.identity.IdentityException;
 import org.jboss.portal.identity.NoSuchUserException;
 import org.jboss.portal.identity.User;
-import org.jboss.portal.identity2.UserModule;
+import org.jboss.portal.identity.UserModule;
 import org.jboss.portal.identity2.UserProfileModule;
+import org.jboss.portal.identity2.IdentityContext;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
 
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
@@ -41,6 +44,7 @@
 import java.util.List;
 import java.util.NoSuchElementException;
 import java.util.Set;
+import java.util.HashSet;
 
 /**
  * Simple implementation of UserModule for LDAP support. Search of users is limited to one place * containerField -  DN
@@ -51,12 +55,16 @@
  * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
  * @version $Revision: 1.1 $
  */
-public class LDAPUserModuleImpl implements UserModule
+public class LDAPUserModuleImpl extends AbstractJBossService implements UserModule
 {
    private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPUserModuleImpl.class);
 
    private LDAPConnectionContext connectionContext;
 
+   private String jndiName;
+
+   private IdentityContext identityContext;
+
    private UserProfileModule userProfileModule;
 
    /** Attribute that stores user id */
@@ -68,7 +76,51 @@
     */
    private String containerDN;
 
+      protected JNDI.Binding jndiBinding;
 
+
+   protected void startService() throws Exception
+   {
+
+      //
+      if (jndiName != null)
+      {
+         jndiBinding = new JNDI.Binding(jndiName, this);
+         jndiBinding.bind();
+      }
+
+      if (identityContext == null)
+      {
+         throw new IdentityException("Cannot register module in context - missing reference");
+      }
+      else
+      {
+         identityContext.register(this, IdentityContext.USER_MODULE);
+      }
+
+
+   }
+
+
+   protected void stopService() throws Exception
+   {
+      if (jndiBinding != null)
+      {
+         jndiBinding.unbind();
+         jndiBinding = null;
+      }
+
+      if (identityContext == null)
+      {
+         log.error("Cannot unregister module in context - missing reference");
+      }
+      else
+      {
+         identityContext.unregister(IdentityContext.USER_MODULE);
+      }
+   }
+
+
    public User findUserByUserName(String userName) throws IdentityException, IllegalArgumentException, NoSuchUserException
    {
       try
@@ -203,14 +255,52 @@
 
    }
 
+
    public Set findUsers(int offset, int limit) throws IdentityException, IllegalArgumentException
    {
-      throw new UnsupportedOperationException("Not yet implemented");
+
+      return findUsersFilteredByUserName("*",0,0);
+
    }
 
+   //TODO:implement something to use offset and limit - sort asc and
    public Set findUsersFilteredByUserName(String filter, int offset, int limit) throws IdentityException, IllegalArgumentException
    {
-      throw new UnsupportedOperationException("Not yet implemented");
+      log.info("Current implementation of findUsersFilteredByUserName returns all users and is not \"offset\" and \"limit\" sensitive ");
+
+      Set uf = new HashSet();
+
+      try
+      {
+         SearchControls controls = new SearchControls();
+         controls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
+
+         //search all entries containing "uid" attribute
+         String ldap_filter = getUidAttributeID().concat("=").concat(filter);
+         log.debug("Search filter: " + filter);
+
+
+         NamingEnumeration results = getConnectionContext().createInitialContext().search(getContainerDN(), ldap_filter, controls);
+         //List sr = Tools.toList(results);
+         while (results.hasMoreElements())
+         {
+            SearchResult res = (SearchResult)results.nextElement();
+            uf.add(createUserInstance(res));
+         }
+
+         //return sr.size();
+
+      }
+      catch (NoSuchElementException e)
+      {
+         log.debug("No users found", e);
+      }
+      catch (Exception e)
+      {
+         throw new IdentityException("User search failed.", e);
+      }
+      return uf;
+
    }
 
    public int getUserCount() throws IdentityException, IllegalArgumentException
@@ -261,7 +351,7 @@
          {
             throw new IdentityException("LDAP entry doesn't contain proper attribute:" + getUidAttributeID());
          }
-         ldapu = new LDAPUserImpl(uida.getID().concat("=").concat((String)uida.get()) + "," + getContainerDN());
+         ldapu = new LDAPUserImpl(uida.getID().concat("=").concat((String)uida.get()) + "," + getContainerDN(),identityContext);
          ldapu.setId((String)uida.get());
 
          //TODO:handle password
@@ -307,15 +397,19 @@
       this.uidAttributeID = uidAttributeID;
    }
 
-   public LDAPConnectionContext getConnectionContext()
+   public LDAPConnectionContext getConnectionContext() throws IdentityException
    {
+      if (connectionContext == null)
+      {
+         this.connectionContext = (LDAPConnectionContext)identityContext.getObject(IdentityContext.CONNECTION_CONTEXT);
+      }
       return connectionContext;
    }
 
-   public void setConnectionContext(LDAPConnectionContext connectionContext)
+   /*public void setConnectionContext(LDAPConnectionContext connectionContext)
    {
       this.connectionContext = connectionContext;
-   }
+   }*/
 
    public String getContainerDN()
    {
@@ -340,4 +434,24 @@
    {
       this.nameAttributeID = nameAttributeID;
    }*/
+
+   public IdentityContext getIdentityContext()
+   {
+      return identityContext;
+   }
+
+   public void setIdentityContext(IdentityContext identityContext)
+   {
+      this.identityContext = identityContext;
+   }
+
+   public String getJndiName()
+   {
+      return jndiName;
+   }
+
+   public void setJndiName(String jndiName)
+   {
+      this.jndiName = jndiName;
+   }
 }

Deleted: trunk/identity/src/main/org/jboss/portal/identity2/ldap/StaticGroupLDAPMembershipStrategyImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/StaticGroupLDAPMembershipStrategyImpl.java	2006-10-30 23:46:58 UTC (rev 5520)
+++ trunk/identity/src/main/org/jboss/portal/identity2/ldap/StaticGroupLDAPMembershipStrategyImpl.java	2006-10-31 01:06:03 UTC (rev 5521)
@@ -1,97 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat                                               *
- * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
- * contributors as indicated by the @authors tag. See the                     *
- * copyright.txt in the distribution for a full listing of                    *
- * individual contributors.                                                   *
- *                                                                            *
- * This is free software; you can redistribute it and/or modify it            *
- * under the terms of the GNU Lesser General Public License as                *
- * published by the Free Software Foundation; either version 2.1 of           *
- * the License, or (at your option) any later version.                        *
- *                                                                            *
- * This software is distributed in the hope that it will be useful,           *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
- * Lesser General Public License for more details.                            *
- *                                                                            *
- * You should have received a copy of the GNU Lesser General Public           *
- * License along with this software; if not, write to the Free                *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
- ******************************************************************************/
-package org.jboss.portal.identity2.ldap;
-
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity2.LDAPMembershipStrategy;
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-
-import java.util.Set;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class StaticGroupLDAPMembershipStrategyImpl extends AbstractJBossService implements LDAPMembershipStrategy
-{
-   private LDAPConnectionContext connectionContext;
-
-
-   /** DN under which roles should be searched. Used only when obtaining roles having only User DN. */
-   private String roleCtxDN;
-
-   /** Name of attribute in role entry that point to belonging user */
-   private String uidAttributeID;
-
-
-   public Set getRoles(LDAPUserImpl user) throws IdentityException
-   {
-      throw new UnsupportedOperationException("Not yet implemented");
-   }
-
-   public Set getUsers(LDAPRoleImpl role) throws IdentityException
-   {
-      throw new UnsupportedOperationException("Not yet implemented");
-   }
-
-   public void assignUsers(LDAPRoleImpl role, Set users) throws IdentityException
-   {
-      throw new UnsupportedOperationException("Not yet implemented");
-   }
-
-   public void assignRoles(LDAPUserImpl user, Set roles) throws IdentityException
-   {
-      throw new UnsupportedOperationException("Not yet implemented");
-   }
-
-
-   public LDAPConnectionContext getConnectionContext()
-   {
-      return connectionContext;
-   }
-
-   public void setConnectionContext(LDAPConnectionContext connectionContext)
-   {
-      this.connectionContext = connectionContext;
-   }
-
-   public String getRoleCtxDN()
-   {
-      return roleCtxDN;
-   }
-
-   public void setRoleCtxDN(String roleCtxDN)
-   {
-      this.roleCtxDN = roleCtxDN;
-   }
-
-   public String getUidAttributeID()
-   {
-      return uidAttributeID;
-   }
-
-   public void setUidAttributeID(String uidAttributeID)
-   {
-      this.uidAttributeID = uidAttributeID;
-   }
-}

Deleted: trunk/identity/src/main/org/jboss/portal/identity2/ldap/StaticRoleLDAPMembershipStrategyImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/StaticRoleLDAPMembershipStrategyImpl.java	2006-10-30 23:46:58 UTC (rev 5520)
+++ trunk/identity/src/main/org/jboss/portal/identity2/ldap/StaticRoleLDAPMembershipStrategyImpl.java	2006-10-31 01:06:03 UTC (rev 5521)
@@ -1,96 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat                                               *
- * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
- * contributors as indicated by the @authors tag. See the                     *
- * copyright.txt in the distribution for a full listing of                    *
- * individual contributors.                                                   *
- *                                                                            *
- * This is free software; you can redistribute it and/or modify it            *
- * under the terms of the GNU Lesser General Public License as                *
- * published by the Free Software Foundation; either version 2.1 of           *
- * the License, or (at your option) any later version.                        *
- *                                                                            *
- * This software is distributed in the hope that it will be useful,           *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
- * Lesser General Public License for more details.                            *
- *                                                                            *
- * You should have received a copy of the GNU Lesser General Public           *
- * License along with this software; if not, write to the Free                *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
- ******************************************************************************/
-package org.jboss.portal.identity2.ldap;
-
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity2.LDAPMembershipStrategy;
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-
-import java.util.Set;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class StaticRoleLDAPMembershipStrategyImpl extends AbstractJBossService implements LDAPMembershipStrategy
-{
-   private LDAPConnectionContext connectionContext;
-
-   /** DN under which users should be searched. Used only when obtaining users having only Role DN. */
-   private String userCtxDN;
-
-   /** Name of attribute in role entry that point to belonging user */
-   private String roleAttributeID;
-
-
-   public Set getRoles(LDAPUserImpl user) throws IdentityException
-   {
-      throw new UnsupportedOperationException("Not yet implemented");
-   }
-
-   public Set getUsers(LDAPRoleImpl role) throws IdentityException
-   {
-      throw new UnsupportedOperationException("Not yet implemented");
-   }
-
-   public void assignUsers(LDAPRoleImpl role, Set users) throws IdentityException
-   {
-      throw new UnsupportedOperationException("Not yet implemented");
-   }
-
-   public void assignRoles(LDAPUserImpl user, Set roles) throws IdentityException
-   {
-      throw new UnsupportedOperationException("Not yet implemented");
-   }
-
-
-   public LDAPConnectionContext getConnectionContext()
-   {
-      return connectionContext;
-   }
-
-   public void setConnectionContext(LDAPConnectionContext connectionContext)
-   {
-      this.connectionContext = connectionContext;
-   }
-
-   public String getUserCtxDN()
-   {
-      return userCtxDN;
-   }
-
-   public void setUserCtxDN(String userCtxDN)
-   {
-      this.userCtxDN = userCtxDN;
-   }
-
-   public String getRoleAttributeID()
-   {
-      return roleAttributeID;
-   }
-
-   public void setRoleAttributeID(String roleAttributeID)
-   {
-      this.roleAttributeID = roleAttributeID;
-   }
-}

Added: trunk/identity/src/main/org/jboss/portal/identity2/ldap/helper/LDAPTools.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/helper/LDAPTools.java	2006-10-30 23:46:58 UTC (rev 5520)
+++ trunk/identity/src/main/org/jboss/portal/identity2/ldap/helper/LDAPTools.java	2006-10-31 01:06:03 UTC (rev 5521)
@@ -0,0 +1,58 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity2.ldap.helper;
+
+/**
+ * Helper class for ldap operation
+ *
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class LDAPTools
+{
+
+   /**
+    * Process dn and retrieves a part from it:
+    * uid=xxx,dc=example,dc=org - retrieves xxx
+    *
+    * @param dn
+    * @return
+    */
+   public static String stripDnToName(String dn)
+   {
+      if (dn == null || dn.length() == 0)
+      {
+         throw new IllegalArgumentException("Cannot process empty dn");
+      }
+      String name = null;
+
+      String[] parts = dn.split(",");
+
+      parts = parts[0].split("=");
+      if (parts.length != 2)
+      {
+         throw new IllegalArgumentException("Wrong dn format: " + dn);
+      }
+
+      return parts[1];
+   }
+}

Copied: trunk/identity/src/main/org/jboss/portal/test/identity/LDAPMembershipModuleTestCase.java (from rev 5472, trunk/identity/src/main/org/jboss/portal/test/identity/LDAPMembershipStrategyTestCase.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/LDAPMembershipStrategyTestCase.java	2006-10-17 00:12:37 UTC (rev 5472)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/LDAPMembershipModuleTestCase.java	2006-10-31 01:06:03 UTC (rev 5521)
@@ -0,0 +1,57 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * This is free software; you can redistribute it and/or modify it            *
+ * under the terms of the GNU Lesser General Public License as                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+package org.jboss.portal.test.identity;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class LDAPMembershipModuleTestCase extends LDAPTestCase implements MembershipStrategyTest.Context
+{
+
+   /** . */
+   protected MembershipStrategyTest mstc;
+
+   public void setUp() throws Exception
+   {
+      //mstc = new MembershipStrategyTest();
+      super.setUp();
+   }
+
+   /*public void testFirstSimple() throws Exception
+   {
+      mstc.testFirstSimple();
+   }
+
+   public void testSecondSimple() throws Exception
+   {
+      mstc.testSecondSimple();
+   }
+
+   public void testThirdSimple() throws Exception
+   {
+      mstc.testThirdSimple();
+   }*/
+}

Deleted: trunk/identity/src/main/org/jboss/portal/test/identity/LDAPMembershipStrategyTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/LDAPMembershipStrategyTestCase.java	2006-10-30 23:46:58 UTC (rev 5520)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/LDAPMembershipStrategyTestCase.java	2006-10-31 01:06:03 UTC (rev 5521)
@@ -1,56 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat                                               *
- * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
- * contributors as indicated by the @authors tag. See the                     *
- * copyright.txt in the distribution for a full listing of                    *
- * individual contributors.                                                   *
- *                                                                            *
- * This is free software; you can redistribute it and/or modify it            *
- * under the terms of the GNU Lesser General Public License as                *
- * published by the Free Software Foundation; either version 2.1 of           *
- * the License, or (at your option) any later version.                        *
- *                                                                            *
- * This software is distributed in the hope that it will be useful,           *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
- * Lesser General Public License for more details.                            *
- *                                                                            *
- * You should have received a copy of the GNU Lesser General Public           *
- * License along with this software; if not, write to the Free                *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
- ******************************************************************************/
-package org.jboss.portal.test.identity;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public abstract class LDAPMembershipStrategyTestCase extends LDAPTestCase
-{
-
-   /** . */
-   protected MembershipStrategyTest mstc;
-
-
-   protected void setUp() throws Exception
-   {
-      //mstc = new MembershipStrategyTest();
-      super.setUp();
-   }
-
-   public void testFirstSimple() throws Exception
-   {
-      mstc.testFirstSimple();
-   }
-
-   public void testSecondSimple() throws Exception
-   {
-      mstc.testSecondSimple();
-   }
-
-   public void testThirdSimple() throws Exception
-   {
-      mstc.testThirdSimple();
-   }
-}

Modified: trunk/identity/src/main/org/jboss/portal/test/identity/LDAPSimpleRoleModuleTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/LDAPSimpleRoleModuleTestCase.java	2006-10-30 23:46:58 UTC (rev 5520)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/LDAPSimpleRoleModuleTestCase.java	2006-10-31 01:06:03 UTC (rev 5521)
@@ -23,9 +23,12 @@
 package org.jboss.portal.test.identity;
 
 import junit.framework.TestSuite;
-import org.jboss.portal.identity2.RoleModule;
+import org.jboss.portal.identity.RoleModule;
 import org.jboss.portal.identity2.ldap.LDAPRoleImpl;
 import org.jboss.portal.identity2.ldap.LDAPRoleModuleImpl;
+import org.jboss.portal.identity2.ldap.LDAPConnectionContext;
+import org.jboss.portal.identity2.ldap.LDAPUserModuleImpl;
+import org.jboss.portal.identity2.IdentityContextImpl;
 import org.jboss.portal.test.framework.TestRuntimeContext;
 
 /**
@@ -43,17 +46,23 @@
 
    RoleModule roleModule;
 
-   protected void setUp() throws Exception
+   public void setUp() throws Exception
    {
       runtimeContext = new TestRuntimeContext("org/jboss/portal/test/identity/ldap-beans.xml");
       runtimeContext.addBean("LDAPTestBean", this);
 
+      IdentityContextImpl context = new IdentityContextImpl();
+      context.start();
+
+      LDAPConnectionContext connection = createConnectionContext();
+      connection.setIdentityContext(context);
+      connection.start();
+
       LDAPRoleModuleImpl roleModule = new LDAPRoleModuleImpl();
-      roleModule.setConnectionContext(createConnectionContext());
-
+      roleModule.setIdentityContext(context);
       roleModule.setContainerDN("ou=Roles,dc=jboss,dc=org");
       roleModule.setRidAttributeID("cn");
-
+      roleModule.start();
       this.roleModule = roleModule;
 
       super.setUp();

Modified: trunk/identity/src/main/org/jboss/portal/test/identity/LDAPSimpleUserModuleTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/LDAPSimpleUserModuleTestCase.java	2006-10-30 23:46:58 UTC (rev 5520)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/LDAPSimpleUserModuleTestCase.java	2006-10-31 01:06:03 UTC (rev 5521)
@@ -23,9 +23,11 @@
 package org.jboss.portal.test.identity;
 
 import junit.framework.TestSuite;
-import org.jboss.portal.identity2.UserModule;
+import org.jboss.portal.identity.UserModule;
 import org.jboss.portal.identity2.ldap.LDAPUserImpl;
 import org.jboss.portal.identity2.ldap.LDAPUserModuleImpl;
+import org.jboss.portal.identity2.ldap.LDAPConnectionContext;
+import org.jboss.portal.identity2.IdentityContextImpl;
 import org.jboss.portal.test.framework.TestRuntimeContext;
 
 /**
@@ -38,22 +40,32 @@
 
    public static TestSuite suite() throws Exception
    {
+      System.out.println("###");
       return createTestSuite(LDAPSimpleUserModuleTestCase.class);
    }
 
    UserModule userModule;
 
-   protected void setUp() throws Exception
+   public void setUp() throws Exception
    {
+      System.out.println("#########################");
       runtimeContext = new TestRuntimeContext("org/jboss/portal/test/identity/ldap-beans.xml");
       runtimeContext.addBean("LDAPTestBean", this);
 
+      IdentityContextImpl context = new IdentityContextImpl();
+      context.start();
+
+      LDAPConnectionContext connection = createConnectionContext();
+      connection.setIdentityContext(context);
+      connection.start();
+
       LDAPUserModuleImpl userModule = new LDAPUserModuleImpl();
-      userModule.setConnectionContext(createConnectionContext());
+      userModule.setIdentityContext(context);
 
       userModule.setContainerDN("ou=People,dc=jboss,dc=org");
       userModule.setUidAttributeID("uid");
 
+      userModule.start();
       this.userModule = userModule;
 
       super.setUp();

Copied: trunk/identity/src/main/org/jboss/portal/test/identity/LDAPStaticGroupMembershipModuleTestCase.java (from rev 5472, trunk/identity/src/main/org/jboss/portal/test/identity/LDAPStaticGroupStrategyTestCase.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/LDAPStaticGroupStrategyTestCase.java	2006-10-17 00:12:37 UTC (rev 5472)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/LDAPStaticGroupMembershipModuleTestCase.java	2006-10-31 01:06:03 UTC (rev 5521)
@@ -0,0 +1,123 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * This is free software; you can redistribute it and/or modify it            *
+ * under the terms of the GNU Lesser General Public License as                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+package org.jboss.portal.test.identity;
+
+import junit.framework.TestSuite;
+import org.jboss.portal.test.framework.TestRuntimeContext;
+import org.jboss.portal.identity2.IdentityContextImpl;
+import org.jboss.portal.identity2.MembershipModule;
+import org.jboss.portal.identity2.ldap.LDAPConnectionContext;
+import org.jboss.portal.identity2.ldap.LDAPUserModuleImpl;
+import org.jboss.portal.identity2.ldap.LDAPRoleModuleImpl;
+import org.jboss.portal.identity2.ldap.LDAPStaticGroupMembershipModuleImpl;
+import org.jboss.portal.identity2.ldap.LDAPRoleImpl;
+import org.jboss.portal.identity.UserModule;
+import org.jboss.portal.identity.RoleModule;
+import org.jboss.portal.identity.User;
+
+
+import java.util.Set;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class LDAPStaticGroupMembershipModuleTestCase extends LDAPMembershipModuleTestCase
+{
+
+   private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPStaticGroupMembershipModuleTestCase.class);
+
+   public static TestSuite suite() throws Exception
+   {
+      return createTestSuite(LDAPStaticGroupMembershipModuleTestCase.class);
+   }
+
+   private UserModule userModule;
+
+   private RoleModule roleModule;
+
+   private MembershipModule membershipModule;
+
+   public void setUp() throws Exception
+   {
+      runtimeContext = new TestRuntimeContext("org/jboss/portal/test/identity/ldap-beans.xml");
+      runtimeContext.addBean("LDAPTestBean", this);
+
+      IdentityContextImpl context = new IdentityContextImpl();
+      context.start();
+
+      LDAPConnectionContext connection = createConnectionContext();
+      connection.setIdentityContext(context);
+      connection.start();
+
+      LDAPUserModuleImpl userModule = new LDAPUserModuleImpl();
+      userModule.setIdentityContext(context);
+
+      userModule.setContainerDN("ou=People,dc=jboss,dc=org");
+      userModule.setUidAttributeID("uid");
+
+      userModule.start();
+      this.userModule = userModule;
+
+      LDAPRoleModuleImpl roleModule = new LDAPRoleModuleImpl();
+      roleModule.setIdentityContext(context);
+      roleModule.setContainerDN("ou=Roles,dc=jboss,dc=org");
+      roleModule.setRidAttributeID("cn");
+      roleModule.start();
+      this.roleModule = roleModule;
+
+      LDAPStaticGroupMembershipModuleImpl membership = new LDAPStaticGroupMembershipModuleImpl();
+      membership.setIdentityContext(context);
+      membership.setUidAttributeID("member");
+      membership.setUidAttributeIsDN(true);
+      membership.start();
+      this.membershipModule = membership;
+
+      mstc = new MembershipStrategyTest();
+      mstc.setContext(this);
+      mstc.setMembershipModule(membership);
+      mstc.setUserModule(userModule);
+      mstc.setRoleModule(roleModule);
+
+
+      super.setUp();
+   }
+
+
+   public void testGetUsers() throws Exception
+   {
+      LDAPRoleImpl role = (LDAPRoleImpl)roleModule.findRoleByName("Echo");
+      Set users = membershipModule.getUsers(role);
+      assertEquals(3, users.size());
+
+      for (Iterator iterator = users.iterator(); iterator.hasNext();)
+      {
+         User user = (User)iterator.next();
+         log.info("####################3User: " + user.getUserName());
+
+      }
+
+   }
+   
+}

Deleted: trunk/identity/src/main/org/jboss/portal/test/identity/LDAPStaticGroupStrategyTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/LDAPStaticGroupStrategyTestCase.java	2006-10-30 23:46:58 UTC (rev 5520)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/LDAPStaticGroupStrategyTestCase.java	2006-10-31 01:06:03 UTC (rev 5521)
@@ -1,58 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat                                               *
- * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
- * contributors as indicated by the @authors tag. See the                     *
- * copyright.txt in the distribution for a full listing of                    *
- * individual contributors.                                                   *
- *                                                                            *
- * This is free software; you can redistribute it and/or modify it            *
- * under the terms of the GNU Lesser General Public License as                *
- * published by the Free Software Foundation; either version 2.1 of           *
- * the License, or (at your option) any later version.                        *
- *                                                                            *
- * This software is distributed in the hope that it will be useful,           *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
- * Lesser General Public License for more details.                            *
- *                                                                            *
- * You should have received a copy of the GNU Lesser General Public           *
- * License along with this software; if not, write to the Free                *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
- ******************************************************************************/
-package org.jboss.portal.test.identity;
-
-import junit.framework.TestSuite;
-import org.jboss.portal.identity2.ldap.StaticGroupLDAPMembershipStrategyImpl;
-import org.jboss.portal.test.framework.TestRuntimeContext;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class LDAPStaticGroupStrategyTestCase extends LDAPMembershipStrategyTestCase
-{
-
-   private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPStaticGroupStrategyTestCase.class);
-
-   public static TestSuite suite() throws Exception
-   {
-      return createTestSuite(LDAPStaticGroupStrategyTestCase.class);
-   }
-
-   protected void setUp() throws Exception
-   {
-      runtimeContext = new TestRuntimeContext("org/jboss/portal/test/identity/ldap-beans.xml");
-      runtimeContext.addBean("LDAPTestBean", this);
-
-      StaticGroupLDAPMembershipStrategyImpl strategy = new StaticGroupLDAPMembershipStrategyImpl();
-      strategy.setConnectionContext(createConnectionContext());
-
-      mstc = new MembershipStrategyTest();
-      mstc.setContext(this);
-      mstc.setLDAPMembershipStrategy(strategy);
-
-
-      super.setUp();
-   }
-}

Deleted: trunk/identity/src/main/org/jboss/portal/test/identity/LDAPStaticRoleStrategyTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/LDAPStaticRoleStrategyTestCase.java	2006-10-30 23:46:58 UTC (rev 5520)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/LDAPStaticRoleStrategyTestCase.java	2006-10-31 01:06:03 UTC (rev 5521)
@@ -1,58 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat                                               *
- * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
- * contributors as indicated by the @authors tag. See the                     *
- * copyright.txt in the distribution for a full listing of                    *
- * individual contributors.                                                   *
- *                                                                            *
- * This is free software; you can redistribute it and/or modify it            *
- * under the terms of the GNU Lesser General Public License as                *
- * published by the Free Software Foundation; either version 2.1 of           *
- * the License, or (at your option) any later version.                        *
- *                                                                            *
- * This software is distributed in the hope that it will be useful,           *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
- * Lesser General Public License for more details.                            *
- *                                                                            *
- * You should have received a copy of the GNU Lesser General Public           *
- * License along with this software; if not, write to the Free                *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
- ******************************************************************************/
-package org.jboss.portal.test.identity;
-
-import junit.framework.TestSuite;
-import org.jboss.portal.identity2.ldap.StaticRoleLDAPMembershipStrategyImpl;
-import org.jboss.portal.test.framework.TestRuntimeContext;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class LDAPStaticRoleStrategyTestCase extends LDAPMembershipStrategyTestCase
-{
-
-   private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPStaticRoleStrategyTestCase.class);
-
-   public static TestSuite suite() throws Exception
-   {
-      return createTestSuite(LDAPStaticRoleStrategyTestCase.class);
-   }
-
-   protected void setUp() throws Exception
-   {
-      runtimeContext = new TestRuntimeContext("org/jboss/portal/test/identity/ldap-beans.xml");
-      runtimeContext.addBean("LDAPTestBean", this);
-
-      StaticRoleLDAPMembershipStrategyImpl strategy = new StaticRoleLDAPMembershipStrategyImpl();
-      strategy.setConnectionContext(createConnectionContext());
-
-      mstc = new MembershipStrategyTest();
-      mstc.setContext(this);
-      mstc.setLDAPMembershipStrategy(strategy);
-
-
-      super.setUp();
-   }
-}

Modified: trunk/identity/src/main/org/jboss/portal/test/identity/LDAPTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/LDAPTestCase.java	2006-10-30 23:46:58 UTC (rev 5520)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/LDAPTestCase.java	2006-10-31 01:06:03 UTC (rev 5521)
@@ -33,6 +33,7 @@
 import org.jboss.portal.test.framework.embedded.DSConfig;
 import org.jboss.portal.common.test.junit.JUnitAdapter;
 import org.jboss.portal.common.test.junit.POJOJUnitTest;
+import org.jboss.portal.test.framework.embedded.apacheds.ApacheDSService;
 
 import javax.naming.Binding;
 import javax.naming.Context;
@@ -51,7 +52,7 @@
  * @author <a href="mailto:boleslaw dot dawidowicz at jboss dot com">Boleslaw Dawidowicz</a>
  * @version $Revision: 5247 $
  */
-public abstract class LDAPTestCase extends junit.framework.TestCase implements MembershipStrategyTest.Context
+public abstract class LDAPTestCase extends junit.framework.TestCase //implements MembershipStrategyTest.Context
 {
 
    private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPTestCase.class);
@@ -90,6 +91,7 @@
 
    private DSConfig directoryServerConfigParameter;
 
+   protected ApacheDSService embeddedDSService;
 
    public String getName()
    {
@@ -106,21 +108,35 @@
       this.directoryServerConfigParameter = directoryServerConfigParameter;
    }
 
-   protected void setUp() throws Exception
+   public void setUp() throws Exception
    {
+      System.out.println("#######################%%%%%%%%%%%%%%%%%%");
+      if(directoryServerConfigParameter.isUseEmbedded())
+      {
+         embeddedDSService = new ApacheDSService();
+         embeddedDSService.setRemoveWorkingDir(true);
+         embeddedDSService.start();
+      }
       runtimeContext.start();
 
 
       populate();
    }
 
-   protected void tearDown() throws Exception
+   public void tearDown() throws Exception
    {
 
       //on exit remove dc=jboss,dc=org
       cleanUp();
 
       runtimeContext.stop();
+
+      if (embeddedDSService != null && directoryServerConfigParameter.isUseEmbedded())
+      {
+         embeddedDSService.stop();
+         //give ApacheDS time to free the port...
+         Thread.sleep(200);
+      }
    }
 
 
@@ -145,7 +161,8 @@
          DirContext ctx = getDirContext();
          ClassLoader tcl = Thread.currentThread().getContextClassLoader();
 
-         URL ldif = tcl.getResource("ldap/ldif/example1.ldif");
+         //URL ldif = tcl.getResource("ldap/ldif/example1.ldif");
+         URL ldif = tcl.getResource(directoryServerConfigParameter.getPopulateLdif());
          log.info("ldif to load by loader: " + ldif.getPath());
 
          LdifFileLoader loader = new LdifFileLoader(ctx, ldif.getPath());
@@ -162,8 +179,17 @@
       try
       {
          DirContext ctx = getDirContext();
-         DirContext org = (DirContext)ctx.lookup("dc=org");
-         removeContext(org, "dc=jboss");
+         String fullDN = directoryServerConfigParameter.getCleanUpDN();
+         String[] parts = fullDN.split(",");
+         String removeContext = parts[0];
+
+         String suffix = fullDN.substring(fullDN.indexOf(",")+1,fullDN.length());
+
+         log.debug("Clean up: \'" + removeContext + "\' from \'" + suffix + "\'");
+
+         //DirContext org = (DirContext)ctx.lookup("dc=org");
+         DirContext org = (DirContext)ctx.lookup(suffix);
+         removeContext(org, removeContext);
       }
       catch (Exception e)
       {

Modified: trunk/identity/src/main/org/jboss/portal/test/identity/MembershipStrategyTest.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/MembershipStrategyTest.java	2006-10-30 23:46:58 UTC (rev 5520)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/MembershipStrategyTest.java	2006-10-31 01:06:03 UTC (rev 5521)
@@ -24,6 +24,9 @@
 
 import junit.framework.Assert;
 import org.jboss.portal.identity2.LDAPMembershipStrategy;
+import org.jboss.portal.identity2.MembershipModule;
+import org.jboss.portal.identity.RoleModule;
+import org.jboss.portal.identity.UserModule;
 
 /**
  * @author <a href="mailto:boleslaw dot dawidowicz at jboss dot com">Boleslaw Dawidowicz</a>
@@ -36,19 +39,32 @@
    /** . */
    private MembershipStrategyTest.Context ctx;
 
-   private LDAPMembershipStrategy strategy;
+   protected MembershipModule membership;
 
+   protected UserModule userModule;
 
+   protected RoleModule roleModule;
+
    public void setContext(MembershipStrategyTest.Context ctx)
    {
       this.ctx = ctx;
    }
 
-   public void setLDAPMembershipStrategy(LDAPMembershipStrategy strategy)
+   public void setMembershipModule(MembershipModule membership)
    {
-      this.strategy = strategy;
+      this.membership = membership;
    }
 
+   public void setUserModule(UserModule userModule)
+   {
+      this.userModule = userModule;
+   }
+
+   public void setRoleModule(RoleModule roleModule)
+   {
+      this.roleModule = roleModule;
+   }
+
    public void testFirstSimple() throws Exception
    {
       log.info("first test");

Modified: trunk/identity/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity/ldap-beans.xml
===================================================================
--- trunk/identity/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity/ldap-beans.xml	2006-10-30 23:46:58 UTC (rev 5520)
+++ trunk/identity/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity/ldap-beans.xml	2006-10-31 01:06:03 UTC (rev 5521)
@@ -27,21 +27,24 @@
             xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
             xmlns="urn:jboss:bean-deployer">
 
-   <bean name="ApacheDSService" class="org.jboss.portal.test.framework.embedded.apacheds.ApacheDSService">
+   <!--<bean name="ApacheDSService" class="org.jboss.portal.test.framework.embedded.apacheds.ApacheDSService">
+      <constructor factoryMethod="getBean">
+         <factory bean="BeanFactory"/>
+         <parameter>ApacheDSServiceBean</parameter>
+      </constructor>
       <property name="removeWorkingDir">true</property>
-   </bean>
+   </bean>-->
 
 
    <bean name="JNDISupport" class="org.jboss.portal.test.framework.embedded.JNDISupport">
    </bean>
 
-
    <bean name="LDAPTestBean" class="org.jboss.portal.test.identity.LDAPUserTestCase">
       <constructor factoryMethod="getBean">
          <factory bean="BeanFactory"/>
          <parameter>LDAPTestBean</parameter>
       </constructor>
-      <depends>ApacheDSService</depends>
+      <!--<depends>ApacheDSService</depends>-->
    </bean>
 
 </deployment>

Modified: trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/Log4JTestCase.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/Log4JTestCase.java	2006-10-30 23:46:58 UTC (rev 5520)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/Log4JTestCase.java	2006-10-31 01:06:03 UTC (rev 5521)
@@ -28,9 +28,9 @@
  * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
  * @version $Revision: 1.1 $
  */
-public class Log4jTestCase extends ServerTestRunner
+public class Log4JTestCase extends ServerTestRunner
 {
-   public Log4jTestCase()
+   public Log4JTestCase()
    {
       super("test-jsr168-misc-log4j.war");
    }

Modified: trunk/test/src/etc/directories.xml
===================================================================
--- trunk/test/src/etc/directories.xml	2006-10-30 23:46:58 UTC (rev 5520)
+++ trunk/test/src/etc/directories.xml	2006-10-31 01:06:03 UTC (rev 5521)
@@ -29,5 +29,8 @@
       <context-factory>com.sun.jndi.ldap.LdapCtxFactory</context-factory>
       <admin-dn>uid=admin,ou=system</admin-dn>
       <admin-password>secret</admin-password>
+      <use-embedded>true</use-embedded>
+      <populate-ldif>ldap/ldif/example1.ldif</populate-ldif>
+      <cleanup-dn>dc=jboss,dc=org</cleanup-dn>
    </directory>
 </directories>

Modified: trunk/test/src/etc/ldap/ldif/example1.ldif
===================================================================
--- trunk/test/src/etc/ldap/ldif/example1.ldif	2006-10-30 23:46:58 UTC (rev 5520)
+++ trunk/test/src/etc/ldap/ldif/example1.ldif	2006-10-31 01:06:03 UTC (rev 5521)
@@ -69,7 +69,9 @@
 objectClass: groupOfNames
 cn: Echo
 description: the JBossAdmin group
-member: uid=jduke,ou=People,dc=jboss,dc=org
+member: uid=jduke1,ou=People,dc=jboss,dc=org
+member: uid=jduke3,ou=People,dc=jboss,dc=org
+member: uid=jduke4,ou=People,dc=jboss,dc=org
 
 dn: cn=TheDuke,ou=Roles,dc=jboss,dc=org
 objectClass: groupOfNames

Modified: trunk/test/src/main/org/jboss/portal/test/framework/embedded/DSConfig.java
===================================================================
--- trunk/test/src/main/org/jboss/portal/test/framework/embedded/DSConfig.java	2006-10-30 23:46:58 UTC (rev 5520)
+++ trunk/test/src/main/org/jboss/portal/test/framework/embedded/DSConfig.java	2006-10-31 01:06:03 UTC (rev 5521)
@@ -57,7 +57,13 @@
 
    private String adminPassword;
 
-   public DSConfig(String name, String description, String url, String contextFactory, String adminDN, String adminPass)
+   private boolean useEmbedded;
+
+   private String populateLdif;
+
+   private String cleanUpDN;
+
+   public DSConfig(String name, String description, String url, String contextFactory, String adminDN, String adminPass, boolean useEmbedded, String populateLdif, String cleanUpDN)
    {
       this.name = name;
       this.description = description;
@@ -65,6 +71,9 @@
       this.contextFactory = contextFactory;
       this.adminDN = adminDN;
       this.adminPassword = adminPass;
+      this.useEmbedded = useEmbedded;
+      this.populateLdif = populateLdif;
+      this.cleanUpDN = cleanUpDN;
    }
 
    public static MultiValuedTestParameterValue fromXML2(URL url) throws Exception
@@ -91,19 +100,30 @@
             Element context = XML.getUniqueChild(childElt, "context-factory", true);
             Element admin = XML.getUniqueChild(childElt, "admin-dn", true);
             Element password = XML.getUniqueChild(childElt, "admin-password", true);
+            Element embedded = XML.getUniqueChild(childElt, "use-embedded", true);
+            Element populate = XML.getUniqueChild(childElt, "populate-ldif", true);
+            Element cleanup = XML.getUniqueChild(childElt, "cleanup-dn", true);
+
             String name = XML.asString(nm);
             String description = XML.asString(desc);
             String providerURL = XML.asString(purl);
             String contextFactory = XML.asString(context);
             String adminDN = XML.asString(admin);
             String adminPassword = XML.asString(password);
+            boolean embedd = XML.asString(embedded).equals("true");
+            String populateLdif = XML.asString(populate);
+            String cleanUpDN = XML.asString(cleanup);
+
             DSConfig dsCfg = new DSConfig(
                name,
                description,
                providerURL,
                contextFactory,
                adminDN,
-               adminPassword);
+               adminPassword,
+               embedd,
+               populateLdif,
+               cleanUpDN);
             configs.add(dsCfg);
          }
          return (DSConfig[])configs.toArray(new DSConfig[configs.size()]);
@@ -173,4 +193,35 @@
    {
       this.description = description;
    }
+
+   public boolean isUseEmbedded()
+   {
+      return useEmbedded;
+   }
+
+   public void setUseEmbedded(boolean useEmbedded)
+   {
+      this.useEmbedded = useEmbedded;
+   }
+
+   public String getPopulateLdif()
+   {
+      return populateLdif;
+   }
+
+   public void setPopulateLdif(String populateLdif)
+   {
+      this.populateLdif = populateLdif;
+   }
+
+   public String getCleanUpDN()
+   {
+      return cleanUpDN;
+   }
+
+   public void setCleanUpDN(String cleanUpDN)
+   {
+      this.cleanUpDN = cleanUpDN;
+   }
+
 }




More information about the jboss-svn-commits mailing list