Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0D01CD30C for ; Wed, 22 May 2013 17:26:38 +0000 (UTC) Received: (qmail 58933 invoked by uid 500); 22 May 2013 17:26:38 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 58851 invoked by uid 500); 22 May 2013 17:26:36 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 58829 invoked by uid 99); 22 May 2013 17:26:36 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 May 2013 17:26:36 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 May 2013 17:26:29 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id A29E623888E4; Wed, 22 May 2013 17:26:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1485295 - in /directory/shared/trunk: ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/ ldap/model/src/main/java/org/apache/directory/api/ldap/model/password/ ldap/model/src/main/java/org/apache/directory/api/ldap/model/s... Date: Wed, 22 May 2013 17:26:07 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130522172607.A29E623888E4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: elecharny Date: Wed May 22 17:26:06 2013 New Revision: 1485295 URL: http://svn.apache.org/r1485295 Log: Fixed many Sonar warnings : o Useless null checks o Bad switch.. case handling with useless fallbacks o Removed commented code o Improved some Map parsing o Removed the AbstractChemaLoader listener, as it's never used and potantially not thread safe o Fixed some signed byte manipulations Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultAttribute.java directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultEntry.java directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/password/PasswordUtil.java directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AttributesFactory.java directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/AbstractSchemaLoader.java directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/SchemaLoader.java directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/helper/LdapSyntaxHelper.java directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/helper/MatchingRuleHelper.java directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/FacsimileTelephoneNumberSyntaxChecker.java directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schemaloader/LdifSchemaLoader.java directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/Hex.java Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultAttribute.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultAttribute.java?rev=1485295&r1=1485294&r2=1485295&view=diff ============================================================================== --- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultAttribute.java (original) +++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultAttribute.java Wed May 22 17:26:06 2013 @@ -1042,13 +1042,6 @@ public class DefaultAttribute implements Value value = createBinaryValue( attributeType, valBytes ); - if ( value == null ) - { - // The value can't be normalized or is invalid : we don't add it. - LOG.error( I18n.err( I18n.ERR_04449, val ) ); - continue; - } - // Now call the add(Value) method if ( add( value ) == 1 ) { @@ -1935,7 +1928,7 @@ public class DefaultAttribute implements attribute.id = attributeType.getOid(); attribute.attributeType = attributeType; } - + attribute.values = new LinkedHashSet>( values.size() ); for ( Value value : values ) Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultEntry.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultEntry.java?rev=1485295&r1=1485294&r2=1485295&view=diff ============================================================================== --- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultEntry.java (original) +++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultEntry.java Wed May 22 17:26:06 2013 @@ -1068,7 +1068,7 @@ public final class DefaultEntry implemen AttributeType attributeType = entryAttribute.getAttributeType(); - if ( ( entryAttribute == null ) || !this.attributes.containsKey( attributeType.getOid() ) ) + if ( ( attributeType == null ) || !this.attributes.containsKey( attributeType.getOid() ) ) { return false; } Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/password/PasswordUtil.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/password/PasswordUtil.java?rev=1485295&r1=1485294&r2=1485295&view=diff ============================================================================== --- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/password/PasswordUtil.java (original) +++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/password/PasswordUtil.java Wed May 22 17:26:06 2013 @@ -359,8 +359,6 @@ public class PasswordUtil { int algoLength = encryptionMethod.getAlgorithm().getName().length() + 2; - int hashLen = 0; - switch ( encryptionMethod.getAlgorithm() ) { case HASH_METHOD_MD5: @@ -403,50 +401,19 @@ public class PasswordUtil } case HASH_METHOD_SSHA: - hashLen = SHA1_LENGTH; + return getCredentials( credentials, algoLength, SHA1_LENGTH, encryptionMethod ); case HASH_METHOD_SHA256: case HASH_METHOD_SSHA256: - if ( hashLen == 0 ) - { - hashLen = SHA256_LENGTH; - } + return getCredentials( credentials, algoLength, SHA256_LENGTH, encryptionMethod ); case HASH_METHOD_SHA384: case HASH_METHOD_SSHA384: - if ( hashLen == 0 ) - { - hashLen = SHA384_LENGTH; - } + return getCredentials( credentials, algoLength, SHA512_LENGTH, encryptionMethod ); case HASH_METHOD_SHA512: case HASH_METHOD_SSHA512: - if ( hashLen == 0 ) - { - hashLen = SHA512_LENGTH; - } - - try - { - // The password is associated with a salt. Decompose it - // in two parts, after having decoded the password. - // The salt will be stored into the EncryptionMethod structure - // The salt is at the end of the credentials, and is 8 bytes long - byte[] passwordAndSalt = Base64.decode( new String( credentials, algoLength, credentials.length - - algoLength, "UTF-8" ).toCharArray() ); - - int saltLength = passwordAndSalt.length - hashLen; - encryptionMethod.setSalt( new byte[saltLength] ); - byte[] password = new byte[hashLen]; - split( passwordAndSalt, 0, password, encryptionMethod.getSalt() ); - - return password; - } - catch ( UnsupportedEncodingException uee ) - { - // do nothing - return credentials; - } + return getCredentials( credentials, algoLength, SHA512_LENGTH, encryptionMethod ); case HASH_METHOD_CRYPT: // The password is associated with a salt. Decompose it @@ -466,6 +433,36 @@ public class PasswordUtil } + /** + * Compute the credentials + */ + private static byte[] getCredentials( byte[] credentials, int algoLength, int hashLen, + EncryptionMethod encryptionMethod ) + { + try + { + // The password is associated with a salt. Decompose it + // in two parts, after having decoded the password. + // The salt will be stored into the EncryptionMethod structure + // The salt is at the end of the credentials, and is 8 bytes long + byte[] passwordAndSalt = Base64.decode( new String( credentials, algoLength, credentials.length + - algoLength, "UTF-8" ).toCharArray() ); + + int saltLength = passwordAndSalt.length - hashLen; + encryptionMethod.setSalt( new byte[saltLength] ); + byte[] password = new byte[hashLen]; + split( passwordAndSalt, 0, password, encryptionMethod.getSalt() ); + + return password; + } + catch ( UnsupportedEncodingException uee ) + { + // do nothing + return credentials; + } + } + + private static void split( byte[] all, int offset, byte[] left, byte[] right ) { System.arraycopy( all, offset, left, 0, left.length ); Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AttributesFactory.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AttributesFactory.java?rev=1485295&r1=1485294&r2=1485295&view=diff ============================================================================== --- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AttributesFactory.java (original) +++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AttributesFactory.java Wed May 22 17:26:06 2013 @@ -30,19 +30,6 @@ import org.apache.directory.api.ldap.mod import org.apache.directory.api.ldap.model.entry.DefaultEntry; import org.apache.directory.api.ldap.model.entry.Entry; import org.apache.directory.api.ldap.model.exception.LdapException; -import org.apache.directory.api.ldap.model.schema.AttributeType; -import org.apache.directory.api.ldap.model.schema.DitContentRule; -import org.apache.directory.api.ldap.model.schema.DitStructureRule; -import org.apache.directory.api.ldap.model.schema.LdapComparator; -import org.apache.directory.api.ldap.model.schema.LdapSyntax; -import org.apache.directory.api.ldap.model.schema.MatchingRule; -import org.apache.directory.api.ldap.model.schema.MatchingRuleUse; -import org.apache.directory.api.ldap.model.schema.NameForm; -import org.apache.directory.api.ldap.model.schema.Normalizer; -import org.apache.directory.api.ldap.model.schema.ObjectClass; -import org.apache.directory.api.ldap.model.schema.SchemaManager; -import org.apache.directory.api.ldap.model.schema.SchemaObject; -import org.apache.directory.api.ldap.model.schema.SyntaxChecker; import org.apache.directory.api.ldap.model.schema.registries.Schema; import org.apache.directory.api.util.DateUtils; @@ -431,9 +418,10 @@ public class AttributesFactory if ( extensions != null ) { - for ( String key : extensions.keySet() ) + for ( Map.Entry> mapEntry : extensions.entrySet() ) { - List values = extensions.get( key ); + String key = mapEntry.getKey(); + List values = mapEntry.getValue(); for ( String value : values ) { Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/AbstractSchemaLoader.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/AbstractSchemaLoader.java?rev=1485295&r1=1485294&r2=1485295&view=diff ============================================================================== --- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/AbstractSchemaLoader.java (original) +++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/AbstractSchemaLoader.java Wed May 22 17:26:06 2013 @@ -34,7 +34,6 @@ import org.apache.directory.api.ldap.mod import org.apache.directory.api.ldap.model.entry.Attribute; import org.apache.directory.api.ldap.model.entry.Entry; import org.apache.directory.api.ldap.model.entry.Value; -import org.apache.directory.api.ldap.model.schema.SchemaManager; import org.apache.directory.api.util.StringConstants; import org.apache.directory.api.util.Strings; @@ -46,10 +45,6 @@ import org.apache.directory.api.util.Str */ public abstract class AbstractSchemaLoader implements SchemaLoader { - - /** The listener. */ - protected SchemaLoaderListener listener; - /** * A map of all available schema names to schema objects. This map is * populated when this class is created with all the schemas present in @@ -86,35 +81,6 @@ public abstract class AbstractSchemaLoad /** * {@inheritDoc} */ - public void setListener( SchemaLoaderListener listener ) - { - this.listener = listener; - } - - - /** - * Notify listener or registries. - * - * @param schema the schema - * @param registries the registries - */ - protected final void notifyListenerOrRegistries( Schema schema, SchemaManager schemaManager ) - { - if ( listener != null ) - { - listener.schemaLoaded( schema ); - } - - if ( schemaManager != listener ) - { - schemaManager.getRegistries().schemaLoaded( schema ); - } - } - - - /** - * {@inheritDoc} - */ public final Collection getAllEnabled() throws Exception { Collection enabledSchemas = new ArrayList(); @@ -242,424 +208,6 @@ public abstract class AbstractSchemaLoad } - // TODO: clean commented code - - /* - * {@inheritDoc} - * - public List loadWithDependencies( Registries registries, boolean check, Schema... schemas ) throws Exception - { - // Relax the controls at first - List errors = new ArrayList(); - boolean wasRelaxed = registries.isRelaxed(); - registries.setRelaxed( true ); - - Map notLoaded = new HashMap(); - - for ( Schema schema : schemas ) - { - if ( ! registries.isSchemaLoaded( schema.getSchemaName() ) ) - { - notLoaded.put( schema.getSchemaName(), schema ); - } - } - - for ( Schema schema : notLoaded.values() ) - { - Stack beenthere = new Stack(); - loadDepsFirst( schema, beenthere, notLoaded, schema, registries ); - } - - // At the end, check the registries if required - if ( check ) - { - errors = registries.checkRefInteg(); - } - - // Restore the Registries isRelaxed flag - registries.setRelaxed( wasRelaxed ); - - return errors; - } - - - /** - * Register the comparator contained in the given LdifEntry into the registries. - * - * @param registries The Registries - * @param entry The LdifEntry containing the comparator description - * @param schema The associated schema - * @throws Exception If the registering failed - * - protected LdapComparator registerComparator( Registries registries, LdifEntry entry, Schema schema ) - throws Exception - { - return registerComparator( registries, entry.getEntry(), schema ); - } - - - /** - * Register the comparator contained in the given Entry into the registries. - * - * @param registries The Registries - * @param entry The Entry containing the comparator description - * @param schema The associated schema - * @throws Exception If the registering failed - * - protected LdapComparator registerComparator( Registries registries, Entry entry, Schema schema ) - throws Exception - { - LdapComparator comparator = - factory.getLdapComparator( entry, registries, schema.getSchemaName() ); - comparator.setOid( entry.get( MetaSchemaConstants.M_OID_AT ).getString() ); - - if ( registries.isRelaxed() ) - { - if ( registries.acceptDisabled() ) - { - registries.register( comparator ); - } - else if ( schema.isEnabled() && comparator.isEnabled() ) - { - registries.register( comparator ); - } - } - else - { - if ( schema.isEnabled() && comparator.isEnabled() ) - { - registries.register( comparator ); - } - } - - return comparator; - } - - - /** - * Register the SyntaxChecker contained in the given LdifEntry into the registries. - * - * @param registries The Registries - * @param entry The LdifEntry containing the SyntaxChecker description - * @param schema The associated schema - * @return the created SyntaxChecker instance - * @throws Exception If the registering failed - * - protected SyntaxChecker registerSyntaxChecker( Registries registries, LdifEntry entry, Schema schema) - throws Exception - { - SyntaxChecker syntaxChecker = - factory.getSyntaxChecker( entry.getEntry(), registries, schema.getSchemaName() ); - syntaxChecker.setOid( entry.get( MetaSchemaConstants.M_OID_AT ).getString() ); - - if ( registries.isRelaxed() ) - { - if ( registries.acceptDisabled() ) - { - registries.register( syntaxChecker ); - } - else if ( schema.isEnabled() && syntaxChecker.isEnabled() ) - { - registries.register( syntaxChecker ); - } - } - else - { - if ( schema.isEnabled() && syntaxChecker.isEnabled() ) - { - registries.register( syntaxChecker ); - } - } - - return syntaxChecker; - } - - - /** - * Register the Normalizer contained in the given LdifEntry into the registries. - * - * @param registries The Registries - * @param entry The LdifEntry containing the Normalizer description - * @param schema The associated schema - * @return the created Normalizer instance - * @throws Exception If the registering failed - * - protected Normalizer registerNormalizer( Registries registries, LdifEntry entry, Schema schema) - throws Exception - { - Normalizer normalizer = - factory.getNormalizer( entry.getEntry(), registries, schema.getSchemaName() ); - - if ( registries.isRelaxed() ) - { - if ( registries.acceptDisabled() ) - { - registries.register( normalizer ); - } - else if ( schema.isEnabled() && normalizer.isEnabled() ) - { - registries.register( normalizer ); - } - } - else - { - if ( schema.isEnabled() && normalizer.isEnabled() ) - { - registries.register( normalizer ); - } - } - - return normalizer; - } - - - /** - * Register the MatchingRule contained in the given LdifEntry into the registries. - * - * @param registries The Registries - * @param entry The LdifEntry containing the MatchingRule description - * @param schema The associated schema - * @return the created MatchingRule instance - * @throws Exception If the registering failed - * - protected MatchingRule registerMatchingRule( Registries registries, LdifEntry entry, Schema schema) - throws Exception - { - MatchingRule matchingRule = factory.getMatchingRule( - entry.getEntry(), registries, schema.getSchemaName() ); - - if ( registries.isRelaxed() ) - { - if ( registries.acceptDisabled() ) - { - registries.register( matchingRule ); - } - else if ( schema.isEnabled() && matchingRule.isEnabled() ) - { - registries.register( matchingRule ); - } - } - else - { - if ( schema.isEnabled() && matchingRule.isEnabled() ) - { - registries.register( matchingRule ); - } - } - - return matchingRule; - } - - - /** - * Register the Syntax contained in the given LdifEntry into the registries. - * - * @param registries The Registries - * @param entry The LdifEntry containing the Syntax description - * @param schema The associated schema - * @return the created Syntax instance - * @throws Exception If the registering failed - * - protected LdapSyntax registerSyntax( Registries registries, LdifEntry entry, Schema schema) - throws Exception - { - LdapSyntax syntax = factory.getSyntax( - entry.getEntry(), registries, schema.getSchemaName() ); - - if ( registries.isRelaxed() ) - { - if ( registries.acceptDisabled() ) - { - registries.register( syntax ); - } - else if ( schema.isEnabled() && syntax.isEnabled() ) - { - registries.register( syntax ); - } - } - else - { - if ( schema.isEnabled() && syntax.isEnabled() ) - { - registries.register( syntax ); - } - } - - return syntax; - } - - - /** - * Register the AttributeType contained in the given LdifEntry into the registries. - * - * @param registries The Registries - * @param entry The LdifEntry containing the AttributeType description - * @param schema The associated schema - * @return the created AttributeType instance - * @throws Exception If the registering failed - * - protected AttributeType registerAttributeType( Registries registries, LdifEntry entry, Schema schema ) - throws Exception - { - AttributeType attributeType = factory.getAttributeType( entry.getEntry(), registries, schema.getSchemaName() ); - - if ( registries.isRelaxed() ) - { - if ( registries.acceptDisabled() ) - { - registries.register( attributeType ); - } - else if ( schema.isEnabled() && attributeType.isEnabled() ) - { - registries.register( attributeType ); - } - } - else - { - if ( schema.isEnabled() && attributeType.isEnabled() ) - { - registries.register( attributeType ); - } - } - - return attributeType; - } - - - /** - * Register the MatchingRuleUse contained in the given LdifEntry into the registries. - * - * @param registries The Registries - * @param entry The LdifEntry containing the MatchingRuleUse description - * @param schema The associated schema - * @return the created MatchingRuleUse instance - * @throws Exception If the registering failed - * - protected MatchingRuleUse registerMatchingRuleUse( Registries registries, LdifEntry entry, Schema schema) - throws Exception - { - throw new NotImplementedException( "Need to implement factory " + - "method for creating a MatchingRuleUse" ); - } - - - /** - * Register the NameForm contained in the given LdifEntry into the registries. - * - * @param registries The Registries - * @param entry The LdifEntry containing the NameForm description - * @param schema The associated schema - * @return the created NameForm instance - * @throws Exception If the registering failed - * - protected NameForm registerNameForm( Registries registries, LdifEntry entry, Schema schema) - throws Exception - { - throw new NotImplementedException( "Need to implement factory " + - "method for creating a NameForm" ); - } - - - /** - * Register the DitContentRule contained in the given LdifEntry into the registries. - * - * @param registries The Registries - * @param entry The LdifEntry containing the DitContentRule description - * @param schema The associated schema - * @return the created DitContentRule instance - * @throws Exception If the registering failed - * - protected DitContentRule registerDitContentRule( Registries registries, LdifEntry entry, Schema schema) - throws Exception - { - throw new NotImplementedException( "Need to implement factory " + - "method for creating a DitContentRule" ); - } - - - /** - * Register the DitStructureRule contained in the given LdifEntry into the registries. - * - * @param registries The Registries - * @param entry The LdifEntry containing the DitStructureRule description - * @param schema The associated schema - * @return the created DitStructureRule instance - * @throws Exception If the registering failed - * - protected DitStructureRule registerDitStructureRule( Registries registries, LdifEntry entry, Schema schema) - throws Exception - { - throw new NotImplementedException( "Need to implement factory " + - "method for creating a DitStructureRule" ); - } - - - /** - * Register the ObjectClass contained in the given LdifEntry into the registries. - * - * @param registries The Registries - * @param entry The LdifEntry containing the ObjectClass description - * @param schema The associated schema - * @return the created ObjectClass instance - * @throws Exception If the registering failed - * - protected ObjectClass registerObjectClass( Registries registries, LdifEntry entry, Schema schema) - throws Exception - { - return registerObjectClass( registries, entry.getEntry(), schema ); - } - - - /** - * Register the ObjectClass contained in the given LdifEntry into the registries. - * - * @param registries The Registries - * @param entry The Entry containing the ObjectClass description - * @param schema The associated schema - * @return the created ObjectClass instance - * @throws Exception If the registering failed - * - protected ObjectClass registerObjectClass( Registries registries, Entry entry, Schema schema) - throws Exception - { - ObjectClass objectClass = factory.getObjectClass( entry, registries, schema.getSchemaName() ); - - if ( registries.isRelaxed() ) - { - if ( registries.acceptDisabled() ) - { - registries.register( objectClass ); - } - else if ( schema.isEnabled() && objectClass.isEnabled() ) - { - registries.register( objectClass ); - } - } - else - { - if ( schema.isEnabled() && objectClass.isEnabled() ) - { - registries.register( objectClass ); - } - } - - return objectClass; - } - - - public EntityFactory getFactory() - { - return factory; - } - */ - - // TODO: is this used? - public Object getDao() - { - return null; - } - - private Schema[] buildSchemaArray( String... schemaNames ) throws Exception { Schema[] schemas = new Schema[schemaNames.length]; Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/SchemaLoader.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/SchemaLoader.java?rev=1485295&r1=1485294&r2=1485295&view=diff ============================================================================== --- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/SchemaLoader.java (original) +++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/SchemaLoader.java Wed May 22 17:26:06 2013 @@ -36,14 +36,6 @@ import org.apache.directory.api.ldap.mod public interface SchemaLoader { /** - * Sets listener used to notify of newly loaded schemas. - * - * @param listener the listener to notify (only one is enough for us) - */ - void setListener( SchemaLoaderListener listener ); - - - /** * Gets a schema object based on it's name. * * @param schemaName the name of the schema to load Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/helper/LdapSyntaxHelper.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/helper/LdapSyntaxHelper.java?rev=1485295&r1=1485294&r2=1485295&view=diff ============================================================================== --- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/helper/LdapSyntaxHelper.java (original) +++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/helper/LdapSyntaxHelper.java Wed May 22 17:26:06 2013 @@ -55,28 +55,25 @@ public class LdapSyntaxHelper { ldapSyntax.unlock(); - if ( registries != null ) - { - SyntaxChecker syntaxChecker = null; + SyntaxChecker syntaxChecker = null; - try - { - // Gets the associated SyntaxChecker - syntaxChecker = registries.getSyntaxCheckerRegistry().lookup( ldapSyntax.getOid() ); - } - catch ( LdapException ne ) - { - // No SyntaxChecker ? Associate the Syntax to a catch all SyntaxChecker - syntaxChecker = new OctetStringSyntaxChecker( ldapSyntax.getOid() ); - } + try + { + // Gets the associated SyntaxChecker + syntaxChecker = registries.getSyntaxCheckerRegistry().lookup( ldapSyntax.getOid() ); + } + catch ( LdapException ne ) + { + // No SyntaxChecker ? Associate the Syntax to a catch all SyntaxChecker + syntaxChecker = new OctetStringSyntaxChecker( ldapSyntax.getOid() ); + } - // Add the references for S : - // S -> SC - if ( syntaxChecker != null ) - { - registries.addReference( ldapSyntax, syntaxChecker ); - ldapSyntax.setSyntaxChecker( syntaxChecker ); - } + // Add the references for S : + // S -> SC + if ( syntaxChecker != null ) + { + registries.addReference( ldapSyntax, syntaxChecker ); + ldapSyntax.setSyntaxChecker( syntaxChecker ); } } finally Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/helper/MatchingRuleHelper.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/helper/MatchingRuleHelper.java?rev=1485295&r1=1485294&r2=1485295&view=diff ============================================================================== --- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/helper/MatchingRuleHelper.java (original) +++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/helper/MatchingRuleHelper.java Wed May 22 17:26:06 2013 @@ -69,75 +69,72 @@ public class MatchingRuleHelper { matchingRule.unlock(); - if ( registries != null ) + LdapComparator ldapComparator = null; + Normalizer normalizer = null; + LdapSyntax ldapSyntax = null; + + try + { + // Gets the associated Comparator + ldapComparator = registries.getComparatorRegistry().lookup( matchingRule.getOid() ); + } + catch ( LdapException ne ) + { + // Default to a catch all comparator + ldapComparator = new ComparableComparator( matchingRule.getOid() ); + } + + try + { + // Gets the associated Normalizer + normalizer = registries.getNormalizerRegistry().lookup( matchingRule.getOid() ); + } + catch ( LdapException ne ) + { + // Default to the NoOp normalizer + normalizer = new NoOpNormalizer( matchingRule.getOid() ); + } + + try + { + // Get the associated LdapSyntax + ldapSyntax = registries.getLdapSyntaxRegistry().lookup( matchingRule.getSyntaxOid() ); + } + catch ( LdapException ne ) + { + // The Syntax is a mandatory element, it must exist. + String msg = I18n.err( I18n.ERR_04317 ); + + LdapSchemaException ldapSchemaException = new LdapSchemaException( + LdapSchemaExceptionCodes.MR_NONEXISTENT_SYNTAX, msg, ne ); + ldapSchemaException.setSourceObject( matchingRule ); + ldapSchemaException.setRelatedId( matchingRule.getSyntaxOid() ); + errors.add( ldapSchemaException ); + LOG.info( msg ); + } + + /** + * Add the MR references (using and usedBy) : + * MR -> C + * MR -> N + * MR -> S + */ + if ( ldapComparator != null ) + { + registries.addReference( matchingRule, ldapComparator ); + matchingRule.setLdapComparator( ldapComparator ); + } + + if ( normalizer != null ) + { + registries.addReference( matchingRule, normalizer ); + matchingRule.setNormalizer( normalizer ); + } + + if ( ldapSyntax != null ) { - LdapComparator ldapComparator = null; - Normalizer normalizer = null; - LdapSyntax ldapSyntax = null; - - try - { - // Gets the associated Comparator - ldapComparator = registries.getComparatorRegistry().lookup( matchingRule.getOid() ); - } - catch ( LdapException ne ) - { - // Default to a catch all comparator - ldapComparator = new ComparableComparator( matchingRule.getOid() ); - } - - try - { - // Gets the associated Normalizer - normalizer = registries.getNormalizerRegistry().lookup( matchingRule.getOid() ); - } - catch ( LdapException ne ) - { - // Default to the NoOp normalizer - normalizer = new NoOpNormalizer( matchingRule.getOid() ); - } - - try - { - // Get the associated LdapSyntax - ldapSyntax = registries.getLdapSyntaxRegistry().lookup( matchingRule.getSyntaxOid() ); - } - catch ( LdapException ne ) - { - // The Syntax is a mandatory element, it must exist. - String msg = I18n.err( I18n.ERR_04317 ); - - LdapSchemaException ldapSchemaException = new LdapSchemaException( - LdapSchemaExceptionCodes.MR_NONEXISTENT_SYNTAX, msg, ne ); - ldapSchemaException.setSourceObject( matchingRule ); - ldapSchemaException.setRelatedId( matchingRule.getSyntaxOid() ); - errors.add( ldapSchemaException ); - LOG.info( msg ); - } - - /** - * Add the MR references (using and usedBy) : - * MR -> C - * MR -> N - * MR -> S - */ - if ( ldapComparator != null ) - { - registries.addReference( matchingRule, ldapComparator ); - matchingRule.setLdapComparator( ldapComparator ); - } - - if ( normalizer != null ) - { - registries.addReference( matchingRule, normalizer ); - matchingRule.setNormalizer( normalizer ); - } - - if ( ldapSyntax != null ) - { - registries.addReference( matchingRule, ldapSyntax ); - matchingRule.setSyntax( ldapSyntax ); - } + registries.addReference( matchingRule, ldapSyntax ); + matchingRule.setSyntax( ldapSyntax ); } } finally Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/FacsimileTelephoneNumberSyntaxChecker.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/FacsimileTelephoneNumberSyntaxChecker.java?rev=1485295&r1=1485294&r2=1485295&view=diff ============================================================================== --- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/FacsimileTelephoneNumberSyntaxChecker.java (original) +++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/FacsimileTelephoneNumberSyntaxChecker.java Wed May 22 17:26:06 2013 @@ -172,7 +172,7 @@ public class FacsimileTelephoneNumberSyn faxParam = strValue.substring( dollarPos + 1, newDollar ); } - if ( faxParam == null ) + if ( faxParam.length() == 0 ) { // Not allowed LOG.debug( "Syntax invalid for '{}'", value ); Modified: directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schemaloader/LdifSchemaLoader.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schemaloader/LdifSchemaLoader.java?rev=1485295&r1=1485294&r2=1485295&view=diff ============================================================================== --- directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schemaloader/LdifSchemaLoader.java (original) +++ directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schemaloader/LdifSchemaLoader.java Wed May 22 17:26:06 2013 @@ -163,79 +163,6 @@ public class LdifSchemaLoader extends Ab /** - * {@inheritDoc} - * - public List loadWithDependencies( Schema schema, Registries registries, boolean check ) throws Exception - { - // Relax the controls at first - List errors = new ArrayList(); - boolean wasRelaxed = registries.isRelaxed(); - registries.setRelaxed( true ); - - Stack beenthere = new Stack(); - Map notLoaded = new HashMap(); - notLoaded.put( schema.getSchemaName(), schema ); - super.loadDepsFirst( schema, beenthere, notLoaded, schema, registries ); - - // At the end, check the registries if required - if ( check ) - { - errors = registries.checkRefInteg(); - } - - // Restore the Registries isRelaxed flag - registries.setRelaxed( wasRelaxed ); - - return errors; - } - - - /** - * Loads a single schema if it has not been loaded already. If the schema - * load request was made because some other schema depends on this one then - * the schema is checked to see if it is disabled. If disabled it is - * enabled with a write to disk and then loaded. Listeners are notified that - * the schema has been loaded. - * - * {@inheritDoc} - * - public void load( Schema schema, Registries registries, boolean isDepLoad ) throws Exception - { - // if we're loading a dependency and it has not been enabled on - // disk then enable it on disk before we proceed to load it - if ( schema.isDisabled() && isDepLoad ) - { - enableSchema( schema ); - } - - if ( registries.isSchemaLoaded( schema.getSchemaName() ) ) - { - LOG.info( "Will not attempt to load already loaded '{}' " + - "schema: \n{}", schema.getSchemaName(), schema ); - return; - } - - LOG.info( "Loading {} schema: \n{}", schema.getSchemaName(), schema ); - - registries.schemaLoaded( schema ); - - loadComparators( schema ); - loadNormalizers( schema, registries ); - loadSyntaxCheckers( schema, registries ); - loadSyntaxes( schema, registries ); - loadMatchingRules( schema, registries ); - loadAttributeTypes( schema, registries ); - loadObjectClasses( schema, registries ); - loadMatchingRuleUses( schema, registries ); - loadDitContentRules( schema, registries ); - loadNameForms( schema, registries ); - loadDitStructureRules( schema, registries ); - - notifyListenerOrRegistries( schema, registries ); - } - - - /** * Utility method to get the file for a schema directory. * * @param schema the schema to get the file for Modified: directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/Hex.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/Hex.java?rev=1485295&r1=1485294&r2=1485295&view=diff ============================================================================== --- directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/Hex.java (original) +++ directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/Hex.java Wed May 22 17:26:06 2013 @@ -20,10 +20,10 @@ package org.apache.directory.api.util; -import org.apache.directory.api.i18n.I18n; - import javax.naming.InvalidNameException; +import org.apache.directory.api.i18n.I18n; + /** * Various hex and string manipulation methods that are more efficient then @@ -38,15 +38,120 @@ public class Hex public static final byte[] HEX_VALUE = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 00 -> 0F - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 10 -> 1F - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 20 -> 2F - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, // 30 -> 3F ( 0, 1,2, 3, 4,5, 6, 7, 8, 9 ) - -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 40 -> 4F ( A, B, C, D, E, F ) - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 50 -> 5F - -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 60 -> 6F ( a, b, c, d, e, f ) - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 70 -> 7F - }; - + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, // 10 -> 1F + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, // 20 -> 2F + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + -1, + -1, + -1, + -1, + -1, + -1, // 30 -> 3F ( 0, 1,2, 3, 4,5, 6, 7, 8, 9 ) + -1, + 10, + 11, + 12, + 13, + 14, + 15, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, // 40 -> 4F ( A, B, C, D, E, F ) + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, // 50 -> 5F + -1, + 10, + 11, + 12, + 13, + 14, + 15, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, // 60 -> 6F ( a, b, c, d, e, f ) + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, // 70 -> 7F + }; + /** Used to build output as Hex */ public static final char[] HEX_CHAR = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; @@ -81,7 +186,7 @@ public class Hex */ public static byte getHexValue( byte high, byte low ) { - if ( ( high > 127 ) || ( low > 127 ) || ( high < 0 ) | ( low < 0 ) ) + if ( ( ( high & 0x7F ) != high ) || ( ( low & 0x7F ) != low ) ) { return -1; }