directory-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lécharny <elecha...@apache.org>
Subject Re: userCertficate;binary problem (was : Re: Upgrading to apacheds-service-2.0.0-M3.jar - ClassNotFoundException)
Date Tue, 18 Oct 2011 19:57:26 GMT
On 10/18/11 7:34 PM, Harakiri wrote:
>
> --- On Tue, 10/18/11, Emmanuel Lecharny<elecharny@gmail.com>  wrote:
>
>> From: Emmanuel Lecharny<elecharny@gmail.com>
>> Subject: userCertficate;binary problem (was : Re: Upgrading to apacheds-service-2.0.0-M3.jar
- ClassNotFoundException)
>> To: users@directory.apache.org
>> Date: Tuesday, October 18, 2011, 12:26 PM
>> Ok,
>>
>> I have fixed the client-side code and now the following
>> code works fine :
>>
>>      /**
>>       * Test method for
>> userCertificate;binary AT
>>       */
>>      @Test
>>      public void testUserCertificateBinary()
>> throws LdapException
>>      {
>>          Entry entry = new DefaultEntry(
>> schemaManager );
>>          entry.add( "objectClass",
>> "top", "person", "inetorgPerson" );
>>          entry.add( "cn", "test1",
>> "test2" );
>>          entry.add( "sn", "Test1",
>> "Test2" );
>>          entry.add( "userPassword",
>> BYTES1, BYTES2 );
>>
>>          entry.add(
>> "userCertificate;binary", Strings.getBytesUtf8( "secret" )
>> );
>>          assertTrue(
>> entry.containsAttribute( "userCertificate;binary" ) );
>>          assertTrue(
>> entry.containsAttribute( "userCertificate" ) );
>>
>>          entry.removeAttributes(
>> "userCertificate;binary" );
>>          assertFalse(
>> entry.containsAttribute( "userCertificate;binary" ) );
>>          assertFalse(
>> entry.containsAttribute( "userCertificate" ) );
>>
>>          entry.add( "userCertificate",
>> Strings.getBytesUtf8( "secret" ) );
>>          assertTrue(
>> entry.containsAttribute( "userCertificate;binary" ) );
>>          assertTrue(
>> entry.containsAttribute( "userCertificate" ) );
>>      }
>>
>>
>> As you can see, there is no more difference between
>> 'userCertificate' and 'userCertificate;binary'.
>>
>>
>> I'm running global tests to see if it has an impact on the
>> client or the server, and if not, i'm going to commit the
>> fix.
>>
> Great job - thank you very much!
>
> Is there a nightly build (complete all-in-one jar) for this available sometime so i can
test it?

No, and I would not advise you to use the current trunk, it's under 
heavy work atm.

I can provide the patch that fixes the issue :

Index: 
ldap/schema/data/src/main/java/org/apache/directory/shared/ldap/schemamanager/impl/DefaultSchemaManager.java
===================================================================
--- 
ldap/schema/data/src/main/java/org/apache/directory/shared/ldap/schemamanager/impl/DefaultSchemaManager.java
   
(revision 1185651)
+++ 
ldap/schema/data/src/main/java/org/apache/directory/shared/ldap/schemamanager/impl/DefaultSchemaManager.java
   
(working copy)
@@ -1593,13 +1593,34 @@
          return new ImmutableSyntaxCheckerRegistry( 
registries.getSyntaxCheckerRegistry() );
      }

+
+    /**
+     * Get rid of AT's options (everything after the ';'
+     * @param oid
+     * @return
+     */
+    private String stripOptions( String oid )
+    {
+        int semiColonPos = oid.indexOf( ';' );
+
+        if ( semiColonPos != -1 )
+        {
+            return oid.substring( 0, semiColonPos );
+        }
+        else
+        {
+            return oid;
+        }
+    }

      /**
       * {@inheritDoc}
       */
      public AttributeType lookupAttributeTypeRegistry( String oid ) 
throws LdapException
      {
-        return registries.getAttributeTypeRegistry().lookup( 
Strings.toLowerCase( oid ).trim() );
+        String oidTrimmed = Strings.toLowerCase( oid ).trim();
+        String oidNoOption = stripOptions( oidTrimmed );
+        return registries.getAttributeTypeRegistry().lookup( oidNoOption );
      }


>
> I gather that when i now query for this attribute - "userCertificate;binary" is also
returned? (The previous hack would make it so, that if "userCertificate;binary" was requested,
just "userCertificate" was returned - which did not help the cause because RFC states that
"userCertificate;binary" must be returned.
Yes, sadly, the ';binary' is not stored. Now, the ';binary' is optional, 
and can somehow being ignored.


-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com


Mime
View raw message