directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r957934 - in /directory: apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/support/ apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/ shared/trunk/ldap/src/main/antlr/ shared/trunk/ldap...
Date Fri, 25 Jun 2010 13:13:17 GMT
Author: elecharny
Date: Fri Jun 25 13:13:16 2010
New Revision: 957934

URL: http://svn.apache.org/viewvc?rev=957934&view=rev
Log:
o Added a toStrng() method in the ACIItem class
o the precedence is now an Integer instead of an int, to be able to know when it has been
set

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/support/HighestPrecedenceFilter.java
    directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/HighestPrecedenceFilterTest.java
    directory/shared/trunk/ldap/src/main/antlr/ACIItem.g
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACIItem.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACITuple.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ItemFirstACIItem.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ItemPermission.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/Permission.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/UserFirstACIItem.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/UserPermission.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/support/HighestPrecedenceFilter.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/support/HighestPrecedenceFilter.java?rev=957934&r1=957933&r2=957934&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/support/HighestPrecedenceFilter.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/support/HighestPrecedenceFilter.java
Fri Jun 25 13:13:16 2010
@@ -69,7 +69,7 @@ public class HighestPrecedenceFilter imp
         // Find the maximum precedence for all tuples.
         for ( ACITuple tuple:tuples )
         {
-            if ( tuple.getPrecedence() > maxPrecedence )
+            if ( ( tuple.getPrecedence() != null ) && (tuple.getPrecedence() >
maxPrecedence ) )
             {
                 maxPrecedence = tuple.getPrecedence();
             }
@@ -80,7 +80,7 @@ public class HighestPrecedenceFilter imp
         {
             ACITuple tuple = i.next();
             
-            if ( tuple.getPrecedence() != maxPrecedence )
+            if ( ( tuple.getPrecedence() != null ) && ( tuple.getPrecedence() !=
maxPrecedence ) )
             {
                 i.remove();
             }

Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/HighestPrecedenceFilterTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/HighestPrecedenceFilterTest.java?rev=957934&r1=957933&r2=957934&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/HighestPrecedenceFilterTest.java
(original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/HighestPrecedenceFilterTest.java
Fri Jun 25 13:13:16 2010
@@ -20,17 +20,17 @@
 package org.apache.directory.server.core.authz.support;
 
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
-import static org.junit.Assert.assertEquals;
-
 import org.apache.directory.junit.tools.Concurrent;
 import org.apache.directory.junit.tools.ConcurrentJunitRunner;
-import org.apache.directory.server.core.authz.support.HighestPrecedenceFilter;
 import org.apache.directory.shared.ldap.aci.ACITuple;
 import org.apache.directory.shared.ldap.aci.MicroOperation;
 import org.apache.directory.shared.ldap.aci.ProtectedItem;
@@ -99,7 +99,8 @@ public class HighestPrecedenceFilterTest
 
         for ( ACITuple tuple:tuples )
         {
-            assertEquals( MAX_PRECEDENCE, tuple.getPrecedence() );
+            assertNotNull( tuple.getPrecedence() );
+            assertEquals( MAX_PRECEDENCE, tuple.getPrecedence().intValue() );
         }
     }
 }

Modified: directory/shared/trunk/ldap/src/main/antlr/ACIItem.g
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/antlr/ACIItem.g?rev=957934&r1=957933&r2=957934&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/antlr/ACIItem.g (original)
+++ directory/shared/trunk/ldap/src/main/antlr/ACIItem.g Fri Jun 25 13:13:16 2010
@@ -111,7 +111,7 @@ tokens
     // these are only used by three first order components
     private String identificationTag;
     private AuthenticationLevel authenticationLevel;
-    private int aciPrecedence = -1;
+    private Integer aciPrecedence = null;
     
     private boolean isItemFirstACIItem;
     
@@ -121,7 +121,7 @@ tokens
     private Set<UserClass> userClasses;
     private Map<String, UserClass> userClassesMap;
     private Set<ItemPermission> itemPermissions;
-    private int precedence = -1;
+    private Integer precedence = null;
     private Set<GrantAndDenial> grantsAndDenials;
     private Set<UserPermission> userPermissions;
     private Map<String, OidNormalizer> oidsMap;
@@ -275,8 +275,8 @@ aci_precedence
     :
     precedence
     {
-        aciPrecedence = precedence;
-        precedence = -1;
+        aciPrecedence = Integer.valueOf( precedence );
+        precedence = null;
     }
     ;
 
@@ -287,7 +287,7 @@ precedence
     :
     ID_precedence ( SP )+ token:INTEGER
     {
-        precedence = token2Integer( token );
+        precedence = Integer.valueOf( token2Integer( token ) );
         
         if ( ( precedence < 0 ) || ( precedence > 255 ) )
         {
@@ -725,7 +725,7 @@ itemPermission returns [ ItemPermission 
         }
         
         itemPermission = new ItemPermission( precedence, grantsAndDenials, userClasses );
-        precedence = -1;
+        precedence = null;
     }
     ;
 
@@ -996,7 +996,7 @@ userPermission returns [ UserPermission 
          }
          
          userPermission = new UserPermission( precedence, grantsAndDenials, protectedItems
);
-         precedence = -1;
+         precedence = null;
      }
      ;
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACIItem.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACIItem.java?rev=957934&r1=957933&r2=957934&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACIItem.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACIItem.java
Fri Jun 25 13:13:16 2010
@@ -126,4 +126,27 @@ public abstract class ACIItem
         
         return microOps;
     }
