directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r289387 - in /directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl: ACIItem.java ItemFirstACIItem.java Permission.java UserFirstACIItem.java
Date Fri, 16 Sep 2005 05:42:33 GMT
Author: trustin
Date: Thu Sep 15 22:42:29 2005
New Revision: 289387

URL: http://svn.apache.org/viewcvs?rev=289387&view=rev
Log:
* Fixed a typo error in ItemPermission
* Added ACIItem.toTuples() and its implementations

Modified:
    directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ACIItem.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/Permission.java
    directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/UserFirstACIItem.java

Modified: directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ACIItem.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ACIItem.java?rev=289387&r1=289386&r2=289387&view=diff
==============================================================================
--- directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ACIItem.java (original)
+++ directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ACIItem.java Thu
Sep 15 22:42:29 2005
@@ -19,6 +19,7 @@
 package org.apache.ldap.common.acl;
 
 import java.io.Serializable;
+import java.util.Collection;
 
 public abstract class ACIItem implements Serializable
 {
@@ -64,4 +65,6 @@
     {
         return authenticationLevel;
     }
+    
+    public abstract Collection toTuples();
 }

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=289387&r1=289386&r2=289387&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
Thu Sep 15 22:42:29 2005
@@ -18,7 +18,10 @@
  */
 package org.apache.ldap.common.acl;
 
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Set;
 
 public class ItemFirstACIItem extends ACIItem
@@ -74,5 +77,38 @@
                "authenticationLevel=" + getAuthenticationLevel() + ", " +
                "protectedItems=" + protectedItems + ", " +
                "itemPermissions=" + itemPermissions;
+    }
+
+    public Collection toTuples()
+    {
+        Collection tuples = new ArrayList();
+        for( Iterator i = itemPermissions.iterator(); i.hasNext(); )
+        {
+            ItemPermission itemPermission = ( ItemPermission ) i.next();
+            Set grants = itemPermission.getGrants();
+            Set denials = itemPermission.getDenials();
+            int precedence = itemPermission.getPrecedence() >= 0?
+                    itemPermission.getPrecedence() : this.getPrecedence();
+                    
+            if( grants.size() > 0 )
+            {
+                tuples.add( new ACITuple(
+                        itemPermission.getUserClasses(),
+                        getAuthenticationLevel(),
+                        getProtectedItems(),
+                        grants,
+                        precedence ) );
+            }
+            if( denials.size() > 0 )
+            {
+                tuples.add( new ACITuple(
+                        itemPermission.getUserClasses(),
+                        getAuthenticationLevel(),
+                        getProtectedItems(),
+                        denials,
+                        precedence ) );
+            }
+        }
+        return tuples;
     }
 }

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=289387&r1=289386&r2=289387&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
Thu Sep 15 22:42:29 2005
@@ -25,7 +25,8 @@
 public abstract class Permission implements Serializable
 {
     private int precedence = -1;
-    private Set grantsAndDenials = new HashSet();
+    private Set grants = new HashSet();
+    private Set denials = new HashSet();
 
     protected Permission()
     {
@@ -47,16 +48,43 @@
     
     public boolean add( GrantAndDenial gad )
     {
-        return grantsAndDenials.add( gad );
+        if( gad.isGrant() )
+        {
+            return grants.add( gad );
+        }
+        else
+        {
+            return denials.add( gad );
+        }
     }
     
     public boolean remove( GrantAndDenial gad )
     {
-        return grantsAndDenials.remove( gad );
+        if( gad.isGrant() )
+        {
+            return grants.remove( gad );
+        }
+        else
+        {
+            return denials.remove( gad );
+        }
     }
     
     public Set getGrantsAndDenials()
     {
-        return new HashSet( grantsAndDenials );
+        Set result = new HashSet( grants.size() + denials.size() );
+        result.addAll( grants );
+        result.addAll( denials );
+        return result;
+    }
+    
+    public Set getGrants()
+    {
+        return new HashSet( grants );
+    }
+    
+    public Set getDenials()
+    {
+        return new HashSet( grants );
     }
 }

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=289387&r1=289386&r2=289387&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
Thu Sep 15 22:42:29 2005
@@ -18,7 +18,10 @@
  */
 package org.apache.ldap.common.acl;
 
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Set;
 
 public class UserFirstACIItem extends ACIItem
@@ -46,7 +49,7 @@
         return userClasses.remove( userClass );
     }
     
-    public Set getUserClass()
+    public Set getUserClasses()
     {
         return new HashSet( userClasses );
     }
@@ -74,5 +77,38 @@
                "authenticationLevel=" + getAuthenticationLevel() + ", " +
                "userClasses=" + userClasses + ", " +
                "userPermissions=" + userPermissions;
+    }
+
+    public Collection toTuples()
+    {
+        Collection tuples = new ArrayList();
+        for( Iterator i = userPermissions.iterator(); i.hasNext(); )
+        {
+            UserPermission userPermission = ( UserPermission ) i.next();
+            Set grants = userPermission.getGrants();
+            Set denials = userPermission.getDenials();
+            int precedence = userPermission.getPrecedence() >= 0?
+                    userPermission.getPrecedence() : this.getPrecedence();
+            
+            if( grants.size() > 0 )
+            {
+                tuples.add( new ACITuple(
+                        getUserClasses(),
+                        getAuthenticationLevel(),
+                        userPermission.getProtectedItems(),
+                        grants,
+                        precedence ) );
+            }
+            if( denials.size() > 0 )
+            {
+                tuples.add( new ACITuple(
+                        getUserClasses(),
+                        getAuthenticationLevel(),
+                        userPermission.getProtectedItems(),
+                        denials,
+                        precedence ) );
+            }
+        }
+        return tuples;
     }
 }



Mime
View raw message