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 2005/10/15 18:35:17 UTC

svn commit: r321370 - in /portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security: SecurityHelper.java impl/PrincipalsSet.java impl/UserManagerImpl.java

Author: taylor
Date: Sat Oct 15 09:35:14 2005
New Revision: 321370

URL: http://svn.apache.org/viewcvs?rev=321370&view=rev
Log:
ordered principal set implementation
user-role-fallback rule requires a ordered list of role principals (set) in the subject

Added:
    portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/PrincipalsSet.java
Modified:
    portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/SecurityHelper.java
    portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/UserManagerImpl.java

Modified: portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/SecurityHelper.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/SecurityHelper.java?rev=321370&r1=321369&r2=321370&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/SecurityHelper.java (original)
+++ portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/SecurityHelper.java Sat Oct 15 09:35:14 2005
@@ -28,6 +28,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.security.impl.PrincipalsSet;
 import org.apache.jetspeed.security.impl.GroupPrincipalImpl;
 import org.apache.jetspeed.security.impl.RolePrincipalImpl;
 import org.apache.jetspeed.security.impl.UserPrincipalImpl;
@@ -178,7 +179,7 @@
     public static Subject createSubject(String principalName)
     {
         Principal principal = new UserPrincipalImpl(principalName);
-        Set principals = new HashSet();
+        Set principals = new PrincipalsSet();
         principals.add(principal);
         return new Subject(true, principals, new HashSet(), new HashSet());
     }

Added: portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/PrincipalsSet.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/PrincipalsSet.java?rev=321370&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/PrincipalsSet.java (added)
+++ portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/PrincipalsSet.java Sat Oct 15 09:35:14 2005
@@ -0,0 +1,141 @@
+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;
+
+
+/**
+ * PrincipalsSet - provides an ordered 'set' of principals required
+ * for some profiling rules that are dependent on order of insert.
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: $
+ */
+
+public class PrincipalsSet implements Set
+{
+    List principals = new LinkedList();
+    Set set = new HashSet();
+
+    public PrincipalsSet()
+    {}
+    
+    /* (non-Javadoc)
+     * @see java.util.Collection#size()
+     */
+    public int size()
+    {
+        return principals.size();
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.Collection#clear()
+     */
+    public void clear()
+    {
+        set.clear();
+        principals.clear();
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.Collection#isEmpty()
+     */
+    public boolean isEmpty()
+    {
+        return principals.isEmpty();
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.Collection#toArray()
+     */
+    public Object[] toArray()
+    {
+        return principals.toArray();
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.Collection#add(java.lang.Object)
+     */
+    public boolean add(Object o)
+    {
+        if (set.add(o))
+        {
+            principals.add(o);
+            return true;
+        }
+        return false;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.Collection#contains(java.lang.Object)
+     */
+    public boolean contains(Object o)
+    {
+        return set.contains(o);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.Collection#remove(java.lang.Object)
+     */
+    public boolean remove(Object o)
+    {
+        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)
+    {
+        return set.containsAll(c);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.Collection#removeAll(java.util.Collection)
+     */
+    public boolean removeAll(Collection c)
+    {
+        set.removeAll(c);
+        return principals.removeAll(c);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.Collection#retainAll(java.util.Collection)
+     */
+    public boolean retainAll(Collection c)
+    {
+        set.retainAll(c);
+        return principals.retainAll(c);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.Collection#iterator()
+     */
+    public Iterator iterator()
+    {
+        return principals.iterator();
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.Collection#toArray(java.lang.Object[])
+     */
+    public Object[] toArray(Object[] a)
+    {
+        return principals.toArray(a);
+    }
+
+}

Modified: portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/UserManagerImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/UserManagerImpl.java?rev=321370&r1=321369&r2=321370&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/UserManagerImpl.java (original)
+++ portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/UserManagerImpl.java Sat Oct 15 09:35:14 2005
@@ -331,7 +331,7 @@
             return guest;
         }
         
-        Set principals = new HashSet();
+        Set principals = new PrincipalsSet();
         String fullPath = (new UserPrincipalImpl(username)).getFullPath();
 
         Principal userPrincipal = atnProviderProxy.getUserPrincipal(username);



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