You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by ta...@apache.org on 2008/08/07 05:52:09 UTC

svn commit: r683497 [2/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-...

Modified: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/AggregationHierarchyResolver.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/AggregationHierarchyResolver.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/impl/AggregationHierarchyResolver.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/AggregationHierarchyResolver.java Wed Aug  6 20:52:05 2008
@@ -16,14 +16,19 @@
  */
 package org.apache.jetspeed.security.impl;
 
-import java.util.prefs.Preferences;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.StringTokenizer;
 
+import org.apache.jetspeed.security.GroupPrincipal;
 import org.apache.jetspeed.security.HierarchyResolver;
-import org.apache.jetspeed.util.ArgUtil;
+import org.apache.jetspeed.security.RolePrincipal;
+import org.apache.jetspeed.security.spi.GroupSecurityHandler;
+import org.apache.jetspeed.security.spi.RoleSecurityHandler;
 
 /**
  * <p>
- * Implementation for "part of" hierarchy. For Example: There're roles:
+ * Implementation for "part of" hierarchy. For Example: given roles:
  * <ul>
  * <li>roleA</li>
  * <li>roleA.roleB</li>
@@ -40,19 +45,73 @@
  * </p>
  * 
  * @author <a href="mailto:Artem.Grinshtein@t-systems.com">Artem Grinshtein </a>
- * @version $Id: AggregationHierarchyResolver.java,v 1.2 2004/09/18 19:33:58
- *          dlestrat Exp $
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id$
  */
 public class AggregationHierarchyResolver extends BaseHierarchyResolver implements HierarchyResolver
 {
+    public AggregationHierarchyResolver(RoleSecurityHandler roleHandler, GroupSecurityHandler groupHandler)
+    {
+        super(roleHandler, groupHandler);
+    }
+    
     /**
-     * @see org.apache.jetspeed.security.HierarchyResolver#resolve(Preferences)
+     * Resolve roles by aggregation of children of the given role path
      */
-    public String[] resolve(Preferences prefs)
+    public Set<RolePrincipal> resolveRoles(String rolePath)
     {
-        ArgUtil.notNull(new Object[] { prefs }, new String[] { "preferences" }, "resolve(java.util.prefs.Preferences)");
-
-        return resolveChildren(prefs);
+        Set<RolePrincipal> resultSet = new HashSet<RolePrincipal>();
+        StringTokenizer tokenizer = new StringTokenizer(this.getHierarchySeparator());
+        if (tokenizer.hasMoreTokens())
+        {    
+            String current = tokenizer.nextToken();
+            RolePrincipal rp = this.roleHandler.getRolePrincipal(current);
+            if (rp != null)
+                resultSet.add(rp);
+            while (tokenizer.hasMoreTokens())
+            { 
+                current = current + this.getHierarchySeparator() + tokenizer.nextToken();
+                rp = this.roleHandler.getRolePrincipal(current);
+                if (rp != null)
+                    resultSet.add(rp);
+            }
+        }
+        else
+        {
+            RolePrincipal rp = this.roleHandler.getRolePrincipal(rolePath);
+            if (rp != null)
+                resultSet.add(rp);
+        }
+        return resultSet;
+    }
+    
+    /**
+     * Resolve groups by aggregation of children of the given group path
+     */
+    public Set<GroupPrincipal> resolveGroups(String groupPath)
+    {
+        Set<GroupPrincipal> resultSet = new HashSet<GroupPrincipal>();
+        StringTokenizer tokenizer = new StringTokenizer(this.getHierarchySeparator());
+        if (tokenizer.hasMoreTokens())
+        {    
+            String current = tokenizer.nextToken();
+            GroupPrincipal gp = this.groupHandler.getGroupPrincipal(current);
+            if (gp != null)
+                resultSet.add(gp);
+            while (tokenizer.hasMoreTokens())
+            { 
+                current = current + this.getHierarchySeparator() + tokenizer.nextToken();
+                gp = this.groupHandler.getGroupPrincipal(current);
+                if (gp != null)
+                    resultSet.add(gp);
+            }
+        }
+        else
+        {
+            GroupPrincipal gp = this.groupHandler.getGroupPrincipal(groupPath);
+            if (gp != null)
+                resultSet.add(gp);
+        }
+        return resultSet;
     }
-
 }
\ No newline at end of file

Modified: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/AuthenticationProviderProxyImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/AuthenticationProviderProxyImpl.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/impl/AuthenticationProviderProxyImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/AuthenticationProviderProxyImpl.java Wed Aug  6 20:52:05 2008
@@ -16,7 +16,6 @@
  */
 package org.apache.jetspeed.security.impl;
 
-import java.security.Principal;
 import java.sql.Date;
 import java.util.ArrayList;
 import java.util.HashSet;
@@ -26,6 +25,7 @@
 
 import org.apache.jetspeed.security.AuthenticationProvider;
 import org.apache.jetspeed.security.AuthenticationProviderProxy;
+import org.apache.jetspeed.security.Credential;
 import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.UserPrincipal;
 
@@ -38,7 +38,7 @@
 {
 
     /** The list of {@link AuthenticationProvider}. */
-    private List authenticationProviders = new ArrayList();
+    private List<AuthenticationProvider> authenticationProviders = new ArrayList<AuthenticationProvider>();
 
     /** The default authentication provider name. */
     private String defaultAuthenticationProvider = null;
@@ -52,7 +52,7 @@
      * @param authenticationProviders The list of {@link AuthenticationProvider}.
      * @param defaultAuthenticationProvider The default authentication provider name.
      */
-    public AuthenticationProviderProxyImpl(List authenticationProviders, String defaultAuthenticationProvider)
+    public AuthenticationProviderProxyImpl(List<AuthenticationProvider> authenticationProviders, String defaultAuthenticationProvider)
     {
         this.authenticationProviders = authenticationProviders;
         this.defaultAuthenticationProvider = defaultAuthenticationProvider;
@@ -64,7 +64,7 @@
         
         for (int i = 0; i < authenticationProviders.size(); i++)
         {
-            provider = (AuthenticationProvider) authenticationProviders.get(i);
+            provider = authenticationProviders.get(i);
             if (providerName.equals(provider.getProviderName()))
             {
                 break;
@@ -129,9 +129,9 @@
     /**
      * @see org.apache.jetspeed.security.spi.UserSecurityHandler#getUserPrincipal(java.lang.String)
      */
-    public Principal getUserPrincipal(String username)
+    public UserPrincipal getUserPrincipal(String username)
     {
-        Principal userPrincipal = null;
+        UserPrincipal userPrincipal = null;
         for (int i = 0; i < authenticationProviders.size(); i++)
         {
             userPrincipal = ((AuthenticationProvider)authenticationProviders.get(i)).getUserSecurityHandler().getUserPrincipal(username);
@@ -146,9 +146,9 @@
     /**
      * @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();
+        List<UserPrincipal> userPrincipals = new LinkedList<UserPrincipal>();
         for (int i = 0; i < authenticationProviders.size(); i++)
         {
             userPrincipals.addAll(((AuthenticationProvider)authenticationProviders.get(i)).getUserSecurityHandler().getUserPrincipals(filter));
@@ -254,9 +254,9 @@
     /**
      * @see org.apache.jetspeed.security.spi.CredentialHandler#getPublicCredentials(java.lang.String)
      */
-    public Set getPublicCredentials(String username)
+    public Set<Credential> getPublicCredentials(String username)
     {
-        Set publicCredentials = new HashSet();
+        Set<Credential> publicCredentials = new HashSet<Credential>();
         String providerName = getAuthenticationProvider(username);
         if ( providerName != null )
         {
@@ -335,9 +335,9 @@
     /**
      * @see org.apache.jetspeed.security.spi.CredentialHandler#getPrivateCredentials(java.lang.String)
      */
-    public Set getPrivateCredentials(String username)
+    public Set<Credential> getPrivateCredentials(String username)
     {
-        Set privateCredentials = new HashSet();
+        Set<Credential> privateCredentials = new HashSet<Credential>();
         String providerName = getAuthenticationProvider(username);
         if ( providerName != null )
         {

Modified: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/BaseHierarchyResolver.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/BaseHierarchyResolver.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/impl/BaseHierarchyResolver.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/BaseHierarchyResolver.java Wed Aug  6 20:52:05 2008
@@ -18,62 +18,35 @@
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.prefs.BackingStoreException;
-import java.util.prefs.Preferences;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.security.HierarchyResolver;
+import org.apache.jetspeed.security.spi.GroupSecurityHandler;
+import org.apache.jetspeed.security.spi.RoleSecurityHandler;
 import org.apache.jetspeed.util.ArgUtil;
 
 /**
  * <p>
  * Base implementation for the hierarchy resolver.
  * <p>
+ * <p>Modified 2008-08-05 - DST - decoupled java preferences</p> 
  * 
  * @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
  */
-public class BaseHierarchyResolver
+public abstract class BaseHierarchyResolver implements HierarchyResolver
 {
-    /** The logger. */
-    private static final Log log = LogFactory.getLog(BaseHierarchyResolver.class);
+    protected RoleSecurityHandler roleHandler;
+    protected GroupSecurityHandler groupHandler; 
     
-    /**
-     * @see org.apache.jetspeed.security.HierarchyResolver#resolveChildren(java.util.prefs.Preferences)
-     */
-    public String[] resolveChildren(Preferences prefs)
+    public BaseHierarchyResolver(RoleSecurityHandler roleHandler, GroupSecurityHandler groupHandler)
     {
-        ArgUtil.notNull(new Object[] { prefs }, new String[] { "preferences" }, "resolveChildren(java.util.prefs.Preferences)");
-
-        List children = new ArrayList();
-        processPreferences(prefs, children);
-        return (String[]) children.toArray(new String[0]);
+        this.roleHandler = roleHandler;
+        this.groupHandler = groupHandler;
     }
     
-    /**
-     * <p>
-     * Recursively processes the preferences.
-     * </p>
-     * 
-     * @param prefs The preferences.
-     * @param list The list to add the preferences to.
-     */
-    protected void processPreferences(Preferences prefs, List list)
+    public String getHierarchySeparator()
     {
-        if (!list.contains(prefs.absolutePath()))
-        {
-            list.add(prefs.absolutePath());
-        }
-        try
-        {
-            String[] names = prefs.childrenNames();
-            for (int i = 0; i < names.length; i++)
-            {
-                processPreferences(prefs.node(names[i]), list);
-            }
-        }
-        catch (BackingStoreException bse)
-        {
-            log.warn("can't find children of " + prefs.absolutePath(), bse);
-        }
+        return HierarchyResolver.DEFAULT_HIERARCHY_SEPARATOR;
     }
 }

Modified: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/BasePrincipalImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/BasePrincipalImpl.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/impl/BasePrincipalImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/BasePrincipalImpl.java Wed Aug  6 20:52:05 2008
@@ -26,53 +26,35 @@
  * @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
  */
 public abstract class BasePrincipalImpl implements BasePrincipal
-{
-    
+{   
     /** The version uid. */
     private static final long serialVersionUID = 5687385387290144541L;
 
     /** The principal name. */
-    private final String name;
-
-    /** The full path. */
-    private final String fullPath;
+    protected final String name;
 
     /** is this principal enabled **/
-    private boolean enabled = true;
+    protected boolean enabled = true;
     
     /** is this principal a mapping **/
-    private boolean isMapping = false;
+    protected boolean isMapping = false;
+
+    protected long id;
     
-    /**
-     * <p>
-     * Principal constructor given a name and preferences root.
-     * </p>
-     * 
-     * @param name The principal name.
-     * @param prefsRoot The preferences root node.
-     */
-    public BasePrincipalImpl(String name, String prefsRoot, boolean hiearchicalNames)
+    public BasePrincipalImpl(String name)
     {
-        this(name, prefsRoot, hiearchicalNames, true, false);
+        this.name = name;
     }
     
-    public BasePrincipalImpl(String name, String prefsRoot, boolean hiearchicalNames, boolean isEnabled, boolean isMapping)
+    public BasePrincipalImpl(long id, String name, boolean isEnabled, boolean isMapping)
     {
+        this.id = id;
         this.name = name;
-        this.fullPath = getFullPathFromPrincipalName(name, prefsRoot, hiearchicalNames);
         this.enabled = isEnabled;
         this.isMapping = isMapping;
     }
 
     /**
-     * @see org.apache.jetspeed.security.BasePrincipal#getFullPath()
-     */
-    public String getFullPath()
-    {
-        return this.fullPath;
-    }
-
-    /**
      * @see java.security.Principal#getName()
      */
     public String getName()
@@ -101,103 +83,6 @@
     }
 
     /**
-     * <p>
-     * Gets the principal implementation full path from the principal name.
-     * </p>
-     * <p>
-     * Hierarchical principal names should follow: {principal}.{subprincipal}. "." is used as the
-     * separator for hierarchical elements.
-     * </p>
-     * <p>
-     * The implementation path follow /PREFS_{PRINCIPAL}_ROOT/{principal}/{subprincipal}.
-     * </p>
-     * 
-     * @param name The principal name.
-     * @param prefsRoot The preferences root node.
-     * @param hiearchicalNames indicator if hierarchy encoding (replacing '.' with '/') should be done
-     * @return The preferences full path / principal name.
-     */
-    public static String getFullPathFromPrincipalName(String name, String prefsRoot, boolean hiearchicalNames)
-    {
-        String fullPath = name;
-        if (null != name )
-        {
-            fullPath = prefsRoot + (hiearchicalNames ? name.replace('.','/') : name );
-        }
-        return fullPath;
-    }
-
-    /**
-     * <p>
-     * Gets the principal implementation full path from the principal name.
-     * </p>
-     * <p>
-     * Hierarchical principal names should follow: {principal}.{subprincipal}. "." is used as the
-     * separator for hierarchical elements.
-     * </p>
-     * <p>
-     * The implementation path follow /PREFS_{PRINCIPAL}_ROOT/{principal}/{subprincipal}.
-     * </p>
-     * 
-     * @param name The principal name.
-     * @param prefsRoot The preferences root node.
-     * @return The preferences full path / principal name.
-     */        
-
-    /**
-     * <p>
-     * Gets the principal name from the principal implementation full path.
-     * </p>
-     * <p>
-     * Hierarchical principal names should follow: {principal}.{subprincipal}. "." is used as the
-     * separator for hierarchical elements.
-     * </p>
-     * <p>
-     * The implementation path follow /PREFS_{PRINCIPAL}_ROOT/{principal}/{subprincipal}.
-     * </p>
-     * 
-     * @param fullPath The principal full path.
-     * @param prefsRoot The preferences root node.
-     * @param hiearchicalNames indicator if hierarchical decoding (replacing '/' with '.') should be done
-     * @return The principal name.
-     */
-    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>
-     * Gets the principal name from the principal implementation full path.
-     * </p>
-     * <p>
-     * Hierarchical principal names should follow: {principal}.{subprincipal}. "." is used as the
-     * separator for hierarchical elements.
-     * </p>
-     * <p>
-     * The implementation path follow /PREFS_{PRINCIPAL}_ROOT/{principal}/{subprincipal}.
-     * </p>
-     * 
-     * @param fullPath The principal full path.
-     * @param prefsRoot The preferences root node.
-     * @return The principal name.
-     */
-// MOVED TO DERVICED CLASSES    
-//    public static String getPrincipalNameFromFullPath(String fullPath, String prefsRoot)
-//    {
-//        return getPrincipalNameFromFullPath(fullPath, prefsRoot, true);
-//    }
-
-    /**
      * @see org.apache.jetspeed.security.BasePrincipal#isEnabled()
      */
     public boolean isEnabled()
@@ -217,5 +102,9 @@
     {
         return isMapping;
     }
-    
+
+    public long getId()
+    {
+        return id;
+    }
 }

Modified: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/GeneralizationHierarchyResolver.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/GeneralizationHierarchyResolver.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/impl/GeneralizationHierarchyResolver.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/GeneralizationHierarchyResolver.java Wed Aug  6 20:52:05 2008
@@ -16,12 +16,15 @@
  */
 package org.apache.jetspeed.security.impl;
 
-import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
-import java.util.prefs.Preferences;
+import java.util.Set;
 
+import org.apache.jetspeed.security.GroupPrincipal;
 import org.apache.jetspeed.security.HierarchyResolver;
-import org.apache.jetspeed.util.ArgUtil;
+import org.apache.jetspeed.security.RolePrincipal;
+import org.apache.jetspeed.security.spi.GroupSecurityHandler;
+import org.apache.jetspeed.security.spi.RoleSecurityHandler;
 
 /**
  * <p>
@@ -37,27 +40,42 @@
  * </p>
  * 
  * @author <a href="mailto:Artem.Grinshtein@t-systems.com">Artem Grinshtein </a>
- * @version $Id: GeneralizationHierarchyResolver.java,v 1.2 2004/09/18 19:33:58
- *          dlestrat Exp $
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id$
  */
 public class GeneralizationHierarchyResolver extends BaseHierarchyResolver implements HierarchyResolver
-{
+{    
+    public GeneralizationHierarchyResolver(RoleSecurityHandler roleHandler, GroupSecurityHandler groupHandler)
+    {
+        super(roleHandler, groupHandler);
+    }
 
     /**
-     * @see org.apache.jetspeed.security.HierarchyResolver#resolve(Preferences)
+     * Resolve roles by aggregation of children of the given role path
      */
-    public String[] resolve(Preferences prefs)
+    public Set<RolePrincipal> resolveRoles(String rolePath)
     {
-        ArgUtil.notNull(new Object[] { prefs }, new String[] { "preferences" }, "resolve(java.util.prefs.Preferences)");
-
-        List list = new ArrayList();
-        Preferences preferences = prefs;
-        while ((preferences.parent() != null) && (preferences.parent().parent() != null))
+        List<RolePrincipal> query = this.roleHandler.getRolePrincipals(rolePath);
+        Set<RolePrincipal> resultSet = new HashSet<RolePrincipal>();
+        for (RolePrincipal rp : query)
         {
-            list.add(preferences.absolutePath());
-            preferences = preferences.parent();
+            resultSet.add(rp);
         }
-        return (String[]) list.toArray(new String[0]);
+        return resultSet;
     }
-
+    
+    /**
+     * Resolve groups by aggregation of children of the given group path
+     */
+    public Set<GroupPrincipal> resolveGroups(String groupPath)
+    {
+        List<GroupPrincipal> query = this.groupHandler.getGroupPrincipals(groupPath);
+        Set<GroupPrincipal> resultSet = new HashSet<GroupPrincipal>();
+        for (GroupPrincipal gp : query)
+        {
+            resultSet.add(gp);
+        }
+        return resultSet;
+    }
+    
 }
\ No newline at end of file

Modified: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/GroupImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/GroupImpl.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/impl/GroupImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/GroupImpl.java Wed Aug  6 20:52:05 2008
@@ -17,16 +17,19 @@
 package org.apache.jetspeed.security.impl;
 
 import java.security.Principal;
-import java.util.prefs.Preferences;
-
 import org.apache.jetspeed.security.Group;
+import org.apache.jetspeed.security.attributes.SecurityAttributes;
 
 /**
- * <p>A group made of a {@link org.apache.jetspeed.security.GroupPrincipal} and the user {@link Preferences}.</p>
+ * <p>Represents a security 'group' made of a {@link org.apache.jetspeed.security.GroupPrincipal} and security attributes.</p>
+ * <p>Modified 2008-08-05 - DST - decoupled java preferences</p> 
  * @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
  */
 public class GroupImpl implements Group
 {
+    private Principal groupPrincipal;
+    private SecurityAttributes attributes;
+    
     /**
      * <p>Default constructor.</p>
      */
@@ -35,18 +38,16 @@
     }
 
     /**
-     * <p>{@link Group} constructor given a group principal and preferences.</p>
+     * <p>{@link Group} constructor given a group principal and security attributes.</p>
      * @param groupPrincipal The group principal.
-     * @param preferences The preferences.
+     * @param attributes The security attributes.
      */
-    public GroupImpl(Principal groupPrincipal, Preferences preferences)
+    public GroupImpl(Principal groupPrincipal, SecurityAttributes attributes)
     {
         this.groupPrincipal = groupPrincipal;
-        this.preferences = preferences;
+        this.attributes = attributes;
     }
 
-    private Principal groupPrincipal;
-
     /**
      * @see org.apache.jetspeed.security.Group#getPrincipal()
      */
@@ -63,22 +64,15 @@
         this.groupPrincipal = groupPrincipal;
     }
 
-    private Preferences preferences;
 
-    /**
-     * @see org.apache.jetspeed.security.Group#getPreferences()
-     */
-    public Preferences getPreferences()
+    public SecurityAttributes getAttributes()
     {
-        return this.preferences;
+        return this.attributes;
     }
 
-    /**
-     * @see org.apache.jetspeed.security.Group#setPreferences(java.util.prefs.Preferences)
-     */
-    public void setPreferences(Preferences preferences)
+    public void setAttributes(SecurityAttributes attributes)
     {
-        this.preferences = preferences;
+        this.attributes = attributes; 
     }
 
 }

Modified: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/GroupManagerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/GroupManagerImpl.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/impl/GroupManagerImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/GroupManagerImpl.java Wed Aug  6 20:52:05 2008
@@ -19,29 +19,26 @@
 import java.security.Principal;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
-import java.util.prefs.BackingStoreException;
-import java.util.prefs.Preferences;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.jetspeed.i18n.KeyedMessage;
 import org.apache.jetspeed.security.AuthenticationProviderProxy;
 import org.apache.jetspeed.security.Group;
 import org.apache.jetspeed.security.GroupManager;
 import org.apache.jetspeed.security.GroupPrincipal;
 import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.SecurityProvider;
+import org.apache.jetspeed.security.attributes.SecurityAttributes;
+import org.apache.jetspeed.security.attributes.SecurityAttributesProvider;
 import org.apache.jetspeed.security.spi.GroupSecurityHandler;
 import org.apache.jetspeed.security.spi.SecurityMappingHandler;
-import org.apache.jetspeed.util.ArgUtil;
 
 /**
  * <p>
- * Describes the service interface for managing groups.
+ * Implements the service interface for managing Jetsped Security Groups.
  * </p>
  * <p>
  * Group hierarchy elements are being returned as a {@link Group}collection.
@@ -49,11 +46,9 @@
  * preferences sub-tree.
  * </p>
  * <p>
- * The convention {principal}.{subprincipal} has been chosen to name groups
- * hierachies. Implementation follow the conventions enforced by the
- * {@link Preferences}API.
+ * The convention {principal}.{subprincipal} has been chosen to name groups hierarchies. 
  * </p>
- * 
+ * <p>Modified 2008-08-05 - DST - decoupled java preferences</p> 
  * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
  * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
  */
@@ -72,120 +67,60 @@
     /** The security mapping handler. */
     private SecurityMappingHandler securityMappingHandler = null;
 
+    private SecurityAttributesProvider attributesProvider;
+    
     /**
      * @param securityProvider
      *            The security provider.
      */
-    public GroupManagerImpl(SecurityProvider securityProvider)
+    public GroupManagerImpl(SecurityProvider securityProvider, SecurityAttributesProvider attributesProvider)
     {
-        this.atnProviderProxy = securityProvider
-                .getAuthenticationProviderProxy();
+        this.atnProviderProxy = securityProvider.getAuthenticationProviderProxy();
         this.groupSecurityHandler = securityProvider.getGroupSecurityHandler();
-        this.securityMappingHandler = securityProvider
-                .getSecurityMappingHandler();
+        this.securityMappingHandler = securityProvider.getSecurityMappingHandler();
+        this.attributesProvider = attributesProvider;
     }
 
     /**
      * @see org.apache.jetspeed.security.GroupManager#addGroup(java.lang.String)
      */
-    public void addGroup(String groupFullPathName) throws SecurityException
+    public void addGroup(String groupName) throws SecurityException
     {
-        ArgUtil.notNull(new Object[]
-        { groupFullPathName}, new String[]
-        { "groupFullPathName"}, "addGroup(java.lang.String)");
-
-        // Check if group already exists.
-        if (groupExists(groupFullPathName)) {  
-            throw new SecurityException(SecurityException.GROUP_ALREADY_EXISTS.create(groupFullPathName)); 
-        }
-
-        GroupPrincipal groupPrincipal = new GroupPrincipalImpl(
-                groupFullPathName);
-        String fullPath = groupPrincipal.getFullPath();
-        // Add the preferences.
-        Preferences preferences = Preferences.userRoot().node(fullPath);
+        if (groupExists(groupName)) 
+        {  
+            throw new SecurityException(SecurityException.GROUP_ALREADY_EXISTS.create(groupName)); 
+        }
+        GroupPrincipal groupPrincipal = new GroupPrincipalImpl(groupName);        
+        groupSecurityHandler.storeGroupPrincipal(groupPrincipal);
+        SecurityAttributes sa = attributesProvider.createSecurityAttributes(groupPrincipal);
+        attributesProvider.saveAttributes(sa);
         if (log.isDebugEnabled())
-        {
-            log.debug("Added group preferences node: " + fullPath);
-        }
-        try
-        {
-            if ((null != preferences)
-                    && preferences.absolutePath().equals(fullPath))
-            {
-                // Add role principal.
-                groupSecurityHandler.setGroupPrincipal(groupPrincipal);
-                if (log.isDebugEnabled())
-                {
-                    log.debug("Added group: " + fullPath);
-                }
-            }
-        } catch (SecurityException se)
-        {
-            String msg = "Unable to create the role.";
-            log.error(msg, se);
-
-            // Remove the preferences node.
-            try
-            {
-                preferences.removeNode();
-            } catch (BackingStoreException bse)
-            {
-                bse.printStackTrace();
-            }
-            throw se;
-        }
+            log.debug("Added group: " + groupName);
     }
 
     /**
      * @see org.apache.jetspeed.security.GroupManager#removeGroup(java.lang.String)
      */
-    public void removeGroup(String groupFullPathName) throws SecurityException
+    public void removeGroup(String groupName) throws SecurityException
     {
-        ArgUtil.notNull(new Object[]
-        { groupFullPathName}, new String[]
-        { "groupFullPathName"}, "removeGroup(java.lang.String)");
-
-        // Resolve the group hierarchy.
-        Preferences prefs = Preferences.userRoot().node(
-                GroupPrincipalImpl
-                        .getFullPathFromPrincipalName(groupFullPathName));
-        String[] groups = securityMappingHandler.getGroupHierarchyResolver()
-                .resolveChildren(prefs);
-        for (int i = 0; i < groups.length; i++)
+        if (securityMappingHandler.getHierarchyResolver() != null)
         {
-            try
-            {
-                groupSecurityHandler
-                        .removeGroupPrincipal(new GroupPrincipalImpl(
-                                GroupPrincipalImpl
-                                        .getPrincipalNameFromFullPath(groups[i])));
-            } catch (SecurityException se)
+            Set<GroupPrincipal> groups = securityMappingHandler.getHierarchyResolver().resolveGroups(groupName);
+            for (GroupPrincipal gp : groups)
             {
-                throw se;
-            } catch (Exception e)
-            {
-                KeyedMessage msg = 
-                    SecurityException.UNEXPECTED.create("GroupManager.removeGroup",
-                                                        "GroupSecurityHandler.removeGroupPrincipal("+
-                        GroupPrincipalImpl.getPrincipalNameFromFullPath(groups[i])+")", 
-                        e.getMessage());
-                log.error(msg, e);
-                throw new SecurityException(msg, e);
+                groupSecurityHandler.removeGroupPrincipal(gp);
+//                TODO: should we use cascading deletes?
+                attributesProvider.deleteAttributes(gp);
             }
-            // Remove preferences
-            Preferences groupPref = Preferences.userRoot().node(
-                    groups[i]);
-            try
-            {
-                groupPref.removeNode();
-            } catch (BackingStoreException bse)
+        }
+        else
+        {
+            GroupPrincipal gp = groupSecurityHandler.getGroupPrincipal(groupName);
+            if (gp != null)
             {
-                KeyedMessage msg =
-                    SecurityException.UNEXPECTED.create("Preferences.removeNode("+groups[i]+")", 
-                                                        bse.getMessage());
-                log.error(msg, bse);
-                throw new SecurityException(msg, bse);
+                groupSecurityHandler.removeGroupPrincipal(new GroupPrincipalImpl(groupName));
+//              TODO: should we use cascading deletes?
+                attributesProvider.deleteAttributes(gp);
             }
         }
     }
@@ -193,69 +128,41 @@
     /**
      * @see org.apache.jetspeed.security.GroupManager#groupExists(java.lang.String)
      */
-    public boolean groupExists(String groupFullPathName)
+    public boolean groupExists(String groupName)
     {
-        ArgUtil.notNull(new Object[]
-        { groupFullPathName}, new String[]
-        { "groupFullPathName"}, "groupExists(java.lang.String)");
-
-        Principal principal = groupSecurityHandler
-                .getGroupPrincipal(groupFullPathName);
+        Principal principal = groupSecurityHandler.getGroupPrincipal(groupName);
         boolean groupExists = (null != principal);
-        if (log.isDebugEnabled())
-        {
-            log.debug("Role exists: " + groupExists);
-            log.debug("Role: " + groupFullPathName);
-        }
         return groupExists;
     }
 
     /**
      * @see org.apache.jetspeed.security.GroupManager#getGroup(java.lang.String)
      */
-    public Group getGroup(String groupFullPathName) throws SecurityException
+    public Group getGroup(String groupName) throws SecurityException
     {
-        ArgUtil.notNull(new Object[]
-        { groupFullPathName}, new String[]
-        { "groupFullPathName"}, "getGroup(java.lang.String)");
-
-        String fullPath = GroupPrincipalImpl
-                .getFullPathFromPrincipalName(groupFullPathName);
-
-        Principal groupPrincipal = groupSecurityHandler
-                .getGroupPrincipal(groupFullPathName);
-        if (null == groupPrincipal) { 
+        Principal groupPrincipal = groupSecurityHandler.getGroupPrincipal(groupName);
+        if (null == groupPrincipal) 
+        { 
             throw new SecurityException(
-                SecurityException.GROUP_DOES_NOT_EXIST.create(groupFullPathName)); 
+                SecurityException.GROUP_DOES_NOT_EXIST.create(groupName)); 
         }
-        Preferences preferences = Preferences.userRoot().node(fullPath);
-        Group group = new GroupImpl(groupPrincipal, preferences);
+        SecurityAttributes attributes = this.attributesProvider.retrieveAttributes(groupPrincipal);
+        Group group = new GroupImpl(groupPrincipal, attributes);
         return group;
     }
 
     /**
      * @see org.apache.jetspeed.security.GroupManager#getGroupsForUser(java.lang.String)
      */
-    public Collection getGroupsForUser(String username)
+    public Collection<Group> getGroupsForUser(String userName)
             throws SecurityException
     {
-        ArgUtil.notNull(new Object[]
-        { username}, new String[]
-        { "username"}, "getGroupsForUser(java.lang.String)");
-
-        Collection groups = new ArrayList();
-
-        Set groupPrincipals = securityMappingHandler
-                .getGroupPrincipals(username);
-        Iterator groupPrincipalsIter = groupPrincipals.iterator();
-        while (groupPrincipalsIter.hasNext())
+        Collection<Group> groups = new ArrayList<Group>();
+        Set<GroupPrincipal> groupPrincipals = securityMappingHandler.getGroupPrincipals(userName);
+        for (GroupPrincipal groupPrincipal : groupPrincipals)
         {
-            Principal groupPrincipal = (Principal) groupPrincipalsIter.next();
-            Preferences preferences = Preferences.userRoot().node(
-                    GroupPrincipalImpl
-                            .getFullPathFromPrincipalName(groupPrincipal
-                                    .getName()));
-            groups.add(new GroupImpl(groupPrincipal, preferences));
+            SecurityAttributes attributes = this.attributesProvider.retrieveAttributes(groupPrincipal);
+            groups.add(new GroupImpl(groupPrincipal, attributes));
         }
         return groups;
     }
@@ -263,26 +170,15 @@
     /**
      * @see org.apache.jetspeed.security.GroupManager#getGroupsInRole(java.lang.String)
      */
-    public Collection getGroupsInRole(String roleFullPathName)
+    public Collection<Group> getGroupsInRole(String roleName)
             throws SecurityException
     {
-        ArgUtil.notNull(new Object[]
-        { roleFullPathName}, new String[]
-        { "roleFullPathName"}, "getGroupsInRole(java.lang.String)");
-
-        Collection groups = new ArrayList();
-
-        Set groupPrincipals = securityMappingHandler
-                .getGroupPrincipalsInRole(roleFullPathName);
-        Iterator groupPrincipalsIter = groupPrincipals.iterator();
-        while (groupPrincipalsIter.hasNext())
+        Collection<Group> groups = new ArrayList<Group>();
+        Set<GroupPrincipal> groupPrincipals = securityMappingHandler.getGroupPrincipalsInRole(roleName);
+        for (GroupPrincipal groupPrincipal : groupPrincipals)
         {
-            Principal groupPrincipal = (Principal) groupPrincipalsIter.next();
-            Preferences preferences = Preferences.userRoot().node(
-                    GroupPrincipalImpl
-                            .getFullPathFromPrincipalName(groupPrincipal
-                                    .getName()));
-            groups.add(new GroupImpl(groupPrincipal, preferences));
+            SecurityAttributes attributes = this.attributesProvider.retrieveAttributes(groupPrincipal);
+            groups.add(new GroupImpl(groupPrincipal, attributes));
         }
         return groups;
     }
@@ -291,30 +187,23 @@
      * @see org.apache.jetspeed.security.GroupManager#addUserToGroup(java.lang.String,
      *      java.lang.String)
      */
-    public void addUserToGroup(String username, String groupFullPathName)
+    public void addUserToGroup(String username, String groupName)
             throws SecurityException
     {
-        ArgUtil.notNull(new Object[]
-        { username, groupFullPathName}, new String[]
-        { "username", "groupFullPathName"},
-                "addUserToGroup(java.lang.String, java.lang.String)");
-
-        // Get the group principal to add to user.
-        GroupPrincipal groupPrincipal = groupSecurityHandler.getGroupPrincipal(groupFullPathName);
-        if (null == groupPrincipal) { 
-            throw new SecurityException(SecurityException.GROUP_DOES_NOT_EXIST.create(groupFullPathName)); 
+        GroupPrincipal groupPrincipal = groupSecurityHandler.getGroupPrincipal(groupName);
+        if (null == groupPrincipal) 
+        { 
+            throw new SecurityException(SecurityException.GROUP_DOES_NOT_EXIST.create(groupName)); 
         }
-        // Check that user exists.
         Principal userPrincipal = atnProviderProxy.getUserPrincipal(username);
-        if (null == userPrincipal) { 
+        if (null == userPrincipal) 
+        { 
             throw new SecurityException(SecurityException.USER_DOES_NOT_EXIST.create(username));
         }
-        // Get the user groups.
-        Set groupPrincipals = securityMappingHandler.getGroupPrincipals(username);
-        // Add group to user.
+        Set<GroupPrincipal> groupPrincipals = securityMappingHandler.getGroupPrincipals(username);
         if (!groupPrincipals.contains(groupPrincipal))
         {
-            securityMappingHandler.setUserPrincipalInGroup(username,groupFullPathName);
+            securityMappingHandler.setUserPrincipalInGroup(username, groupName);
         }
     }
 
@@ -322,26 +211,18 @@
      * @see org.apache.jetspeed.security.GroupManager#removeUserFromGroup(java.lang.String,
      *      java.lang.String)
      */
-    public void removeUserFromGroup(String username, String groupFullPathName)
+    public void removeUserFromGroup(String username, String groupName)
             throws SecurityException
     {
-        ArgUtil.notNull(new Object[]
-        { username, groupFullPathName}, new String[]
-        { "username", "groupFullPathName"},
-                "removeUserFromGroup(java.lang.String, java.lang.String)");
-
-        // Check that user exists.
         Principal userPrincipal = atnProviderProxy.getUserPrincipal(username);
-        if (null == userPrincipal) { 
+        if (null == userPrincipal) 
+        { 
             throw new SecurityException(SecurityException.USER_DOES_NOT_EXIST.create(username));
         }
-        // Get the group principal to remove.
-        Principal groupPrincipal = groupSecurityHandler
-                .getGroupPrincipal(groupFullPathName);
+        Principal groupPrincipal = groupSecurityHandler.getGroupPrincipal(groupName);
         if (null != groupPrincipal)
         {
-            securityMappingHandler.removeUserPrincipalInGroup(username,
-                    groupFullPathName);
+            securityMappingHandler.removeUserPrincipalInGroup(username, groupName);
         }
     }
 
@@ -349,19 +230,12 @@
      * @see org.apache.jetspeed.security.GroupManager#isUserInGroup(java.lang.String,
      *      java.lang.String)
      */
-    public boolean isUserInGroup(String username, String groupFullPathName)
+    public boolean isUserInGroup(String username, String groupName)
             throws SecurityException
     {
-        ArgUtil.notNull(new Object[]
-        { username, groupFullPathName}, new String[]
-        { "username", "groupFullPathName"},
-                "isUserInGroup(java.lang.String, java.lang.String)");
-
         boolean isUserInGroup = false;
-
-        Set groupPrincipals = securityMappingHandler
-                .getGroupPrincipals(username);
-        Principal groupPrincipal = new GroupPrincipalImpl(groupFullPathName);
+        Set<GroupPrincipal> groupPrincipals = securityMappingHandler.getGroupPrincipals(username);
+        Principal groupPrincipal = new GroupPrincipalImpl(groupName);
         if (groupPrincipals.contains(groupPrincipal))
         {
             isUserInGroup = true;
@@ -372,36 +246,33 @@
     /**
      * @see org.apache.jetspeed.security.GroupManager#getGroups(java.lang.String)
      */
-    public Iterator getGroups(String filter) throws SecurityException
+    public Collection<Group> getGroups(String filter) throws SecurityException
     {
-        List groups = new LinkedList();
-        Iterator groupPrincipals = groupSecurityHandler.getGroupPrincipals(filter).iterator();
-        while (groupPrincipals.hasNext())
+        List<Group> groups = new LinkedList<Group>();
+        Collection<GroupPrincipal> groupPrincipals = groupSecurityHandler.getGroupPrincipals(filter);
+        for (GroupPrincipal principal : groupPrincipals)
         {
-            String groupName = ((Principal) groupPrincipals.next()).getName();
-            Group group = getGroup(groupName);
+            SecurityAttributes attributes = this.attributesProvider.retrieveAttributes(principal);
+            Group group = new GroupImpl(principal, attributes);
             groups.add(group);
         }
-        return groups.iterator();
+        return groups;
     }
     
     /**
      * @see org.apache.jetspeed.security.GroupManager#setGroupEnabled(java.lang.String, boolean)
      */
-    public void setGroupEnabled(String groupFullPathName, boolean enabled) throws SecurityException
+    public void setGroupEnabled(String groupName, boolean enabled) throws SecurityException
     {
-        ArgUtil.notNull(new Object[] { groupFullPathName }, new String[] { "groupFullPathName" },
-                "setGroupEnabled(java.lang.String,boolean)");
-
-        GroupPrincipalImpl groupPrincipal = (GroupPrincipalImpl)groupSecurityHandler.getGroupPrincipal(groupFullPathName);
+        GroupPrincipalImpl groupPrincipal = (GroupPrincipalImpl)groupSecurityHandler.getGroupPrincipal(groupName);
         if (null == groupPrincipal)
         {
-            throw new SecurityException(SecurityException.GROUP_DOES_NOT_EXIST.create(groupFullPathName));
+            throw new SecurityException(SecurityException.GROUP_DOES_NOT_EXIST.create(groupName));
         }
         if ( enabled != groupPrincipal.isEnabled() )
         {
             groupPrincipal.setEnabled(enabled);
-            groupSecurityHandler.setGroupPrincipal(groupPrincipal);
+            groupSecurityHandler.storeGroupPrincipal(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/impl/GroupPrincipalImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/GroupPrincipalImpl.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/impl/GroupPrincipalImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/GroupPrincipalImpl.java Wed Aug  6 20:52:05 2008
@@ -25,30 +25,22 @@
  */
 public class GroupPrincipalImpl extends BasePrincipalImpl implements GroupPrincipal
 {
-
     /** The serial version uid. */
     private static final long serialVersionUID = 6061115481776568899L;
 
-    private static boolean hiearchicalNames = true;
-
-    public static final Object useHierarchicalNames(boolean hierarchicalNames)
+    public GroupPrincipalImpl(String name)
     {
-        GroupPrincipalImpl.hiearchicalNames = hierarchicalNames;
-        return null;
+        super(name);
     }
     
-    /**
-     * <p>The group principal constructor.</p>
-     * @param groupName The group principal name.
-     */
-    public GroupPrincipalImpl(String groupName)
+    public GroupPrincipalImpl(long id, String groupName)
     {
-        super(groupName, PREFS_GROUP_ROOT, hiearchicalNames);
+        this(id, groupName, true, false);
     }
 
-    public GroupPrincipalImpl(String groupName, boolean isEnabled, boolean isMapping)
+    public GroupPrincipalImpl(long id, String groupName, boolean isEnabled, boolean isMapping)
     {
-        super(groupName, PREFS_GROUP_ROOT, hiearchicalNames, isEnabled, isMapping);
+        super(id, groupName, isEnabled, isMapping);
     }
     
     /**
@@ -67,32 +59,5 @@
         GroupPrincipalImpl principal = (GroupPrincipalImpl)another;
         return this.getName().equals(principal.getName());
     }
-
-    /**
-     * <p>Gets the principal implementation full path from the principal name.</p>
-     * <p>Prepends PREFS_GROUP_ROOT if not prepended.</p>        
-     * @param name The principal name.
-     * @return The preferences full path / principal name.
-     */
-    public static String getFullPathFromPrincipalName(String name)
-    {
-        return BasePrincipalImpl.getFullPathFromPrincipalName(name, PREFS_GROUP_ROOT, hiearchicalNames);
-    }
-
-    /**
-     * <p>Gets the principal name from the principal implementation full path.</p>
-     * <p>Remove prepended PREFS_GROUP_ROOT if present.</p>        
-     * @param fullPath The principal full path.
-     * @return The principal name.
-     */
-    public static String getPrincipalNameFromFullPath(String fullPath)
-    {
-        return BasePrincipalImpl.getPrincipalNameFromFullPath(fullPath, PREFS_GROUP_ROOT, hiearchicalNames);
-    }
-
-    public static String getFullPathFromPrincipalName(String name, String prefsRoot)    
-    {
-        return BasePrincipalImpl.getFullPathFromPrincipalName(name, prefsRoot, hiearchicalNames);
-    }
     
 }

Modified: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/PermissionManagerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/PermissionManagerImpl.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/impl/PermissionManagerImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/PermissionManagerImpl.java Wed Aug  6 20:52:05 2008
@@ -81,90 +81,79 @@
 public class PermissionManagerImpl extends PersistenceBrokerDaoSupport implements PermissionManager 
 {
     private static final Log log = LogFactory.getLog(PermissionManagerImpl.class);
-    private static ThreadLocal permissionsCache = new ThreadLocal();
+    private static ThreadLocal<HashMap<String, HashSet<Permission>>> permissionsCache 
+        = new ThreadLocal<HashMap<String, HashSet<Permission>>>();
     
     /**
      * @see org.apache.jetspeed.security.PermissionManager#getPermissions(java.security.Principal)
      */
     public Permissions getPermissions(Principal principal)
     {        
-        String fullPath = SecurityHelper.getPreferencesFullPath(principal);
-        ArgUtil.notNull(new Object[] { fullPath }, new String[] { "fullPath" },
-                "removePermission(java.security.Principal)");
-
-        HashMap permissionsMap = (HashMap)permissionsCache.get();
+        HashMap<String, HashSet<Permission>> permissionsMap = permissionsCache.get();
         if ( permissionsMap == null )
         {
-            permissionsMap = new HashMap();
+            permissionsMap = new HashMap<String, HashSet<Permission>>();
             permissionsCache.set(permissionsMap);
         }
-        HashSet principalPermissions = (HashSet)permissionsMap.get(fullPath);
+        HashSet<Permission> principalPermissions = permissionsMap.get(principal.getName());
         if ( principalPermissions == null )
         {
-            InternalPrincipal internalPrincipal = getInternalPrincipal(fullPath);
+            InternalPrincipal internalPrincipal = getInternalPrincipal(principal.getName());
             if (null != internalPrincipal)
             {
                 principalPermissions = getSecurityPermissions(internalPrincipal.getPermissions());
             }
             if ( principalPermissions == null)
             {
-                principalPermissions = new HashSet();
+                principalPermissions = new HashSet<Permission>();
             }
-            permissionsMap.put(fullPath, principalPermissions);
+            permissionsMap.put(principal.getName(), principalPermissions);
         }
         
         Permissions permissions = new Permissions();
-        Iterator iter =principalPermissions.iterator();
-        while (iter.hasNext())
+        for (Permission p : principalPermissions)
         {
-            permissions.add((Permission)iter.next());
+            permissions.add(p);
         }
-        
         return permissions;
     }
 
     /**
      * @see org.apache.jetspeed.security.PermissionManager#getPermissions(java.util.Collection)
      */
-    public Permissions getPermissions(Collection principals)
+    public Permissions getPermissions(Collection<Principal> principals)
     {
-        ArgUtil.notNull(new Object[] { principals }, new String[] { "principals" },
-                "getPermissions(java.util.Collection)");
-
         Permissions permissions = new Permissions();
-        Collection principalsFullPath = getPrincipalsFullPath(principals);
-        if ((null != principalsFullPath) && principalsFullPath.size() > 0)
+        if ((null != principals) && principals.size() > 0)
         {
-            HashSet permissionsSet = new HashSet();
-            HashMap permissionsMap = (HashMap)permissionsCache.get();
+            HashSet<Permission> permissionsSet = new HashSet<Permission>();
+            HashMap<String, HashSet<Permission>> permissionsMap = permissionsCache.get();
             if (permissionsMap == null)
             {
-                permissionsMap = new HashMap();
+                permissionsMap = new HashMap<String, HashSet<Permission>>();
                 permissionsCache.set(permissionsMap);
-            }
-            
-            Iterator iter = principalsFullPath.iterator();
-            HashSet principalPermissions;
-            while ( iter.hasNext())
+            }            
+            Iterator<Principal> iter = principals.iterator();
+            HashSet<Permission> principalPermissions;
+            while (iter.hasNext())
+            for (Principal p : principals)
             {
-                principalPermissions = (HashSet)permissionsMap.get(iter.next());
+                principalPermissions = permissionsMap.get(iter.next());
                 if ( principalPermissions != null )
                 {
                     iter.remove();
                     permissionsSet.addAll(principalPermissions);
                 }
             }
-            if ( principalsFullPath.size() > 0)
+            if ( principals.size() > 0)
             {
                 Criteria filter = new Criteria();
-                filter.addIn("fullPath", principalsFullPath);
+                filter.addIn("name", principals);
                 Query query = QueryFactory.newQuery(InternalPrincipalImpl.class, filter);
-                Collection internalPrincipals = getPersistenceBrokerTemplate().getCollectionByQuery(query);
-                Iterator internalPrincipalsIter = internalPrincipals.iterator();
-                while (internalPrincipalsIter.hasNext())
+                Collection<InternalPrincipal> internalPrincipals = getPersistenceBrokerTemplate().getCollectionByQuery(query);
+                for (InternalPrincipal internalPrincipal : internalPrincipals)
                 {
-                    InternalPrincipal internalPrincipal = (InternalPrincipal) internalPrincipalsIter.next();
-                    Collection internalPermissions = internalPrincipal.getPermissions();
+                    Collection<InternalPermission> internalPermissions = internalPrincipal.getPermissions();
                     if (null != internalPermissions)
                     {
                         principalPermissions = getSecurityPermissions(internalPermissions);
@@ -172,15 +161,14 @@
                     }
                     else
                     {
-                        principalPermissions = new HashSet();
+                        principalPermissions = new HashSet<Permission>();
                     }
-                    permissionsMap.put(internalPrincipal.getFullPath(),principalPermissions);
+                    permissionsMap.put(internalPrincipal.getName(), principalPermissions);
                 }
             }
-            iter = permissionsSet.iterator();
-            while (iter.hasNext())
+            for (Permission permission : permissionsSet)
             {
-                permissions.add((Permission)iter.next());
+                permissions.add(permission);
             }
         }
         return permissions;
@@ -188,43 +176,18 @@
 
     /**
      * <p>
-     * Get the full path for the {@link Principal}in the collection.
-     * </p>
-     * 
-     * @param principals The collection of principals.
-     * @return The collection of principals names.
-     */
-    private Collection getPrincipalsFullPath(Collection principals)
-    {
-        Collection principalsFullPath = new ArrayList();
-        Iterator principalsIterator = principals.iterator();
-        while (principalsIterator.hasNext())
-        {
-            Principal principal = (Principal) principalsIterator.next();
-            String fullPath = SecurityHelper.getPreferencesFullPath(principal);
-            if (null != fullPath)
-            {
-                principalsFullPath.add(fullPath);
-            }
-        }
-        return principalsFullPath;
-    }
-
-    /**
-     * <p>
      * Iterate through a collection of {@link InternalPermission}and build a
      * unique collection of {@link java.security.Permission}.
      * </p>
      * 
      * @param omPermissions The collection of {@link InternalPermission}.
      */
-    private HashSet getSecurityPermissions(Collection omPermissions)
+    @SuppressWarnings("unchecked")
+    private HashSet<Permission> getSecurityPermissions(Collection<InternalPermission> omPermissions)
     {     
-        HashSet permissions = new HashSet();
-        Iterator internalPermissionsIter = omPermissions.iterator();
-        while (internalPermissionsIter.hasNext())
+        HashSet<Permission> permissions = new HashSet<Permission>();
+        for (InternalPermission internalPermission : omPermissions)
         {
-            InternalPermission internalPermission = (InternalPermission) internalPermissionsIter.next();
             Permission permission = null;
             try
             {
@@ -255,9 +218,6 @@
      */
     public void addPermission(Permission permission) throws SecurityException
     {
-        ArgUtil.notNull(new Object[] { permission }, new String[] { "permission" },
-                "addPermission(java.security.Permission)");
-
         InternalPermission internalPermission = new InternalPermissionImpl(permission.getClass().getName(), permission
                 .getName(), permission.getActions());
         try
@@ -278,9 +238,6 @@
      */
     public void removePermission(Permission permission) throws SecurityException
     {
-        ArgUtil.notNull(new Object[] { permission }, new String[] { "permission" },
-                "removePermission(java.security.Permission)");
-
         InternalPermission internalPermission = getInternalPermission(permission);
         if (null != internalPermission)
         {
@@ -306,15 +263,11 @@
      */
     public void removePermissions(Principal principal) throws SecurityException
     {
-        String fullPath = SecurityHelper.getPreferencesFullPath(principal);
-        ArgUtil.notNull(new Object[] { fullPath }, new String[] { "fullPath" },
-                "removePermission(java.security.Principal)");
-
         // Remove permissions on principal.
-        InternalPrincipal internalPrincipal = getInternalPrincipal(fullPath);
+        InternalPrincipal internalPrincipal = getInternalPrincipal(principal.getName());
         if (null != internalPrincipal)
         {
-            Collection internalPermissions = internalPrincipal.getPermissions();
+            Collection<InternalPermission> internalPermissions = internalPrincipal.getPermissions();
             if (null != internalPermissions)
             {
                 internalPermissions.clear();
@@ -344,13 +297,8 @@
      */
     public void grantPermission(Principal principal, Permission permission) throws SecurityException
     {
-        String fullPath = SecurityHelper.getPreferencesFullPath(principal);
-        ArgUtil.notNull(new Object[] { fullPath, permission }, new String[] { "fullPath", "permission" },
-                "grantPermission(java.security.Principal, java.security.Permission)");
-
-        Collection internalPermissions = new ArrayList();
-
-        InternalPrincipal internalPrincipal = getInternalPrincipal(fullPath);
+        Collection<InternalPermission> internalPermissions = new ArrayList<InternalPermission>();
+        InternalPrincipal internalPrincipal = getInternalPrincipal(principal.getName());
         if (null == internalPrincipal)
         {
             if ( principal instanceof UserPrincipal )
@@ -416,23 +364,17 @@
      */
     public void revokePermission(Principal principal, Permission permission) throws SecurityException
     {
-        String fullPath = SecurityHelper.getPreferencesFullPath(principal);
-        ArgUtil.notNull(new Object[] { fullPath, permission }, new String[] { "fullPath", "permission" },
-                "revokePermission(java.security.Principal, java.security.Permission)");
-
         // Remove permissions on principal.
-        InternalPrincipal internalPrincipal = getInternalPrincipal(fullPath);
+        InternalPrincipal internalPrincipal = getInternalPrincipal(principal.getName());
         if (null != internalPrincipal)
         {
-            Collection internalPermissions = internalPrincipal.getPermissions();
+            Collection<InternalPermission> internalPermissions = internalPrincipal.getPermissions();
             if (null != internalPermissions)
             {
                 boolean revokePermission = false;
-                ArrayList newInternalPermissions = new ArrayList();
-                Iterator internalPermissionsIter = internalPermissions.iterator();
-                while (internalPermissionsIter.hasNext())
+                ArrayList<InternalPermission> newInternalPermissions = new ArrayList<InternalPermission>();
+                for (InternalPermission internalPermission : internalPermissions)
                 {
-                    InternalPermission internalPermission = (InternalPermission) internalPermissionsIter.next();
                     if (!((internalPermission.getClassname().equals(permission.getClass().getName()))
                             && (internalPermission.getName().equals(permission.getName())) && (internalPermission.getActions()
                             .equals(permission.getActions()))))
@@ -472,13 +414,13 @@
      * Returns the {@link InternalPrincipal}from the full path.
      * </p>
      * 
-     * @param fullPath The full path.
+     * @param name The full path.
      * @return The {@link InternalPrincipal}.
      */
-    InternalPrincipal getInternalPrincipal(String fullPath)
+    InternalPrincipal getInternalPrincipal(String name)
     {
         Criteria filter = new Criteria();
-        filter.addEqualTo("fullPath", fullPath);
+        filter.addEqualTo("name", name);
         Query query = QueryFactory.newQuery(InternalPrincipalImpl.class, filter);
         InternalPrincipal internalPrincipal = (InternalPrincipal) getPersistenceBrokerTemplate().getObjectByQuery(query);
         return internalPrincipal;
@@ -524,29 +466,29 @@
         return true;         
     }
     
-    public Collection getPermissions()
+    @SuppressWarnings("unchecked")
+    public Collection<InternalPermission> getInternalPermissions()
     {
         QueryByCriteria query = QueryFactory.newQuery(InternalPermissionImpl.class, new Criteria());
         query.addOrderByAscending("classname");
         query.addOrderByAscending("name");
-        Collection internalPermissions = getPersistenceBrokerTemplate().getCollectionByQuery(query);
+        Collection<InternalPermission> internalPermissions = getPersistenceBrokerTemplate().getCollectionByQuery(query);
         return internalPermissions;
     }
     
+    @SuppressWarnings("unchecked")
     public Permissions getPermissions(String classname, String resource)
     {
         Criteria filter = new Criteria();
         filter.addEqualTo("classname", classname);
         filter.addEqualTo("name", resource);
         Query query = QueryFactory.newQuery(InternalPermissionImpl.class, filter);
-        Collection internalPermissions = getPersistenceBrokerTemplate().getCollectionByQuery(query);        
+        Collection<InternalPermission> internalPermissions = getPersistenceBrokerTemplate().getCollectionByQuery(query);        
         Permissions permissions = new Permissions();
-        Iterator iter = internalPermissions.iterator();
         try
         {
-            while (iter.hasNext())
+            for (InternalPermission internalPermission : internalPermissions)
             {
-                InternalPermission internalPermission = (InternalPermission)iter.next();
                 Class permissionClass = Class.forName(internalPermission.getClassname());
                 Class[] parameterTypes = { String.class, String.class };
                 Constructor permissionConstructor = permissionClass.getConstructor(parameterTypes);
@@ -562,18 +504,15 @@
         return permissions;        
     }    
     
-    public int updatePermission(Permission permission, Collection principals)
+    public int updatePermission(Permission permission, Collection<Principal> principals)
     throws SecurityException
     {
         int count = 0;
         InternalPermission internal = getInternalPermission(permission);
-        Iterator iter = principals.iterator();
-        Collection newPrincipals = new LinkedList();
-        while (iter.hasNext())
-        {
-            Principal principal = (Principal)iter.next();
-            String fullPath = SecurityHelper.getPreferencesFullPath(principal);
-            InternalPrincipal internalPrincipal = getInternalPrincipal(fullPath);
+        Collection<InternalPrincipal> newPrincipals = new LinkedList<InternalPrincipal>();
+        for (Principal principal : principals)
+        {
+            InternalPrincipal internalPrincipal = getInternalPrincipal(principal.getName());
             newPrincipals.add(internalPrincipal);            
         }
         internal.setPrincipals(newPrincipals);
@@ -589,28 +528,22 @@
             logger.error(msg, e);            
             throw new SecurityException(msg, e);
         }
-
         return count;
     }
     
-    public Collection getPrincipals(Permission permission)
+    public Collection<Principal> getPrincipals(Permission permission)
     {
-        Collection result = new LinkedList();        
+        Collection<Principal> result = new LinkedList<Principal>();        
         InternalPermission internalPermission = this.getInternalPermission(permission);
         if (internalPermission == null)
         {
             return result;
         }
-        Iterator principals = internalPermission.getPrincipals().iterator();
-        while (principals.hasNext())
-        {
-            InternalPrincipal internalPrincipal = (InternalPrincipal)principals.next();            
-            Principal principal = 
-                SecurityHelper.createPrincipalFromFullPath(internalPrincipal.getFullPath());
+        for (InternalPrincipal internalPrincipal : internalPermission.getPrincipals())
+        {
+            Principal principal = SecurityHelper.createPrincipalFromInternal(internalPrincipal); 
             result.add(principal);
         }
         return  result;
     }
-    
-    
 }

Modified: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/PrincipalsSet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/PrincipalsSet.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/impl/PrincipalsSet.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/PrincipalsSet.java Wed Aug  6 20:52:05 2008
@@ -16,12 +16,13 @@
 */
 package org.apache.jetspeed.security.impl;
 
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
+import java.security.Principal;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
 
 
 /**
@@ -32,10 +33,10 @@
  * @version $Id: $
  */
 
-public class PrincipalsSet implements Set
+public class PrincipalsSet implements Set<Principal>
 {
-    List principals = new LinkedList();
-    Set set = new HashSet();
+    List<Principal> principals = new LinkedList<Principal>();
+    Set<Principal> set = new HashSet<Principal>();
 
     public PrincipalsSet()
     {}
@@ -65,18 +66,20 @@
         return principals.isEmpty();
     }
 
-    /* (non-Javadoc)
-     * @see java.util.Collection#toArray()
-     */
-    public Object[] toArray()
-    {
-        return principals.toArray();
-    }
-
+    public <T> T[] toArray(T[] a)
+    {
+        return principals.toArray(a);
+    }
+
+    public Object[] toArray()
+    {
+        return principals.toArray();
+    }
+    
     /* (non-Javadoc)
      * @see java.util.Collection#add(java.lang.Object)
      */
-    public boolean add(Object o)
+    public boolean add(Principal o)
     {
         if (set.add(o))
         {
@@ -93,7 +96,7 @@
     {
         return set.contains(o);
     }
-
+    
     /* (non-Javadoc)
      * @see java.util.Collection#remove(java.lang.Object)
      */
@@ -102,20 +105,11 @@
         set.remove(o);
         return principals.remove(o);
     }
-
-    /* (non-Javadoc)
-     * @see java.util.Collection#addAll(java.util.Collection)
-     */
-    public boolean addAll(Collection c)
-    {
-        set.addAll(c);
-        return principals.addAll(c);
-    }
-
+    
     /* (non-Javadoc)
      * @see java.util.Collection#containsAll(java.util.Collection)
      */
-    public boolean containsAll(Collection c)
+    public boolean containsAll(Collection<?> c)
     {
         return set.containsAll(c);
     }
@@ -123,7 +117,7 @@
     /* (non-Javadoc)
      * @see java.util.Collection#removeAll(java.util.Collection)
      */
-    public boolean removeAll(Collection c)
+    public boolean removeAll(Collection<?> c)
     {
         set.removeAll(c);
         return principals.removeAll(c);
@@ -132,7 +126,7 @@
     /* (non-Javadoc)
      * @see java.util.Collection#retainAll(java.util.Collection)
      */
-    public boolean retainAll(Collection c)
+    public boolean retainAll(Collection<?> c)
     {
         set.retainAll(c);
         return principals.retainAll(c);
@@ -141,17 +135,15 @@
     /* (non-Javadoc)
      * @see java.util.Collection#iterator()
      */
-    public Iterator iterator()
+    public Iterator<Principal> iterator()
     {
         return principals.iterator();
-    }
-
-    /* (non-Javadoc)
-     * @see java.util.Collection#toArray(java.lang.Object[])
-     */
-    public Object[] toArray(Object[] a)
-    {
-        return principals.toArray(a);
-    }
-
+    }
+
+    public boolean addAll(Collection<? extends Principal> c)
+    {
+        set.addAll(c);
+        return principals.addAll(c);
+    }
+
 }

Added: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/RemotePrincipalImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/RemotePrincipalImpl.java?rev=683497&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/RemotePrincipalImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/RemotePrincipalImpl.java Wed Aug  6 20:52:05 2008
@@ -0,0 +1,59 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.security.impl;
+
+import org.apache.jetspeed.security.RemotePrincipal;
+
+
+public class RemotePrincipalImpl extends BasePrincipalImpl implements
+        RemotePrincipal
+{
+    private static final long serialVersionUID = 8920767857498863854L;
+
+    public RemotePrincipalImpl(String remoteName)
+    {
+        super(remoteName);
+    }
+    
+    public RemotePrincipalImpl(long id, String remoteName)
+    {
+        this(id, remoteName, true, false);
+    }
+        
+    public RemotePrincipalImpl(long id, String remoteName, boolean isEnabled, boolean isMapping)
+    {
+        super(id, remoteName, isEnabled, isMapping);
+    }
+    
+    /**
+     * <p>Compares this principal to the specified object.  Returns true
+     * if the object passed in matches the principal represented by
+     * the implementation of this interface.</p>
+     * @param another Principal to compare with.
+     * @return True if the principal passed in is the same as that
+     * encapsulated by this principal, and false otherwise.
+
+     */
+    public boolean equals(Object another)
+    {
+        if (!(another instanceof RemotePrincipalImpl))
+            return false;
+        RemotePrincipalImpl principal = (RemotePrincipalImpl) another;
+        return this.getName().equals(principal.getName());
+    }
+
+}

Modified: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/RoleImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/RoleImpl.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/impl/RoleImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/RoleImpl.java Wed Aug  6 20:52:05 2008
@@ -17,17 +17,19 @@
 package org.apache.jetspeed.security.impl;
 
 import java.security.Principal;
-import java.util.prefs.Preferences;
-
 import org.apache.jetspeed.security.Role;
+import org.apache.jetspeed.security.attributes.SecurityAttributes;
 
 /**
- * <p>A role made of a {@link Principal} and the user {@link Preferences}.</p>
+ * <p>Represents a security 'role' made of a {@link org.apache.jetspeed.security.RolePrincipal} and security attributes.</p>
+ * <p>Modified 2008-08-05 - DST - decoupled java preferences</p> 
  * @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
  */
 public class RoleImpl implements Role
 {
-
+    private Principal rolePrincipal;
+    private SecurityAttributes attributes;
+    
     /**
      * <p>Default constructor.</p>
      */
@@ -36,17 +38,16 @@
     }
 
     /**
-     * <p>{@link Role} constructor given a role principal and preferences.</p>
+     * <p>{@link Role} constructor given a role principal and its security attributes.</p>
      * @param rolePrincipal The role principal.
-     * @param preferences The preferences.
+     * @param attributes The security attributes.
      */
-    public RoleImpl(Principal rolePrincipal, Preferences preferences)
+    public RoleImpl(Principal rolePrincipal, SecurityAttributes attributes)
     {
         this.rolePrincipal = rolePrincipal;
-        this.preferences = preferences;
+        this.attributes = attributes;
     }
 
-    private Principal rolePrincipal;
     
     /**
      * @see org.apache.jetspeed.security.Role#getPrincipal()
@@ -64,22 +65,14 @@
         this.rolePrincipal = rolePrincipal;
     }
 
-    private Preferences preferences;
-
-    /**
-     * @see org.apache.jetspeed.security.Role#getPreferences()
-     */
-    public Preferences getPreferences()
+    public SecurityAttributes getAttributes()
     {
-        return this.preferences;
+        return this.attributes;
     }
 
-    /**
-     * @see org.apache.jetspeed.security.Role#setPreferences(java.util.prefs.Preferences)
-     */
-    public void setPreferences(Preferences preferences)
+    public void setAttributes(SecurityAttributes attributes)
     {
-        this.preferences = preferences;
+        this.attributes = attributes;
     }
 
 }



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