+
+
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        StringBuilder buf = new StringBuilder();
+        
+        // identificationTag
+        buf.append( "identificationTag \"" );
+        buf.append( getIdentificationTag() );
+
+        // precedence
+        buf.append( "\", precedence " );
+        buf.append( getPrecedence() );
+        
+        // authenticationLevel
+        buf.append( ", authenticationLevel " );
+        buf.append( getAuthenticationLevel().getName() );
+        
+        return buf.toString();
+    }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACITuple.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACITuple.java?rev=957934&r1=957933&r2=957934&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACITuple.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACITuple.java
Fri Jun 25 13:13:16 2010
@@ -51,7 +51,7 @@ public class ACITuple implements Seriali
 
     private final boolean grant;
 
-    private final int precedence;
+    private final Integer precedence;
 
 
     /**
@@ -76,7 +76,7 @@ public class ACITuple implements Seriali
             Collection<ProtectedItem> protectedItems,
             Set<MicroOperation> microOperations, 
             boolean grant, 
-            int precedence )
+            Integer precedence )
     {
         if ( authenticationLevel == null )
         {
@@ -145,7 +145,7 @@ public class ACITuple implements Seriali
     /**
      * Returns the precedence of this tuple (<tt>0</tt>-<tt>255</tt>).
      */
-    public int getPrecedence()
+    public Integer getPrecedence()
     {
         return precedence;
     }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ItemFirstACIItem.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ItemFirstACIItem.java?rev=957934&r1=957933&r2=957934&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ItemFirstACIItem.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ItemFirstACIItem.java
Fri Jun 25 13:13:16 2010
@@ -39,23 +39,18 @@ public class ItemFirstACIItem extends AC
     /** The list of protected items ( userClasses or userPermissions ) */
     private final Collection<ProtectedItem> protectedItems;
 
+    /** The associated permissions */
     private final Collection<ItemPermission> itemPermissions;
 
 
     /**
      * Creates a new instance.
      * 
-     * @param identificationTag
-     *            the id string of this item
-     * @param precedence
-     *            the precedence of this item
-     * @param authenticationLevel
-     *            the level of authentication required to this item
-     * @param protectedItems
-     *            the collection of {@link ProtectedItem}s this item protects
-     * @param itemPermissions
-     *            the collection of {@link ItemPermission}s each
-     *            <tt>protectedItems</tt> will have
+     * @param identificationTag the id string of this item
+     * @param precedence the precedence of this item
+     * @param authenticationLevel the level of authentication required to this item
+     * @param protectedItems the collection of {@link ProtectedItem}s this item protects
+     * @param itemPermissions the collection of {@link ItemPermission}s each <tt>protectedItems</tt>
will have
      */
     public ItemFirstACIItem( String identificationTag, int precedence, AuthenticationLevel
authenticationLevel,
         Collection<ProtectedItem> protectedItems, Collection<ItemPermission>
itemPermissions )
@@ -85,21 +80,15 @@ public class ItemFirstACIItem extends AC
     }
 
 
