You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by tr...@apache.org on 2005/09/16 11:00:41 UTC

svn commit: r289443 - in /directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl: ACITuple.java ItemFirstACIItem.java ItemPermission.java Permission.java ProtectedItem.java UserFirstACIItem.java UserPermission.java

Author: trustin
Date: Fri Sep 16 02:00:34 2005
New Revision: 289443

URL: http://svn.apache.org/viewcvs?rev=289443&view=rev
Log:
Modified the API as Ersin requested to me.
* No add and remove methods
* All input comes as constructor parameters

Modified:
    directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ACITuple.java
    directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ItemFirstACIItem.java
    directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ItemPermission.java
    directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/Permission.java
    directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ProtectedItem.java
    directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/UserFirstACIItem.java
    directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/UserPermission.java

Modified: directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ACITuple.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ACITuple.java?rev=289443&r1=289442&r2=289443&view=diff
==============================================================================
--- directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ACITuple.java (original)
+++ directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ACITuple.java Fri Sep 16 02:00:34 2005
@@ -19,6 +19,9 @@
 package org.apache.ldap.common.acl;
 
 import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
@@ -27,15 +30,15 @@
 {
     private static final long serialVersionUID = 4353150626941232371L;
 
-    private final Set userClasses;
+    private final Collection userClasses;
     private final AuthenticationLevel authenticationLevel;
-    private final Set protectedItems;
+    private final Collection protectedItems;
     private final Set grantsAndDenials;
     private final int precedence;
     
     public ACITuple(
-            Set userClasses, AuthenticationLevel authenticationLevel,
-            Set protectedItems, Set grantsAndDenials, int precedence )
+            Collection userClasses, AuthenticationLevel authenticationLevel,
+            Collection protectedItems, Set grantsAndDenials, int precedence )
     {
         for( Iterator i = userClasses.iterator(); i.hasNext(); )
         {
@@ -74,16 +77,16 @@
             throw new IllegalArgumentException( "precedence: " + precedence );
         }
         
-        this.userClasses = new HashSet( userClasses );
+        this.userClasses = Collections.unmodifiableCollection( new ArrayList( userClasses ) );
         this.authenticationLevel = authenticationLevel;
-        this.protectedItems = new HashSet( protectedItems );
-        this.grantsAndDenials = new HashSet( grantsAndDenials );
+        this.protectedItems = Collections.unmodifiableCollection( new ArrayList( protectedItems ) );
+        this.grantsAndDenials = Collections.unmodifiableSet( new HashSet( grantsAndDenials ) );
         this.precedence = precedence;
     }
     
-    public Set getUserClasses()
+    public Collection getUserClasses()
     {
-        return new HashSet( userClasses );
+        return userClasses;
     }
     
     public AuthenticationLevel getAuthenticationLevel()
@@ -91,14 +94,14 @@
         return authenticationLevel;
     }
     
-    public Set getProtectedItems()
+    public Collection getProtectedItems()
     {
-        return new HashSet( protectedItems );
+        return protectedItems;
     }
     
     public Set getGrantsAndDenials()
     {
-        return new HashSet( grantsAndDenials ); 
+        return grantsAndDenials; 
     }
     
     public int getPrecedence()

Modified: directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ItemFirstACIItem.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ItemFirstACIItem.java?rev=289443&r1=289442&r2=289443&view=diff
==============================================================================
--- directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ItemFirstACIItem.java (original)
+++ directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ItemFirstACIItem.java Fri Sep 16 02:00:34 2005
@@ -20,7 +20,7 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashSet;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.Set;
 
