directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1242044 - in /directory: apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/ apacheds/trunk/ldap-client-test/src/main/java/org/apache/directory/shared/client/api/ apacheds/trunk/ldap-client-test/src/test/java/org/ap...
Date Wed, 08 Feb 2012 19:08:23 GMT
Author: elecharny
Date: Wed Feb  8 19:08:22 2012
New Revision: 1242044

URL: http://svn.apache.org/viewvc?rev=1242044&view=rev
Log:
o Refactored the BinaryDetector hierarchy
o Applied the modification into teh API and the server
o Added a list of binary attributes in the DefaultConfigurableBinaryAttributeDetector class
o Added some missing Javadoc
o Some other minor refactoring (use of the Interface instead of the class)

Added:
    directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/ConfigurableBinaryAttributeDetector.java
    directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/DefaultConfigurableBinaryAttributeDetector.java
      - copied, changed from r1241708, directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/DefaultBinaryAttributeDetector.java
    directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/SchemaBinaryAttributeDetector.java
      - copied, changed from r1241708, directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/NoSchemaBinaryAttributeDetector.java
Removed:
    directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/DefaultBinaryAttributeDetector.java
    directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/NoSchemaBinaryAttributeDetector.java
Modified:
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/LdapCoreSessionConnection.java
    directory/apacheds/trunk/ldap-client-test/src/main/java/org/apache/directory/shared/client/api/LdapApiIntegrationUtils.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/AdsSchemaLoaderTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapSSLConnectionTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/ServerSchemaLoaderTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientDeleteRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientExtendedRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/GetRootDseTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolHandler.java
    directory/apacheds/trunk/service/src/test/java/org/apache/directory/server/UberJarMainTest.java
    directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapAsyncConnection.java
    directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
    directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionPool.java
    directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
    directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/BinaryAttributeDetector.java
    directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/LdapMessageContainer.java

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/LdapCoreSessionConnection.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/LdapCoreSessionConnection.java?rev=1242044&r1=1242043&r2=1242044&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/LdapCoreSessionConnection.java (original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/LdapCoreSessionConnection.java Wed Feb  8 19:08:22 2012
@@ -33,6 +33,7 @@ import org.apache.directory.ldap.client.
 import org.apache.directory.server.core.api.filtering.EntryFilteringCursor;
 import org.apache.directory.server.core.api.interceptor.context.BindOperationContext;
 import org.apache.directory.shared.asn1.util.Oid;
+import org.apache.directory.shared.ldap.codec.api.BinaryAttributeDetector;
 import org.apache.directory.shared.ldap.codec.api.LdapApiService;
 import org.apache.directory.shared.ldap.codec.api.LdapApiServiceFactory;
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
@@ -1306,4 +1307,24 @@ public class LdapCoreSessionConnection i
         this.schemaManager = directoryService.getSchemaManager();
         this.session = directoryService.getAdminSession();
     }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public BinaryAttributeDetector getBinaryAttributeDetector()
+    {
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setBinaryAttributeDetector( BinaryAttributeDetector binaryAttributeDetector )
+    {
+        // Does nothing
+    }
 }

Modified: directory/apacheds/trunk/ldap-client-test/src/main/java/org/apache/directory/shared/client/api/LdapApiIntegrationUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/main/java/org/apache/directory/shared/client/api/LdapApiIntegrationUtils.java?rev=1242044&r1=1242043&r2=1242044&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/main/java/org/apache/directory/shared/client/api/LdapApiIntegrationUtils.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/main/java/org/apache/directory/shared/client/api/LdapApiIntegrationUtils.java Wed Feb  8 19:08:22 2012
@@ -23,13 +23,14 @@ import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.LdapConnectionConfig;
 import org.apache.directory.ldap.client.api.LdapConnectionPool;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.ldap.client.api.PoolableLdapConnectionFactory;
 import org.apache.directory.server.constants.ServerDNConstants;
 import org.apache.directory.server.ldap.LdapServer;
-import org.apache.directory.shared.ldap.codec.api.DefaultBinaryAttributeDetector;
+import org.apache.directory.shared.ldap.codec.api.SchemaBinaryAttributeDetector;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -100,9 +101,15 @@ public class LdapApiIntegrationUtils
      * @return the pooled admin connection
      * @throws Exception the exception
      */
-    public static LdapNetworkConnection getPooledAdminConnection( LdapServer ldapServer ) throws Exception
+    public static LdapConnection getPooledAdminConnection( LdapServer ldapServer ) throws Exception
     {
-        return getAdminPool( ldapServer ).getConnection();
+        LdapConnection ldapConnection = getAdminPool( ldapServer ).getConnection();
+        
+        ldapConnection.setBinaryAttributeDetector(
+            new SchemaBinaryAttributeDetector(
+                ldapServer.getDirectoryService().getSchemaManager()) );
+        
+        return ldapConnection;
     }
 
 
@@ -113,7 +120,7 @@ public class LdapApiIntegrationUtils
      * @param ldapServer the LDAP server instance, used to obtain the port used
      * @throws Exception the exception
      */
