directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1569071 - in /directory: apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/ apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ apacheds/trunk/server-integ/sr...
Date Mon, 17 Feb 2014 18:30:02 GMT
Author: kayyagari
Date: Mon Feb 17 18:30:02 2014
New Revision: 1569071

URL: http://svn.apache.org/r1569071
Log:
o added default binary attribute detector instead of the one based on schema manager (DIRSERVER-1959)
o removed a unit test invalidated by the above change
o updated a test to check the replication of binary attributes
o set the schema manager in consumer's connection
o update LDAP message container to access the internal binary attribute detector

Modified:
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ReplicationConsumerImpl.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.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/api/ldap/codec/api/LdapMessageContainer.java

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=1569071&r1=1569070&r2=1569071&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
Mon Feb 17 18:30:02 2014
@@ -247,32 +247,6 @@ public void testLookup() throws Exceptio
 
 
     /**
-     * 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
      */

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ReplicationConsumerImpl.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ReplicationConsumerImpl.java?rev=1569071&r1=1569070&r2=1569071&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ReplicationConsumerImpl.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ReplicationConsumerImpl.java
Mon Feb 17 18:30:02 2014
@@ -216,7 +216,8 @@ public class ReplicationConsumerImpl imp
             {
                 connection = new LdapNetworkConnection( providerHost, port );
                 connection.setTimeOut( -1L );
-
+                connection.setSchemaManager( schemaManager );
+                
                 if ( config.isUseTls() )
                 {
                     connection.getConfig().setTrustManagers( config.getTrustManager() );

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java?rev=1569071&r1=1569070&r2=1569071&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java
Mon Feb 17 18:30:02 2014
@@ -33,6 +33,7 @@ import java.util.concurrent.atomic.Atomi
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.csn.Csn;
 import org.apache.directory.api.ldap.model.cursor.Cursor;
+import org.apache.directory.api.ldap.model.entry.Attribute;
 import org.apache.directory.api.ldap.model.entry.DefaultEntry;
 import org.apache.directory.api.ldap.model.entry.Entry;
 import org.apache.directory.api.ldap.model.message.ModifyRequest;
@@ -43,6 +44,7 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.name.Dn;
 import org.apache.directory.api.ldap.model.name.Rdn;
 import org.apache.directory.api.ldap.model.schema.SchemaManager;
+import org.apache.directory.api.util.Strings;
 import org.apache.directory.junit.tools.MultiThreadedMultiInvoker;
 import org.apache.directory.server.annotations.CreateConsumer;
 import org.apache.directory.server.annotations.CreateLdapServer;
@@ -53,9 +55,9 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.annotations.CreatePartition;
 import org.apache.directory.server.core.api.CoreSession;
 import org.apache.directory.server.core.api.DirectoryService;
-import org.apache.directory.server.core.api.filtering.EntryFilteringCursor;
 import org.apache.directory.server.core.factory.DSAnnotationProcessor;
 import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.server.core.security.TlsKeyGenerator;
 import org.apache.directory.server.factory.ServerAnnotationProcessor;
 import org.apache.directory.server.ldap.LdapServer;
 import org.apache.directory.server.ldap.replication.consumer.ReplicationConsumer;
@@ -275,6 +277,12 @@ public class ClientServerReplicationIT
         modReq.setName( provUser.getDn() );
         modReq.add( "userPassword", "secret" );
 
+        // to test replication of binary data
+        modReq.add( "objectClass", "inetOrgPerson" );
+        modReq.add( "uid", "uid" );
+        TlsKeyGenerator.addKeyPair( provUser );
+        modReq.add( "userCertificate", provUser.get( "userCertificate" ).getBytes() );
+        
         //System.out.println( ">--------------------------------------- Modifying " +
modReq );
         providerSession.modify( modReq );
         //System.out.println( ">--------------------------------------- Modified " );
@@ -494,8 +502,8 @@ public class ClientServerReplicationIT
             provUser = restartConsumer( provUser );
         }
     }
-
-
+    
+    
     private void compareEntries( Dn dn ) throws Exception
     {
         String[] searchAttributes = new String[]

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=1569071&r1=1569070&r2=1569071&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
Mon Feb 17 18:30:02 2014
@@ -54,6 +54,7 @@ import javax.security.sasl.SaslClient;
 import org.apache.directory.api.asn1.DecoderException;
 import org.apache.directory.api.asn1.util.Oid;
 import org.apache.directory.api.ldap.codec.api.BinaryAttributeDetector;
+import org.apache.directory.api.ldap.codec.api.ConfigurableBinaryAttributeDetector;
 import org.apache.directory.api.ldap.codec.api.DefaultConfigurableBinaryAttributeDetector;
 import org.apache.directory.api.ldap.codec.api.ExtendedResponseDecorator;
 import org.apache.directory.api.ldap.codec.api.LdapApiService;
@@ -501,7 +502,7 @@ public class LdapNetworkConnection exten
             config.setLdapHost( server );
         }
 
-        config.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector( null ) );
+        config.setBinaryAttributeDetector( new DefaultConfigurableBinaryAttributeDetector()
);
         
         return config;
     }
@@ -673,11 +674,27 @@ public class LdapNetworkConnection exten
             ( LdapMessageContainer<MessageDecorator<? extends Message>> ) ldapSession
                 .getAttribute( LdapDecoder.MESSAGE_CONTAINER_ATTR );
 
-        if ( container == null )
+        if ( container != null )
         {
+            if( schemaManager != null )
+            {
+                if ( !( container.getBinaryAttributeDetector() instanceof SchemaBinaryAttributeDetector
) )
+                {
+                    container.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector(
schemaManager ) );
+                }
+            }
+        }
+        else
+        {
+            BinaryAttributeDetector atDetector = new DefaultConfigurableBinaryAttributeDetector();
+            
+            if ( schemaManager != null )
+            {
+               atDetector = new SchemaBinaryAttributeDetector( schemaManager ); 
+            }
+            
             ldapSession.setAttribute( LdapDecoder.MESSAGE_CONTAINER_ATTR,
-                new LdapMessageContainer<MessageDecorator<? extends Message>>(
codec,
-                    new DefaultConfigurableBinaryAttributeDetector() ) );
+                new LdapMessageContainer<MessageDecorator<? extends Message>>(
codec, atDetector ) );
         }
 
         // Initialize the MessageId

Modified: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapMessageContainer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapMessageContainer.java?rev=1569071&r1=1569070&r2=1569071&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapMessageContainer.java
(original)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapMessageContainer.java
Mon Feb 17 18:30:02 2014
@@ -40,7 +40,7 @@ public class LdapMessageContainer<E exte
     private E messageDecorator;
 
     /** checks if attribute is binary */
-    private final BinaryAttributeDetector binaryAttributeDetector;
+    private BinaryAttributeDetector binaryAttributeDetector;
 
     /** The message ID */
     private int messageId;
@@ -171,4 +171,24 @@ public class LdapMessageContainer<E exte
     {
         this.currentControl = currentControl;
     }
+
+
+    /**
+     * Sets the binary attribute detector
+     * 
+     * @param binaryAttributeDetector the binary attribute detector
+     */
+    public void setBinaryAttributeDetector( BinaryAttributeDetector binaryAttributeDetector
)
+    {
+        this.binaryAttributeDetector = binaryAttributeDetector;
+    }
+
+
+    /**
+     * @return the binary attribute detector
+     */
+    public BinaryAttributeDetector getBinaryAttributeDetector()
+    {
+        return binaryAttributeDetector;
+    }
 }



Mime
View raw message