@@ -28,25 +28,15 @@
 {
     private static final long serialVersionUID = -8199453391060356463L;
     
-    private static final Set EMPTY_SET = new HashSet();
+    private final Collection protectedItems;
+    private final Collection itemPermissions;
 
-    private final Set protectedItems;
-    private final Set itemPermissions;
-
-    public ItemFirstACIItem(
-            String identificationTag,
-            int precedence,
-            AuthenticationLevel authenticationLevel )
-    {
-        this( identificationTag, precedence, authenticationLevel, EMPTY_SET, EMPTY_SET );
-    }
-    
     public ItemFirstACIItem(
             String identificationTag,
             int precedence,
             AuthenticationLevel authenticationLevel,
-            Set protectedItems,
-            Set itemPermissions )
+            Collection protectedItems,
+            Collection itemPermissions )
     {
         super( identificationTag, precedence, authenticationLevel );
         
@@ -68,38 +58,18 @@
             }
         }
 
-        this.protectedItems = new HashSet( protectedItems );
-        this.itemPermissions = new HashSet( itemPermissions );
+        this.protectedItems = Collections.unmodifiableCollection( new ArrayList( protectedItems ) );
+        this.itemPermissions = Collections.unmodifiableCollection( new ArrayList( itemPermissions ) );
     }
 
-    public boolean add( ProtectedItem protectedItem )
-    {
-        return protectedItems.add( protectedItem );
-    }
-    
-    public boolean remove( ProtectedItem protectedItem )
-    {
-        return protectedItems.remove( protectedItem );
-    }
-    
-    public Set getProtectedItems()
-    {
-        return new HashSet( protectedItems );
-    }
-    
-    public boolean add( ItemPermission itemPermission )
-    {
-        return itemPermissions.add( itemPermission );
-    }
-    
-    public boolean remove( ItemPermission itemPermission )
+    public Collection getProtectedItems()
     {
-        return itemPermissions.remove( itemPermission );
+        return protectedItems;
     }
     
-    public Set getItemPermissions()
+    public Collection getItemPermissions()
     {
-        return new HashSet( itemPermissions );
+        return itemPermissions;
     }
     
     public String toString()
@@ -128,7 +98,7 @@
                 tuples.add( new ACITuple(
                         itemPermission.getUserClasses(),
                         getAuthenticationLevel(),
-                        getProtectedItems(),
+                        protectedItems,
                         grants,
                         precedence ) );
             }
@@ -137,7 +107,7 @@
                 tuples.add( new ACITuple(
                         itemPermission.getUserClasses(),
                         getAuthenticationLevel(),
-                        getProtectedItems(),
+                        protectedItems,
                         denials,
                         precedence ) );
             }

Modified: directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ItemPermission.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ItemPermission.java?rev=289443&r1=289442&r2=289443&view=diff
==============================================================================
--- directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ItemPermission.java (original)
+++ directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ItemPermission.java Fri Sep 16 02:00:34 2005
@@ -18,32 +18,37 @@
  */
 package org.apache.ldap.common.acl;
 
