portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r683497 [4/7] - in /portals/jetspeed-2/portal/branches/JS2-869: components/jetspeed-capability/src/main/java/org/apache/jetspeed/serializer/ components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/serializer/ components/jetspeed-...
Date Thu, 07 Aug 2008 03:52:09 GMT
Modified: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/DefaultRoleSecurityHandler.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/DefaultRoleSecurityHandler.java?rev=683497&r1=683496&r2=683497&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/DefaultRoleSecurityHandler.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/DefaultRoleSecurityHandler.java Wed Aug  6 20:52:05 2008
@@ -16,7 +16,7 @@
  */
 package org.apache.jetspeed.security.spi.impl;
 
-import java.util.Iterator;
+import java.util.Collection;
 import java.util.LinkedList;
 import java.util.List;
 
@@ -52,17 +52,14 @@
     /**
      * @see org.apache.jetspeed.security.spi.RoleSecurityHandler#getRolePrincipal(java.lang.String)
      */
-    public RolePrincipal getRolePrincipal(String roleFullPathName)
+    public RolePrincipal getRolePrincipal(String roleName)
     {
         RolePrincipal rolePrincipal = null;
-        InternalRolePrincipal internalRole = commonQueries
-                .getInternalRolePrincipal(RolePrincipalImpl
-                        .getFullPathFromPrincipalName(roleFullPathName));
+        InternalRolePrincipal internalRole = commonQueries.getInternalRolePrincipal(roleName);        
         if (null != internalRole)
         {
-            rolePrincipal = new RolePrincipalImpl(RolePrincipalImpl
-                    .getPrincipalNameFromFullPath(internalRole.getFullPath()), 
-                    internalRole.isEnabled(), internalRole.isMappingOnly());
+            rolePrincipal = new RolePrincipalImpl(internalRole.getPrincipalId(), internalRole.getName(),
+                                            internalRole.isEnabled(), internalRole.isMappingOnly());
         }
         return rolePrincipal;
     }
@@ -70,23 +67,22 @@
     /**
      * @see org.apache.jetspeed.security.spi.RoleSecurityHandler#setRolePrincipal(org.apache.jetspeed.security.RolePrincipal)
      */
-    public void setRolePrincipal(RolePrincipal rolePrincipal)
+    public void storeRolePrincipal(RolePrincipal rolePrincipal)
             throws SecurityException
