You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2005/11/05 08:20:39 UTC

svn commit: r330978 - in /directory: apacheds/trunk/core/src/main/java/org/apache/ldap/server/ apacheds/trunk/core/src/main/java/org/apache/ldap/server/schema/ apacheds/trunk/core/src/main/java/org/apache/ldap/server/schema/bootstrap/ apacheds/trunk/se...

Author: akarasulu
Date: Fri Nov  4 23:20:26 2005
New Revision: 330978

URL: http://svn.apache.org/viewcvs?rev=330978&view=rev
Log:
changes ...

 o touched up DIREVE-163
 o server now sets the JNDI parameter java.naming.ldap.attributes.binary by
   using the schema of the server - the human readable property of the 
   attributeTypes in the system are used to determine if the attribute is
   binary
 o the server takes the union of the schema information along with the values
   provided in this parameter 
 o the server replaces or adds this property key as a Set object
 o the ldap-common MessageDecoder code can detect if a Set is used and 
   will use that to feed the providers a set
 

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/DefaultDirectoryService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/schema/SchemaService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/schema/bootstrap/SystemSyntaxProducer.java
    directory/apacheds/trunk/server-main/server.xml
    directory/apacheds/trunk/server-unit/   (props changed)
    directory/shared/ldap/trunk/apache-provider/src/main/java/org/apache/ldap/common/berlib/asn1/SnickersDecoder.java
    directory/shared/ldap/trunk/apache-provider/src/main/java/org/apache/ldap/common/berlib/asn1/SnickersProvider.java
    directory/shared/ldap/trunk/apache2-provider/src/main/java/org/apache/asn1new/ldap/TwixDecoder.java
    directory/shared/ldap/trunk/apache2-provider/src/main/java/org/apache/asn1new/ldap/TwixProvider.java
    directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/message/MessageDecoder.java
    directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/message/spi/Provider.java
    directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/schema/SchemaUtils.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/DefaultDirectoryService.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/DefaultDirectoryService.java?rev=330978&r1=330977&r2=330978&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/DefaultDirectoryService.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/DefaultDirectoryService.java Fri Nov  4 23:20:26 2005
@@ -18,6 +18,8 @@
 
 import java.util.Hashtable;
 import java.util.Iterator;
+import java.util.Set;
+import java.util.HashSet;
 
 import javax.naming.Context;
 import javax.naming.Name;
@@ -35,6 +37,7 @@
 import org.apache.ldap.common.name.LdapName;
 import org.apache.ldap.common.name.NameComponentNormalizer;
 import org.apache.ldap.common.util.DateUtils;
+import org.apache.ldap.common.schema.AttributeType;
 import org.apache.ldap.server.authz.AuthorizationService;
 import org.apache.ldap.server.configuration.Configuration;
 import org.apache.ldap.server.configuration.ConfigurationException;
@@ -49,6 +52,7 @@
 import org.apache.ldap.server.schema.GlobalRegistries;
 import org.apache.ldap.server.schema.bootstrap.BootstrapRegistries;
 import org.apache.ldap.server.schema.bootstrap.BootstrapSchemaLoader;
+import org.apache.asn1.codec.util.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -62,6 +66,7 @@
 class DefaultDirectoryService extends DirectoryService
 {
     private static final Logger log = LoggerFactory.getLogger( DefaultDirectoryService.class );
+    private static final String BINARY_KEY = "java.naming.ldap.attributes.binary";
 
     private final String instanceId;
 
@@ -605,7 +610,7 @@
         {
             needToChangeAdminPassword = DirectoryPartitionNexus.ADMIN_PASSWORD.equals( new String( ( byte[] ) userPassword ) );
         }
-        else if ( userPassword.toString().equals( new String( DirectoryPartitionNexus.ADMIN_PASSWORD ) ) )
+        else if ( userPassword.toString().equals( DirectoryPartitionNexus.ADMIN_PASSWORD ) )
         {
             needToChangeAdminPassword = DirectoryPartitionNexus.ADMIN_PASSWORD.equals( userPassword.toString() );
         }
@@ -645,6 +650,7 @@
         }
     }
 