-import java.util.HashSet;
-import java.util.Set;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
 
 public class ItemPermission extends Permission
 {
     private static final long serialVersionUID = 3940100745409337694L;
 
-    private final Set userClasses = new HashSet();
+    private final Collection userClasses;
     
-    public ItemPermission()
+    public ItemPermission( int precedence, Collection grantsAndDenials, Collection userClasses )
     {
+        super( precedence, grantsAndDenials );
+        
+        for( Iterator i = userClasses.iterator(); i.hasNext(); )
+        {
+            Object val = i.next();
+            if( !( val instanceof UserClass ) )
+            {
+                throw new IllegalArgumentException(
+                        "userClasses contains a wrong element." );
+            }
+        }
+        
+        this.userClasses = Collections.unmodifiableCollection( new ArrayList( userClasses ) );
     }
 
-    public boolean add( UserClass userClass )
+    public Collection getUserClasses()
     {
-        return userClasses.add( userClass );
-    }
-    
-    public boolean remove( UserClass userClass )
-    {
-        return userClasses.remove( userClass );
-    }
-    
-    public Set getUserClasses()
-    {
-        return new HashSet( userClasses );
+        return userClasses;
     }
     
     public String toString()

Modified: directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/Permission.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/Permission.java?rev=289443&r1=289442&r2=289443&view=diff
==============================================================================
--- directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/Permission.java (original)
+++ directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/Permission.java Fri Sep 16 02:00:34 2005
@@ -19,72 +19,74 @@
 package org.apache.ldap.common.acl;
 
 import java.io.Serializable;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Set;
 
 public abstract class Permission implements Serializable
 {
-    private int precedence = -1;
-    private Set grants = new HashSet();
-    private Set denials = new HashSet();
+    private final int precedence;
+    private final Set grantsAndDenials;
+    private final Set grants;
+    private final Set denials;
 
-    protected Permission()
+    protected Permission( int precedence, Collection grantsAndDenials )
     {
-    }
-    
-    public int getPrecedence()
-    {
-        return precedence;
-    }
-    
-    public void setPrecedence( int precedence )
-    {
-        if( precedence < -1 || precedence > 255 )
+        if( precedence < 0 || precedence > 255 )
         {
-            throw new IllegalArgumentException( "precedence: " + precedence );
+            precedence = -1;
         }
+        
         this.precedence = precedence;
-    }
-    
-    public boolean add( GrantAndDenial gad )
-    {
-        if( gad.isGrant() )
-        {
-            return grants.add( gad );
-        }
-        else
+        
+        Set tmpGrantsAndDenials = new HashSet();
+        Set tmpGrants = new HashSet();
+        Set tmpDenials = new HashSet();
+        for( Iterator i = grantsAndDenials.iterator(); i.hasNext(); )
         {
-            return denials.add( gad );
+            Object val = i.next();
+            if( !( val instanceof GrantAndDenial ) )
+            {
+                throw new IllegalArgumentException(
+                        "grantsAndDenials contains a wrong element." );
+            }
+            
+            GrantAndDenial gad = ( GrantAndDenial ) val;
+            if( gad.isGrant() )
+            {
+                tmpGrants.add( gad );
+            }
+            else
+            {
+                tmpDenials.add( gad );
+            }
+            tmpGrantsAndDenials.add( gad );
         }
+        
+        this.grants = Collections.unmodifiableSet( tmpGrants );
+        this.denials = Collections.unmodifiableSet( tmpDenials );
+        this.grantsAndDenials = Collections.unmodifiableSet( tmpGrantsAndDenials );
     }
     
-    public boolean remove( GrantAndDenial gad )
+    public int getPrecedence()
     {
-        if( gad.isGrant() )
-        {
-            return grants.remove( gad );
-        }
-        else
-        {
-            return denials.remove( gad );
-        }
+        return precedence;
     }
     
     public Set getGrantsAndDenials()
     {
-        Set result = new HashSet( grants.size() + denials.size() );
-        result.addAll( grants );
-        result.addAll( denials );
-        return result;
+        return grantsAndDenials;
     }
     
     public Set getGrants()
     {
-        return new HashSet( grants );
+        return grants;
     }
     
     public Set getDenials()
     {
-        return new HashSet( grants );
+        return denials;
     }
 }

Modified: directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ProtectedItem.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ProtectedItem.java?rev=289443&r1=289442&r2=289443&view=diff
==============================================================================
--- directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ProtectedItem.java (original)
+++ directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ProtectedItem.java Fri Sep 16 02:00:34 2005
@@ -19,6 +19,12 @@
 package org.apache.ldap.common.acl;
 
 import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+
+import javax.naming.directory.Attribute;
 
 import org.apache.ldap.common.filter.ExprNode;
 
@@ -77,21 +83,29 @@
     
     private abstract static class AttributeTypeProtectedItem extends ProtectedItem
     {
-        private final String type;
+        protected final Collection attributeTypes;
         
-        protected AttributeTypeProtectedItem( String type )
+        protected AttributeTypeProtectedItem( Collection attributeTypes )
         {
-            if( type == null )
+            Collection tmp = new ArrayList();
+            for( Iterator i = attributeTypes.iterator(); i.hasNext(); )
             {
-                throw new NullPointerException( "type" );
+                Object val = i.next();
+                if( !String.class.isAssignableFrom( val.getClass() ) )
+                {
+                    throw new IllegalArgumentException(
+                            "attributeTypes contains an element which is not a string." );
+                }
+                
+                tmp.add( ( ( String ) val ).toLowerCase() ); 
             }
             
-            this.type = type;
+            this.attributeTypes = Collections.unmodifiableCollection( tmp );
         }
         
-        public String getType()
+        public Iterator iterator()
         {
-            return type;
+            return attributeTypes.iterator();
         }
         
         public boolean equals( Object o )
@@ -109,7 +123,7 @@
             if( getClass().isAssignableFrom( o.getClass() ) )
             {
                 AttributeTypeProtectedItem that = ( AttributeTypeProtectedItem ) o;
-                return this.type.equalsIgnoreCase( that.type );
+                return this.attributeTypes.equals( that.attributeTypes );
             }
             
             return false;
@@ -120,14 +134,14 @@
     {
         private static final long serialVersionUID = -9039274739078220203L;
 
-        public AttributeType( String type )
+        public AttributeType( Collection attributeTypes )
         {
-            super( type );
+            super( attributeTypes );
         }
         
         public String toString()
         {
-            return "attributType: " + getType();
+            return "attributType: " + attributeTypes;
         }
     }
     
@@ -135,14 +149,14 @@
     {
         private static final long serialVersionUID = -9039274739078220203L;
 
-        public AllAttributeValues( String type )
+        public AllAttributeValues( Collection attributeTypes )
         {
-            super( type );
+            super( attributeTypes );
         }
         
         public String toString()
         {
-            return "allAttributeValues: " + getType();
+            return "allAttributeValues: " + attributeTypes;
         }
     }
     
@@ -150,37 +164,39 @@
     {
         private static final long serialVersionUID = -7788463918070206609L;
 
-        public SelfValue( String type )
+        public SelfValue( Collection attributeTypes )
         {
-            super( type );
+            super( attributeTypes );
         }
 
         public String toString()
         {
-            return "selfValue: " + getType();
+            return "selfValue: " + attributeTypes;
         }
     }
     
-    public static class AttributeValue extends AttributeTypeProtectedItem
+    public static class AttributeValue extends ProtectedItem
     {
         private static final long serialVersionUID = -258318397837951363L;
 
-        private final Object value;
+        private final Collection attributes;
         
-        public AttributeValue( String type, Object value )
+        public AttributeValue( Collection attributes )
         {
-            super( type );
-            if( value == null )
+            for( Iterator i = attributes.iterator(); i.hasNext(); )
             {
-                throw new NullPointerException( "value" );
+                if( !Attribute.class.isAssignableFrom( i.next().getClass() ) )
+                {
+                    throw new IllegalArgumentException(
+                            "attributeTypes contains an element which is not an attribute." );
+                }
             }
-            
-            this.value = value;
+            this.attributes = Collections.unmodifiableCollection( new ArrayList( attributes ) );
         }
         
-        public Object getValue()
+        public Iterator iterator()
         {
-            return value;
+            return attributes.iterator();
         }
         
         public boolean equals( Object o )
@@ -193,7 +209,7 @@
             if( o instanceof AttributeValue )
             {
                 AttributeValue that = ( AttributeValue ) o;
-                return this.value.equals( that.value );
+                return this.attributes.equals( that.attributes );
             }
             
             return false;
@@ -201,25 +217,33 @@
         
         public String toString()
         {
-            return "attributeValue: " + getType() + "=" + value.toString();
+            return "attributeValue: " + attributes;
         }
     }
     
-    public static class MaxValueCount extends AttributeTypeProtectedItem
+    public static class MaxValueCount extends ProtectedItem
     {
         private static final long serialVersionUID = 5261651541488944572L;
 
-        private final int maxCount;
+        private final Collection items;
         
-        public MaxValueCount( String type, int maxCount )
+        public MaxValueCount( Collection items )
         {
-            super( type );
-            this.maxCount = maxCount;
+            for( Iterator i = items.iterator(); i.hasNext(); )
+            {
+                if( !MaxValueCountItem.class.isAssignableFrom( i.next().getClass() ) )
+                {
+                    throw new IllegalArgumentException(
+                            "Max value count contains a wrong element." );
+                }
+            }
+            
+            this.items = Collections.unmodifiableCollection( new ArrayList( items ) ); 
         }
         
-        public int getMaxCount()
+        public Iterator iterator()
         {
-            return maxCount;
+            return items.iterator();
         }
         
         public boolean equals( Object o )
@@ -232,7 +256,7 @@
             if( o instanceof MaxValueCount )
             {
                 MaxValueCount that = ( MaxValueCount ) o;
-                return this.maxCount == that.maxCount;
+                return this.items.equals( that.items );
             }
             
             return false;
@@ -240,7 +264,7 @@
 
         public String toString()
         {
-            return "maxValueCount: " + getType() + ", " + maxCount;
+            return "maxValueCount: " + items;
         }
     }
 
@@ -328,25 +352,29 @@
         }
     }
     