-    public static void releasePooledAdminConnection( LdapNetworkConnection conn, LdapServer ldapServer )
+    public static void releasePooledAdminConnection( LdapConnection conn, LdapServer ldapServer )
         throws Exception
     {
         getAdminPool( ldapServer ).releaseConnection( conn );
@@ -137,8 +144,6 @@ public class LdapApiIntegrationUtils
             config.setLdapPort( port );
             config.setName( DEFAULT_ADMIN );
             config.setCredentials( DEFAULT_PASSWORD );
-            config.setBinaryAttributeDetector( new DefaultBinaryAttributeDetector(
-                ldapServer.getDirectoryService().getSchemaManager() ) );
             PoolableLdapConnectionFactory factory = new PoolableLdapConnectionFactory( config );
             LdapConnectionPool pool = new LdapConnectionPool( factory );
             pool.setTestOnBorrow( true );

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/AdsSchemaLoaderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/AdsSchemaLoaderTest.java?rev=1242044&r1=1242043&r2=1242044&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/AdsSchemaLoaderTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/AdsSchemaLoaderTest.java Wed Feb  8 19:08:22 2012
@@ -24,7 +24,7 @@ package org.apache.directory.shared.clie
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import org.apache.directory.ldap.client.api.LdapNetworkConnection;
+import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.NetworkSchemaLoader;
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.annotations.CreateTransport;
@@ -49,7 +49,7 @@ import org.junit.runner.RunWith;
     { @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") })
 public class AdsSchemaLoaderTest extends AbstractLdapTestUnit
 {
-    private LdapNetworkConnection connection;
+    private LdapConnection connection;
 
 
     @Before

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java?rev=1242044&r1=1242043&r2=1242044&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java Wed Feb  8 19:08:22 2012
@@ -39,8 +39,9 @@ import org.apache.directory.server.const
 import org.apache.directory.server.core.annotations.ApplyLdifs;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
-import org.apache.directory.shared.ldap.codec.api.DefaultBinaryAttributeDetector;
-import org.apache.directory.shared.ldap.codec.api.NoSchemaBinaryAttributeDetector;
+import org.apache.directory.shared.ldap.codec.api.ConfigurableBinaryAttributeDetector;
+import org.apache.directory.shared.ldap.codec.api.DefaultConfigurableBinaryAttributeDetector;
+import org.apache.directory.shared.ldap.codec.api.SchemaBinaryAttributeDetector;
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.model.cursor.EntryCursor;
 import org.apache.directory.shared.ldap.model.entry.Entry;
@@ -67,7 +68,7 @@ public class LdapConnectionTest extends 
 
     private static final String ADMIN_DN = "uid=admin,ou=system";
 
-    private LdapNetworkConnection connection;
+    private LdapConnection connection;
 
 
     @Before
@@ -127,9 +128,9 @@ public class LdapConnectionTest extends 
             "objectClass: top",
             "uid: kayyagari",
             "ref: ldap://ad.example.com/uid=kayyagari,ou=system"
-    })
-@Test
-public void testLookup() throws Exception
+        })
+    @Test
+    public void testLookup() throws Exception
     {
         Entry entry = connection.lookup( ADMIN_DN );
         assertNull( entry.get( SchemaConstants.ENTRY_UUID_AT ) );
@@ -170,21 +171,28 @@ public void testLookup() throws Exceptio
         config.setLdapPort( ldapServer.getPort() );
         config.setName( ServerDNConstants.ADMIN_SYSTEM_DN );
         config.setCredentials( "secret" );
-        config.setBinaryAttributeDetector( new NoSchemaBinaryAttributeDetector() );
+        config.setBinaryAttributeDetector( new DefaultConfigurableBinaryAttributeDetector() );
 
         LdapConnection myConnection = new LdapNetworkConnection( config );
         myConnection.bind( "uid=admin,ou=system", "secret" );
 
+        // Use the default list of binary Attributes
         Entry entry = myConnection.lookup( "uid=admin,ou=system" );
+        assertFalse( entry.get( SchemaConstants.USER_PASSWORD_AT ).get().isHumanReadable() );
+        
+        // Remove the UserPassword from the list
+        ((ConfigurableBinaryAttributeDetector)config.getBinaryAttributeDetector()).
+            removeBinaryAttribute( "userPassword" );
+        entry = myConnection.lookup( "uid=admin,ou=system" );
         assertTrue( entry.get( SchemaConstants.USER_PASSWORD_AT ).get().isHumanReadable() );
         
         // Now, load a new binary Attribute
-        config.getBinaryAttributeDetector().addBinaryAttribute( "userPassword" );
+        ((ConfigurableBinaryAttributeDetector)config.getBinaryAttributeDetector()).
+            addBinaryAttribute( "userPassword" );
         entry = myConnection.lookup( "uid=admin,ou=system" );
         assertFalse( entry.get( SchemaConstants.USER_PASSWORD_AT ).get().isHumanReadable() );
 
         connection.loadDefaultSchema();
-        connection.getConfig().setBinaryAttributeDetector( new DefaultBinaryAttributeDetector( connection.getSchemaManager() ) );
 
         entry = connection.lookup( "uid=admin,ou=system" );
         assertFalse( entry.get( SchemaConstants.USER_PASSWORD_AT ).get().isHumanReadable() );
@@ -236,4 +244,52 @@ public void testLookup() throws Exceptio
         assertTrue( connection.isAuthenticated() );
         connection.close();
     }
+    
+    
+    /**
+     * Test a connection which does not have any schemaManager loaded
+     */
+    @ApplyLdifs(
+        {
+            "dn: uid=kayyagari,ou=system",
+            "objectClass: extensibleObject",
+            "objectClass: uidObject",
+            "objectClass: referral",
+            "objectClass: top",
+            "uid: kayyagari",
+            "ref: ldap://ad.example.com/uid=kayyagari,ou=system"
+        })
+    @Test
+    public void testNoSchemaConnection() throws Exception
+    {
+        LdapConnection ldapConnection = new LdapNetworkConnection( "localHost", ldapServer.getPort() );
+        
+        ldapConnection.bind( "uid=admin,ou=system", "secret" );
+        
+        // Try to retrieve a binary attribute : it should be seen as a String
+        Entry entry = ldapConnection.lookup( "uid=admin,ou=system" );
+        assertTrue( entry.get( SchemaConstants.USER_PASSWORD_AT ).get().isHumanReadable() );
+    }
+    
+    
+    /**
+     * Test a connection which does not have any schemaManager loaded but in which connection we
+     * inject a BinaryAttributeDetector
+     */
+    @Test
+    public void testNoSchemaConnectionWithBinaryDetector() throws Exception
+    {
+        LdapConnectionConfig config = new LdapConnectionConfig();
+        config.setLdapHost( "localhost" );
+        config.setLdapPort( ldapServer.getPort() );
+        config.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector() );
+        
+        LdapConnection ldapConnection = new LdapNetworkConnection( config );
+        
+        ldapConnection.bind( "uid=admin,ou=system", "secret" );
+        
+        // Try to retrieve a binary attribute : it should be seen as a String
+        Entry entry = ldapConnection.lookup( "uid=admin,ou=system" );
+        assertTrue( entry.get( SchemaConstants.USER_PASSWORD_AT ).get().isHumanReadable() );
+    }
 }

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapSSLConnectionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapSSLConnectionTest.java?rev=1242044&r1=1242043&r2=1242044&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapSSLConnectionTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapSSLConnectionTest.java Wed Feb  8 19:08:22 2012
@@ -43,7 +43,7 @@ import org.apache.directory.server.ldap.
 import org.apache.directory.server.ldap.handlers.bind.ntlm.NtlmMechanismHandler;
 import org.apache.directory.server.ldap.handlers.bind.plain.PlainMechanismHandler;
 import org.apache.directory.server.ldap.handlers.extended.StartTlsHandler;
-import org.apache.directory.shared.ldap.codec.api.DefaultBinaryAttributeDetector;
+import org.apache.directory.shared.ldap.codec.api.SchemaBinaryAttributeDetector;
 import org.apache.directory.shared.ldap.model.constants.SupportedSaslMechanisms;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
 import org.apache.directory.shared.ldap.model.name.Dn;
@@ -94,14 +94,14 @@ public class LdapSSLConnectionTest exten
         sslConfig.setUseSsl( true );
         sslConfig.setLdapPort( getLdapServer().getPortSSL() );
         sslConfig.setTrustManagers( new NoVerificationTrustManager() );