+
     /**
      * Kicks off the initialization of the entire system.
      *
@@ -673,6 +679,69 @@
 
         globalRegistries = new GlobalRegistries( bootstrapRegistries );
         
+        if ( this.environment.containsKey( BINARY_KEY ) )
+        {
+            if ( log.isInfoEnabled() )
+            {
+                log.info( "Startup environment contains " + BINARY_KEY );
+            }
+
+            String binaryIds = ( String ) this.environment.get( BINARY_KEY );
+            Set binaries = new HashSet();
+            if ( binaryIds == null )
+            {
+                if ( log.isWarnEnabled() )
+                {
+                    log.warn( BINARY_KEY + " in startup environment contains null value.  " +
+                        "Using only schema info to set binary attributeTypes." );
+                }
+            }
+            else
+            {
+                if ( ! StringUtils.isEmpty( binaryIds ) )
+                {
+                    String[] binaryArray = binaryIds.split( " " );
+
+                    for ( int i = 0; i < binaryArray.length; i++ )
+                    {
+                        binaries.add( StringUtils.lowerCase( StringUtils.trim( binaryArray[i] ) ) );
+                    }
+                }
+
+                if ( log.isInfoEnabled() )
+                {
+                    log.info( "Setting binaries to union of schema defined binaries and those provided in "
+                            + BINARY_KEY );
+                }
+            }
+
+            AttributeTypeRegistry registry = globalRegistries.getAttributeTypeRegistry();
+            Iterator list = registry.list();
+            while ( list.hasNext() )
+            {
+                AttributeType type = ( AttributeType ) list.next();
+                if ( ! type.getSyntax().isHumanReadible() )
+                {
+                    // add the OID for the attributeType
+                    binaries.add( type.getOid() );
+
+                    // add the lowercased name for the names for the attributeType
+                    String[] names = type.getNames();
+                    for ( int ii = 0; ii < names.length; ii++ )
+                    {
+                        binaries.add( StringUtils.lowerCase( StringUtils.trim( names[ii] ) ) );
+                    }
+                }
+            }
+
+            this.environment.put( BINARY_KEY, binaries );
+
+            if ( log.isDebugEnabled() )
+            {
+                log.debug( "binary ids used: " + binaries );
+            }
+        }
+
         partitionNexus = new DefaultDirectoryPartitionNexus( new LockableAttributesImpl() );
         partitionNexus.init( configuration, null );
         

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/schema/SchemaService.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/schema/SchemaService.java?rev=330978&r1=330977&r2=330978&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/schema/SchemaService.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/schema/SchemaService.java Fri Nov  4 23:20:26 2005
@@ -18,7 +18,6 @@
 
 
 import java.util.HashSet;
-import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
@@ -114,36 +113,20 @@
         startUpTimeStamp = DateUtils.getGeneralizedTime();
     }
 
-    private void initBinaries( Hashtable env ) 
-    {
-        // construct the set for fast lookups while filtering
-        String binaryIds = (String)env.get( BINARY_KEY );
-
-        binaries = new HashSet();
-
-        if ( StringUtils.isEmpty( binaryIds ) == false )
-        {
-            String[] binaryArray = binaryIds.split( "/" );
-            
-            for ( int i = 0; i < binaryArray.length; i++ )
-            {
-                binaries.add( StringUtils.lowerCase( StringUtils.trim( binaryArray[i] ) ) );
-            }
-        }
-    }
 
     public void init( DirectoryServiceConfiguration factoryCfg, InterceptorConfiguration cfg ) throws NamingException
     {
         this.nexus = factoryCfg.getPartitionNexus();
         this.globalRegistries = factoryCfg.getGlobalRegistries();
         binaryAttributeFilter = new BinaryAttributeFilter();
-        initBinaries( factoryCfg.getEnvironment() );
+        binaries = ( Set ) factoryCfg.getEnvironment().get( BINARY_KEY );
 
         // stuff for dealing with subentries (garbage for now)
         String subschemaSubentry = ( String ) nexus.getRootDSE().get( "subschemaSubentry" ).get();
         subentryDn = new LdapName( subschemaSubentry ).toString().toLowerCase();
     }
 
+
     /**
      * @return Returns the binaries.
      */
