directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1744327 - in /directory/shared/branches/shared-value/ldap: model/src/main/java/org/apache/directory/api/ldap/model/entry/ model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/ model/src/main/java/org/apache/directory/...
Date Tue, 17 May 2016 22:19:52 GMT
Author: elecharny
Date: Tue May 17 22:19:52 2016
New Revision: 1744327

URL: http://svn.apache.org/viewvc?rev=1744327&view=rev
Log:
o Check the Value upName syntax, not the normName
o Fixed the ObjectIdentifier normalizer : it was only accepting values which were already
present in the registries
o Some warning removal

Modified:
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Value.java
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/DnNormalizer.java
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/ObjectIdentifierNormalizer.java
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NumericOidSyntaxChecker.java
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ObjectNameSyntaxChecker.java
    directory/shared/branches/shared-value/ldap/schema/data/src/main/resources/schema/ou=schema/cn=adsconfig/ou=attributetypes/m-oid=1.3.6.1.4.1.18060.0.4.1.2.920.ldif

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Value.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Value.java?rev=1744327&r1=1744326&r2=1744327&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Value.java
(original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Value.java
Tue May 17 22:19:52 2016
@@ -274,7 +274,7 @@ public class Value implements Cloneable,
             // Check the value
             if ( attributeType.getSyntax().getSyntaxChecker() != null )
             {
-                if ( !attributeType.getSyntax().getSyntaxChecker().isValidSyntax( normValue
) )
+                if ( !attributeType.getSyntax().getSyntaxChecker().isValidSyntax( upValue
) )
                 {
                     throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX,
"Invalid upValue per syntax" );
                 }

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/DnNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/DnNormalizer.java?rev=1744327&r1=1744326&r2=1744327&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/DnNormalizer.java
(original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/DnNormalizer.java
Tue May 17 22:19:52 2016
@@ -95,6 +95,7 @@ public class DnNormalizer extends Normal
     /**
      * {@inheritDoc}
      */
+    @Override
     public void setSchemaManager( SchemaManager schemaManager )
     {
         this.schemaManager = schemaManager;

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/ObjectIdentifierNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/ObjectIdentifierNormalizer.java?rev=1744327&r1=1744326&r2=1744327&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/ObjectIdentifierNormalizer.java
(original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/ObjectIdentifierNormalizer.java
Tue May 17 22:19:52 2016
@@ -20,8 +20,12 @@
 package org.apache.directory.api.ldap.model.schema.normalizers;
 
 
+import org.apache.directory.api.asn1.util.Oid;
+import org.apache.directory.api.i18n.I18n;
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.exception.LdapException;
+import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException;
+import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
 import org.apache.directory.api.ldap.model.schema.Normalizer;
 import org.apache.directory.api.ldap.model.schema.PrepareString;
 import org.apache.directory.api.ldap.model.schema.SchemaManager;
@@ -69,7 +73,53 @@ public class ObjectIdentifierNormalizer
             return "";
         }
         
-        return schemaManager.getRegistries().getOid( value.trim() );
+        String trimmedValue = value.trim();
+        
+        if ( Strings.isEmpty( trimmedValue ) )
+        {
+            return "";
+        }
+
+        String oid = schemaManager.getRegistries().getOid( trimmedValue );
+        
+        if ( oid == null )
+        {
+            // Not found in the schemaManager : keep it as is
+            if ( Oid.isOid( trimmedValue ) )
+            {
+                // It's an numericOid
+                oid = trimmedValue;
+            }
+            else
+            {
+                // It's a descr : ALPHA ( ALPHA | DIGIT | '-' )*
+                for ( int i = 0; i < trimmedValue.length(); i++ )
+                {
+                    char c = trimmedValue.charAt( i );
+                    
+                    if ( i == 0 )
+                    {
+                        if ( !Character.isLetter( c ) )
+                        {
+                            throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX,
I18n.err(
+                                I18n.ERR_04224, value ) );
+                        }
+                    }
+                    else
+                    {
+                        if ( !( Character.isDigit( c ) || Character.isLetter( c ) || ( c
== '-'  ) || ( c == '_' ) ) )
+                            {
+                            throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX,
I18n.err(
+                                I18n.ERR_04224, value ) );
+                            }
+                    }
+                }
+                
+                oid = trimmedValue;
+            }
+        }
+        
+        return oid;
     }
 
 
@@ -79,13 +129,6 @@ public class ObjectIdentifierNormalizer
     @Override
     public String normalize( String value, PrepareString.AssertionType assertionType ) throws
LdapException
     {
-        if ( value == null )
-        {
-            return null;
-        }
-
-        String str = value.trim();
-
-        return schemaManager.getRegistries().getOid( str );
+        return normalize( value );
     }
 }

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NumericOidSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NumericOidSyntaxChecker.java?rev=1744327&r1=1744326&r2=1744327&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NumericOidSyntaxChecker.java
(original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NumericOidSyntaxChecker.java
Tue May 17 22:19:52 2016
@@ -92,7 +92,7 @@ public class NumericOidSyntaxChecker ext
         }
 
         // Just check that the value is a valid OID
-        boolean result = ( Oid.isOid( strValue ) );
+        boolean result = Oid.isOid( strValue );
 
         if ( result )
         {

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ObjectNameSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ObjectNameSyntaxChecker.java?rev=1744327&r1=1744326&r2=1744327&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ObjectNameSyntaxChecker.java
(original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ObjectNameSyntaxChecker.java
Tue May 17 22:19:52 2016
@@ -71,7 +71,7 @@ public class ObjectNameSyntaxChecker ext
      */
     public boolean isValidSyntax( Object value )
     {
-        String strValue = null;
+        String strValue;
 
         if ( value == null )
         {

Modified: directory/shared/branches/shared-value/ldap/schema/data/src/main/resources/schema/ou=schema/cn=adsconfig/ou=attributetypes/m-oid=1.3.6.1.4.1.18060.0.4.1.2.920.ldif
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/schema/data/src/main/resources/schema/ou%3Dschema/cn%3Dadsconfig/ou%3Dattributetypes/m-oid%3D1.3.6.1.4.1.18060.0.4.1.2.920.ldif?rev=1744327&r1=1744326&r2=1744327&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/schema/data/src/main/resources/schema/ou=schema/cn=adsconfig/ou=attributetypes/m-oid=1.3.6.1.4.1.18060.0.4.1.2.920.ldif
(original)
+++ directory/shared/branches/shared-value/ldap/schema/data/src/main/resources/schema/ou=schema/cn=adsconfig/ou=attributetypes/m-oid=1.3.6.1.4.1.18060.0.4.1.2.920.ldif
Tue May 17 22:19:52 2016
@@ -1,5 +1,5 @@
 version: 1
-dn: m-oid=1.3.6.1.4.1.18060.0.4.1.2.920,ou=attributetypes,cn=adsconfig,ou=schema
+dn: m-oid=1.3.6.1.4.1.18060.0.4.1.2.920,ou=attributeTypes,cn=adsconfig,ou=schema
 objectclass: metaAttributeType
 objectclass: metaTop
 objectclass: top



Mime
View raw message