-        sslConfig.setBinaryAttributeDetector( new DefaultBinaryAttributeDetector(
+        sslConfig.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector(
                 ldapServer.getDirectoryService().getSchemaManager() ) );
 
         tlsConfig = new LdapConnectionConfig();
         tlsConfig.setLdapHost( "localhost" );
         tlsConfig.setLdapPort( getLdapServer().getPort() );
         tlsConfig.setTrustManagers( new NoVerificationTrustManager() );
-        tlsConfig.setBinaryAttributeDetector( new DefaultBinaryAttributeDetector(
+        tlsConfig.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector(
             ldapServer.getDirectoryService().getSchemaManager() ) );
     }
 

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/ServerSchemaLoaderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/ServerSchemaLoaderTest.java?rev=1242044&r1=1242043&r2=1242044&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/ServerSchemaLoaderTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/ServerSchemaLoaderTest.java Wed Feb  8 19:08:22 2012
@@ -27,7 +27,7 @@ import static org.junit.Assert.assertNot
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import org.apache.directory.ldap.client.api.LdapNetworkConnection;
+import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.SsseSchemaLoader;
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.annotations.CreateTransport;
@@ -53,7 +53,7 @@ import org.junit.runner.RunWith;
     { @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") })
 public class ServerSchemaLoaderTest extends AbstractLdapTestUnit
 {
-    private LdapNetworkConnection connection;
+    private LdapConnection connection;
 
 
     @Before

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java?rev=1242044&r1=1242043&r2=1242044&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java Wed Feb  8 19:08:22 2012
@@ -68,7 +68,7 @@ public class ClientAbandonRequestTest ex
     @Before
     public void setup() throws Exception
     {
-        connection = LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
+        connection = (LdapNetworkConnection)LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
     }
 
 

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java?rev=1242044&r1=1242043&r2=1242044&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java Wed Feb  8 19:08:22 2012
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ * 
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ * 
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ * 
  */
 package org.apache.directory.shared.client.api.operations;
 
@@ -73,7 +73,7 @@ public class ClientAddRequestTest extend
     @Before
     public void setup() throws Exception
     {
-        connection = LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
+        connection = (LdapNetworkConnection)LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
         session = getLdapServer().getDirectoryService().getAdminSession();
     }
 

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java?rev=1242044&r1=1242043&r2=1242044&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java Wed Feb  8 19:08:22 2012
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ * 
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ * 
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ * 
  */
 package org.apache.directory.shared.client.api.operations;
 
@@ -63,7 +63,7 @@ public class ClientCompareRequestTest ex
     @Before
     public void setup() throws Exception
     {
-        connection = LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
+        connection = (LdapNetworkConnection)LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
         session = getLdapServer().getDirectoryService().getAdminSession();
     }
 

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientDeleteRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientDeleteRequestTest.java?rev=1242044&r1=1242043&r2=1242044&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientDeleteRequestTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientDeleteRequestTest.java Wed Feb  8 19:08:22 2012
@@ -94,7 +94,7 @@ public class ClientDeleteRequestTest ext
     @Before
     public void setup() throws Exception
     {
-        connection = LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
+        connection = (LdapNetworkConnection)LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
         session = getLdapServer().getDirectoryService().getAdminSession();
     }
 
@@ -152,11 +152,11 @@ public class ClientDeleteRequestTest ext
 
     /**
      * this method uses reflection to test deleteChildren method without using the
-     * convenient method delete( dn, true ), cause the convenient method checks 
+     * convenient method delete( dn, true ), cause the convenient method checks
      * whether the server supports the CascadeControl.
      * 
      * Cause ADS supports this control, delete(dn, true) will never call the method
-     * deleteChildren() (which has private scope) 
+     * deleteChildren() (which has private scope)
      * To test the manual deletion of the entries in the absence of this CascadeControl
      * reflection was used to invoke the private method deleteChildren().
      * 

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientExtendedRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientExtendedRequestTest.java?rev=1242044&r1=1242043&r2=1242044&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientExtendedRequestTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientExtendedRequestTest.java Wed Feb  8 19:08:22 2012
@@ -67,7 +67,7 @@ public class ClientExtendedRequestTest e
     @Before
     public void setup() throws Exception
     {
-        connection = LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
+        connection = (LdapNetworkConnection)LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
     }
 
 

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java?rev=1242044&r1=1242043&r2=1242044&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java Wed Feb  8 19:08:22 2012
@@ -70,7 +70,7 @@ public class ClientModifyDnRequestTest e
     @Before
     public void setup() throws Exception
     {
-        connection = LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
+        connection = (LdapNetworkConnection)LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
         session = getLdapServer().getDirectoryService().getAdminSession();
     }
 

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java?rev=1242044&r1=1242043&r2=1242044&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java Wed Feb  8 19:08:22 2012
@@ -83,7 +83,7 @@ private CoreSession session;
 @Before
 public void setup() throws Exception
 {
-    connection = LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
+    connection = (LdapNetworkConnection)LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
     session = getLdapServer().getDirectoryService().getAdminSession();
 }
 

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/GetRootDseTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/GetRootDseTest.java?rev=1242044&r1=1242043&r2=1242044&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/GetRootDseTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/GetRootDseTest.java Wed Feb  8 19:08:22 2012
@@ -54,7 +54,7 @@ public class GetRootDseTest extends Abst
     @Before
     public void setup() throws Exception
     {
-        connection = LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
+        connection = (LdapNetworkConnection)LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
     }
 
 

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java?rev=1242044&r1=1242043&r2=1242044&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java Wed Feb  8 19:08:22 2012
@@ -93,7 +93,7 @@ public class ClientSearchRequestTest ext
     @Before
     public void setup() throws Exception
     {
-        connection = LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
+        connection = (LdapNetworkConnection)LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
     }
     
     

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java?rev=1242044&r1=1242043&r2=1242044&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java Wed Feb  8 19:08:22 2012
@@ -75,7 +75,7 @@ public class SearchRequestReturningAttri
     @Before
     public void setup() throws Exception
     {
-        connection = LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
+        connection = (LdapNetworkConnection)LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
     }
 
 

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolHandler.java?rev=1242044&r1=1242043&r2=1242044&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolHandler.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolHandler.java Wed Feb  8 19:08:22 2012
@@ -20,10 +20,10 @@
 package org.apache.directory.server.ldap;
 
 
-import org.apache.directory.shared.ldap.codec.api.DefaultBinaryAttributeDetector;
 import org.apache.directory.shared.ldap.codec.api.LdapApiServiceFactory;
 import org.apache.directory.shared.ldap.codec.api.LdapMessageContainer;
 import org.apache.directory.shared.ldap.codec.api.MessageDecorator;
+import org.apache.directory.shared.ldap.codec.api.SchemaBinaryAttributeDetector;
 import org.apache.directory.shared.ldap.model.exception.ResponseCarryingMessageException;
 import org.apache.directory.shared.ldap.model.message.Control;
 import org.apache.directory.shared.ldap.model.message.ExtendedRequest;
@@ -89,7 +89,7 @@ class LdapProtocolHandler extends Demuxi
         LdapMessageContainer<? extends MessageDecorator<Message>> ldapMessageContainer =
             new LdapMessageContainer<MessageDecorator<Message>>(
                 ldapServer.getDirectoryService().getLdapCodecService(),
-                new DefaultBinaryAttributeDetector(
+                new SchemaBinaryAttributeDetector(
                     ldapServer.getDirectoryService().getSchemaManager() ) );
 
         session.setAttribute( "messageContainer", ldapMessageContainer );

Modified: directory/apacheds/trunk/service/src/test/java/org/apache/directory/server/UberJarMainTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/service/src/test/java/org/apache/directory/server/UberJarMainTest.java?rev=1242044&r1=1242043&r2=1242044&view=diff
==============================================================================
--- directory/apacheds/trunk/service/src/test/java/org/apache/directory/server/UberJarMainTest.java (original)
+++ directory/apacheds/trunk/service/src/test/java/org/apache/directory/server/UberJarMainTest.java Wed Feb  8 19:08:22 2012
@@ -29,11 +29,9 @@ import org.apache.directory.ldap.client.
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.server.constants.ServerDNConstants;
 import org.apache.directory.server.core.api.partition.PartitionNexus;
-import org.apache.directory.shared.ldap.codec.api.DefaultBinaryAttributeDetector;
+import org.apache.directory.shared.ldap.codec.api.SchemaBinaryAttributeDetector;
 import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.name.Dn;
-import org.apache.directory.shared.ldap.model.schema.SchemaManager;
-import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
 import org.junit.Test;
 
 
@@ -77,15 +75,15 @@ public class UberJarMainTest
             {
                 try
                 {
-                    SchemaManager schemaManager = new DefaultSchemaManager();
                     // Creating a connection on the created server
                     LdapConnectionConfig configuration = new LdapConnectionConfig();
                     configuration.setLdapHost( "localhost" );
                     configuration.setLdapPort( 10389 );
                     configuration.setName( ServerDNConstants.ADMIN_SYSTEM_DN );
                     configuration.setCredentials( PartitionNexus.ADMIN_PASSWORD_STRING );
-                    configuration.setBinaryAttributeDetector( new DefaultBinaryAttributeDetector( schemaManager ) );
+                    configuration.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector() );
                     LdapNetworkConnection connection = new LdapNetworkConnection( configuration );
+                    connection.loadDefaultSchema();
 
                     // Binding on the connection
                     connection.bind();

Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapAsyncConnection.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapAsyncConnection.java?rev=1242044&r1=1242043&r2=1242044&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapAsyncConnection.java (original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapAsyncConnection.java Wed Feb  8 19:08:22 2012
@@ -53,7 +53,7 @@ public interface LdapAsyncConnection ext
 {
 
     /**
-     * Add an entry to the server asynchronously. This is a non blocking add : 
+     * Add an entry to the server asynchronously. This is a non blocking add :
      * the user has to get for the response from the returned Future.
      * 
      * @param entry The entry to add
@@ -74,7 +74,7 @@ public interface LdapAsyncConnection ext
 
 
     /**
-     * Asynchronous Bind on a server, using the LdapConnectionConfig informations. 
+     * Asynchronous Bind on a server, using the LdapConnectionConfig informations.
      *
      * @return the bind operation's future
      * @throws LdapException if some error occurred
@@ -84,7 +84,7 @@ public interface LdapAsyncConnection ext
 
 
     /**
-     * Anonymous asynchronous Bind on a server. 
+     * Anonymous asynchronous Bind on a server.
      *
      * @return the bind operation's future
      * @throws LdapException if some error occurred
@@ -97,7 +97,7 @@ public interface LdapAsyncConnection ext
      * Simple asynchronous Bind on a server.
      *
      * @param name The name we use to authenticate the user, it must be a valid Dn
-     * @param credentials The password, it can't be null 
+     * @param credentials The password, it can't be null
      * @return the bind operation's future
      * @throws LdapException if some error occurred
      * @throws IOException if some IO error occurred
@@ -143,8 +143,8 @@ public interface LdapAsyncConnection ext
      * 
      * @param baseDn The base for the search, it must be a valid Dn, and can't be emtpy
      * @param filter The filter to use for this search, it can't be empty
-     * @param scope The search scope : OBJECT, ONELEVEL or SUBTREE 
-     * @param attributes The attributes for this search 
+     * @param scope The search scope : OBJECT, ONELEVEL or SUBTREE
+     * @param attributes The attributes for this search
      * @return the search operation's future
      * @throws org.apache.directory.shared.ldap.model.exception.LdapException if some error occurred
      */
@@ -168,7 +168,7 @@ public interface LdapAsyncConnection ext
      * @param baseDn The base for the search, it must be a valid Dn, and can't be empty
      * @param filter The filter to use for this search, it can't be empty
      * @param scope The search scope : OBJECT, ONELEVEL or SUBTREE
-     * @param attributes The attributes for this search 
+     * @param attributes The attributes for this search
      * @return the search operation's future
      * @throws LdapException if some error occurred
      */
@@ -197,7 +197,7 @@ public interface LdapAsyncConnection ext
 
 
     /**
-     * Performs an asynchronous modify operation based on the modifications present in 
+     * Performs an asynchronous modify operation based on the modifications present in
      * the ModifyRequest.
      *
      * @param modRequest the request for modify operation
@@ -219,7 +219,7 @@ public interface LdapAsyncConnection ext
 
     /**
      * Performs an asynchronous delete operation based on the delete request object.
-     *  
+     * 
      * @param delRequest the delete operation's request
      * @return delete operation's future
      * @throws LdapException If the Dn is not valid or if the deletion failed
@@ -229,7 +229,7 @@ public interface LdapAsyncConnection ext
 
     /**
      * Asynchronously compares an entry's attribute's value with that of the given value
-     *   
+     * 
      * @param compareRequest the CompareRequest which contains the target Dn, attribute name and value
      * @return compare operation's future
      * @throws LdapException if some error occurred

Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java?rev=1242044&r1=1242043&r2=1242044&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java (original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java Wed Feb  8 19:08:22 2012
@@ -24,6 +24,7 @@ import java.io.IOException;
 import java.util.List;
 
 import org.apache.directory.shared.asn1.util.Oid;
+import org.apache.directory.shared.ldap.codec.api.BinaryAttributeDetector;
 import org.apache.directory.shared.ldap.codec.api.LdapApiService;
 import org.apache.directory.shared.ldap.model.cursor.EntryCursor;
 import org.apache.directory.shared.ldap.model.cursor.SearchCursor;
@@ -813,4 +814,17 @@ public interface LdapConnection
      * @return true if there is a non-null future exists, false otherwise
      */
     boolean doesFutureExistFor( int messageId );
+    
+    
+    /**
+     * @return the object responsible for the detection of binary attributes
+     */
+    BinaryAttributeDetector getBinaryAttributeDetector();
+    
+    
+    /**
+     * Sets the object responsible for the detection of binary attributes
+     * @return
+     */
+    void setBinaryAttributeDetector( BinaryAttributeDetector binaryAttributeDetecter);
 }
\ No newline at end of file

Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionPool.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionPool.java?rev=1242044&r1=1242043&r2=1242044&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionPool.java (original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionPool.java Wed Feb  8 19:08:22 2012
@@ -27,7 +27,7 @@ import org.apache.commons.pool.impl.Gene
 /**
  * A pool implementation for LdapConnection objects.
  * 
- * This class is just a wrapper around the commons GenericObjectPool, and has 
+ * This class is just a wrapper around the commons GenericObjectPool, and has
  * a more meaningful name to represent the pool type.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
@@ -49,22 +49,22 @@ public class LdapConnectionPool extends 
     /**
      * Gives a LdapConnection fetched from the pool.
      *
-     * @return an LdapConnection object from pool 
+     * @return an LdapConnection object from pool
      * @throws Exception if an error occurs while obtaining a connection from the factory
      */
-    public LdapNetworkConnection getConnection() throws Exception
+    public LdapConnection getConnection() throws Exception
     {
-        return ( LdapNetworkConnection ) super.borrowObject();
+        return ( LdapConnection ) super.borrowObject();
     }
 
 
     /**
      * Places the given LdapConnection back in the pool.
-     *  
+     * 
      * @param connection the LdapConnection to be released
      * @throws Exception if an error occurs while releasing the connection
      */
-    public void releaseConnection( LdapNetworkConnection connection ) throws Exception
+    public void releaseConnection( LdapConnection connection ) throws Exception
     {
         super.returnObject( connection );
     }

Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java?rev=1242044&r1=1242043&r2=1242044&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java (original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java Wed Feb  8 19:08:22 2012
@@ -63,12 +63,14 @@ import org.apache.directory.ldap.client.
 import org.apache.directory.ldap.client.api.future.SearchFuture;
 import org.apache.directory.shared.asn1.DecoderException;
 import org.apache.directory.shared.asn1.util.Oid;
-import org.apache.directory.shared.ldap.codec.api.DefaultBinaryAttributeDetector;
+import org.apache.directory.shared.ldap.codec.api.BinaryAttributeDetector;
+import org.apache.directory.shared.ldap.codec.api.DefaultConfigurableBinaryAttributeDetector;
 import org.apache.directory.shared.ldap.codec.api.LdapApiService;
 import org.apache.directory.shared.ldap.codec.api.LdapApiServiceFactory;
 import org.apache.directory.shared.ldap.codec.api.LdapMessageContainer;
 import org.apache.directory.shared.ldap.codec.api.MessageDecorator;
 import org.apache.directory.shared.ldap.codec.api.MessageEncoderException;
+import org.apache.directory.shared.ldap.codec.api.SchemaBinaryAttributeDetector;
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.model.cursor.Cursor;
 import org.apache.directory.shared.ldap.model.cursor.EntryCursor;
@@ -350,7 +352,7 @@ public class LdapNetworkConnection exten
         config.setUseSsl( false );
         config.setLdapPort( config.getDefaultLdapPort() );
         config.setLdapHost( config.getDefaultLdapHost() );
-        config.setBinaryAttributeDetector( new DefaultBinaryAttributeDetector( schemaManager ) );
+        config.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector() );
         messageId = new AtomicInteger( 0 );
     }
 
@@ -364,6 +366,12 @@ public class LdapNetworkConnection exten
     public LdapNetworkConnection( LdapConnectionConfig config )
     {
         this.config = config;
+        
+        if ( config.getBinaryAttributeDetector() == null )
+        {
+            config.setBinaryAttributeDetector( new DefaultConfigurableBinaryAttributeDetector() );
+        }
+        
         messageId = new AtomicInteger( 0 );
     }
 
@@ -380,7 +388,7 @@ public class LdapNetworkConnection exten
         config.setUseSsl( useSsl );
         config.setLdapPort( useSsl ? config.getDefaultLdapsPort() : config.getDefaultLdapPort() );
         config.setLdapHost( config.getDefaultLdapHost() );
-        config.setBinaryAttributeDetector( new DefaultBinaryAttributeDetector( schemaManager ) );
+        config.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector() );
         messageId = new AtomicInteger( 0 );
     }
 