-    public static class RestrictedBy extends AttributeTypeProtectedItem
+    public static class RestrictedBy extends ProtectedItem
     {
         private static final long serialVersionUID = -8157637446588058799L;
 
-        private final String valuesIn;
+        private final Collection items;
         
-        public RestrictedBy( String type, String valuesIn )
+        public RestrictedBy( Collection items )
         {
-            super( type );
-            if( valuesIn == null )
+            for( Iterator i = items.iterator(); i.hasNext(); )
             {
-                throw new NullPointerException( "valuesIn" );
+                if( !RestrictedByItem.class.isAssignableFrom( i.next().getClass() ) )
+                {
+                    throw new IllegalArgumentException(
+                            "RestrictedBy items contains a wrong element." );
+                }
             }
-            this.valuesIn = valuesIn;
+            
+            this.items = Collections.unmodifiableCollection( new ArrayList( items ) ); 
         }
         
-        public String getValuesIn()
+        public Iterator iterator()
         {
-            return valuesIn;
+            return items.iterator();
         }
         
         public boolean equals( Object o )
@@ -359,7 +387,7 @@
             if( o instanceof RestrictedBy )
             {
                 RestrictedBy that = ( RestrictedBy ) o;
-                return this.valuesIn.equalsIgnoreCase( that.valuesIn );
+                return this.items.equals( that.items );
             }
             
             return false;
@@ -367,9 +395,67 @@
         
         public String toString()
         {
-            return "restrictedBy: " + getType() + ", " + valuesIn;
+            return "restrictedBy: " + items;
         }
     }
 
     // TODO: Contexts and Classes
