You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2009/05/14 17:20:15 UTC

svn commit: r774815 - in /directory/apacheds/trunk: core/src/main/java/org/apache/directory/server/core/changelog/ protocol-ldap/src/main/java/org/apache/directory/server/ldap/ server-integ/src/test/java/org/apache/directory/server/operations/modify/

Author: elecharny
Date: Thu May 14 15:20:15 2009
New Revision: 774815

URL: http://svn.apache.org/viewvc?rev=774815&view=rev
Log:
Partial fix for DIRSERVER-1198 : We can now inject usercertificat;binary values with bytes above 0x7F.

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolCodecFactory.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddIT.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java?rev=774815&r1=774814&r2=774815&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java Thu May 14 15:20:15 2009
@@ -233,7 +233,7 @@
             
          // if there are no modifications due to stripping out bogus non-
          // existing attributes then we will have no modification items and
-         // should ignore not this without registerring it with the changelog
+         // should ignore not this without registering it with the changelog
          
             opContext.getModItems().size() == 0 )  
         {

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolCodecFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolCodecFactory.java?rev=774815&r1=774814&r2=774815&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolCodecFactory.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolCodecFactory.java Thu May 14 15:20:15 2009
@@ -28,6 +28,7 @@
 import org.apache.directory.shared.ldap.message.MessageEncoder;
 import org.apache.directory.shared.ldap.message.spi.BinaryAttributeDetector;
 import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.util.StringTools;
 import org.apache.mina.core.session.IoSession;
 import org.apache.mina.filter.codec.ProtocolCodecFactory;
 import org.apache.mina.filter.codec.ProtocolDecoder;
@@ -89,7 +90,12 @@
                 }
                 catch ( Exception e )
                 {
-                    return false;
+                    if ( StringTools.isEmpty( id ) )
+                    {
+                        return false;
+                    }
+                    
+                    return id.endsWith( ";binary" );
                 }
             }
         },

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddIT.java?rev=774815&r1=774814&r2=774815&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddIT.java Thu May 14 15:20:15 2009
@@ -45,6 +45,7 @@
 import static org.apache.directory.server.integ.ServerIntegrationUtils.getWiredContext;
 
 import org.apache.directory.server.ldap.LdapService;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import static org.junit.Assert.fail;
@@ -566,7 +567,7 @@
 
 
     /**
-     * Add a new attribute to a person entry.
+     * Add a new binary attribute to a person entry.
      */
     @Test
     public void testAddNewBinaryAttributeValue() throws Exception
@@ -587,4 +588,68 @@
         assertTrue( Arrays.equals( newValue, certificate ) );
         assertEquals( 1, attr.size() );
     }
+    
+    
+    /**
+     * Add a new attribute to a person entry.
+     */
+    @Test
+    public void testAddNewBinaryAttributeValueAbove0x80() throws Exception
+    {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapService ).lookup( BASE );
+        
+        // Add a binary attribute
+        byte[] newValue = new byte[]{(byte)0x80, (byte)0x81, (byte)0x82, (byte)0x83};
+        Attributes attrs = new BasicAttributes( "userCertificate;binary", newValue, true );
+        ctx.modifyAttributes( RDN_TORI_AMOS, DirContext.ADD_ATTRIBUTE, attrs );
+
+        // Verify, that attribute value is added
+        attrs = ctx.getAttributes( RDN_TORI_AMOS );
+        Attribute attr = attrs.get( "userCertificate" );
+        assertNotNull( attr );
+        assertTrue( attr.contains( newValue ) );
+        byte[] certificate = (byte[])attr.get();
+        assertTrue( Arrays.equals( newValue, certificate ) );
+        assertEquals( 1, attr.size() );
+    }
+
+
+    /**
+     * Add a new binary attribute to a person entry.
+     */
+    @Ignore
+    @Test
+    public void testRetrieveEntryWithBinaryAttributeValue() throws Exception
+    {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapService ).lookup( BASE );
+
+        // Add a ;binary attribute
+        byte[] newValue = new byte[]{0x00, 0x01, 0x02, 0x03};
+        Attributes attrs = new BasicAttributes( "userCertificate;binary", newValue );
+        ctx.modifyAttributes( RDN_TORI_AMOS, DirContext.ADD_ATTRIBUTE, attrs );
+        
+        // Search entry an request ;binary attribute
+        SearchControls sctls = new SearchControls();
+        sctls.setSearchScope(SearchControls.OBJECT_SCOPE);
+        sctls.setReturningAttributes( new String[]{ "userCertificate;binary" } );
+        String filter = "(objectClass=*)";
+        String base = RDN_TORI_AMOS;
+   
+        // Test that ;binary attribute is present
+        NamingEnumeration<SearchResult> enm = ctx.search( base, filter, sctls);
+        assertTrue(enm.hasMore());
+        
+        while (enm.hasMore()) 
+        {
+            SearchResult sr = enm.next();
+            attrs = sr.getAttributes();
+            Attribute attr = attrs.get("userCertificate;binary");
+            assertNotNull(attr);
+            assertTrue( attr.contains( newValue ) );
+            byte[] certificate = (byte[])attr.get();
+            assertTrue( Arrays.equals( newValue, certificate ) );
+            assertEquals( 1, attr.size() );
+        }
+        
+    }
 }