directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r289384 - /directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ACITuple.java
Date Fri, 16 Sep 2005 05:27:55 GMT
Author: trustin
Date: Thu Sep 15 22:27:52 2005
New Revision: 289384

URL: http://svn.apache.org/viewcvs?rev=289384&view=rev
Log:
Changed ACITuple into a concrete class.

Modified:
    directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ACITuple.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=289384&r1=289383&r2=289384&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 Thu
Sep 15 22:27:52 2005
@@ -18,13 +18,100 @@
  */
 package org.apache.ldap.common.acl;
 
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Set;
 
-public interface ACITuple
+public class ACITuple implements Serializable
 {
-    Set getUserClasses();
-    AuthenticationLevel getAuthenticationLevel();
-    Set getProtectedItems();
-    Set getGrantsAndDenials();
-    int getPrecedence();
+    private static final long serialVersionUID = 4353150626941232371L;
+
+    private final Set userClasses;
+    private final AuthenticationLevel authenticationLevel;
+    private final Set protectedItems;
+    private final Set grantsAndDenials;
+    private final int precedence;
+    
+    public ACITuple(
+            Set userClasses, AuthenticationLevel authenticationLevel,
+            Set protectedItems, Set grantsAndDenials, int precedence )
+    {
+        for( Iterator i = userClasses.iterator(); i.hasNext(); )
+        {
+            if( !UserClass.class.isAssignableFrom( i.next().getClass() ) )
+            {
+                throw new IllegalArgumentException(
+                        "userClasses contains an element which is not a user classs." );
+            }
+        }
+        
+        for( Iterator i = protectedItems.iterator(); i.hasNext(); )
+        {
+            if( !ProtectedItem.class.isAssignableFrom( i.next().getClass() ) )
+            {
+                throw new IllegalArgumentException(
+                        "protectedItems contains an element which is not a protected item."
);
+            }
+        }
+
+        for( Iterator i = grantsAndDenials.iterator(); i.hasNext(); )
+        {
+            if( !GrantAndDenial.class.isAssignableFrom( i.next().getClass() ) )
+            {
+                throw new IllegalArgumentException(
+                        "grantsAndDenials contains an element which is not a grant or a denial."
);
+            }
+        }
+        
+        if( authenticationLevel == null )
+        {
+            throw new NullPointerException( "authenticationLevel" );
+        }
+        
+        if( precedence < 0 || precedence > 255 )
+        {
+            throw new IllegalArgumentException( "precedence: " + precedence );
+        }
+        
+        this.userClasses = new HashSet( userClasses );
+        this.authenticationLevel = authenticationLevel;
+        this.protectedItems = new HashSet( protectedItems );
+        this.grantsAndDenials = new HashSet( grantsAndDenials );
+        this.precedence = precedence;
+    }
+    
+    public Set getUserClasses()
+    {
+        return new HashSet( userClasses );
+    }
+    
+    public AuthenticationLevel getAuthenticationLevel()
+    {
+        return authenticationLevel;
+    }
+    
+    public Set getProtectedItems()
+    {
+        return new HashSet( protectedItems );
+    }
+    
+    public Set getGrantsAndDenials()
+    {
+        return new HashSet( grantsAndDenials ); 
+    }
+    
+    public int getPrecedence()
+    {
+        return precedence;
+    }
+    
+    public String toString()
+    {
+        return "ACITuple: userClasses=" + userClasses + ", " +
+               "authenticationLevel=" + authenticationLevel + ", " +
+               "protectedItems=" + protectedItems + ", " +
+               "grantsAndDenials=" + grantsAndDenials + ", " +
+               "precedence=" + precedence;
+    }
 }



Mime
View raw message