@@ -405,10 +413,11 @@ public class LdapNetworkConnection exten
         }
         else
         {
-            config.setBinaryAttributeDetector( new DefaultBinaryAttributeDetector( schemaManager ) );
             config.setLdapHost( server );
         }
 
+        config.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector() );
+
         messageId = new AtomicInteger( 0 );
     }
 
@@ -438,7 +447,7 @@ public class LdapNetworkConnection exten
             config.setLdapHost( server );
         }
 
-        config.setBinaryAttributeDetector( new DefaultBinaryAttributeDetector( schemaManager ) );
+        config.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector() );
 
         messageId = new AtomicInteger( 0 );
     }
@@ -483,7 +492,7 @@ public class LdapNetworkConnection exten
             config.setLdapHost( server );
         }
 
-        config.setBinaryAttributeDetector( new DefaultBinaryAttributeDetector( schemaManager ) );
+        config.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector() );
         messageId = new AtomicInteger();
     }
 
@@ -3360,6 +3369,30 @@ public class LdapNetworkConnection exten
             }
 
             loadSchema( jarSchemaLoader );
+            
+            // Update the BinaryAttributeDetector
+            BinaryAttributeDetector binaryAttributeDetector = getBinaryAttributeDetector();
+            
+            if ( binaryAttributeDetector == null )
+            {
+                // We don't have any BAD : create a SchemaBad
+                binaryAttributeDetector = new SchemaBinaryAttributeDetector( schemaManager );
+            }
+            else
+            {
+                if ( binaryAttributeDetector instanceof SchemaBinaryAttributeDetector )
+                {
+                    // Inject the Schema in the existing SchemaBAD (it may replace a previous one)
+                    ((SchemaBinaryAttributeDetector)binaryAttributeDetector).setSchemaManager( schemaManager );
+                }
+                else
+                {
+                    // Replace the old BAD by a SchemaBAD
+                    binaryAttributeDetector = new SchemaBinaryAttributeDetector( schemaManager );
+                }
+            }
+            
+            setBinaryAttributeDetector( binaryAttributeDetector );
         }
         catch ( LdapException e )
         {
@@ -4011,4 +4044,32 @@ public class LdapNetworkConnection exten
 
         return krb5ConfPath;
     }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public BinaryAttributeDetector getBinaryAttributeDetector()