@@ -152,6 +135,7 @@
         return binaries.contains( StringUtils.lowerCase( StringUtils.trim( id ) ) );
     }
 
+
     public void destroy()
     {
     }
@@ -401,8 +385,7 @@
     public Attributes lookup( NextInterceptor nextInterceptor, Name name ) throws NamingException
     {
         Attributes result = nextInterceptor.lookup( name );
-        Invocation invocation = InvocationStack.getInstance().peek();
-        doFilter( invocation, result );
+        doFilter( result );
         return result;
     }
 
@@ -415,8 +398,7 @@
             return null;
         }
 
-        Invocation invocation = InvocationStack.getInstance().peek();
-        doFilter( invocation, result );
+        doFilter( result );
         return result;
     }
 
@@ -639,8 +621,7 @@
     }
 
 
-    private void doFilter( Invocation invocation, Attributes entry )
-            throws NamingException
+    private void doFilter( Attributes entry ) throws NamingException
     {
         long t0 = System.currentTimeMillis();
         
@@ -727,7 +708,7 @@
 
         public boolean accept( Invocation invocation, SearchResult result, SearchControls controls ) throws NamingException
         {
-            doFilter( invocation, result.getAttributes() );
+            doFilter( result.getAttributes() );
             return true;
         }
     }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/schema/bootstrap/SystemSyntaxProducer.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/schema/bootstrap/SystemSyntaxProducer.java?rev=330978&r1=330977&r2=330978&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/schema/bootstrap/SystemSyntaxProducer.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/schema/bootstrap/SystemSyntaxProducer.java Fri Nov  4 23:20:26 2005
@@ -69,7 +69,12 @@
  * 36 Object Class Description        Y  1.3.6.1.4.1.1466.115.121.1.37
  * 37 OID                             Y  1.3.6.1.4.1.1466.115.121.1.38
  * 38 Other Mailbox                   Y  1.3.6.1.4.1.1466.115.121.1.39
+ *
  * 39 Octet String                    Y  1.3.6.1.4.1.1466.115.121.1.40
+ *
+ * This is not going to be followed for OctetString which needs to be treated
+ * as binary data.
+ *
  * 40 Postal Address                  Y  1.3.6.1.4.1.1466.115.121.1.41
  * 41 Protocol Information            Y  1.3.6.1.4.1.1466.115.121.1.42
  * 42 Presentation Address            Y  1.3.6.1.4.1.1466.115.121.1.43
@@ -369,9 +374,17 @@
         syntax.setHumanReadible( true );
         cb.schemaObjectProduced( this, syntax.getOid(), syntax );
 
+        /*
+         * This is where we deviate.  An octet string may or may not be human readable.  Essentially
+         * we are using this property of a syntax to determine if a value should be treated as binary
+         * data or not.  It must be human readable always in order to get this property set to true.
+         *
+         * If we set this to true then userPasswords which implement this syntax are not treated as
+         * binary attributes.  If that happens we can have data corruption due to UTF-8 handling.
+         */
         syntax = new BootstrapSyntax( "1.3.6.1.4.1.1466.115.121.1.40", syntaxCheckerRegistry );
         syntax.setNames( new String[] { "Octet String" } );
