directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r413479 - in /directory/branches/apacheds/optimization/core/src: main/java/org/apache/directory/server/core/authz/ main/java/org/apache/directory/server/core/authz/support/ main/java/org/apache/directory/server/core/partition/ test/java/org...
Date Sun, 11 Jun 2006 17:07:29 GMT
Author: akarasulu
Date: Sun Jun 11 10:07:29 2006
New Revision: 413479

URL: http://svn.apache.org/viewvc?rev=413479&view=rev
Log:
finished fixing all integration tests which were failing due to normalization issues

Modified:
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/authz/AuthorizationService.java
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/authz/support/ACDFEngine.java
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilter.java
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/DefaultDirectoryPartitionNexus.java
    directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/authz/support/DummyAttributeTypeRegistry.java
    directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/authz/support/DummyOidRegistry.java
    directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilterTest.java

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/authz/AuthorizationService.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/authz/AuthorizationService.java?rev=413479&r1=413478&r2=413479&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/authz/AuthorizationService.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/authz/AuthorizationService.java
Sun Jun 11 10:07:29 2006
@@ -693,8 +693,9 @@
         DirectoryPartitionNexusProxy proxy = invocation.getProxy();
         Attributes entry = proxy.lookup( name, DirectoryPartitionNexusProxy.LOOKUP_BYPASS
);
         LdapPrincipal user = ( ( ServerContext ) invocation.getCaller() ).getPrincipal();
-
-        if ( user.getName().equalsIgnoreCase( DirectoryPartitionNexus.ADMIN_PRINCIPAL_NORMALIZED
) || !enabled )
+        LdapDN principalDn = parseNormalized( user.getName() );
+        
+        if ( principalDn.toNormName().equals( DirectoryPartitionNexus.ADMIN_PRINCIPAL_NORMALIZED
) || !enabled )
         {
             return next.lookup( name );
         }
@@ -951,12 +952,12 @@
         LdapPrincipal principal = ( ( ServerContext ) invocation.getCaller() ).getPrincipal();
         LdapDN userName = parseNormalized( principal.getName() );
 
-        if ( userName.toString().equalsIgnoreCase( DirectoryPartitionNexus.ADMIN_PRINCIPAL_NORMALIZED
) || !enabled )
+        if ( userName.toNormName().equals( DirectoryPartitionNexus.ADMIN_PRINCIPAL_NORMALIZED
) || !enabled )
         {
             return next.compare( name, oid, value );
         }
 
-        Set userGroups = groupCache.getGroups( userName.toString() );
+        Set userGroups = groupCache.getGroups( userName.toNormName() );
         Collection tuples = new HashSet();
         addPerscriptiveAciTuples( proxy, tuples, name, entry );
         addEntryAciTuples( tuples, entry );
@@ -1028,7 +1029,7 @@
         Attributes entry = invocation.getProxy().lookup( normName, DirectoryPartitionNexusProxy.LOOKUP_BYPASS
);
         ServerLdapContext ctx = ( ServerLdapContext ) invocation.getCaller();
         LdapDN userDn = parseNormalized( ctx.getPrincipal().getName() );