+    {
+        if ( config != null )
+        {
+            return config.getBinaryAttributeDetector();
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setBinaryAttributeDetector( BinaryAttributeDetector binaryAttributeDetector )
+    {
+        if ( config != null )
+        {
+            config.setBinaryAttributeDetector( binaryAttributeDetector );
+        }
+    }
 }

Modified: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/BinaryAttributeDetector.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/BinaryAttributeDetector.java?rev=1242044&r1=1242043&r2=1242044&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/BinaryAttributeDetector.java (original)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/BinaryAttributeDetector.java Wed Feb  8 19:08:22 2012
@@ -19,8 +19,6 @@
  */
 package org.apache.directory.shared.ldap.codec.api;
 
-import java.util.Set;
-
 
 /**
  * An interface used to abstract the means to detect whether or not an attribute
@@ -35,52 +33,4 @@ public interface BinaryAttributeDetector
      * @return true if the attribute specified is not human readible, false otherwise
      */
     boolean isBinary( String attributeId );
-    
-    
-    /**
-     * Add some binary Attributes Id to the list of attributes
-     * 
-     * @param binaryAttributes The added binary attributes Id
-     */
-    public void addBinaryAttribute( String... binaryAttributes );
-
-    
-    /**
-     * Remove some binary Attributes Id from the list of attributes
-     * 
-     * @param binaryAttributes The binary attributes Id to remove
-     */
-    public void removeBinaryAttribute( String... binaryAttributes );
-
-    
-    /**
-     * Inject a new set of binary attributes that will replace the old one
-     * 
-     * @param binaryAttributes The new set of binary attributes
-     */
-    public void setBinaryAttributes( Set<String> binaryAttributes );
-    
-    
-    /**
-     * Add some binary Syntaxes Id to the list of Syntaxes
-     * 
-     * @param binarySyntaxes The added binary Syntaxes Id
-     */
-    public void addBinarySyntaxes( String... binarySyntaxes );
-
-    
-    /**
-     * Remove some binary Syntaxes Id from the list of Syntaxes
-     * 
-     * @param binarySyntaxes The binary Syntaxes Id to remove
-     */
-    public void removeBinarySyntaxes( String... binarySyntaxes );
-
-    
-    /**
-     * Inject a new set of binary Syntaxes that will replace the old one
-     * 
-     * @param binarySyntaxes The new set of binary Syntaxes
-     */
-    public void setBinarySyntaxes( Set<String> binarySyntaxes );
 }

