directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1087320 - in /directory: apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/entry/ apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/ apacheds/trunk/core/src/main/java/org/apache/directory/server/...
Date Thu, 31 Mar 2011 14:42:08 GMT
Author: elecharny
Date: Thu Mar 31 14:42:08 2011
New Revision: 1087320

URL: http://svn.apache.org/viewvc?rev=1087320&view=rev
Log:
Modified the isIntanceOf() method to take an AttributeType parameter instead of a String

Modified:
    directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/entry/SchemaAwareEntryAttributeTest.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/TupleCache.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/RefinementEvaluator.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluator.java
    directory/apacheds/trunk/interceptor-kerberos/src/main/java/org/apache/directory/server/core/kerberos/KeyDerivationInterceptor.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntryAttribute.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/EntryAttribute.java

Modified: directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/entry/SchemaAwareEntryAttributeTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/entry/SchemaAwareEntryAttributeTest.java?rev=1087320&r1=1087319&r2=1087320&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/entry/SchemaAwareEntryAttributeTest.java
(original)
+++ directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/entry/SchemaAwareEntryAttributeTest.java
Thu Mar 31 14:42:08 2011
@@ -80,6 +80,7 @@ public class SchemaAwareEntryAttributeTe
     private static AttributeType atCN;
     private static AttributeType atDC;
     private static AttributeType atSN;
+    private static AttributeType atName;
 
     // A SINGLE-VALUE attribute
     private static AttributeType atC;
@@ -152,6 +153,7 @@ public class SchemaAwareEntryAttributeTe
         atSN = schemaManager.lookupAttributeTypeRegistry( "sn" );
         atPwd = schemaManager.lookupAttributeTypeRegistry( "userpassword" );
         atEMail = schemaManager.lookupAttributeTypeRegistry( "email" );
+        atName = schemaManager.lookupAttributeTypeRegistry( "name" );
     }
 
 
@@ -1521,12 +1523,9 @@ public class SchemaAwareEntryAttributeTe
     {
         EntryAttribute attr = new DefaultEntryAttribute( atCN );
 
-        assertTrue( attr.isInstanceOf( "CommonName" ) );
-        assertTrue( attr.isInstanceOf( "2.5.4.3" ) );
-        assertTrue( attr.isInstanceOf( "  Cn  " ) );
-        assertFalse( attr.isInstanceOf( "  " ) );
-        assertFalse( attr.isInstanceOf( "sn" ) );
-        assertFalse( attr.isInstanceOf( "name" ) );
+        assertTrue( attr.isInstanceOf( atCN ) );
+        assertTrue( attr.isInstanceOf( atName) );
+        assertFalse( attr.isInstanceOf( atSN ) );
     }
 
 
@@ -1695,7 +1694,7 @@ public class SchemaAwareEntryAttributeTe
 
         attr.apply( atSN );
 
-        assertTrue( attr.isInstanceOf( "Surname" ) );
+        assertTrue( attr.isInstanceOf( atSN ) );
         assertEquals( "2.5.4.4", attr.getId() );
         assertEquals( "sn", attr.getUpId() );
     }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/TupleCache.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/TupleCache.java?rev=1087320&r1=1087319&r2=1087320&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/TupleCache.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/TupleCache.java
Thu Mar 31 14:42:08 2011
@@ -253,7 +253,7 @@ public class TupleCache
 
         for ( Modification mod : mods )
         {
-            if ( mod.getAttribute().isInstanceOf( SchemaConstants.PRESCRIPTIVE_ACI_AT ) )
+            if ( mod.getAttribute().isInstanceOf( PRESCRIPTIVE_ACI_AT ) )
             {
                 subentryDeleted( normName, entry );
                 subentryAdded( normName, entry );

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/RefinementEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/RefinementEvaluator.java?rev=1087320&r1=1087319&r2=1087320&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/RefinementEvaluator.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/RefinementEvaluator.java
Thu Mar 31 14:42:08 2011
@@ -65,7 +65,7 @@ public class RefinementEvaluator
             throw new IllegalArgumentException( I18n.err( I18n.ERR_296 ) );
         }
         
-        if ( !objectClasses.isInstanceOf( SchemaConstants.OBJECT_CLASS_AT ) )
+        if ( !( SchemaConstants.OBJECT_CLASS_AT_OID.equals( objectClasses.getAttributeType().getOid()
) ) )
         {
             throw new IllegalArgumentException( I18n.err( I18n.ERR_297 ) );
         }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluator.java?rev=1087320&r1=1087319&r2=1087320&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluator.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluator.java
Thu Mar 31 14:42:08 2011
@@ -101,7 +101,7 @@ public class RefinementLeafEvaluator
             throw new IllegalArgumentException( I18n.err( I18n.ERR_303 ) );
         }
         
-        if ( !objectClasses.isInstanceOf( SchemaConstants.OBJECT_CLASS_AT ) )
+        if ( !(  objectClasses.isInstanceOf( OBJECT_CLASS_AT ) ) )
         {
             throw new IllegalArgumentException( I18n.err( I18n.ERR_304 ) );
         }