-        syntax.setHumanReadible( true );
+        syntax.setHumanReadible( false );
         cb.schemaObjectProduced( this, syntax.getOid(), syntax );
 
         /*

Modified: directory/apacheds/trunk/server-main/server.xml
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/server-main/server.xml?rev=330978&r1=330977&r2=330978&view=diff
==============================================================================
--- directory/apacheds/trunk/server-main/server.xml (original)
+++ directory/apacheds/trunk/server-main/server.xml Fri Nov  4 23:20:26 2005
@@ -16,7 +16,18 @@
         <!--<prop key="kdc.java.naming.security.credentials">secret</prop>-->
         <!--<prop key="changepw.entryBaseDn">ou=users,dc=example,dc=com</prop>-->
         <!--<prop key="changepw.java.naming.security.credentials">secret</prop>-->
-        <prop key="java.naming.ldap.attributes.binary">0.9.2342.19200300.100.1.55/audio/2.5.4.38/authorityRevocationList/2.5.4.37/cACertificate/2.5.4.39/certificateRevocationList/2.5.4.40/crossCertificatePair/2.5.4.53/deltaRevocationList/1.3.6.1.4.1.42.2.27.4.1.8/javaSerializedData/0.9.2342.19200300.100.1.60/jpegPhoto/1.3.6.1.4.1.5322.10.1.10/krb5Key/1.3.6.1.4.1.5322.10.1.12/krb5RealmName/0.9.2342.19200300.100.1.53/personalSignature/0.9.2342.19200300.100.1.7/photo/2.5.4.52/supportedAlgorithms/2.5.4.36/userCertificate/2.5.4.35/userPassword/2.16.840.1.113730.3.1.216/userPKCS12/2.16.840.1.113730.3.1.40/userSMIMECertificate</prop>
+        <!-- Set this key to a space delimited set of attributeType descriptions
+             and their OID's if you want an attributeType to be handled as 
+             binary content.
+ 
+             The server will use the schema to derive the set of attributeTypes
+             to treat as binary.  The union if the values you provide here 
+             will be taken as the set of binaries. Note to be consistent you 
+             must add both the OID and all the names an attributeType can have.
+        -->
+        <!-- 
+        <prop key="java.naming.ldap.attributes.binary"></prop>
+        -->
       </props>
     </property>
   </bean>

Propchange: directory/apacheds/trunk/server-unit/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Fri Nov  4 23:20:26 2005
@@ -1,4 +1,5 @@
 target
+server-work
 *.iml
 *.log
 .classpath

Modified: directory/shared/ldap/trunk/apache-provider/src/main/java/org/apache/ldap/common/berlib/asn1/SnickersDecoder.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache-provider/src/main/java/org/apache/ldap/common/berlib/asn1/SnickersDecoder.java?rev=330978&r1=330977&r2=330978&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache-provider/src/main/java/org/apache/ldap/common/berlib/asn1/SnickersDecoder.java (original)
+++ directory/shared/ldap/trunk/apache-provider/src/main/java/org/apache/ldap/common/berlib/asn1/SnickersDecoder.java Fri Nov  4 23:20:26 2005
@@ -27,11 +27,9 @@
 import org.apache.ldap.common.message.spi.Provider;
 import org.apache.ldap.common.message.spi.ProviderDecoder;
 import org.apache.ldap.common.message.spi.ProviderException;
-import org.apache.ldap.common.schema.SchemaUtils;
 
 import java.io.InputStream;
 import java.nio.ByteBuffer;
-import java.util.Hashtable;
 import java.util.Set;
 
 
@@ -45,7 +43,6 @@
     private final Provider provider;
     private final BERDigester digester;
     private Set binaries;
-    private static final String BINARY_KEY = "java.naming.ldap.attributes.binary";
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -57,11 +54,11 @@
      *
      * @param provider the owning provider.
      */
-    public SnickersDecoder( Provider provider, Hashtable env )
+    public SnickersDecoder( Provider provider, Set binaries )
     {
         this.provider = provider;
         LdapDigesterFactory factory = LdapDigesterFactory.getSingleton();
-        binaries = SchemaUtils.initBinaries( env, BINARY_KEY );
+        this.binaries = binaries;
         digester = factory.create( binaries );
     }
 