+    /**
+     * @see Object#toString()
+     */
     public String toString()
     {
         StringBuilder buf = new StringBuilder();
         
-        // identificationTag
-        buf.append( "{ identificationTag \"" );
-        buf.append( getIdentificationTag() );
-
-        // precedence
-        buf.append( "\", precedence " );
-        buf.append( getPrecedence() );
-        
-        // authenticationLevel
-        buf.append( ", authenticationLevel " );
-        buf.append( getAuthenticationLevel().getName() );
+        buf.append( "{" );
+        buf.append( super.toString() );
         
         // itemOrUserFirst
         buf.append( ", itemOrUserFirst itemFirst: { " );
@@ -156,8 +145,9 @@ public class ItemFirstACIItem extends AC
         {
             Set<GrantAndDenial> grants = itemPermission.getGrants();
             Set<GrantAndDenial> denials = itemPermission.getDenials();
-            int precedence = itemPermission.getPrecedence() >= 0 ? itemPermission.getPrecedence()
: this
-                .getPrecedence();
+            int precedence = itemPermission.getPrecedence() != null ? 
+                itemPermission.getPrecedence() :
+                this.getPrecedence();
 
             if ( grants.size() > 0 )
             {

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ItemPermission.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ItemPermission.java?rev=957934&r1=957933&r2=957934&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ItemPermission.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ItemPermission.java
Fri Jun 25 13:13:16 2010
@@ -49,7 +49,7 @@ public class ItemPermission extends Perm
      * @param userClasses
      *            the collection of {@link UserClass}es
      */
-    public ItemPermission( int precedence, Collection<GrantAndDenial> grantsAndDenials,
Collection<UserClass> userClasses )
+    public ItemPermission( Integer precedence, Collection<GrantAndDenial> grantsAndDenials,
Collection<UserClass> userClasses )
     {
         super( precedence, grantsAndDenials );
 
@@ -72,7 +72,7 @@ public class ItemPermission extends Perm
         
         buffer.append( "{ " );
 
-        if ( getPrecedence() >= 0 && getPrecedence() <= 255 )
+        if ( getPrecedence() != null )
         {
             buffer.append( "precedence " );
             buffer.append( getPrecedence() );

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/Permission.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/Permission.java?rev=957934&r1=957933&r2=957934&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/Permission.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/Permission.java
Fri Jun 25 13:13:16 2010
@@ -34,7 +34,7 @@ import java.util.Set;
  */
 public abstract class Permission implements Serializable
 {
-    private final int precedence;
+    private final Integer precedence;
 
     private final Set<GrantAndDenial> grantsAndDenials;
 
@@ -52,13 +52,8 @@ public abstract class Permission impleme
      * @param grantsAndDenials
      *            the set of {@link GrantAndDenial}s
      */
-    protected Permission(int precedence, Collection<GrantAndDenial> grantsAndDenials)
+    protected Permission( Integer precedence, Collection<GrantAndDenial> grantsAndDenials)
     {
-        if ( precedence < 0 || precedence > 255 )
-        {
-            precedence = -1;
-        }
-
         this.precedence = precedence;
 
         Set<GrantAndDenial> tmpGrantsAndDenials = new HashSet<GrantAndDenial>();
@@ -88,7 +83,7 @@ public abstract class Permission impleme
     /**
      * Returns the precedence of this permission.
      */
-    public int getPrecedence()
+    public Integer getPrecedence()
     {
         return precedence;
     }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/UserFirstACIItem.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/UserFirstACIItem.java?rev=957934&r1=957933&r2=957934&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/UserFirstACIItem.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/UserFirstACIItem.java
Fri Jun 25 13:13:16 2010
@@ -162,8 +162,9 @@ public class UserFirstACIItem extends AC
         {
             Set<GrantAndDenial> grants = userPermission.getGrants();
             Set<GrantAndDenial> denials = userPermission.getDenials();
-            int precedence = userPermission.getPrecedence() >= 0 ? userPermission.getPrecedence()
: this
-                .getPrecedence();
+            int precedence = userPermission.getPrecedence() != null ? 
+                userPermission.getPrecedence() :
+                this.getPrecedence();
 
             if ( grants.size() > 0 )
             {

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/UserPermission.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/UserPermission.java?rev=957934&r1=957933&r2=957934&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/UserPermission.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/UserPermission.java
Fri Jun 25 13:13:16 2010
@@ -48,7 +48,7 @@ public class UserPermission extends Perm
      * @param protectedItems
      *            the collection of {@link ProtectedItem}s
      */
-    public UserPermission( int precedence, Collection<GrantAndDenial> grantsAndDenials,
Collection<ProtectedItem> protectedItems )
+    public UserPermission( Integer precedence, Collection<GrantAndDenial> grantsAndDenials,
Collection<ProtectedItem> protectedItems )
     {
         super( precedence, grantsAndDenials );
 
@@ -71,7 +71,7 @@ public class UserPermission extends Perm
         
         buf.append( "{ " );
 
-        if ( getPrecedence() >= 0 && getPrecedence() <= 255 )
+        if ( getPrecedence() != null )
         {
             buf.append( "precedence " );
             buf.append( getPrecedence() );

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java?rev=957934&r1=957933&r2=957934&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java
Fri Jun 25 13:13:16 2010
@@ -545,7 +545,7 @@ public class ACIItemParserTest
             }
             else
             {
-                fail( "Got precedence " + precedence + ", excpected precedence 1 or 2." );
+                fail( "Got precedence " + precedence + ", expected precedence 1 or 2." );
             }
         }
     }



Mime
View raw message