-        Set userGroups = groupCache.getGroups( userDn.toString() );
+        Set userGroups = groupCache.getGroups( userDn.toNormName() );
         Collection tuples = new HashSet();
         addPerscriptiveAciTuples( invocation.getProxy(), tuples, normName, entry );
         addEntryAciTuples( tuples, entry );

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/authz/support/ACDFEngine.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/authz/support/ACDFEngine.java?rev=413479&r1=413478&r2=413479&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/authz/support/ACDFEngine.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/authz/support/ACDFEngine.java
Sun Jun 11 10:07:29 2006
@@ -82,7 +82,8 @@
 
         filters = new ACITupleFilter[]
             { new RelatedUserClassFilter( subtreeEvaluator ),
-                new RelatedProtectedItemFilter( refinementEvaluator, entryEvaluator ), new
MaxValueCountFilter(),
+                new RelatedProtectedItemFilter( refinementEvaluator, entryEvaluator, oidRegistry,
attrTypeRegistry ), 
+                new MaxValueCountFilter(),
                 new MaxImmSubFilter(), new RestrictedByFilter(), new MicroOperationFilter(),
                 new HighestPrecedenceFilter(), new MostSpecificUserClassFilter(),
                 new MostSpecificProtectedItemFilter(), };

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilter.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilter.java?rev=413479&r1=413478&r2=413479&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilter.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilter.java
Sun Jun 11 10:07:29 2006
@@ -26,8 +26,11 @@
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 
+import org.apache.directory.server.core.ServerUtils;
 import org.apache.directory.server.core.event.Evaluator;
 import org.apache.directory.server.core.partition.DirectoryPartitionNexusProxy;
+import org.apache.directory.server.core.schema.AttributeTypeRegistry;
+import org.apache.directory.server.core.schema.OidRegistry;
 import org.apache.directory.server.core.subtree.RefinementEvaluator;
 import org.apache.directory.shared.ldap.aci.ACITuple;
 import org.apache.directory.shared.ldap.aci.AuthenticationLevel;