Added: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/ConfigurableBinaryAttributeDetector.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/ConfigurableBinaryAttributeDetector.java?rev=1242044&view=auto
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/ConfigurableBinaryAttributeDetector.java (added)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/ConfigurableBinaryAttributeDetector.java Wed Feb  8 19:08:22 2012
@@ -0,0 +1,55 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.codec.api;
+
+
+/**
+ * An interface used to abstract the means to detect whether or not an attribute
+ * identifier/descriptor represents a binary attributeType.
+ */
+public interface ConfigurableBinaryAttributeDetector extends BinaryAttributeDetector
+{
+    /**
+     * Add some binary Attributes Id to the list of attributes
+     * 
+     * @param binaryAttributes The added binary attributes Id
+     */
+    public void addBinaryAttribute( String... binaryAttributes );
+
+    
+    /**
+     * Remove some binary Attributes Id from the list of attributes
+     * 
+     * @param binaryAttributes The binary attributes Id to remove
+     */
+    public void removeBinaryAttribute( String... binaryAttributes );
+
+    
+    /**
+     * Inject a new set of binary attributes that will replace the old one.
+     * If one inject a null set of attributes, the list of attributes will be
+     * cleared, and reset to the default list of binary attributes. If one
+     * injects an empty String array, then all the attributes will be removed
+     * from the list, and we won't inject the default attributes into it.
+     * 
+     * @param binaryAttributes The new set of binary attributes
+     */
+    public void setBinaryAttributes( String... binaryAttributes );
+}