@@ -84,7 +81,7 @@
 
     public void decode( Object encoded ) throws DecoderException
     {
-        ByteBuffer buf = null;
+        ByteBuffer buf;
 
         if ( encoded instanceof ByteBuffer )
         {
@@ -174,11 +171,11 @@
     private void digest( BERDigester digesterTmp, InputStream in )
             throws ProviderException
     {
-        byte[] buf = null;
+        byte[] buf;
 
         try
         {
-            int amount = -1;
+            int amount;
             while( in.available() > 0 )
             {
                 buf = new byte[in.available()];

Modified: directory/shared/ldap/trunk/apache-provider/src/main/java/org/apache/ldap/common/berlib/asn1/SnickersProvider.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache-provider/src/main/java/org/apache/ldap/common/berlib/asn1/SnickersProvider.java?rev=330978&r1=330977&r2=330978&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache-provider/src/main/java/org/apache/ldap/common/berlib/asn1/SnickersProvider.java (original)
+++ directory/shared/ldap/trunk/apache-provider/src/main/java/org/apache/ldap/common/berlib/asn1/SnickersProvider.java Fri Nov  4 23:20:26 2005
@@ -17,7 +17,8 @@
 package org.apache.ldap.common.berlib.asn1;
 
 
-import java.util.Hashtable;
+import java.util.HashSet;
+import java.util.Set;
 
 import org.apache.ldap.common.message.spi.Provider;
 import org.apache.ldap.common.message.spi.ProviderDecoder;
@@ -91,7 +92,7 @@
      */
     public ProviderDecoder getDecoder() throws ProviderException
     {
-        return new SnickersDecoder( this, new Hashtable() );
+        return new SnickersDecoder( this, new HashSet() );
     }
 
     /**
@@ -101,9 +102,9 @@
      * @throws org.apache.ldap.common.message.spi.ProviderException
      *          if the provider or its decoder cannot be found
      */
-    public ProviderDecoder getDecoder( Hashtable env ) throws ProviderException
+    public ProviderDecoder getDecoder( Set binaries ) throws ProviderException
     {
-        return new SnickersDecoder( this, env );
+        return new SnickersDecoder( this, binaries );
     }
 
 

Modified: directory/shared/ldap/trunk/apache2-provider/src/main/java/org/apache/asn1new/ldap/TwixDecoder.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/main/java/org/apache/asn1new/ldap/TwixDecoder.java?rev=330978&r1=330977&r2=330978&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/main/java/org/apache/asn1new/ldap/TwixDecoder.java (original)
+++ directory/shared/ldap/trunk/apache2-provider/src/main/java/org/apache/asn1new/ldap/TwixDecoder.java Fri Nov  4 23:20:26 2005
@@ -2,7 +2,7 @@
 
 import java.io.InputStream;
 import java.nio.ByteBuffer;
-import java.util.Hashtable;
+import java.util.Set;
 
 import org.apache.asn1.codec.DecoderException;
 import org.apache.asn1.codec.stateful.DecoderCallback;
@@ -15,7 +15,6 @@
 import org.apache.ldap.common.message.spi.Provider;
 import org.apache.ldap.common.message.spi.ProviderDecoder;
 import org.apache.ldap.common.message.spi.ProviderException;
-import org.apache.ldap.common.schema.SchemaUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -35,17 +34,15 @@
     /** The callback to call when the decoding is done */
     private DecoderCallback decoderCallback;
 
-    private static final String BINARY_KEY = "java.naming.ldap.attributes.binary";
-
     /**
      * Creates an instance of a Twix Decoder implementation.
      *
      * @param provider the owning provider.
      */
-    public TwixDecoder( Provider provider, Hashtable env )
+    public TwixDecoder( Provider provider, Set binaries )
     {
         this.provider = provider;
-        ldapMessageContainer = new LdapMessageContainer( SchemaUtils.initBinaries( env, BINARY_KEY ) );
+        ldapMessageContainer = new LdapMessageContainer( binaries );
         ldapDecoder = new LdapDecoder();
     }
 
@@ -58,7 +55,7 @@
      */
     public void decode( Object encoded ) throws DecoderException
     {
-        ByteBuffer buf = null;
+        ByteBuffer buf;
 
         if ( encoded instanceof ByteBuffer )
         {
@@ -121,11 +118,11 @@
     private void digest( InputStream in )
             throws ProviderException
     {
-        byte[] buf = null;
+        byte[] buf;
 
         try
         {
-            int amount = -1;
+            int amount;
             
             while( in.available() > 0 )
             {

Modified: directory/shared/ldap/trunk/apache2-provider/src/main/java/org/apache/asn1new/ldap/TwixProvider.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/main/java/org/apache/asn1new/ldap/TwixProvider.java?rev=330978&r1=330977&r2=330978&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/main/java/org/apache/asn1new/ldap/TwixProvider.java (original)
+++ directory/shared/ldap/trunk/apache2-provider/src/main/java/org/apache/asn1new/ldap/TwixProvider.java Fri Nov  4 23:20:26 2005
@@ -17,9 +17,8 @@
 package org.apache.asn1new.ldap;
 
 
-import java.util.Hashtable;
+import java.util.Set;
 
-import org.apache.asn1new.ldap.TwixDecoder;
 import org.apache.ldap.common.message.spi.Provider;
 import org.apache.ldap.common.message.spi.ProviderDecoder;
 import org.apache.ldap.common.message.spi.ProviderEncoder;
@@ -85,9 +84,9 @@
      * @throws org.apache.ldap.common.message.spi.ProviderException
      *          if the provider or its decoder cannot be found
      */
-    public ProviderDecoder getDecoder( Hashtable env ) throws ProviderException
+    public ProviderDecoder getDecoder( Set binaries ) throws ProviderException
     {
-        return new TwixDecoder( this, env );
+        return new TwixDecoder( this, binaries );
     }
 
     /**

Modified: directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/message/MessageDecoder.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/message/MessageDecoder.java?rev=330978&r1=330977&r2=330978&view=diff
==============================================================================
--- directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/message/MessageDecoder.java (original)
+++ directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/message/MessageDecoder.java Fri Nov  4 23:20:26 2005
@@ -18,16 +18,19 @@
 
 
 import java.io.InputStream;
-import java.util.Hashtable;
+import java.util.*;
 
 import org.apache.ldap.common.message.spi.Provider;
 import org.apache.ldap.common.message.spi.TransformerSpi;
 import org.apache.ldap.common.message.spi.ProviderDecoder;
 
 import org.apache.asn1.codec.DecoderException;
+import org.apache.asn1.codec.util.StringUtils;
 import org.apache.asn1.codec.stateful.DecoderMonitor;
 import org.apache.asn1.codec.stateful.DecoderCallback;
 import org.apache.asn1.codec.stateful.StatefulDecoder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -39,6 +42,9 @@
  */
 public final class MessageDecoder implements ProviderDecoder
 {
+    private static final Logger log = LoggerFactory.getLogger( MessageDecoder.class );
+    private static final String BINARY_KEY = "java.naming.ldap.attributes.binary";
+
     /** Environment parameters stored here */
     private final Hashtable env;
     /** the ASN.1 provider */
@@ -74,7 +80,60 @@
     {
         this.env = ( Hashtable ) env.clone();
         this.provider = Provider.getProvider( this.env );
-        this.decoder = this.provider.getDecoder( this.env );
+        Set binaries;
+
+        if ( env.containsKey( BINARY_KEY ) )
+        {
+            Object val = env.get( BINARY_KEY );
+
+            if ( val == null )
+            {
+                if ( log.isWarnEnabled() )
+                {
+                    log.warn( "Null value for " + BINARY_KEY + " key in environment.  Using empty set for binaries." );
+                }
+                binaries = Collections.EMPTY_SET;
+            }
+            else if ( val instanceof String )
+            {
+                // parse out all words based on expected JNDI format of this attribute
+                String binaryIds = ( String ) val;
+                binaries = new HashSet();
+
+                if ( ! StringUtils.isEmpty( binaryIds ) )
+                {
+                    String[] binaryArray = binaryIds.split( " " );
+
+                    for ( int i = 0; i < binaryArray.length; i++ )
+                    {
+                        binaries.add( StringUtils.lowerCase( StringUtils.trim( binaryArray[i] ) ) );
+                    }
+                }
+            } // if already parsed and set as a collection use it
+            else if ( val instanceof Collection )
+            {
+                binaries = new HashSet();
+                binaries.addAll( ( Set ) val );
+            } // complain if it's something else
+            else
+            {
+                if ( log.isWarnEnabled() )
+                {
+                    log.warn( "Unrecognized value for " + BINARY_KEY + " key in environment.  Using empty set for binaries." );
+                }
+                binaries = Collections.EMPTY_SET;
+            }
+        }
+        else
+        {
+            if ( log.isWarnEnabled() )
+            {
+                log.warn( "Could not find " + BINARY_KEY + " key in environment.  Using empty set for binaries." );
+            }
+            binaries = Collections.EMPTY_SET;
+        }
+
+        this.decoder = this.provider.getDecoder( binaries );
         this.transformer = this.provider.getTransformer();
         this.decoder.setCallback( new DecoderCallback()
         {
@@ -97,7 +156,7 @@
      */
     public Object decode( final Object lock, final InputStream in ) throws MessageException
     {
-        Object providerEnvelope = null;
+        Object providerEnvelope;
 
         if ( lock == null )
         {

Modified: directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/message/spi/Provider.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/message/spi/Provider.java?rev=330978&r1=330977&r2=330978&view=diff
==============================================================================
--- directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/message/spi/Provider.java (original)
+++ directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/message/spi/Provider.java Fri Nov  4 23:20:26 2005
@@ -40,6 +40,7 @@
 import java.util.List ;
 import java.util.Properties ;
 import java.util.Hashtable;
+import java.util.Set;
 
 
 /**
@@ -53,11 +54,11 @@
 public abstract class Provider
 {
     /** Default BER Library provider class name */
-    public static final String DEFAULT_PROVIDER = 
+    public static final String DEFAULT_PROVIDER =
         "org.apache.ldap.common.berlib.asn1.SnickersProvider" ;
 
     /** BER Library provider class name property */
-    public static final String BERLIB_PROVIDER = 
+    public static final String BERLIB_PROVIDER =
         "asn.1.berlib.provider" ;
 
     /** The default file searched for on CP to load default provider props. */
@@ -98,7 +99,7 @@
 
             if ( fqcn != null )
             {
-                Class mc = null;
+                Class mc;
 
                 try
                 {
@@ -200,7 +201,7 @@
      * @return the provider's decoder.
      * @throws ProviderException if the provider or its decoder cannot be found
      */
-    public abstract ProviderDecoder getDecoder( Hashtable env ) throws ProviderException ;
+    public abstract ProviderDecoder getDecoder( Set binaries ) throws ProviderException ;
 
 
     /**
@@ -249,7 +250,7 @@
      */
     public static Provider getProvider( Hashtable a_env ) throws ProviderException
     {
-        Provider provider = null ;
+        Provider provider;
         String className = ( String ) a_env.get( BERLIB_PROVIDER ) ;
 
         // --------------------------------------------------------------------
@@ -328,7 +329,7 @@
         {
             public boolean accept( File file )
             {
-                return ( file.exists() && file.isDirectory() ) ? true : false;
+                return ( file.exists() && file.isDirectory() );
             }
         } ;
 
@@ -379,12 +380,12 @@
         if ( env == null )
         {
             File propFile = new File( javaHome, BERLIB_PROPFILE );
-            
+
             if ( ! propFile.exists() )
             {
                 propFile = new File( userHome, BERLIB_PROPFILE );
             }
-            
+
             if ( ! propFile.exists() )
             {
                 propFile = new File( wkdirHome, BERLIB_PROPFILE );

Modified: directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/schema/SchemaUtils.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/schema/SchemaUtils.java?rev=330978&r1=330977&r2=330978&view=diff
==============================================================================
--- directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/schema/SchemaUtils.java (original)
+++ directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/schema/SchemaUtils.java Fri Nov  4 23:20:26 2005
@@ -34,28 +34,6 @@
  */
 public class SchemaUtils
 {
-
-    public static Set initBinaries( Hashtable env, String key ) 
-    {
-        // construct the set for fast lookups while filtering
-        String binaryIds = (String)env.get( key );
-
-        Set binaries = new HashSet();
-
-        if ( StringUtils.isEmpty( binaryIds ) == false )
-        {
-            String[] binaryArray = binaryIds.split( "/" );
-            
-            for ( int i = 0; i < binaryArray.length; i++ )
-            {
-                binaries.add( StringUtils.lowerCase( StringUtils.trim( binaryArray[i] ) ) );
-            }
-        }
-        
-        return binaries;
-    }
-
-    
     // ------------------------------------------------------------------------
     // qdescrs rendering operations
     // ------------------------------------------------------------------------