Modified: directory/apacheds/trunk/interceptor-kerberos/src/main/java/org/apache/directory/server/core/kerberos/KeyDerivationInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/interceptor-kerberos/src/main/java/org/apache/directory/server/core/kerberos/KeyDerivationInterceptor.java?rev=1087320&r1=1087319&r2=1087320&view=diff
==============================================================================
--- directory/apacheds/trunk/interceptor-kerberos/src/main/java/org/apache/directory/server/core/kerberos/KeyDerivationInterceptor.java
(original)
+++ directory/apacheds/trunk/interceptor-kerberos/src/main/java/org/apache/directory/server/core/kerberos/KeyDerivationInterceptor.java
Thu Mar 31 14:42:08 2011
@@ -235,7 +235,7 @@ public class KeyDerivationInterceptor ex
 
             EntryAttribute attr = mod.getAttribute();
 
-            if ( attr.isInstanceOf( SchemaConstants.USER_PASSWORD_AT ) )
+            if ( SchemaConstants.USER_PASSWORD_AT_OID.equals( attr.getAttributeType().getOid()
) )
             {
                 Object firstValue = attr.get();
                 String password = null;
@@ -263,7 +263,7 @@ public class KeyDerivationInterceptor ex
                 log.debug( "Got userPassword '{}'.", subContext.getUserPassword() );
             }
 
-            if ( attr.isInstanceOf( KerberosAttribute.KRB5_PRINCIPAL_NAME_AT ) )
+            if ( KerberosAttribute.KRB5_PRINCIPAL_NAME_AT_OID.equals( attr.getAttributeType().getOid()
) )
             {
                 subContext.setPrincipalName( attr.getString() );
                 log.debug( "Got principal '{}'.", subContext.getPrincipalName() );

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntryAttribute.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntryAttribute.java?rev=1087320&r1=1087319&r2=1087320&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntryAttribute.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntryAttribute.java
Thu Mar 31 14:42:08 2011
@@ -1959,30 +1959,15 @@ public class DefaultEntryAttribute imple
      * false if we ask if it's an instance of "Name". 
      * </p> 
      *
-     * @param attributeId The AttributeType ID to check
+     * @param attributeType The AttributeType to check
      * @return True if the current attribute is of the expected attributeType
      * @throws LdapInvalidAttributeValueException If there is no AttributeType
      */
-    public boolean isInstanceOf( String attributeId ) throws LdapInvalidAttributeValueException
+    public boolean isInstanceOf( AttributeType attributeType ) throws LdapInvalidAttributeValueException
     {
-        String trimmedId = Strings.trim(attributeId);
-        
-        if ( Strings.isEmpty(trimmedId) )
-        {
-            return false;
-        }
-        
-        String normId = Strings.lowerCaseAscii(trimmedId);
-        
-        for ( String name:attributeType.getNames() )
-        {
-            if ( normId.equalsIgnoreCase( name ) )
-            {
-                return true;
-            }
-        }
-        
-        return normId.equalsIgnoreCase( attributeType.getOid() );
+        return ( attributeType != null ) && 
+                ( this.attributeType.equals( attributeType ) || 
+                  this.attributeType.isDescendantOf( attributeType ) ); 
     }
 
 

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/EntryAttribute.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/EntryAttribute.java?rev=1087320&r1=1087319&r2=1087320&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/EntryAttribute.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/EntryAttribute.java
Thu Mar 31 14:42:08 2011
@@ -165,7 +165,7 @@ public interface EntryAttribute extends 
      * </p>
      *
      * @param vals the values
-     * @return true if this attribute contains all the values, otherwise false
+     * @return true if this attribute contains all the given values, otherwise false
      */
     boolean contains( String... vals );
 
@@ -179,7 +179,7 @@ public interface EntryAttribute extends 
      * </p>
      *
      * @param vals the values
-     * @return true if this attribute contains all the values, otherwise false
+     * @return true if this attribute contains all the given values, otherwise false
      */
     boolean contains( byte[]... vals );
 
@@ -194,13 +194,13 @@ public interface EntryAttribute extends 
      * </p>
      *
      * @param vals the values
-     * @return true if this attribute contains all the values, otherwise false
+     * @return true if this attribute contains all the given values, otherwise false
      */
     boolean contains( Value<?>... vals );
 
 
     /**
-     * Get the attribute type associated with this ServerAttribute.
+     * Get the attribute type associated with this EntryAttribute.
      *
      * @return the attributeType associated with this entry attribute
      */
@@ -209,7 +209,7 @@ public interface EntryAttribute extends 
     
     /**
      * <p>
-     * Set the attribute type associated with this ServerAttribute.
+     * Set the attribute type associated with this EntryAttribute.
      * </p>
      * <p>
      * The current attributeType will be replaced. It is the responsibility of
@@ -224,19 +224,14 @@ public interface EntryAttribute extends 
     
     /**
      * <p>
-     * Check if the current attribute type is of the expected attributeType
-     * </p>
-     * <p>
-     * This method won't tell if the current attribute is a descendant of 
-     * the attributeType. For instance, the "CN" serverAttribute will return
-     * false if we ask if it's an instance of "Name". 
-     * </p> 
+     * Check if the current attribute type has the same type (or is a descendant of)
+     * than the given attributeType
      *
-     * @param attributeId The AttributeType ID to check
+     * @param attributeType The AttributeType to check
      * @return True if the current attribute is of the expected attributeType
      * @throws LdapInvalidAttributeValueException If there is no AttributeType
      */
-    boolean isInstanceOf( String attributeId ) throws LdapInvalidAttributeValueException;
+    boolean isInstanceOf( AttributeType attributeType ) throws LdapInvalidAttributeValueException;
 
     
     /**



Mime
View raw message