Author: elecharny
Date: Mon Dec 21 16:34:34 2009
New Revision: 892869
URL: http://svn.apache.org/viewvc?rev=892869&view=rev
Log:
Thrown an exception if the class loaded SchemaObject has a different OID than its description
Modified:
directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/SchemaEntityFactory.java
Modified: directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/SchemaEntityFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/SchemaEntityFactory.java?rev=892869&r1=892868&r2=892869&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/SchemaEntityFactory.java
(original)
+++ directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/SchemaEntityFactory.java
Mon Dec 21 16:34:34 2009
@@ -284,6 +284,13 @@
// Create the syntaxChecker instance
syntaxChecker = ( SyntaxChecker ) clazz.newInstance();
+ // Check that the loaded OID is the same than the description OID
+ if ( !syntaxChecker.getOid().equals( oid ) )
+ {
+ String msg = "The SyntaxChecker OID (" + oid + ") is different from the loaded
class' OID (" + syntaxChecker.getOid();
+ throw new LdapInvalidAttributeValueException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM
);
+ }
+
// Update the common fields
syntaxChecker.setBytecode( byteCodeStr );
syntaxChecker.setFqcn( className );
@@ -417,9 +424,17 @@
}
catch ( NoSuchMethodException nsme )
{
- // Ok, let's try with the constructor without argument
+ // Ok, let's try with the constructor without argument.
+ // In this case, we will have to check that the OID is the same than
+ // the one we got in the Comparator entry
Constructor<?> constructor = clazz.getConstructor();
comparator = ( LdapComparator<?> ) clazz.newInstance();
+
+ if ( !comparator.getOid().equals( oid ) )
+ {
+ String msg = "The Comparator's OID (" + oid + ") is different from the loaded
class' OID (" + comparator.getOid();
+ throw new LdapInvalidAttributeValueException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM
);
+ }
}
// Update the loadable fields
@@ -546,6 +561,13 @@
// Create the normalizer instance
normalizer = ( Normalizer ) clazz.newInstance();
+
+ // Check that the loaded OID is the same than the description OID
+ if ( !normalizer.getOid().equals( oid ) )
+ {
+ String msg = "The Normalizer's OID (" + oid + ") is different from the loaded
class' OID (" + normalizer.getOid();
+ throw new LdapInvalidAttributeValueException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM
);
+ }
// Update the common fields
normalizer.setBytecode( byteCodeStr );
|