Copied: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/DefaultConfigurableBinaryAttributeDetector.java (from r1241708, directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/DefaultBinaryAttributeDetector.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/DefaultConfigurableBinaryAttributeDetector.java?p2=directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/DefaultConfigurableBinaryAttributeDetector.java&p1=directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/DefaultBinaryAttributeDetector.java&r1=1241708&r2=1242044&rev=1242044&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/DefaultBinaryAttributeDetector.java (original)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/DefaultConfigurableBinaryAttributeDetector.java Wed Feb  8 19:08:22 2012
@@ -21,39 +21,87 @@ package org.apache.directory.shared.ldap
 
 import java.util.Set;
 
-import org.apache.directory.shared.ldap.model.schema.AttributeType;
-import org.apache.directory.shared.ldap.model.schema.LdapSyntax;
-import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 import org.apache.directory.shared.util.Strings;
 import org.apache.mina.util.ConcurrentHashSet;
 
 /**
  * An implementation of the BinaryAttributeDetector interface. It's used
- * on the client and server side to detect if an Attribute is HumanRedable.
+ * on the client side to detect if an Attribute is HumanRedable.<br/>
+ * One can inject some new attributes, replace the existing list,
+ * remove some attributes. <br/>
+ * We provide a list of Attributes which are known to be binary :
+ * <ul>
+ * <li>entryACI</li>
+ * <li>prescriptiveACI</li>
+ * <li>subentryACI</li>
+ * <li>audio</li>
+ * <li>javaByteCode</li>
+ * <li>javaClassByteCode</li>
+ * <li>krb5key</li>
+ * <li>m-byteCode</li>
+ * <li>privateKey</li>
+ * <li>publicKey</li>
+ * <li>userPKCS12</li>
+ * <li>userSMIMECertificate</li>
+ * <li>cACertificate</li>
+ * <li>userCertificate</li>
+ * <li>authorityRevocationList</li>
+ * <li>certificateRevocationList</li>
+ * <li>deltaRevocationList</li>
+ * <li>crossCertificatePair</li>
+ * <li>personalSignature</li>
+ * <li>photo</li>
+ * <li>jpegPhoto</li>
+ * <li>supportedAlgorithms</li>
+ * </ul>
+ * <br/>
+ * In order to reset the detector to get back to those default value, it's enough
+ * to call the setBinaryAttributes() with null as a parameter.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class DefaultBinaryAttributeDetector implements BinaryAttributeDetector
+public class DefaultConfigurableBinaryAttributeDetector extends SchemaBinaryAttributeDetector
+    implements ConfigurableBinaryAttributeDetector
 {
     /** A set of binary Attribute ID */
     private Set<String> binaryAttributes = new ConcurrentHashSet<String>();
-
-    /** A set of binary Syntax ID */
-    private Set<String> binarySyntaxes = new ConcurrentHashSet<String>();
-    
-    /** The schemaManager to use */
-    private SchemaManager schemaManager;
     
+    /** A list of all the known binary attributes */
+    public final static String[] DEFAULT_BINARY_ATTRIBUTES = new String[]
+        {
+            "entryACI",                 // Syntax : ACI Item
+            "prescriptiveACI",          // Syntax : ACI Item
+            "subentryACI",              // Syntax : ACI Item
+            "audio",                    // Syntax : Audio
+            "javaByteCode",             // Syntax : Binary
+            "javaClassByteCode",        // Syntax : Binary
+            "krb5key",                  // Syntax : Binary
+            "m-byteCode",               // Syntax : Binary
+            "privateKey",               // Syntax : Binary
+            "publicKey",                // Syntax : Binary
+            "userPKCS12",               // Syntax : Binary
+            "userSMIMECertificate",     // Syntax : Binary
+            "cACertificate",            // Syntax : Certificate
+            "userCertificate",          // Syntax : Certificate
+            "authorityRevocationList",  // Syntax : Certificate List
+            "certificateRevocationList",// Syntax : Certificate List
+            "deltaRevocationList",      // Syntax : Certificate List
+            "crossCertificatePair",     // Syntax : Certificate Pair
+            "personalSignature",        // Syntax : Fax
+            "photo",                    // Syntax : Fax
+            "jpegPhoto",                // Syntax : JPEG
+            "supportedAlgorithms",      // Syntax : Supported Algorithm
+            "javaSerializedData",       // Syntax : Octet String
+            "userPassword"              // Syntax : Octet String
+        };
     
     /**
-     * Creates a new instance of BinaryAttributeDetector. The SchemaManager can
-     * be null if we don't have any.
-     * 
-     * @param schemaManager The associated SchemaManager
+     * Creates a new instance of a ConfigurableBinaryAttributeDetector. This will
+     * load a set of default attribute ID that are known to be binary.
      */
-    public DefaultBinaryAttributeDetector( SchemaManager schemaManager )
+    public DefaultConfigurableBinaryAttributeDetector()
     {
-        this.schemaManager = schemaManager;
+        setBinaryAttributes( DEFAULT_BINARY_ATTRIBUTES );
     }
     
     
@@ -62,47 +110,16 @@ public class DefaultBinaryAttributeDetec
      */
     public boolean isBinary( String attributeId )
     {
-        String attrId = Strings.toLowerCase( attributeId );
-
-        if ( attrId.endsWith( ";binary" ) )
+        boolean isBinary = super.isBinary( attributeId );
+        
+        if ( isBinary )
         {
             return true;
         }
 
-        if ( schemaManager != null )
-        {
-            AttributeType attributeType =  schemaManager.getAttributeType( attrId );
-            
-            if ( attributeType == null )
-            {
-                return false;
-            }
-            
-            LdapSyntax ldapSyntax = attributeType.getSyntax();
-            
-            if ( ldapSyntax != null )
-            {
-                if ( ldapSyntax.hasHumanReadableFlag() )
-                {
-                    return !ldapSyntax.isHumanReadable();
-                }
-                else
-                {
-                    // Check the syntaxes
-                    String syntaxId = ldapSyntax.getOid();
-                    
-                    return ( binarySyntaxes.contains( syntaxId ) );
-                }
-            }
-            else
-            {
-                return binaryAttributes.contains( attrId );
-            }
-        }
-        else
-        {
-            return binaryAttributes.contains( attrId );
-        }
+        String attrId = Strings.toLowerCase( attributeId );
+
+        return binaryAttributes.contains( attrId );
     }
     
 
@@ -141,67 +158,21 @@ public class DefaultBinaryAttributeDetec
     /**
      * {@inheritDoc}
      */
-    public void setBinaryAttributes( Set<String> binaryAttributes )
+    public void setBinaryAttributes( String... binaryAttributes )
     {
-        if ( binaryAttributes != null )
+        if ( binaryAttributes == null )
         {
+            // Clear the Set and reinject the default attributes
             this.binaryAttributes.clear();
+            setBinaryAttributes( DEFAULT_BINARY_ATTRIBUTES );
             
-            for ( String binaryAttribute : binaryAttributes )
-            {
-                String attrId = Strings.toLowerCase( binaryAttribute );
-                this.binaryAttributes.add( attrId );
-            }
+            return;
         }
-    }
-    
 
-    /**
-     * {@inheritDoc}
-     */
-    public void addBinarySyntaxes( String... binarySyntaxes )
-    {
-        if ( binarySyntaxes != null )
-        {
-            for ( String binarySyntax : binarySyntaxes )
-            {
-                String syntaxId = Strings.toLowerCase( binarySyntax );
-                this.binarySyntaxes.add( syntaxId );
-            }
-        }
-    }
-    
-
-    /**
-     * {@inheritDoc}
-     */
-    public void setBinarySyntaxes( Set<String> binarySyntaxes )
-    {
-        if ( binarySyntaxes != null )
+        for ( String binaryAttribute : binaryAttributes )
         {
-            this.binarySyntaxes.clear();
-            
-            for ( String binarySyntax : binarySyntaxes )
-            {
-                String syntaxId = Strings.toLowerCase( binarySyntax );
-                this.binarySyntaxes.add( syntaxId );
-            }
-        }
-    }
-    
-
-    /**
-     * {@inheritDoc}
-     */
-    public void removeBinarySyntaxes( String... binarySyntaxes )
-    {
-        if ( binarySyntaxes != null )
-        {
-            for ( String binarySyntax : binarySyntaxes )
-            {
-                String syntaxId = Strings.toLowerCase( binarySyntax );
-                this.binarySyntaxes.remove( syntaxId );
-            }
+            String attrId = Strings.toLowerCase( binaryAttribute );
+            this.binaryAttributes.add( attrId );
         }
     }
 }

Modified: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/LdapMessageContainer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/LdapMessageContainer.java?rev=1242044&r1=1242043&r2=1242044&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/LdapMessageContainer.java (original)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/LdapMessageContainer.java Wed Feb  8 19:08:22 2012
@@ -20,8 +20,6 @@
 package org.apache.directory.shared.ldap.codec.api;
 
 
-import java.util.Set;
-
 import org.apache.directory.shared.asn1.ber.AbstractContainer;
 import org.apache.directory.shared.asn1.ber.Asn1Container;
 import org.apache.directory.shared.ldap.codec.LdapMessageGrammar;