@@ -35,6 +38,8 @@
 import org.apache.directory.shared.ldap.aci.ProtectedItem.MaxValueCountItem;
 import org.apache.directory.shared.ldap.aci.ProtectedItem.RestrictedByItem;
 import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.util.AttributeUtils;
 
 
 /**
@@ -48,12 +53,17 @@
 {
     private final RefinementEvaluator refinementEvaluator;
     private final Evaluator entryEvaluator;
+    private final OidRegistry oidRegistry;
+    private final AttributeTypeRegistry attrRegistry;
 
 
-    public RelatedProtectedItemFilter(RefinementEvaluator refinementEvaluator, Evaluator
entryEvaluator)
+    public RelatedProtectedItemFilter( RefinementEvaluator refinementEvaluator, Evaluator
entryEvaluator, 
+        OidRegistry oidRegistry, AttributeTypeRegistry attrRegistry )
     {
         this.refinementEvaluator = refinementEvaluator;
         this.entryEvaluator = entryEvaluator;
+        this.oidRegistry = oidRegistry;
+        this.attrRegistry = attrRegistry;
     }
 
 
@@ -84,6 +94,12 @@
     private boolean isRelated( ACITuple tuple, OperationScope scope, LdapDN userName, LdapDN
entryName, String attrId,
                                Object attrValue, Attributes entry ) throws NamingException,
InternalError
     {
+        String oid = null;
+        if ( attrId != null )
+        {
+            oid = oidRegistry.getOid( attrId );
+        }
+        
         for ( Iterator i = tuple.getProtectedItems().iterator(); i.hasNext(); )
         {
             ProtectedItem item = ( ProtectedItem ) i.next();
@@ -101,10 +117,7 @@
                     continue;
                 }
 
-                if ( isUserAttribute( attrId ) )
-                {
-                    return true;
-                }
+                return true;
             }
             else if ( item == ProtectedItem.ALL_USER_ATTRIBUTE_TYPES_AND_VALUES )
             {
@@ -113,10 +126,7 @@
                     continue;
                 }
 
-                if ( isUserAttribute( attrId ) )
-                {
-                    return true;
-                }
+                return true;
             }
             else if ( item instanceof ProtectedItem.AllAttributeValues )
             {
@@ -128,7 +138,7 @@
                 ProtectedItem.AllAttributeValues aav = ( ProtectedItem.AllAttributeValues
) item;
                 for ( Iterator j = aav.iterator(); j.hasNext(); )
                 {
-                    if ( attrId.equalsIgnoreCase( ( String ) j.next() ) )
+                    if ( oid.equals( oidRegistry.getOid( ( String ) j.next() ) ) )
                     {
                         return true;
                     }
@@ -144,7 +154,7 @@
                 ProtectedItem.AttributeType at = ( ProtectedItem.AttributeType ) item;
                 for ( Iterator j = at.iterator(); j.hasNext(); )
                 {
-                    if ( attrId.equalsIgnoreCase( ( String ) j.next() ) )
+                    if ( oid.equals( oidRegistry.getOid( ( String ) j.next() ) ) )
                     {
                         return true;
                     }
@@ -161,7 +171,10 @@
                 for ( Iterator j = av.iterator(); j.hasNext(); )
                 {
                     Attribute attr = ( Attribute ) j.next();
-                    if ( attrId.equalsIgnoreCase( attr.getID() ) && attr.contains(
attrValue ) )
+                    String attrOid = oidRegistry.getOid( attr.getID() );
+                    AttributeType attrType = attrRegistry.lookup( attrOid );
+                    
+                    if ( oid.equals( attrOid ) && AttributeUtils.containsValue( attr,
attrValue, attrType ) )
                     {
                         return true;
                     }
@@ -190,7 +203,7 @@
                 for ( Iterator j = mvc.iterator(); j.hasNext(); )
                 {
                     MaxValueCountItem mvcItem = ( MaxValueCountItem ) j.next();
-                    if ( attrId.equalsIgnoreCase( mvcItem.getAttributeType() ) )
+                    if ( oid.equals( oidRegistry.getOid( mvcItem.getAttributeType() ) ) )
                     {
                         return true;
                     }
@@ -215,7 +228,7 @@
                 for ( Iterator j = rb.iterator(); j.hasNext(); )
                 {
                     RestrictedByItem rbItem = ( RestrictedByItem ) j.next();
-                    if ( attrId.equalsIgnoreCase( rbItem.getAttributeType() ) )
+                    if ( oid.equals( oidRegistry.getOid( rbItem.getAttributeType() ) ) )
                     {
                         return true;
                     }
@@ -232,10 +245,11 @@
                 for ( Iterator j = sv.iterator(); j.hasNext(); )
                 {
                     String svItem = String.valueOf( j.next() );
-                    if ( svItem.equalsIgnoreCase( attrId ) )
+                    if ( oid.equals( oidRegistry.getOid( svItem ) ) )
                     {
-                        Attribute attr = entry.get( attrId );
-                        if ( attr != null && ( attr.contains( userName ) || attr.contains(
userName.toString() ) ) )
+                        AttributeType attrType = attrRegistry.lookup( oid );
+                        Attribute attr = ServerUtils.getAttribute( attrType, entry );
+                        if ( attr != null && ( ( attr.contains( userName.toNormName()
) || attr.contains( userName.toUpName() ) ) ) )
                         {
                             return true;
                         }
@@ -249,29 +263,5 @@
         }
 
         return false;
-    }
-
-
-    private final boolean isUserAttribute( String attrId )
-    {
-        /* Not used anymore.  Just retaining in case of resurrection. */
-        return true;
-
-        /*
-         try
-         {
-         AttributeType type = attrTypeRegistry.lookup( attrId );
-         if( type != null && type.isCanUserModify() )
-         {
-         return true;
-         }
-         }
-         catch( NamingException e )
-         {
-         // Ignore
-         }
-
-         return false;
-         */
     }
 }

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/DefaultDirectoryPartitionNexus.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/DefaultDirectoryPartitionNexus.java?rev=413479&r1=413478&r2=413479&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/DefaultDirectoryPartitionNexus.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/DefaultDirectoryPartitionNexus.java
Sun Jun 11 10:07:29 2006
@@ -478,7 +478,7 @@
                 return dn;
             }
 
-            dn = ( LdapDN ) dn.getPrefix( 1 );
+            dn.remove( dn.size() - 1 );
         }
 
         return dn;