-    {
-        String fullPath = rolePrincipal.getFullPath();
-        InternalRolePrincipal internalRole = commonQueries.getInternalRolePrincipal(fullPath);
+    {        
+        InternalRolePrincipal internalRole = commonQueries.getInternalRolePrincipal(rolePrincipal.getName());
         if ( null == internalRole )
         {
-            internalRole = new InternalRolePrincipalImpl(fullPath);
+            internalRole = new InternalRolePrincipalImpl(rolePrincipal.getName());
             internalRole.setEnabled(rolePrincipal.isEnabled());
-            commonQueries.setInternalRolePrincipal(internalRole, false);
+            commonQueries.storeInternalRolePrincipal(internalRole, false);
         }
         else if ( !internalRole.isMappingOnly() )
         {
             if ( internalRole.isEnabled() != rolePrincipal.isEnabled() )
             {
                 internalRole.setEnabled(rolePrincipal.isEnabled());
-                commonQueries.setInternalRolePrincipal(internalRole, false);
+                commonQueries.storeInternalRolePrincipal(internalRole, false);
             }
         }
         else
@@ -102,7 +98,7 @@
             throws SecurityException
     {
         InternalRolePrincipal internalRole = commonQueries
-                .getInternalRolePrincipal(rolePrincipal.getFullPath());
+                .getInternalRolePrincipal(rolePrincipal.getName());
         if (null != internalRole)
         {
             commonQueries.removeInternalRolePrincipal(internalRole);
@@ -112,23 +108,15 @@
     /**
      * @see org.apache.jetspeed.security.spi.RoleSecurityHandler#getRolePrincipals(java.lang.String)
      */
-    public List getRolePrincipals(String filter)
+    public List<RolePrincipal> getRolePrincipals(String filter)
     {
-        List rolePrincipals = new LinkedList();
-        Iterator result = commonQueries.getInternalRolePrincipals(filter);
-        while (result.hasNext())
-        {
-            InternalRolePrincipal internalRole = (InternalRolePrincipal) result
-                    .next();
-            String path = internalRole.getFullPath();
-            if (path == null)
-            {
-                continue;
-            }
-            rolePrincipals.add(new RolePrincipalImpl(RolePrincipalImpl
-                    .getPrincipalNameFromFullPath(internalRole.getFullPath())));
+        List<RolePrincipal> rolePrincipals = new LinkedList<RolePrincipal>();
+        Collection<InternalRolePrincipal> internalRolePrincipals = commonQueries.getInternalRolePrincipals(filter);
+        for (InternalRolePrincipal internalRole : internalRolePrincipals)
+        {
+            rolePrincipals.add(new RolePrincipalImpl(internalRole.getPrincipalId(), internalRole.getName(), 
+                                internalRole.isEnabled(), internalRole.isMappingOnly()));
         }
         return rolePrincipals;
-    }
-        
+    }        
 }
\ No newline at end of file

Modified: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/DefaultSecurityMappingHandler.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/DefaultSecurityMappingHandler.java?rev=683497&r1=683496&r2=683497&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/DefaultSecurityMappingHandler.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/DefaultSecurityMappingHandler.java Wed Aug  6 20:52:05 2008
@@ -16,16 +16,15 @@
  */
 package org.apache.jetspeed.security.spi.impl;
 
-import java.security.Principal;
 import java.util.Collection;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Set;
-import java.util.prefs.Preferences;
 
+import org.apache.jetspeed.security.GroupPrincipal;
 import org.apache.jetspeed.security.HierarchyResolver;
+import org.apache.jetspeed.security.RolePrincipal;
 import org.apache.jetspeed.security.SecurityException;
-import org.apache.jetspeed.security.impl.GeneralizationHierarchyResolver;
+import org.apache.jetspeed.security.UserPrincipal;
 import org.apache.jetspeed.security.impl.GroupPrincipalImpl;
 import org.apache.jetspeed.security.impl.RolePrincipalImpl;
 import org.apache.jetspeed.security.impl.UserPrincipalImpl;
@@ -40,15 +39,13 @@
 /**
  * @see org.apache.jetspeed.security.spi.SecurityMappingHandler
  * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
  */
 public class DefaultSecurityMappingHandler implements SecurityMappingHandler
 {
 
-    /** The role hierarchy resolver. */
-    HierarchyResolver roleHierarchyResolver = new GeneralizationHierarchyResolver();
-
-    /** The group hierarchy resolver. */
-    HierarchyResolver groupHierarchyResolver = new GeneralizationHierarchyResolver();
+    /** The hierarchy resolver. */
+    HierarchyResolver hierarchyResolver = null;
 
     /** Common queries. */
     private SecurityAccess commonQueries = null;
@@ -69,79 +66,53 @@
      * resolvers.
      * </p>
      */
-    public DefaultSecurityMappingHandler(SecurityAccess commonQueries, HierarchyResolver roleHierarchyResolver,
-            HierarchyResolver groupHierarchyResolver)
+    public DefaultSecurityMappingHandler(SecurityAccess commonQueries, HierarchyResolver hierarchyResolver)
     {
         this.commonQueries = commonQueries;
-        if (null != roleHierarchyResolver)
-        {
-            this.roleHierarchyResolver = roleHierarchyResolver;
-        }
-        if (null != groupHierarchyResolver)
-        {
-            this.groupHierarchyResolver = groupHierarchyResolver;
-        }
-    }
-
-    /**
-     * @return Returns the roleHierarchyResolver.
-     */
-    public HierarchyResolver getRoleHierarchyResolver()
-    {
-        return roleHierarchyResolver;
-    }
-
-    /**
-     * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#setRoleHierarchyResolver(org.apache.jetspeed.security.HierarchyResolver)
-     */
-    public void setRoleHierarchyResolver(HierarchyResolver roleHierarchyResolver)
-    {
-        this.roleHierarchyResolver = roleHierarchyResolver;
+        this.hierarchyResolver = hierarchyResolver;
     }
 
     /**
-     * @return Returns the groupHierarchyResolver.
+     * @return Returns the HierarchyResolver.
      */
-    public HierarchyResolver getGroupHierarchyResolver()
+    public HierarchyResolver getHierarchyResolver()
     {
-        return groupHierarchyResolver;
+        return hierarchyResolver;
     }
 
-    /**
-     * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#setGroupHierarchyResolver(org.apache.jetspeed.security.HierarchyResolver)
-     */
-    public void setGroupHierarchyResolver(HierarchyResolver groupHierarchyResolver)
+    public void setHierarchyResolver(HierarchyResolver hierarchyResolver)
     {
-        this.groupHierarchyResolver = groupHierarchyResolver;
+        this.hierarchyResolver = hierarchyResolver;
     }
 
     /**
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#getRolePrincipals(java.lang.String)
      */
-    public Set getRolePrincipals(String username)
+    public Set<RolePrincipal> getRolePrincipals(String username)
     {
-        Set rolePrincipals = new HashSet();
+        Set<RolePrincipal> rolePrincipals = new HashSet<RolePrincipal>();
         InternalUserPrincipal internalUser = commonQueries.getInternalUserPrincipal(username);
         if (null != internalUser)
         {
-            Collection internalRoles = internalUser.getRolePrincipals();
+            Collection<InternalRolePrincipal> internalRoles = internalUser.getRolePrincipals();
             if (null != internalRoles)
             {
-                Iterator internalRolesIter = internalRoles.iterator();
-                while (internalRolesIter.hasNext())
+                for (InternalRolePrincipal internalRole : internalRoles)    
                 {
-                    InternalRolePrincipal internalRole = (InternalRolePrincipal) internalRolesIter.next();
-                    Preferences preferences = Preferences.userRoot().node(internalRole.getFullPath());
-                    String[] fullPaths = roleHierarchyResolver.resolve(preferences);
-                    for (int i = 0; i < fullPaths.length; i++)
+                    if (this.hierarchyResolver != null)
                     {
-                        Principal rolePrincipal = new RolePrincipalImpl(RolePrincipalImpl
-                                .getPrincipalNameFromFullPath(fullPaths[i]));
-                        if (!rolePrincipals.contains(rolePrincipal))
+                        Set<RolePrincipal> subset = hierarchyResolver.resolveRoles(internalRole.getName());
+                        for (RolePrincipal rp : subset)
                         {
-                            rolePrincipals.add(rolePrincipal);
+                            if (!rolePrincipals.contains(rp))
+                                rolePrincipals.add(rp);
                         }
                     }
+                    else
+                    {
+                        rolePrincipals.add(new RolePrincipalImpl(internalRole.getPrincipalId(), internalRole.getName(),
+                                internalRole.isEnabled(), internalRole.isMappingOnly()));
+                    }
                 }
             }
         }
@@ -152,7 +123,7 @@
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#setUserPrincipalInRole(java.lang.String,
      *      java.lang.String)
      */
-    public void setUserPrincipalInRole(String username, String roleFullPathName) throws SecurityException
+    public void setUserPrincipalInRole(String username, String roleName) throws SecurityException
     {
         InternalUserPrincipal internalUser = commonQueries.getInternalUserPrincipal(username);
         boolean isMappingOnly = false;
@@ -160,27 +131,26 @@
         {
             // This is a record for mapping only.
             isMappingOnly = true;
-            internalUser = new InternalUserPrincipalImpl(UserPrincipalImpl.getFullPathFromPrincipalName(username));
+            internalUser = new InternalUserPrincipalImpl(username);
         }
-        Collection internalRoles = internalUser.getRolePrincipals();
+        Collection<InternalRolePrincipal> internalRoles = internalUser.getRolePrincipals();
         // This should not be null. Check for null should be made by the caller.
-        InternalRolePrincipal internalRole = commonQueries.getInternalRolePrincipal(RolePrincipalImpl
-                .getFullPathFromPrincipalName(roleFullPathName));
+        InternalRolePrincipal internalRole = commonQueries.getInternalRolePrincipal(roleName);
         // Check anyway.
         if (null == internalRole)
         {
-            throw new SecurityException(SecurityException.ROLE_DOES_NOT_EXIST.create(roleFullPathName));
+            throw new SecurityException(SecurityException.ROLE_DOES_NOT_EXIST.create(roleName));
         }
         internalRoles.add(internalRole);
         internalUser.setRolePrincipals(internalRoles);
-        commonQueries.setInternalUserPrincipal(internalUser, isMappingOnly);
+        commonQueries.storeInternalUserPrincipal(internalUser, isMappingOnly);
     }
 
     /**
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#removeUserPrincipalInRole(java.lang.String,
      *      java.lang.String)
      */
-    public void removeUserPrincipalInRole(String username, String roleFullPathName) throws SecurityException
+    public void removeUserPrincipalInRole(String username, String roleName) throws SecurityException
     {
         boolean isMappingOnly = false;
         // Check is the record is used for mapping only.
@@ -192,14 +162,12 @@
         }
         if (null != internalUser)
         {
-            Collection internalRoles = internalUser.getRolePrincipals();
+            Collection<InternalRolePrincipal> internalRoles = internalUser.getRolePrincipals();
             // This should not be null. Check for null should be made by the caller.
-            InternalRolePrincipal internalRole = commonQueries.getInternalRolePrincipal(RolePrincipalImpl
-                    .getFullPathFromPrincipalName(roleFullPathName));
-            // Check anyway.
+            InternalRolePrincipal internalRole = commonQueries.getInternalRolePrincipal(roleName);
             if (null == internalRole)
             {
-                throw new SecurityException(SecurityException.ROLE_DOES_NOT_EXIST.create(roleFullPathName));
+                throw new SecurityException(SecurityException.ROLE_DOES_NOT_EXIST.create(roleName));
             }
             internalRoles.remove(internalRole);
             // Remove dead mapping records. I.e. No mapping is associated with the specific record.
@@ -211,7 +179,7 @@
             else
             {
                 internalUser.setRolePrincipals(internalRoles);
-                commonQueries.setInternalUserPrincipal(internalUser, isMappingOnly);
+                commonQueries.storeInternalUserPrincipal(internalUser, isMappingOnly);
             }
         }
         else
@@ -223,34 +191,37 @@
     /**
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#getRolePrincipalsInGroup(java.lang.String)
      */
-    public Set getRolePrincipalsInGroup(String groupFullPathName)
+    public Set<RolePrincipal> getRolePrincipalsInGroup(String groupName)
     {
-        Set rolePrincipals = new HashSet();
-
-        Preferences preferences = Preferences.userRoot().node(
-                GroupPrincipalImpl.getFullPathFromPrincipalName(groupFullPathName));
-        String[] fullPaths = groupHierarchyResolver.resolve(preferences);
-        for (int i = 0; i < fullPaths.length; i++)
+        Set<RolePrincipal> rolePrincipals = new HashSet<RolePrincipal>();
+        InternalGroupPrincipal internalGroup = commonQueries.getInternalGroupPrincipal(groupName);
+        if (internalGroup != null)
         {
-            InternalGroupPrincipal internalGroup = commonQueries.getInternalGroupPrincipal(fullPaths[i]);
-            if (null != internalGroup)
+            if (this.hierarchyResolver != null)
             {
-                Collection internalRoles = internalGroup.getRolePrincipals();
-                if (null != internalRoles)
+                Collection<InternalRolePrincipal> internalRoles = internalGroup.getRolePrincipals();
+                for (InternalRolePrincipal internalRole: internalRoles)
                 {
-                    Iterator internalRolesIter = internalRoles.iterator();
-                    while (internalRolesIter.hasNext())
-                    {
-                        InternalRolePrincipal internalRole = (InternalRolePrincipal) internalRolesIter.next();
-                        Principal rolePrincipal = new RolePrincipalImpl(UserPrincipalImpl
-                                .getPrincipalNameFromFullPath(internalRole.getFullPath()));
-                        if (!rolePrincipals.contains(rolePrincipal))
+                    Set<RolePrincipal> resolvedRoles = hierarchyResolver.resolveRoles(internalRole.getName());            
+                    for (RolePrincipal rp : resolvedRoles)
+                    {    
+                        if (!rolePrincipals.contains(rp))
                         {
-                            rolePrincipals.add(rolePrincipal);
+                            rolePrincipals.add(new RolePrincipalImpl(internalRole.getPrincipalId(), internalRole.getName(),
+                                    internalRole.isEnabled(), internalRole.isMappingOnly()));                
                         }
                     }
                 }
             }
+            else
+            {
+                Collection<InternalRolePrincipal> internalRoles = internalGroup.getRolePrincipals();
+                for (InternalRolePrincipal internalRole: internalRoles)
+                {
+                    rolePrincipals.add(new RolePrincipalImpl(internalRole.getPrincipalId(), internalRole.getName(),
+                            internalRole.isEnabled(), internalRole.isMappingOnly()));                
+                }
+            }
         }
         return rolePrincipals;
     }
@@ -259,74 +230,75 @@
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#setRolePrincipalInGroup(java.lang.String,
      *      java.lang.String)
      */
-    public void setRolePrincipalInGroup(String groupFullPathName, String roleFullPathName) throws SecurityException
+    public void setRolePrincipalInGroup(String groupName, String roleName) throws SecurityException
     {
-        InternalGroupPrincipal internalGroup = commonQueries.getInternalGroupPrincipal(GroupPrincipalImpl
-                .getFullPathFromPrincipalName(groupFullPathName));
+        InternalGroupPrincipal internalGroup = commonQueries.getInternalGroupPrincipal(groupName);
         boolean isMappingOnly = false;
         if (null == internalGroup)
         {
             // This is a record for mapping only.
             isMappingOnly = true;
-            internalGroup = new InternalGroupPrincipalImpl(groupFullPathName);
+            internalGroup = new InternalGroupPrincipalImpl(groupName);
         }        
-        Collection internalRoles = internalGroup.getRolePrincipals();
-        InternalRolePrincipal internalRole = commonQueries.getInternalRolePrincipal(RolePrincipalImpl
-                .getFullPathFromPrincipalName(roleFullPathName));
+        Collection<InternalRolePrincipal> internalRoles = internalGroup.getRolePrincipals();
+        InternalRolePrincipal internalRole = commonQueries.getInternalRolePrincipal(roleName);
         internalRoles.add(internalRole);
         internalGroup.setRolePrincipals(internalRoles);
-        commonQueries.setInternalGroupPrincipal(internalGroup, isMappingOnly);
+        commonQueries.storeInternalGroupPrincipal(internalGroup, isMappingOnly);
     }
 
     /**
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#removeRolePrincipalInGroup(java.lang.String,
      *      java.lang.String)
      */
-    public void removeRolePrincipalInGroup(String groupFullPathName, String roleFullPathName) throws SecurityException
+    public void removeRolePrincipalInGroup(String groupName, String roleName) throws SecurityException
     {
-        InternalGroupPrincipal internalGroup = commonQueries.getInternalGroupPrincipal(GroupPrincipalImpl
-                .getFullPathFromPrincipalName(groupFullPathName));
+        InternalGroupPrincipal internalGroup = commonQueries.getInternalGroupPrincipal(groupName);
         boolean isMappingOnly = false;
         if (null == internalGroup)
         {
             // This is a record for mapping only.
             isMappingOnly = true;
-            internalGroup = new InternalGroupPrincipalImpl(groupFullPathName);
+            internalGroup = new InternalGroupPrincipalImpl(groupName);
         }                
         if (null == internalGroup)
         {
             throw new SecurityException(SecurityException.GROUP_DOES_NOT_EXIST.create(internalGroup));
         }
-        Collection internalRoles = internalGroup.getRolePrincipals();
-        InternalRolePrincipal internalRole = commonQueries.getInternalRolePrincipal(RolePrincipalImpl
-                .getFullPathFromPrincipalName(roleFullPathName));
+        Collection<InternalRolePrincipal> internalRoles = internalGroup.getRolePrincipals();
+        InternalRolePrincipal internalRole = commonQueries.getInternalRolePrincipal(roleName);
         internalRoles.remove(internalRole);
         internalGroup.setRolePrincipals(internalRoles);
-        commonQueries.setInternalGroupPrincipal(internalGroup, isMappingOnly);
+        commonQueries.storeInternalGroupPrincipal(internalGroup, isMappingOnly);
     }
 
     /**
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#getGroupPrincipals(java.lang.String)
      */
-    public Set getGroupPrincipals(String username)
+    public Set<GroupPrincipal> getGroupPrincipals(String username)
     {
-        Set groupPrincipals = new HashSet();
+        Set<GroupPrincipal> groupPrincipals = new HashSet<GroupPrincipal>();
         InternalUserPrincipal internalUser = commonQueries.getInternalUserPrincipal(username);
         if (null != internalUser)
         {
-            Collection internalGroups = internalUser.getGroupPrincipals();
+            Collection<InternalGroupPrincipal> internalGroups = internalUser.getGroupPrincipals();
             if (null != internalGroups)
             {
-                Iterator internalGroupsIter = internalGroups.iterator();
-                while (internalGroupsIter.hasNext())
+                for (InternalGroupPrincipal internalGroup : internalGroups)
                 {
-                    InternalGroupPrincipal internalGroup = (InternalGroupPrincipal) internalGroupsIter.next();
-                    Preferences preferences = Preferences.userRoot().node(internalGroup.getFullPath());
-                    String[] fullPaths = groupHierarchyResolver.resolve(preferences);
-                    for (int i = 0; i < fullPaths.length; i++)
+                    if (hierarchyResolver != null)
                     {
-                        groupPrincipals.add(new GroupPrincipalImpl(GroupPrincipalImpl
-                                .getPrincipalNameFromFullPath(fullPaths[i])));
+                        Set<GroupPrincipal> resolvedGroups = hierarchyResolver.resolveGroups(internalGroup.getName());                    
+                        for (GroupPrincipal gp : resolvedGroups)
+                        {
+                            if (!groupPrincipals.contains(gp))
+                                groupPrincipals.add(gp);
+                        }
+                    }
+                    else
+                    {
+                        groupPrincipals.add(new GroupPrincipalImpl(internalGroup.getPrincipalId(), internalGroup.getName(),
+                                internalGroup.isEnabled(), internalGroup.isMappingOnly()));                                        
                     }
                 }
             }
@@ -337,34 +309,37 @@
     /**
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#getGroupPrincipalsInRole(java.lang.String)
      */
-    public Set getGroupPrincipalsInRole(String roleFullPathName)
+    public Set<GroupPrincipal> getGroupPrincipalsInRole(String roleName)
     {
-        Set groupPrincipals = new HashSet();
-
-        Preferences preferences = Preferences.userRoot().node(
-                RolePrincipalImpl.getFullPathFromPrincipalName(roleFullPathName));
-        String[] fullPaths = roleHierarchyResolver.resolve(preferences);
-        for (int i = 0; i < fullPaths.length; i++)
+        Set<GroupPrincipal> groupPrincipals = new HashSet<GroupPrincipal>();
+        InternalRolePrincipal internalRole = commonQueries.getInternalRolePrincipal(roleName);
+        if (internalRole != null)
         {
-            InternalRolePrincipal internalRole = commonQueries.getInternalRolePrincipal(fullPaths[i]);
-            if (null != internalRole)
+            if (this.hierarchyResolver != null)
             {
-                Collection internalGroups = internalRole.getGroupPrincipals();
-                if (null != internalGroups)
+                Collection<InternalGroupPrincipal> internalGroups = internalRole.getGroupPrincipals();
+                for (InternalGroupPrincipal internalGroup: internalGroups)
                 {
-                    Iterator internalGroupsIter = internalGroups.iterator();
-                    while (internalGroupsIter.hasNext())
-                    {
-                        InternalGroupPrincipal internalGroup = (InternalGroupPrincipal) internalGroupsIter.next();
-                        Principal groupPrincipal = new GroupPrincipalImpl(GroupPrincipalImpl
-                                .getPrincipalNameFromFullPath(internalGroup.getFullPath()));
-                        if (!groupPrincipals.contains(groupPrincipal))
+                    Set<GroupPrincipal> resolvedGroups = hierarchyResolver.resolveGroups(internalGroup.getName());            
+                    for (GroupPrincipal gp : resolvedGroups)
+                    {    
+                        if (!groupPrincipals.contains(gp))
                         {
-                            groupPrincipals.add(groupPrincipal);
+                            groupPrincipals.add(new GroupPrincipalImpl(internalGroup.getPrincipalId(), internalGroup.getName(),
+                                    internalGroup.isEnabled(), internalGroup.isMappingOnly()));                
                         }
                     }
                 }
             }
+            else
+            {
+                Collection<InternalGroupPrincipal> internalGroups = internalRole.getGroupPrincipals();
+                for (InternalGroupPrincipal internalGroup: internalGroups)
+                {
+                    groupPrincipals.add(new GroupPrincipalImpl(internalGroup.getPrincipalId(), internalGroup.getName(),
+                            internalGroup.isEnabled(), internalGroup.isMappingOnly()));                
+                }
+            }
         }
         return groupPrincipals;
     }
@@ -372,33 +347,17 @@
     /**
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#getUserPrincipalsInRole(java.lang.String)
      */
-    public Set getUserPrincipalsInRole(String roleFullPathName)
+    public Set<UserPrincipal> getUserPrincipalsInRole(String roleName)
     {
-        Set userPrincipals = new HashSet();
-
-        Preferences preferences = Preferences.userRoot().node(
-                RolePrincipalImpl.getFullPathFromPrincipalName(roleFullPathName));
-        String[] fullPaths = roleHierarchyResolver.resolve(preferences);
-        for (int i = 0; i < fullPaths.length; i++)
+        Set<UserPrincipal> userPrincipals = new HashSet<UserPrincipal>();
+        InternalRolePrincipal internalRole = commonQueries.getInternalRolePrincipal(roleName);
+        if (internalRole != null)
         {
-            InternalRolePrincipal internalRole = commonQueries.getInternalRolePrincipal(fullPaths[i]);
-            if (null != internalRole)
+            Collection<InternalUserPrincipal> internalUsers = internalRole.getUserPrincipals();
+            for (InternalUserPrincipal internalUser: internalUsers)
             {
-                Collection internalUsers = internalRole.getUserPrincipals();
-                if (null != internalUsers)
-                {
-                    Iterator internalUsersIter = internalUsers.iterator();
-                    while (internalUsersIter.hasNext())
-                    {
-                        InternalUserPrincipal internalUser = (InternalUserPrincipal) internalUsersIter.next();
-                        Principal userPrincipal = new UserPrincipalImpl(UserPrincipalImpl
-                                .getPrincipalNameFromFullPath(internalUser.getFullPath()));
-                        if (!userPrincipals.contains(userPrincipal))
-                        {
-                            userPrincipals.add(userPrincipal);
-                        }
-                    }
-                }
+                userPrincipals.add(new UserPrincipalImpl(internalUser.getPrincipalId(), internalUser.getName(),
+                        internalUser.isEnabled(), internalUser.isMappingOnly()));                
             }
         }
         return userPrincipals;
@@ -407,33 +366,17 @@
     /**
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#getUserPrincipalsInGroup(java.lang.String)
      */
-    public Set getUserPrincipalsInGroup(String groupFullPathName)
+    public Set<UserPrincipal> getUserPrincipalsInGroup(String groupName)
     {
-        Set userPrincipals = new HashSet();
-
-        Preferences preferences = Preferences.userRoot().node(
-                GroupPrincipalImpl.getFullPathFromPrincipalName(groupFullPathName));
-        String[] fullPaths = groupHierarchyResolver.resolve(preferences);
-        for (int i = 0; i < fullPaths.length; i++)
+        Set<UserPrincipal> userPrincipals = new HashSet<UserPrincipal>();
+        InternalGroupPrincipal internalGroup = commonQueries.getInternalGroupPrincipal(groupName);
+        if (internalGroup != null)
         {
-            InternalGroupPrincipal internalGroup = commonQueries.getInternalGroupPrincipal(fullPaths[i]);
-            if (null != internalGroup)
+            Collection<InternalUserPrincipal> internalUsers = internalGroup.getUserPrincipals();
+            for (InternalUserPrincipal internalUser: internalUsers)
             {
-                Collection internalUsers = internalGroup.getUserPrincipals();
-                if (null != internalUsers)
-                {
-                    Iterator internalUsersIter = internalUsers.iterator();
-                    while (internalUsersIter.hasNext())
-                    {
-                        InternalUserPrincipal internalUser = (InternalUserPrincipal) internalUsersIter.next();
-                        Principal userPrincipal = new UserPrincipalImpl(UserPrincipalImpl
-                                .getPrincipalNameFromFullPath(internalUser.getFullPath()));
-                        if (!userPrincipals.contains(userPrincipal))
-                        {
-                            userPrincipals.add(userPrincipal);
-                        }
-                    }
-                }
+                userPrincipals.add(new UserPrincipalImpl(internalUser.getPrincipalId(), internalUser.getName(),
+                        internalUser.isEnabled(), internalUser.isMappingOnly()));                
             }
         }
         return userPrincipals;
@@ -443,7 +386,7 @@
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#setUserPrincipalInGroup(java.lang.String,
      *      java.lang.String)
      */
-    public void setUserPrincipalInGroup(String username, String groupFullPathName) throws SecurityException
+    public void setUserPrincipalInGroup(String username, String groupName) throws SecurityException
     {
         InternalUserPrincipal internalUser = commonQueries.getInternalUserPrincipal(username);
         boolean isMappingOnly = false;
@@ -451,27 +394,26 @@
         {
             // This is a record for mapping only.
             isMappingOnly = true;
-            internalUser = new InternalUserPrincipalImpl(UserPrincipalImpl.getFullPathFromPrincipalName(username));
+            internalUser = new InternalUserPrincipalImpl(username);
         }
-        Collection internalGroups = internalUser.getGroupPrincipals();
+        Collection<InternalGroupPrincipal> internalGroups = internalUser.getGroupPrincipals();
         // This should not be null. Check for null should be made by the caller.
-        InternalGroupPrincipal internalGroup = commonQueries.getInternalGroupPrincipal(GroupPrincipalImpl
-                .getFullPathFromPrincipalName(groupFullPathName));
+        InternalGroupPrincipal internalGroup = commonQueries.getInternalGroupPrincipal(groupName);
         // Check anyway.
         if (null == internalGroup)
         {
-            throw new SecurityException(SecurityException.GROUP_DOES_NOT_EXIST.create(groupFullPathName));
+            throw new SecurityException(SecurityException.GROUP_DOES_NOT_EXIST.create(groupName));
         }
         internalGroups.add(internalGroup);
         internalUser.setGroupPrincipals(internalGroups);
-        commonQueries.setInternalUserPrincipal(internalUser, isMappingOnly);
+        commonQueries.storeInternalUserPrincipal(internalUser, isMappingOnly);
     }
 
     /**
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#removeUserPrincipalInGroup(java.lang.String,
      *      java.lang.String)
      */
-    public void removeUserPrincipalInGroup(String username, String groupFullPathName) throws SecurityException
+    public void removeUserPrincipalInGroup(String username, String groupName) throws SecurityException
     {
         boolean isMappingOnly = false;
         // Check is the record is used for mapping only.
@@ -483,14 +425,12 @@
         }
         if (null != internalUser)
         {
-            Collection internalGroups = internalUser.getGroupPrincipals();
+            Collection<InternalGroupPrincipal> internalGroups = internalUser.getGroupPrincipals();
             // This should not be null. Check for null should be made by the caller.
-            InternalGroupPrincipal internalGroup = commonQueries.getInternalGroupPrincipal(GroupPrincipalImpl
-                    .getFullPathFromPrincipalName(groupFullPathName));
-            // Check anyway.
+            InternalGroupPrincipal internalGroup = commonQueries.getInternalGroupPrincipal(groupName);
             if (null == internalGroup)
             {
-                throw new SecurityException(SecurityException.GROUP_DOES_NOT_EXIST.create(groupFullPathName));
+                throw new SecurityException(SecurityException.GROUP_DOES_NOT_EXIST.create(groupName));
             }
             internalGroups.remove(internalGroup);
             // Remove dead mapping records. I.e. No mapping is associated with the specific record.
@@ -501,8 +441,8 @@
             }
             else
             {
-            internalUser.setGroupPrincipals(internalGroups);
-            commonQueries.setInternalUserPrincipal(internalUser, isMappingOnly);
+                internalUser.setGroupPrincipals(internalGroups);
+                commonQueries.storeInternalUserPrincipal(internalUser, isMappingOnly);
             }
         }
         else

Modified: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/DefaultUserSecurityHandler.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/DefaultUserSecurityHandler.java?rev=683497&r1=683496&r2=683497&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/DefaultUserSecurityHandler.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/DefaultUserSecurityHandler.java Wed Aug  6 20:52:05 2008
@@ -16,8 +16,7 @@
  */
 package org.apache.jetspeed.security.spi.impl;
 
-import java.security.Principal;
-import java.util.Iterator;
+import java.util.Collection;
 import java.util.LinkedList;
 import java.util.List;
 
@@ -57,14 +56,14 @@
     /**
      * @see org.apache.jetspeed.security.spi.UserSecurityHandler#getUserPrincipal(java.lang.String)
      */
-    public Principal getUserPrincipal(String username)
+    public UserPrincipal getUserPrincipal(String username)
     {
         UserPrincipal userPrincipal = null;
         InternalUserPrincipal internalUser = securityAccess.getInternalUserPrincipal(username, false);
         if (null != internalUser)
         {
-            userPrincipal = new UserPrincipalImpl(UserPrincipalImpl.getPrincipalNameFromFullPath(internalUser.getFullPath()), true, internalUser.isMappingOnly());
-            userPrincipal.setEnabled(internalUser.isEnabled());
+            userPrincipal = new UserPrincipalImpl(internalUser.getPrincipalId(), internalUser.getName(),
+                    internalUser.isEnabled(), internalUser.isMappingOnly());
         }
         return userPrincipal;
     }
@@ -72,20 +71,14 @@
     /**
      * @see org.apache.jetspeed.security.spi.UserSecurityHandler#getUserPrincipals(java.lang.String)
      */
-    public List getUserPrincipals(String filter)
+    public List<UserPrincipal> getUserPrincipals(String filter)
     {
-        List userPrincipals = new LinkedList();
-        Iterator result = securityAccess.getInternalUserPrincipals(filter);
-        while (result.hasNext())
-        {
-            InternalUserPrincipal internalUser = (InternalUserPrincipal) result.next();
-            String path = internalUser.getFullPath();
-            if (path == null)
-            {
-                continue;
-            }
-            UserPrincipal userPrincipal = new UserPrincipalImpl(UserPrincipalImpl.getPrincipalNameFromFullPath(internalUser.getFullPath()));
-            userPrincipal.setEnabled(internalUser.isEnabled());
+        List<UserPrincipal> userPrincipals = new LinkedList<UserPrincipal>();
+        Collection<InternalUserPrincipal> internalPrincipals = securityAccess.getInternalUserPrincipals(filter);
+        for (InternalUserPrincipal internalUser : internalPrincipals)
+        {
+            UserPrincipal userPrincipal = new UserPrincipalImpl(internalUser.getPrincipalId(), internalUser.getName(), 
+                    internalUser.isEnabled(), internalUser.isMappingOnly());
             userPrincipals.add(userPrincipal);
         }
         return userPrincipals;
@@ -98,7 +91,7 @@
     {
         if ( null == securityAccess.getInternalUserPrincipal(userPrincipal.getName(), false) )
         {
-            securityAccess.setInternalUserPrincipal(new InternalUserPrincipalImpl(userPrincipal.getFullPath()), false);        
+            securityAccess.storeInternalUserPrincipal(new InternalUserPrincipalImpl(userPrincipal.getName()), false);        
         }
         else
         {
@@ -112,12 +105,12 @@
     public void updateUserPrincipal(UserPrincipal userPrincipal) throws SecurityException
     {
         InternalUserPrincipal internalUser = securityAccess.getInternalUserPrincipal(userPrincipal.getName(), false);
-        if ( null != internalUser )
+        if (null != internalUser)
         {
             if ( internalUser.isEnabled() != userPrincipal.isEnabled())
             {
                 internalUser.setEnabled(userPrincipal.isEnabled());
-                securityAccess.setInternalUserPrincipal(internalUser, false);        
+                securityAccess.storeInternalUserPrincipal(internalUser, false);        
             }
         }
         else

Modified: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/LdapCredentialHandler.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/LdapCredentialHandler.java?rev=683497&r1=683496&r2=683497&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/LdapCredentialHandler.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/LdapCredentialHandler.java Wed Aug  6 20:52:05 2008
@@ -25,6 +25,7 @@
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.security.Credential;
 import org.apache.jetspeed.security.PasswordCredential;
 import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.spi.CredentialHandler;
@@ -71,18 +72,17 @@
     /**
      * @see org.apache.jetspeed.security.spi.CredentialHandler#getPublicCredentials(java.lang.String)
      */
-    public Set getPublicCredentials(String username)
+    public Set<Credential> getPublicCredentials(String username)
     {
-        return new HashSet();
+        return new HashSet<Credential>();
     }
 
     /**
      * @see org.apache.jetspeed.security.spi.CredentialHandler#getPrivateCredentials(java.lang.String)
      */
-    public Set getPrivateCredentials(String uid)
+    public Set<Credential> getPrivateCredentials(String uid)
     {
-        Set privateCredentials = new HashSet();
-
+        Set<Credential> privateCredentials = new HashSet<Credential>();
         try
         {
             privateCredentials.add(new DefaultPasswordCredentialImpl(uid, ldap.getPassword(uid)));

Modified: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/LdapGroupSecurityHandler.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/LdapGroupSecurityHandler.java?rev=683497&r1=683496&r2=683497&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/LdapGroupSecurityHandler.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/LdapGroupSecurityHandler.java Wed Aug  6 20:52:05 2008
@@ -16,8 +16,10 @@
  */
 package org.apache.jetspeed.security.spi.impl;
 
+import java.security.Principal;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.LinkedList;
 import java.util.List;
 
 import javax.naming.NamingException;
@@ -29,8 +31,8 @@
 import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.impl.GroupPrincipalImpl;
 import org.apache.jetspeed.security.spi.GroupSecurityHandler;
-import org.apache.jetspeed.security.spi.impl.ldap.LdapPrincipalDao;
 import org.apache.jetspeed.security.spi.impl.ldap.LdapGroupDaoImpl;
+import org.apache.jetspeed.security.spi.impl.ldap.LdapPrincipalDao;
 
 /**
  * @see org.apache.jetspeed.security.spi.GroupSecurityHandler
@@ -123,17 +125,14 @@
     /**
      * @see org.apache.jetspeed.security.spi.GroupSecurityHandler#setGroupPrincipal(org.apache.jetspeed.security.GroupPrincipal)
      */
-    public void setGroupPrincipal(GroupPrincipal groupPrincipal) throws SecurityException
+    public void storeGroupPrincipal(GroupPrincipal groupPrincipal) throws SecurityException
     {
         verifyGroupPrincipal(groupPrincipal);
-
-        String fullPath = groupPrincipal.getFullPath();
-        String groupUidWithoutSlashes = ldap.convertUidToLdapAcceptableName(fullPath);
+        String groupUidWithoutSlashes = ldap.convertUidToLdapAcceptableName(groupPrincipal.getName());
         if (getGroupPrincipal(groupUidWithoutSlashes) == null)
         {
             ldap.create(groupUidWithoutSlashes);
         }
-
     }
 
     /**
@@ -157,26 +156,30 @@
     public void removeGroupPrincipal(GroupPrincipal groupPrincipal) throws SecurityException
     {
         verifyGroupPrincipal(groupPrincipal);
-
-        String fullPath = groupPrincipal.getFullPath();
-        String groupUidWithoutSlashes = ldap.convertUidToLdapAcceptableName(fullPath);
-
+        String groupUidWithoutSlashes = ldap.convertUidToLdapAcceptableName(groupPrincipal.getName());
         ldap.delete(groupUidWithoutSlashes);
     }
 
     /**
      * @see org.apache.jetspeed.security.spi.GroupSecurityHandler#getGroupPrincipals(java.lang.String)
      */
-    public List getGroupPrincipals(String filter)
+    public List<GroupPrincipal> getGroupPrincipals(String filter)
     {
         try
         {
-            return Arrays.asList(ldap.find(filter, GroupPrincipal.PREFS_GROUP_ROOT));
+            List<GroupPrincipal> principals = new LinkedList<GroupPrincipal>();
+            List<Principal> result = Arrays.asList(ldap.find(filter, GroupPrincipal.PREFS_GROUP_ROOT));
+            for (Principal p : result)
+            {
+                if (p instanceof GroupPrincipal)
+                    principals.add((GroupPrincipal)p);
+            }
+            return principals;
         }
         catch (SecurityException e)
         {
             logSecurityException(e, filter);
         }
-        return new ArrayList();
+        return new ArrayList<GroupPrincipal>();
     }
 }
\ No newline at end of file

Modified: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/LdapRoleSecurityHandler.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/LdapRoleSecurityHandler.java?rev=683497&r1=683496&r2=683497&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/LdapRoleSecurityHandler.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/LdapRoleSecurityHandler.java Wed Aug  6 20:52:05 2008
@@ -16,21 +16,23 @@
  */
 package org.apache.jetspeed.security.spi.impl;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import javax.naming.NamingException;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jetspeed.security.RolePrincipal;
-import org.apache.jetspeed.security.SecurityException;
-import org.apache.jetspeed.security.impl.RolePrincipalImpl;
-import org.apache.jetspeed.security.spi.RoleSecurityHandler;
-import org.apache.jetspeed.security.spi.impl.ldap.LdapRoleDaoImpl;
-import org.apache.jetspeed.security.spi.impl.ldap.LdapPrincipalDao;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.naming.NamingException;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.security.RolePrincipal;
+import org.apache.jetspeed.security.SecurityException;
+import org.apache.jetspeed.security.impl.RolePrincipalImpl;
+import org.apache.jetspeed.security.spi.RoleSecurityHandler;
+import org.apache.jetspeed.security.spi.impl.ldap.LdapPrincipalDao;
+import org.apache.jetspeed.security.spi.impl.ldap.LdapRoleDaoImpl;
 
 public class LdapRoleSecurityHandler implements RoleSecurityHandler {
 
@@ -61,7 +63,8 @@
         this(new LdapRoleDaoImpl());
     }
 	
-	public RolePrincipal getRolePrincipal(String roleFullPathName) {
+	public RolePrincipal getRolePrincipal(String roleFullPathName) 
+	{
         String roleUidWithoutSlashes = ldap.convertUidToLdapAcceptableName(roleFullPathName);
         verifyRoleId(roleUidWithoutSlashes);
         try
@@ -80,36 +83,41 @@
         return null;
 	}
 
-	public void setRolePrincipal(RolePrincipal rolePrincipal) throws SecurityException {
+	public void storeRolePrincipal(RolePrincipal rolePrincipal) throws SecurityException 
+	{
         verifyRolePrincipal(rolePrincipal);
-
-        String fullPath = rolePrincipal.getFullPath();
-        String groupUidWithoutSlashes = ldap.convertUidToLdapAcceptableName(fullPath);
+        String groupUidWithoutSlashes = ldap.convertUidToLdapAcceptableName(rolePrincipal.getName());
         if (getRolePrincipal(groupUidWithoutSlashes) == null)
         {
             ldap.create(groupUidWithoutSlashes);
         }
 	}
 
-	public void removeRolePrincipal(RolePrincipal rolePrincipal) throws SecurityException {
+	public void removeRolePrincipal(RolePrincipal rolePrincipal) throws SecurityException 
+	{
         verifyRolePrincipal(rolePrincipal);
-
-        String fullPath = rolePrincipal.getFullPath();
-        String roleUidWithoutSlashes = ldap.convertUidToLdapAcceptableName(fullPath);
-
+        String roleUidWithoutSlashes = ldap.convertUidToLdapAcceptableName(rolePrincipal.getName());
         ldap.delete(roleUidWithoutSlashes);
 	}
 
-	public List getRolePrincipals(String filter) {
+	public List<RolePrincipal> getRolePrincipals(String filter) 
+	{
         try
-        {
-            return Arrays.asList(ldap.find(filter, RolePrincipal.PREFS_ROLE_ROOT));
+        {
+            List<RolePrincipal> principals = new LinkedList<RolePrincipal>();            
+            List<Principal> result = Arrays.asList(ldap.find(filter, RolePrincipal.PREFS_ROLE_ROOT));
+            for (Principal p : result)
+            {
+                if (p instanceof RolePrincipal)
+                    principals.add((RolePrincipal)p);
+            }
+            return principals;
         }
         catch (SecurityException e)
         {
             logSecurityException(e, filter);
         }
-        return new ArrayList();
+        return new ArrayList<RolePrincipal>();
 	}
 	
     /**

Modified: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/LdapSecurityMappingHandler.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/LdapSecurityMappingHandler.java?rev=683497&r1=683496&r2=683497&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/LdapSecurityMappingHandler.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/LdapSecurityMappingHandler.java Wed Aug  6 20:52:05 2008
@@ -19,7 +19,6 @@
 import java.security.Principal;
 import java.util.HashSet;
 import java.util.Set;
-import java.util.prefs.Preferences;
 
 import javax.naming.NamingException;
 
@@ -30,7 +29,6 @@
 import org.apache.jetspeed.security.RolePrincipal;
 import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.UserPrincipal;
-import org.apache.jetspeed.security.impl.GeneralizationHierarchyResolver;
 import org.apache.jetspeed.security.impl.GroupPrincipalImpl;
 import org.apache.jetspeed.security.impl.RolePrincipalImpl;
 import org.apache.jetspeed.security.impl.UserPrincipalImpl;
@@ -59,10 +57,7 @@
     private static final Log LOG = LogFactory.getLog(LdapSecurityMappingHandler.class);
 
     /** The role hierarchy resolver. */
-    private HierarchyResolver roleHierarchyResolver = new GeneralizationHierarchyResolver();
-
-    /** The group hierarchy resolver. */
-    private HierarchyResolver groupHierarchyResolver = new GeneralizationHierarchyResolver();
+    private HierarchyResolver hierarchyResolver = null;
 
     /**
      * @param userDao
@@ -86,44 +81,19 @@
         this.roleDao = new LdapRoleDaoImpl();
     }
 
-    /** 
-     * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#getRoleHierarchyResolver()
-     */
-    public HierarchyResolver getRoleHierarchyResolver()
-    {
-        return roleHierarchyResolver;
-    }
-
-    /**
-     * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#setRoleHierarchyResolver(org.apache.jetspeed.security.HierarchyResolver)
-     */
-    public void setRoleHierarchyResolver(HierarchyResolver roleHierarchyResolver)
-    {
-        this.roleHierarchyResolver = roleHierarchyResolver;
-    }
-
-    /**
-     * @return Returns the groupHierarchyResolver.
-     */
-    public HierarchyResolver getGroupHierarchyResolver()
+    public HierarchyResolver getHierarchyResolver()
     {
-        return groupHierarchyResolver;
+        return hierarchyResolver;
     }
 
-    /**
-     * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#setGroupHierarchyResolver(org.apache.jetspeed.security.HierarchyResolver)
-     */
-    public void setGroupHierarchyResolver(HierarchyResolver groupHierarchyResolver)
+    public void setHierarchyResolver(HierarchyResolver hierarchyResolver)
     {
-        this.groupHierarchyResolver = groupHierarchyResolver;
+        this.hierarchyResolver = hierarchyResolver;
     }
 
-    /**
-     * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#getRolePrincipals(java.lang.String)
-     */
-    public Set getRolePrincipals(String username)
+    public Set<RolePrincipal> getRolePrincipals(String username)
     {
-        Set rolePrincipals = new HashSet();
+        Set<RolePrincipal> rolePrincipals = new HashSet<RolePrincipal>();
         String[] roles;
         try
         {
@@ -164,9 +134,9 @@
     /**
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#getRolePrincipalsInGroup(java.lang.String)
      */
-    public Set getRolePrincipalsInGroup(String groupFullPathName)
+    public Set<RolePrincipal> getRolePrincipalsInGroup(String groupFullPathName)
     {
-        Set rolePrincipalsInGroup = new HashSet();
+        Set<RolePrincipal> rolePrincipalsInGroup = new HashSet<RolePrincipal>();
         String[] roles;
         try
         {
@@ -184,36 +154,26 @@
         return rolePrincipalsInGroup;        
     }
 
-    /**
-     * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#setRolePrincipalInGroup(java.lang.String,
-     *      java.lang.String)
-     */
     public void setRolePrincipalInGroup(String groupFullPathName, String roleFullPathName) throws SecurityException
     {
         verifyGroupAndRoleExist(groupFullPathName, roleFullPathName);
         addRoleToGroup(groupFullPathName, roleFullPathName);    	
     }
 
-    /**
-     * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#removeRolePrincipalInGroup(java.lang.String,
-     *      java.lang.String)
-     */
     public void removeRolePrincipalInGroup(String groupFullPathName, String roleFullPathName) throws SecurityException
     {
         verifyGroupAndRoleExist(groupFullPathName, roleFullPathName);
         removeRoleFromGroup(groupFullPathName, roleFullPathName);    	
     }
 
-
 	/**
      * This method returns the set of group principals associated with a user.
      * 
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#getGroupPrincipals(java.lang.String)
      */
-    public Set getGroupPrincipals(String userPrincipalUid)
+    public Set<GroupPrincipal> getGroupPrincipals(String userPrincipalUid)
     {
-    	Set groupPrincipals = new HashSet();
-
+    	Set<GroupPrincipal> groupPrincipals = new HashSet<GroupPrincipal>();
         String[] groups;
         try
         {
@@ -230,22 +190,19 @@
         return groupPrincipals;
     }
 
-    /**
-     * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#getGroupPrincipalsInRole(java.lang.String)
-     */
-    public Set getGroupPrincipalsInRole(String roleFullPathName)
+    public Set<GroupPrincipal> getGroupPrincipalsInRole(String roleFullPathName)
     {
-        Set groupPrincipals = new HashSet();
+        Set<GroupPrincipal> groupPrincipals = new HashSet<GroupPrincipal>();
         return groupPrincipals;
     }
 
     /**
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#getUserPrincipalsInRole(java.lang.String)
      */
-    public Set getUserPrincipalsInRole(String roleFullPathName)
+    public Set<UserPrincipal> getUserPrincipalsInRole(String roleFullPathName)
     {
     	//TODO: Check that this is correct
-    	Set userPrincipals = new HashSet();
+    	Set<UserPrincipal> userPrincipals = new HashSet<UserPrincipal>();
         String[] fullPaths = {roleFullPathName};
         try
         {
@@ -266,16 +223,14 @@
      * 
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#getUserPrincipalsInGroup(java.lang.String)
      */
-    public Set getUserPrincipalsInGroup(String groupFullPathName)
+    public Set<UserPrincipal> getUserPrincipalsInGroup(String groupFullPathName)
     {
-    	Set userPrincipals = new HashSet();
-
+    	Set<UserPrincipal> userPrincipals = new HashSet<UserPrincipal>();
     	//TODO: Check that this is correct
     	String[] fullPaths = {groupFullPathName};
-
         try
         {
-           getUserPrincipalsInGroup(userPrincipals, fullPaths);
+            getUserPrincipalsInGroup(userPrincipals, fullPaths);
         }
         catch (SecurityException e)
         {
@@ -293,14 +248,14 @@
      * @param fullPaths
      * @throws SecurityException A {@link SecurityException}.
      */
-    private void getUserPrincipalsInGroup(Set userPrincipals, String[] fullPaths) throws SecurityException
+    private void getUserPrincipalsInGroup(Set<UserPrincipal> userPrincipals, String[] fullPaths) throws SecurityException
     {
         for (int i = 0; i < fullPaths.length; i++)
         {
             String[] usersInGroup = userDao.getUserUidsForGroup(fullPaths[i]);
             for (int y = 0; y < usersInGroup.length; y++)
             {
-                Principal userPrincipal = new UserPrincipalImpl(usersInGroup[y]);
+                UserPrincipal userPrincipal = new UserPrincipalImpl(usersInGroup[y]);
                 userPrincipals.add(userPrincipal);
             }
         }
@@ -315,14 +270,14 @@
      * @param fullPaths
      * @throws SecurityException A {@link SecurityException}.
      */
-    private void getUserPrincipalsInRole(Set userPrincipals, String[] fullPaths) throws SecurityException
+    private void getUserPrincipalsInRole(Set<UserPrincipal> userPrincipals, String[] fullPaths) throws SecurityException
     {
         for (int i = 0; i < fullPaths.length; i++)
         {
             String[] usersInRole = userDao.getUserUidsForRole(fullPaths[i]);
             for (int y = 0; y < usersInRole.length; y++)
             {
-                Principal userPrincipal = new UserPrincipalImpl(usersInRole[y]);
+                UserPrincipal userPrincipal = new UserPrincipalImpl(usersInRole[y]);
                 userPrincipals.add(userPrincipal);
             }
         }
@@ -398,19 +353,15 @@
      * @param groups
      * @param i
      */
-    private void createResolvedGroupPrincipalSet(String username, Set groupPrincipals, String[] groups, int i)
+    private void createResolvedGroupPrincipalSet(String username, Set<GroupPrincipal> groupPrincipals, String[] groups, int i)
     {
         LOG.debug("Group [" + i + "] for user[" + username + "] is [" + groups[i] + "]");
-
         GroupPrincipal group = new GroupPrincipalImpl(groups[i]);
-        Preferences preferences = Preferences.userRoot().node(group.getFullPath());
-        LOG.debug("Group name:" + group.getName());
-        String[] fullPaths = groupHierarchyResolver.resolve(preferences);
-        for (int n = 0; n < fullPaths.length; n++)
-        {
-            LOG.debug("Group [" + i + "] for user[" + username + "] is ["
-                    + GroupPrincipalImpl.getPrincipalNameFromFullPath(fullPaths[n]) + "]");
-            groupPrincipals.add(new GroupPrincipalImpl(GroupPrincipalImpl.getPrincipalNameFromFullPath(fullPaths[n])));
+        Set<GroupPrincipal> x = hierarchyResolver.resolveGroups(group.getName());
+        for (GroupPrincipal groupPrincipal : x)
+        {
+            LOG.debug("Group [" + i + "] for user[" + username + "] is [" + groupPrincipal.getName() + "]");
+            groupPrincipals.add(groupPrincipal);
         }
     }
 
@@ -420,31 +371,27 @@
      * @param groups
      * @param i
      */
-    private void createResolvedRolePrincipalSet(String username, Set rolePrincipals, String[] roles, int i)
+    private void createResolvedRolePrincipalSet(String username, Set<RolePrincipal> rolePrincipals, String[] roles, int i)
     {
-        LOG.debug("Group [" + i + "] for user[" + username + "] is [" + roles[i] + "]");
-
+        LOG.debug("Role [" + i + "] for user[" + username + "] is [" + roles[i] + "]");
         RolePrincipal role = new RolePrincipalImpl(roles[i]);
-        Preferences preferences = Preferences.userRoot().node(role.getFullPath());
-        LOG.debug("Group name:" + role.getName());
-        String[] fullPaths = roleHierarchyResolver.resolve(preferences);
-        for (int n = 0; n < fullPaths.length; n++)
-        {
-            LOG.debug("Group [" + i + "] for user[" + username + "] is ["
-                    + RolePrincipalImpl.getPrincipalNameFromFullPath(fullPaths[n]) + "]");
-            rolePrincipals.add(new RolePrincipalImpl(RolePrincipalImpl.getPrincipalNameFromFullPath(fullPaths[n])));
+        Set<RolePrincipal> x = hierarchyResolver.resolveRoles(role.getName());
+        for (RolePrincipal rolePrincipal : x)
+        {
+            LOG.debug("Role [" + i + "] for user[" + username + "] is [" + rolePrincipal.getName() + "]");
+            rolePrincipals.add(rolePrincipal);
         }
     }
 
     
     /**
      * @param username
-     * @param groupFullPathName
+     * @param groupName
      * @throws SecurityException
      */
-    private void removeUserFromGroup(String username, String groupFullPathName) throws SecurityException
+    private void removeUserFromGroup(String username, String groupName) throws SecurityException
     {
-        userDao.removeGroup(username, groupFullPathName);
+        userDao.removeGroup(username, groupName);
     }
     
     /**
@@ -547,7 +494,6 @@
     private void addRoleToGroup(String groupFullPathName, String roleFullPathName) throws SecurityException
     {
         userDao.addRoleToGroup(groupFullPathName, roleFullPathName);
-    }    
-
+    }
 
 }
\ No newline at end of file

Modified: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/LdapUserSecurityHandler.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/LdapUserSecurityHandler.java?rev=683497&r1=683496&r2=683497&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/LdapUserSecurityHandler.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/LdapUserSecurityHandler.java Wed Aug  6 20:52:05 2008
@@ -19,6 +19,7 @@
 import java.security.Principal;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.LinkedList;
 import java.util.List;
 
 import javax.naming.NamingException;
@@ -81,7 +82,7 @@
     /**
      * @see org.apache.jetspeed.security.spi.UserSecurityHandler#getUserPrincipal(java.lang.String)
      */
-    public Principal getUserPrincipal(String uid)
+    public UserPrincipal getUserPrincipal(String uid)
     {
         verifyUid(uid);
         try
@@ -131,18 +132,25 @@
     /**
      * @see org.apache.jetspeed.security.spi.UserSecurityHandler#getUserPrincipals(java.lang.String)
      */
-    public List getUserPrincipals(String filter)
+    public List<UserPrincipal> getUserPrincipals(String filter)
     {
         try
         {
-            return Arrays.asList(ldap.find(filter, UserPrincipal.PREFS_USER_ROOT));
+            List<UserPrincipal> principals = new LinkedList<UserPrincipal>();            
+            List<Principal> result = Arrays.asList(ldap.find(filter, UserPrincipal.PREFS_USER_ROOT));
+            for (Principal p : result)
+            {
+                if (p instanceof UserPrincipal)
+                    principals.add((UserPrincipal)p);
+            }
+            return principals;            
         }
         catch (SecurityException e)
         {
             logSecurityException(e, filter);
         }
 
-        return new ArrayList();
+        return new ArrayList<UserPrincipal>();
     }
 
     /**

Modified: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/SecurityAccessImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/SecurityAccessImpl.java?rev=683497&r1=683496&r2=683497&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/SecurityAccessImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/SecurityAccessImpl.java Wed Aug  6 20:52:05 2008
@@ -18,13 +18,10 @@
 
 import java.security.Principal;
 import java.util.Collection;
-import java.util.Iterator;
 
 import org.apache.jetspeed.components.dao.InitablePersistenceBrokerDaoSupport;
 import org.apache.jetspeed.i18n.KeyedMessage;
 import org.apache.jetspeed.security.SecurityException;
-import org.apache.jetspeed.security.UserPrincipal;
-import org.apache.jetspeed.security.impl.UserPrincipalImpl;
 import org.apache.jetspeed.security.om.InternalGroupPrincipal;
 import org.apache.jetspeed.security.om.InternalRolePrincipal;
 import org.apache.jetspeed.security.om.InternalUserPrincipal;
@@ -46,8 +43,6 @@
  */
 public class SecurityAccessImpl extends InitablePersistenceBrokerDaoSupport implements SecurityAccess
 {
-    
-
     /**
      * 
      * @param repositoryPath
@@ -67,11 +62,8 @@
      */
     public boolean isKnownUser(String username)
     {
-        UserPrincipal userPrincipal = new UserPrincipalImpl(username);
-        String fullPath = userPrincipal.getFullPath();
-        // Get user.
         Criteria filter = new Criteria();
-        filter.addEqualTo("fullPath", fullPath);
+        filter.addEqualTo("name", username);
         // The isMappingOnly must not be true.
         // We don't need the mapping only user, mapping user can't be authenticated with this provider. 
         // we just need the true user.
@@ -90,11 +82,8 @@
      */
     public InternalUserPrincipal getInternalUserPrincipal(String username)
     {
-        UserPrincipal userPrincipal = new UserPrincipalImpl(username);
-        String fullPath = userPrincipal.getFullPath();
-        // Get user.
         Criteria filter = new Criteria();
-        filter.addEqualTo("fullPath", fullPath);
+        filter.addEqualTo("name", username);
         Query query = QueryFactory.newQuery(InternalUserPrincipalImpl.class, filter);
         InternalUserPrincipal internalUser = (InternalUserPrincipal) getPersistenceBrokerTemplate().getObjectByQuery(query);
         return internalUser;
@@ -111,11 +100,8 @@
      */
     public InternalUserPrincipal getInternalUserPrincipal(String username, boolean isMappingOnly)
     {
-        UserPrincipal userPrincipal = new UserPrincipalImpl(username);
-        String fullPath = userPrincipal.getFullPath();
-        // Get user.
         Criteria filter = new Criteria();
-        filter.addEqualTo("fullPath", fullPath);
+        filter.addEqualTo("name", username);
         filter.addEqualTo("isMappingOnly", new Boolean(isMappingOnly));
         Query query = QueryFactory.newQuery(InternalUserPrincipalImpl.class, filter);
         InternalUserPrincipal internalUser = (InternalUserPrincipal) getPersistenceBrokerTemplate().getObjectByQuery(query);
@@ -130,14 +116,14 @@
      * @param filter The filter.
      * @return Collection of {@link InternalUserPrincipal}.
      */
-    public Iterator getInternalUserPrincipals(String filter)
+    @SuppressWarnings("unchecked")
+    public Collection<InternalUserPrincipal> getInternalUserPrincipals(String filter)
     {
         Criteria queryCriteria = new Criteria();
         queryCriteria.addEqualTo("isMappingOnly", new Boolean(false));
-        queryCriteria.addLike("fullPath", UserPrincipal.PREFS_USER_ROOT + filter + "%");
+        queryCriteria.addLike("name", filter + "%");
         Query query = QueryFactory.newQuery(InternalUserPrincipalImpl.class, queryCriteria);
-        Iterator result = getPersistenceBrokerTemplate().getIteratorByQuery(query);
-        return result;
+        return getPersistenceBrokerTemplate().getCollectionByQuery(query);
     }
 
     /**
@@ -149,7 +135,7 @@
      * @param isMappingOnly Whether a principal's purpose is for security mappping only.
      * @throws SecurityException Throws a {@link SecurityException}.
      */
-    public void setInternalUserPrincipal(InternalUserPrincipal internalUser, boolean isMappingOnly) throws SecurityException
+    public void storeInternalUserPrincipal(InternalUserPrincipal internalUser, boolean isMappingOnly) throws SecurityException
     {
         try
         {
@@ -161,7 +147,7 @@
         }
         catch (Exception e)
         {
-            KeyedMessage msg = SecurityException.UNEXPECTED.create("SecurityAccess.setInternalUserPrincipal",
+            KeyedMessage msg = SecurityException.UNEXPECTED.create("SecurityAccess.storeInternalUserPrincipal",
                                                                    "store",
                                                                    e.getMessage());
             logger.error(msg, e);
@@ -185,7 +171,7 @@
             getPersistenceBrokerTemplate().delete(internalUser);
             if (logger.isDebugEnabled())
             {
-                logger.debug("Deleted user: " + internalUser.getFullPath());
+                logger.debug("Deleted user: " + internalUser.getName());
             }
 
         }
@@ -204,13 +190,13 @@
      * Returns the {@link InternalRolePrincipal}from the role full path name.
      * </p>
      * 
-     * @param roleFullPathName The role full path name.
+     * @param roleName The role full path name.
      * @return The {@link InternalRolePrincipal}.
      */
-    public InternalRolePrincipal getInternalRolePrincipal(String roleFullPathName)
+    public InternalRolePrincipal getInternalRolePrincipal(String roleName)
     {
         Criteria filter = new Criteria();
-        filter.addEqualTo("fullPath", roleFullPathName);
+        filter.addEqualTo("name", roleName);
         Query query = QueryFactory.newQuery(InternalRolePrincipalImpl.class, filter);
         InternalRolePrincipal internalRole = (InternalRolePrincipal) getPersistenceBrokerTemplate().getObjectByQuery(query);
         return internalRole;
@@ -225,7 +211,7 @@
      * @param isMappingOnly Whether a principal's purpose is for security mappping only.
      * @throws SecurityException Throws a {@link SecurityException}.
      */
-    public void setInternalRolePrincipal(InternalRolePrincipal internalRole, boolean isMappingOnly) throws SecurityException
+    public void storeInternalRolePrincipal(InternalRolePrincipal internalRole, boolean isMappingOnly) throws SecurityException
     {
         try
         {
@@ -237,7 +223,7 @@
         }
         catch (Exception e)
         {
-            KeyedMessage msg = SecurityException.UNEXPECTED.create("SecurityAccess.setInternalRolePrincipal",
+            KeyedMessage msg = SecurityException.UNEXPECTED.create("SecurityAccess.storeInternalRolePrincipal",
                                                                    "store",
                                                                    e.getMessage());
             logger.error(msg, e);
@@ -262,7 +248,7 @@
             getPersistenceBrokerTemplate().delete(internalRole);
             if (logger.isDebugEnabled())
             {
-                logger.debug("Deleted role: " + internalRole.getFullPath());
+                logger.debug("Deleted role: " + internalRole.getName());
             }
 
         }
@@ -282,13 +268,13 @@
      * Returns the {@link InternalGroupPrincipal}from the group full path name.
      * </p>
      * 
-     * @param groupFullPathName The group full path name.
+     * @param groupName The group full path name.
      * @return The {@link InternalGroupPrincipal}.
      */
-    public InternalGroupPrincipal getInternalGroupPrincipal(String groupFullPathName)
+    public InternalGroupPrincipal getInternalGroupPrincipal(String groupName)
     {
         Criteria filter = new Criteria();
-        filter.addEqualTo("fullPath", groupFullPathName);
+        filter.addEqualTo("name", groupName);
         Query query = QueryFactory.newQuery(InternalGroupPrincipalImpl.class, filter);
         InternalGroupPrincipal internalGroup = (InternalGroupPrincipal) getPersistenceBrokerTemplate().getObjectByQuery(query);
         return internalGroup;
@@ -303,7 +289,7 @@
      * @param isMappingOnly Whether a principal's purpose is for security mappping only.
      * @throws SecurityException Throws a {@link SecurityException}.
      */
-    public void setInternalGroupPrincipal(InternalGroupPrincipal internalGroup, boolean isMappingOnly) throws SecurityException
+    public void storeInternalGroupPrincipal(InternalGroupPrincipal internalGroup, boolean isMappingOnly) throws SecurityException
     {
         try
         {
@@ -316,7 +302,7 @@
         }
         catch (Exception e)
         {
-            KeyedMessage msg = SecurityException.UNEXPECTED.create("SecurityAccess.setInternalGroupPrincipal",
+            KeyedMessage msg = SecurityException.UNEXPECTED.create("SecurityAccess.storeInternalGroupPrincipal",
                                                                    "store",
                                                                    e.getMessage());
             logger.error(msg, e);         
@@ -341,7 +327,7 @@
        
             if (logger.isDebugEnabled())
             {
-                logger.debug("Deleted group: " + internalGroup.getFullPath());
+                logger.debug("Deleted group: " + internalGroup.getName());
             }
 
         }
@@ -356,25 +342,25 @@
         
     }
 
-    public Iterator getInternalRolePrincipals(String filter)
+    @SuppressWarnings("unchecked")
+    public Collection<InternalRolePrincipal> getInternalRolePrincipals(String filter)
     {
         Criteria queryCriteria = new Criteria();
         queryCriteria.addEqualTo("isMappingOnly", new Boolean(false));
-        queryCriteria.addLike("fullPath", UserPrincipal.PREFS_ROLE_ROOT + filter + "%");
+        queryCriteria.addLike("name", filter + "%");
         Query query = QueryFactory.newQuery(InternalRolePrincipalImpl.class, queryCriteria);
-        Collection c = getPersistenceBrokerTemplate().getCollectionByQuery(query);
-        return c.iterator();
+        return getPersistenceBrokerTemplate().getCollectionByQuery(query);
     }
 
-    public Iterator getInternalGroupPrincipals(String filter)
+    @SuppressWarnings("unchecked")    
+    public Collection<InternalGroupPrincipal> getInternalGroupPrincipals(String filter)
     {
       
         Criteria queryCriteria = new Criteria();
         queryCriteria.addEqualTo("isMappingOnly", new Boolean(false));
-        queryCriteria.addLike("fullPath", UserPrincipal.PREFS_GROUP_ROOT + filter + "%");        
+        queryCriteria.addLike("name", filter + "%");        
         Query query = QueryFactory.newQuery(InternalGroupPrincipalImpl.class, queryCriteria);
-        Collection c = getPersistenceBrokerTemplate().getCollectionByQuery(query);
-        return c.iterator();
+        return getPersistenceBrokerTemplate().getCollectionByQuery(query);
     }
     
 }
\ No newline at end of file

Modified: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/ldap/LdapPrincipalDaoImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/ldap/LdapPrincipalDaoImpl.java?rev=683497&r1=683496&r2=683497&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/ldap/LdapPrincipalDaoImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/ldap/LdapPrincipalDaoImpl.java Wed Aug  6 20:52:05 2008
@@ -34,9 +34,6 @@
 import org.apache.jetspeed.security.GroupPrincipal;
 import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.UserPrincipal;
-import org.apache.jetspeed.security.impl.GroupPrincipalImpl;
-import org.apache.jetspeed.security.impl.RolePrincipalImpl;
-import org.apache.jetspeed.security.impl.UserPrincipalImpl;
 
 /**
  * @see org.apache.jetspeed.security.spi.impl.ldap.LdapPrincipalDao
@@ -182,15 +179,15 @@
         }
         else if (fullPath.indexOf(UserPrincipal.PREFS_USER_ROOT) >= 0)
         {
-            ldapAcceptableName = convertUidWithoutSlashes(UserPrincipalImpl.getPrincipalNameFromFullPath(fullPath));
+            ldapAcceptableName = convertUidWithoutSlashes(getPrincipalNameFromFullPath(fullPath, UserPrincipal.PREFS_USER_ROOT, false));
         }
         else if (fullPath.indexOf(GroupPrincipal.PREFS_GROUP_ROOT) >= 0)
         {
-            ldapAcceptableName = convertUidWithoutSlashes(GroupPrincipalImpl.getPrincipalNameFromFullPath(fullPath));
+            ldapAcceptableName = convertUidWithoutSlashes(getPrincipalNameFromFullPath(fullPath, GroupPrincipal.PREFS_GROUP_ROOT, false));
         }
         else if (fullPath.indexOf(GroupPrincipal.PREFS_ROLE_ROOT) >= 0)
         {
-            ldapAcceptableName = convertUidWithoutSlashes(RolePrincipalImpl.getPrincipalNameFromFullPath(fullPath));
+            ldapAcceptableName = convertUidWithoutSlashes(getPrincipalNameFromFullPath(fullPath, GroupPrincipal.PREFS_ROLE_ROOT, false));
         }        
         if (logger.isErrorEnabled())
         {
@@ -199,7 +196,22 @@
 
         return ldapAcceptableName;
     }
-
+    
+    public static String getPrincipalNameFromFullPath(String fullPath, String prefsRoot, boolean hiearchicalNames)
+    {
+        String name = fullPath;
+        if (null != name)
+        {
+            name = name.substring(prefsRoot.length(), name.length());
+            if ( hiearchicalNames )
+            {
+                name = name.replace('/', '.');
+            }
+        }
+        return name;
+    }
+    
+    
     /**
      * <p>
      * Returns a well formed uid for LDAP.

Modified: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/util/test/AbstractSecurityTestcase.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/util/test/AbstractSecurityTestcase.java?rev=683497&r1=683496&r2=683497&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/util/test/AbstractSecurityTestcase.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/util/test/AbstractSecurityTestcase.java Wed Aug  6 20:52:05 2008
@@ -25,6 +25,7 @@
 import javax.security.auth.Subject;
 
 import org.apache.jetspeed.JetspeedActions;
+import org.apache.jetspeed.components.util.DatasourceEnabledSpringTestCase;
 import org.apache.jetspeed.prefs.util.test.AbstractPrefsSupportedTestCase;
 import org.apache.jetspeed.security.AuthenticationProvider;
 import org.apache.jetspeed.security.AuthenticationProviderProxy;
@@ -33,6 +34,7 @@
 import org.apache.jetspeed.security.RoleManager;
 import org.apache.jetspeed.security.SecurityProvider;
 import org.apache.jetspeed.security.UserManager;
+import org.apache.jetspeed.security.attributes.SecurityAttributesProvider;
 import org.apache.jetspeed.security.impl.SecurityProviderImpl;
 import org.apache.jetspeed.security.spi.CredentialHandler;
 import org.apache.jetspeed.security.spi.GroupSecurityHandler;
@@ -47,7 +49,7 @@
  * @version $Id$
  *  
  */
-public class AbstractSecurityTestcase extends AbstractPrefsSupportedTestCase
+public class AbstractSecurityTestcase extends DatasourceEnabledSpringTestCase //AbstractPrefsSupportedTestCase
 {
     /** SPI Common Queries. */
     protected SecurityAccess securityAccess;
@@ -82,6 +84,8 @@
     /** The permission manager. */
     protected PermissionManager pms;
 
+    protected SecurityAttributesProvider sap;
+    
     /**
      * @see junit.framework.TestCase#setUp()
      */
@@ -116,6 +120,8 @@
         // Authorization.
         pms = (PermissionManager) scm.getComponent("org.apache.jetspeed.security.PermissionManager");
         
+        sap = (SecurityAttributesProvider) scm.getComponent("org.apache.jetspeed.security.attributes.SecurityAttributesProvider");
+        
         new JetspeedActions(new String[] {"secure"}, new String[] {});
     }
 
@@ -141,8 +147,8 @@
 
     protected String[] getConfigurations()
     {
-        String[] confs = super.getConfigurations();
-        List confList = new ArrayList(Arrays.asList(confs));
+        //String[] confs = super.getConfigurations();
+        List confList = new ArrayList(); //Arrays.asList(confs));
         confList.add("security-atn.xml");
         confList.add("security-atz.xml");
         confList.add("security-managers.xml");
@@ -150,6 +156,9 @@
         confList.add("security-spi.xml");
         confList.add("security-spi-atn.xml");
         confList.add("security-spi-atz.xml");
+        confList.add("security-attributes.xml");
+        confList.add("transaction.xml");
+        confList.add("cache.xml");
         return (String[]) confList.toArray(new String[1]);
     }
 



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


Mime
View raw message