@@ -61,37 +59,7 @@ public class LdapMessageContainer<E exte
      */
     public LdapMessageContainer( LdapApiService codec )
     {
-        this( codec, new BinaryAttributeDetector()
-        {
-            public boolean isBinary( String attributeId )
-            {
-                return false;
-            }
-
-            public void addBinaryAttribute( String... binaryAttributes )
-            {
-            }
-
-            public void removeBinaryAttribute( String... binaryAttributes )
-            {
-            }
-
-            public void setBinaryAttributes( Set<String> binaryAttributes )
-            {
-            }
-
-            public void addBinarySyntaxes( String... binarySyntaxes )
-            {
-            }
-
-            public void removeBinarySyntaxes( String... binarySyntaxes )
-            {
-            }
-
-            public void setBinarySyntaxes( Set<String> binarySyntaxes )
-            {
-            }
-        } );
+        this( codec, new DefaultConfigurableBinaryAttributeDetector() );
     }
 
 

Copied: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/SchemaBinaryAttributeDetector.java (from r1241708, directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/NoSchemaBinaryAttributeDetector.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/SchemaBinaryAttributeDetector.java?p2=directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/SchemaBinaryAttributeDetector.java&p1=directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/NoSchemaBinaryAttributeDetector.java&r1=1241708&r2=1242044&rev=1242044&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/NoSchemaBinaryAttributeDetector.java (original)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/api/SchemaBinaryAttributeDetector.java Wed Feb  8 19:08:22 2012
@@ -19,10 +19,10 @@
  */
 package org.apache.directory.shared.ldap.codec.api;
 
-import java.util.Set;
-
+import org.apache.directory.shared.ldap.model.schema.AttributeType;
+import org.apache.directory.shared.ldap.model.schema.LdapSyntax;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 import org.apache.directory.shared.util.Strings;
-import org.apache.mina.util.ConcurrentHashSet;
 
 /**
  * An implementation of the BinaryAttributeDetector interface. It's not
@@ -30,135 +30,60 @@ import org.apache.mina.util.ConcurrentHa
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class NoSchemaBinaryAttributeDetector implements BinaryAttributeDetector
+public class SchemaBinaryAttributeDetector implements BinaryAttributeDetector
 {
-    /** A set of binary Attribute ID */
-    private Set<String> binaryAttributes = new ConcurrentHashSet<String>();
-
-    /** A set of binary Syntax ID */
-    private Set<String> binarySyntaxes = new ConcurrentHashSet<String>();
+    /** The schemaManager to use */
+    private SchemaManager schemaManager;
     
     
-    /**
-     * Creates a new instance of BinaryAttributeDetector. It's not schema aware
-     */
-    public NoSchemaBinaryAttributeDetector()
+    public SchemaBinaryAttributeDetector()
     {
     }
     
     
-    /**
-     * {@inheritDoc}
-     */
-    public boolean isBinary( String attributeId )
+    public SchemaBinaryAttributeDetector( SchemaManager schemaManager )
     {
-        String attrId = Strings.toLowerCase( attributeId );
-
-        if ( attrId.endsWith( ";binary" ) )
-        {
-            return true;
-        }
-
-        return binaryAttributes.contains( attrId );
+        this.schemaManager = schemaManager;
     }
-    
 
     /**
-     * {@inheritDoc}
+     * @param schemaManager the schemaManager to set
      */
-    public void addBinaryAttribute( String... binaryAttributes )
+    public void setSchemaManager( SchemaManager schemaManager )
     {
-        if ( binaryAttributes != null )
-        {
-            for ( String binaryAttribute : binaryAttributes )
-            {
-                String attrId = Strings.toLowerCase( binaryAttribute );
-                this.binaryAttributes.add( attrId );
-            }
-        }
+        this.schemaManager = schemaManager;
     }
-    
 
-    /**
-     * {@inheritDoc}
-     */
-    public void removeBinaryAttribute( String... binaryAttributes )
-    {
-        if ( binaryAttributes != null )
-        {
-            for ( String binaryAttribute : binaryAttributes )
-            {
-                String attrId = Strings.toLowerCase( binaryAttribute );
-                this.binaryAttributes.remove( attrId );
-            }
-        }
-    }
-    
 
     /**
      * {@inheritDoc}
      */
-    public void setBinaryAttributes( Set<String> binaryAttributes )
+    public boolean isBinary( String attributeId )
     {
-        if ( binaryAttributes != null )
-        {
-            this.binaryAttributes.clear();
-            
-            for ( String binaryAttribute : binaryAttributes )
-            {
-                String attrId = Strings.toLowerCase( binaryAttribute );
-                this.binaryAttributes.add( attrId );
-            }
-        }
-    }
-    
+        String attrId = Strings.toLowerCase( attributeId );
 
-    /**
-     * {@inheritDoc}
-     */
-    public void addBinarySyntaxes( String... binarySyntaxes )
-    {
-        if ( binarySyntaxes != null )
+        if ( attrId.endsWith( ";binary" ) )
         {
-            for ( String binarySyntax : binarySyntaxes )
-            {
-                String syntaxId = Strings.toLowerCase( binarySyntax );
-                this.binarySyntaxes.add( syntaxId );
-            }
+            return true;
         }
-    }
-    
 
-    /**
-     * {@inheritDoc}
-     */
-    public void setBinarySyntaxes( Set<String> binarySyntaxes )
-    {
-        if ( binarySyntaxes != null )
+        if ( schemaManager != null )
         {
-            this.binarySyntaxes.clear();
+            AttributeType attributeType =  schemaManager.getAttributeType( attrId );
             
-            for ( String binarySyntax : binarySyntaxes )
+            if ( attributeType == null )
             {
-                String syntaxId = Strings.toLowerCase( binarySyntax );
-                this.binarySyntaxes.add( syntaxId );
+                return false;
             }
+            
+            LdapSyntax ldapSyntax = attributeType.getSyntax();
+            
+            return ( ( ldapSyntax != null ) &&
+                 ldapSyntax.hasHumanReadableFlag() &&
+                 ldapSyntax.hasHumanReadableFlag() ) &&
+                 !ldapSyntax.isHumanReadable();
         }
-    }
-    
 
-    /**
-     * {@inheritDoc}
-     */
-    public void removeBinarySyntaxes( String... binarySyntaxes )
-    {
-        if ( binarySyntaxes != null )
-        {
-            for ( String binarySyntax : binarySyntaxes )
-            {
-                String syntaxId = Strings.toLowerCase( binarySyntax );
-                this.binarySyntaxes.remove( syntaxId );
-            }
-        }
+        return false;
     }
 }



Mime
View raw message