+    
+    public static class MaxValueCountItem implements Serializable
+    {
+        private static final long serialVersionUID = 43697038363452113L;
+
+        private String attributeType;
+        private int maxCount;
+        
+        public MaxValueCountItem( String attributeType, int maxCount )
+        {
+            this.attributeType = attributeType;
+            this.maxCount = maxCount;
+        }
+
+        public String getAttributeType()
+        {
+            return attributeType;
+        }
+        
+        public int getMaxCount()
+        {
+            return maxCount;
+        }
+        
+        public String toString()
+        {
+            return "attributeType=" + attributeType + ", maxCount=" + maxCount;
+        }
+    }
+    
+    public static class RestrictedByItem implements Serializable
+    {
+        private static final long serialVersionUID = 4319052153538757099L;
+
+        private String attributeType;
+        private String valuesIn;
+        
+        public RestrictedByItem( String attributeType, String valuesIn )
+        {
+            this.attributeType = attributeType;
+            this.valuesIn = valuesIn;
+        }
+
+        public String getAttributeType()
+        {
+            return attributeType;
+        }
+        
+        public String getValuesIn()
+        {
+            return valuesIn;
+        }
+        
+        public String toString()
+        {
+            return "attributeType=" + attributeType + ", valuesIn=" + valuesIn;
+        }
+    }
 }