Modified: directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/authz/support/DummyAttributeTypeRegistry.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/authz/support/DummyAttributeTypeRegistry.java?rev=413479&r1=413478&r2=413479&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/authz/support/DummyAttributeTypeRegistry.java
(original)
+++ directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/authz/support/DummyAttributeTypeRegistry.java
Sun Jun 11 10:07:29 2006
@@ -20,6 +20,7 @@
 
 
 import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.Iterator;
 import java.util.Map;
 
@@ -29,8 +30,11 @@
 import org.apache.directory.server.core.schema.AttributeTypeRegistry;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.MatchingRule;
+import org.apache.directory.shared.ldap.schema.Normalizer;
 import org.apache.directory.shared.ldap.schema.Syntax;
+import org.apache.directory.shared.ldap.schema.SyntaxChecker;
 import org.apache.directory.shared.ldap.schema.UsageEnum;
+import org.apache.directory.shared.ldap.util.StringTools;
 
 
 /**
@@ -106,7 +110,56 @@
 
                 public MatchingRule getEquality() throws NamingException
                 {
-                    return null;
+                    return new MatchingRule()
+                    {
+
+                        public Syntax getSyntax() throws NamingException
+                        {
+                            return null;
+                        }
+
+                        public Comparator getComparator() throws NamingException
+                        {
+                            return null;
+                        }
+
+                        public Normalizer getNormalizer() throws NamingException
+                        {
+                            return new Normalizer()
+                            {
+                                public Object normalize( Object value ) throws NamingException
+                                {
+                                    return StringTools.deepTrimToLower( value.toString()
);
+                                }
+                            };
+                        }
+
+                        public boolean isObsolete()
+                        {
+                            return false;
+                        }
+
+                        public String getOid()
+                        {
+                            return null;
+                        }
+
+                        public String[] getNames()
+                        {
+                            return null;
+                        }
+
+                        public String getName()
+                        {
+                            return null;
+                        }
+
+                        public String getDescription()
+                        {
+                            return null;
+                        }
+                        
+                    };
                 }
 
 
@@ -189,7 +242,45 @@
 
                 public Syntax getSyntax() throws NamingException
                 {
-                    return null;
+                    return new Syntax()
+                    {
+
+                        public boolean isHumanReadible()
+                        {
+                            return true;
+                        }
+
+                        public SyntaxChecker getSyntaxChecker() throws NamingException
+                        {
+                            return null;
+                        }
+
+                        public boolean isObsolete()
+                        {
+                            return false;
+                        }
+
+                        public String getOid()
+                        {
+                            return null;
+                        }
+
+                        public String[] getNames()
+                        {
+                            return null;
+                        }
+
+                        public String getName()
+                        {
+                            return null;
+                        }
+
+                        public String getDescription()
+                        {
+                            return null;
+                        }
+                        
+                    };
                 }
 
 
@@ -201,7 +292,94 @@
 
                 public MatchingRule getEquality() throws NamingException
                 {
-                    return null;
+                    return new MatchingRule()
+                    {
+
+                        public Syntax getSyntax() throws NamingException
+                        {
+                            return new Syntax()
+                            {
+
+                                public boolean isHumanReadible()
+                                {
+                                    return true;
+                                }
+
+                                public SyntaxChecker getSyntaxChecker() throws NamingException
+                                {
+                                    return null;
+                                }
+
+                                public boolean isObsolete()
+                                {
+                                    return false;
+                                }
+
+                                public String getOid()
+                                {
+                                    return null;
+                                }
+
+                                public String[] getNames()
+                                {
+                                    return null;
+                                }
+
+                                public String getName()
+                                {
+                                    return null;
+                                }
+
+                                public String getDescription()
+                                {
+                                    return null;
+                                }
+                                
+                            };
+                        }
+
+                        public Comparator getComparator() throws NamingException
+                        {
+                            return null;
+                        }
+
+                        public Normalizer getNormalizer() throws NamingException
+                        {
+                            return new Normalizer()
+                            {
+                                public Object normalize( Object value ) throws NamingException
+                                {
+                                    return StringTools.deepTrimToLower( value.toString()
);
+                                }
+                            };
+                        }
+
+                        public boolean isObsolete()
+                        {
+                            return false;
+                        }
+
+                        public String getOid()
+                        {
+                            return null;
+                        }
+
+                        public String[] getNames()
+                        {
+                            return null;
+                        }
+
+                        public String getName()
+                        {
+                            return null;
+                        }
+
+                        public String getDescription()
+                        {
+                            return null;
+                        }
+                        
+                    };
                 }
 
 

Modified: directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/authz/support/DummyOidRegistry.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/authz/support/DummyOidRegistry.java?rev=413479&r1=413478&r2=413479&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/authz/support/DummyOidRegistry.java
(original)
+++ directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/authz/support/DummyOidRegistry.java
Sun Jun 11 10:07:29 2006
@@ -41,7 +41,7 @@
 {
     public String getOid( String name ) throws NamingException
     {
-        return String.valueOf( name.hashCode() );
+        return name.toLowerCase();
     }
 
 

Modified: directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilterTest.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilterTest.java?rev=413479&r1=413478&r2=413479&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilterTest.java
(original)
+++ directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilterTest.java
Sun Jun 11 10:07:29 2006
@@ -28,7 +28,6 @@
 import javax.naming.NamingException;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.BasicAttributes;
 
 import junit.framework.Assert;
 import junit.framework.TestCase;
@@ -46,6 +45,7 @@
 import org.apache.directory.shared.ldap.aci.ProtectedItem;
 import org.apache.directory.shared.ldap.aci.ProtectedItem.MaxValueCountItem;
 import org.apache.directory.shared.ldap.aci.ProtectedItem.RestrictedByItem;
+import org.apache.directory.shared.ldap.message.LockableAttributesImpl;
 import org.apache.directory.shared.ldap.name.LdapDN;
 
 
@@ -80,10 +80,10 @@
             USER_NAME = new LdapDN( "ou=test, ou=users, ou=system" );
 
             filterA = new RelatedProtectedItemFilter( new RefinementEvaluator( new RefinementLeafEvaluator(
-                OID_REGISTRY ) ), new ExpressionEvaluator( OID_REGISTRY, ATTR_TYPE_REGISTRY_A
) );
+                OID_REGISTRY ) ), new ExpressionEvaluator( OID_REGISTRY, ATTR_TYPE_REGISTRY_A
), OID_REGISTRY, ATTR_TYPE_REGISTRY_A );
 
             filterB = new RelatedProtectedItemFilter( new RefinementEvaluator( new RefinementLeafEvaluator(
-                OID_REGISTRY ) ), new ExpressionEvaluator( OID_REGISTRY, ATTR_TYPE_REGISTRY_B
) );
+                OID_REGISTRY ) ), new ExpressionEvaluator( OID_REGISTRY, ATTR_TYPE_REGISTRY_B
), OID_REGISTRY, ATTR_TYPE_REGISTRY_B );
         }
         catch ( NamingException e )
         {
@@ -107,7 +107,7 @@
         Collection tuples = getTuples( ProtectedItem.ENTRY );
 
         Assert.assertEquals( 1, filterA.filter( tuples, OperationScope.ENTRY, null, null,
null, null,
-            AuthenticationLevel.NONE, null, null, null, null, null ).size() );
+            AuthenticationLevel.NONE, null, "ou", null, null, null ).size() );
     }
 
 
@@ -312,8 +312,8 @@
         attrTypes.add( "attrA" );
         Collection tuples = getTuples( new ProtectedItem.SelfValue( attrTypes ) );
 
-        Attributes entry = new BasicAttributes();
-        entry.put( "attrA", USER_NAME );
+        Attributes entry = new LockableAttributesImpl();
+        entry.put( "attrA", USER_NAME.toNormName() );
 
         // Test wrong scope
         Assert.assertEquals( 0, filterA.filter( tuples, OperationScope.ENTRY, null, null,
USER_NAME, null, null, null,



Mime
View raw message