Modified: directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/UserFirstACIItem.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/UserFirstACIItem.java?rev=289443&r1=289442&r2=289443&view=diff
==============================================================================
--- directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/UserFirstACIItem.java (original)
+++ directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/UserFirstACIItem.java Fri Sep 16 02:00:34 2005
@@ -20,7 +20,7 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashSet;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.Set;
 
@@ -28,25 +28,15 @@
 {
     private static final long serialVersionUID = 5587483838404246148L;
     
-    private static final Set EMPTY_SET = new HashSet();
+    private final Collection userClasses;
+    private final Collection userPermissions;
 
-    private final Set userClasses;
-    private final Set userPermissions;
-
-    public UserFirstACIItem(
-            String identificationTag,
-            int precedence,
-            AuthenticationLevel authenticationLevel )
-    {
-        this( identificationTag, precedence, authenticationLevel, EMPTY_SET, EMPTY_SET );
-    }
-    
     public UserFirstACIItem(
             String identificationTag,
             int precedence,
             AuthenticationLevel authenticationLevel,
-            Set userClasses,
-            Set userPermissions )
+            Collection userClasses,
+            Collection userPermissions )
     {
         super( identificationTag, precedence, authenticationLevel );
         
@@ -68,38 +58,18 @@
             }
         }
 
-        this.userClasses = new HashSet( userClasses );
-        this.userPermissions = new HashSet( userPermissions );
+        this.userClasses = Collections.unmodifiableCollection( new ArrayList( userClasses ) );
+        this.userPermissions = Collections.unmodifiableCollection( new ArrayList( userPermissions ) );
     }
 
-    public boolean add( UserClass userClass )
-    {
-        return userClasses.add( userClass );
-    }
-    
-    public boolean remove( UserClass userClass )
-    {
-        return userClasses.remove( userClass );
-    }
-    
-    public Set getUserClasses()
-    {
-        return new HashSet( userClasses );
-    }
-    
-    public boolean add( UserPermission userPermission )
-    {
-        return userPermissions.add( userPermission );
-    }
-    
-    public boolean remove( UserPermission userPermission )
+    public Collection getUserClasses()
     {
-        return userPermissions.remove( userPermission );
+        return userClasses;
     }
     
-    public Set getUserPermission()
+    public Collection getUserPermission()
     {
-        return new HashSet( userPermissions );
+        return userPermissions;
     }
     
     public String toString()

Modified: directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/UserPermission.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/UserPermission.java?rev=289443&r1=289442&r2=289443&view=diff
==============================================================================
--- directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/UserPermission.java (original)
+++ directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/UserPermission.java Fri Sep 16 02:00:34 2005
@@ -18,32 +18,36 @@
  */
 package org.apache.ldap.common.acl;
 
-import java.util.HashSet;
-import java.util.Set;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
 
 public class UserPermission extends Permission
 {
     private static final long serialVersionUID = 3940100745409337694L;
 
-    private final Set protectedItems = new HashSet();
+    private final Collection protectedItems;
     
-    public UserPermission()
+    public UserPermission( int precedence, Collection grantsAndDenials, Collection protectedItems )
     {
+        super( precedence, grantsAndDenials );
+        
+        for( Iterator i = protectedItems.iterator(); i.hasNext(); )
+        {
+            Object val = i.next();
+            if( !( val instanceof ProtectedItem ) )
+            {
+                throw new IllegalArgumentException(
+                        "protectedItems contains a wrong element." );
+            }
+        }
+        
+        this.protectedItems = Collections.unmodifiableCollection( protectedItems );
     }
 
-    public boolean add( ProtectedItem protectedItem )
+    public Collection getProtectedItems()
     {
-        return protectedItems.add( protectedItem );
-    }
-    
-    public boolean remove( ProtectedItem protectedItem )
-    {
-        return protectedItems.remove( protectedItem );
-    }
-    
-    public Set getProtectedItems()
-    {
-        return new HashSet( protectedItems );
+        return protectedItems;
     }
     
     public String toString()