Issue Details (XML | Word | Printable)

Key: DIRSERVER-251
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Emmanuel Lecharny
Reporter: Tony Blanchard
Votes: 2
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Directory ApacheDS

Putting a jpeg picture in the inetOrgPerson jpegPhoto attribute alter the bytes datas of the picture

Created: 16/Jun/05 12:47 AM   Updated: 21/Apr/07 11:09 AM
Return to search
Component/s: None
Affects Version/s: pre-1.0
Fix Version/s: 1.0-RC1

Time Tracking:
Not Specified

File Attachments:
  Size
Java Source File Licensed for inclusion in ASF works BinaryTest.java 2005-08-05 03:18 PM Stefan Zoerner 3 kB
Environment:
Windows XP SP2
JRE 1.5
Built with Netbeans 4.0
Mevenide.

Resolution Date: 03/Nov/05 12:09 PM


 Description  « Hide
All the picture byte values like those (-113 , -115, -112, -127 and -99) are changed to the "63" value when reading jpeg datas. "-39" value is changed to "0".
This is on my jpeg sample picture but I think there is enought datas to be representative.

I have tried to put a picture with JXplorer and my own client program. The same thing happens...
Seems to be a server problem.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Stefan Zoerner added a comment - 05/Aug/05 03:18 PM
I faced the same problem in 0.9.1 with different clients on different hard- and software platforms.

Therfore I created a testcase (attached). It opens a JNDI connection, adds a person entry with 64k random binary data for attribute jpegPhoto, reads it out again and compares the binary data byte by byte.

It fails with

junit.framework.AssertionFailedError: Byte number 47 expected:<-112> but was:<63>
at junit.framework.Assert.fail(Assert.java:47)
at junit.framework.Assert.failNotEquals(Assert.java:282)
at junit.framework.Assert.assertEquals(Assert.java:64)
at junit.framework.Assert.assertEquals(Assert.java:162)
at simple.BinaryTest.testToriWithFunData(BinaryTest.java(Compiled Code))

Testcase is attached and works for other directory solutions, e.g. Sun Java System Directory Server 5.2

Stefan Zoerner made changes - 05/Aug/05 03:18 PM
Field Original Value New Value
Attachment BinaryTest.java [ 12311573 ]
Alex Karasulu added a comment - 12/Aug/05 12:07 AM
Assigning this to Emmanuel who is already working on it.

Alex Karasulu made changes - 12/Aug/05 12:07 AM
Assignee Alex Karasulu [ akarasulu ] Emmanuel Lecharny [ elecharny ]
Emmanuel Lecharny added a comment - 13/Aug/05 03:02 PM
This pb is due to a new String(xxx) done on the value.

We have to check the attribute's type to see if it's a binary attribute or a String, so we have to check the attribute agaisnt the Schema (RFC 2252 : 4.3.2. Syntax Object Identifiers)

I expect a patch to be submitted soon.

Alex Karasulu made changes - 25/Aug/05 01:57 AM
Assignee Emmanuel Lecharny [ elecharny ]
Fix Version/s 0.9.3 [ 12310193 ]
Emmanuel Lecharny added a comment - 31/Aug/05 03:27 PM
Attribute values are generally stored as String. This is a major problem for binary attributes, as we loose information (jpegPhoto for instance).

here is an exemple of code where this problem occurs :
org.apache.ldap.common.berlib.asn1.decoder.compare.CompareAVARule {
...


    public void finish()
    {
        // pop the ByteBuffer the super method pushed
        ByteBuffer buf = ( ByteBuffer ) getDigester().pop() ;
        // peek at the CompareRequest underneath whose name we set
        CompareRequest req = ( CompareRequest ) getDigester().peek() ;

        byte[] octets = null ;
        if ( buf.limit() == buf.capacity() && buf.hasArray() )
        {
            // use the backing store
            octets = buf.array() ;
        }
        else
        {
            // copy because we don't have accessible array or data < array
            octets = new byte[buf.remaining()] ;
            buf.get( octets ) ;
        }

        if ( req.getAttributeId() == null )
        {
            req.setAttributeId( new String( octets ) ) ;
        }
        else
        {
            req.setAssertionValue( new String( octets ) ) ;
        }
    }


The "new String(octets)" is destructing when applied to binary values.

Alex Karasulu added a comment - 13/Sep/05 05:58 AM
Figured I can assign this to you since you're working on it already.

Alex Karasulu made changes - 13/Sep/05 05:58 AM
Assignee Emmanuel Lecharny [ elecharny ]
Alex Karasulu added a comment - 29/Oct/05 11:43 AM
move it to next release

Alex Karasulu made changes - 29/Oct/05 11:43 AM
Fix Version/s 0.9.4 [ 12310230 ]
Fix Version/s 0.9.3 [ 12310193 ]
Repository Revision Date User Message
ASF #330524 Thu Nov 03 10:30:52 UTC 2005 szoerner Add test case for adding entries with binary data.
This is to demonstrate that DIREVE-163 does not occur any more.
Files Changed
MODIFY /directory/testsuite/trunk/ldaptests/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/util/AttributesFactory.java
MODIFY /directory/testsuite/trunk/ldaptests/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/add/AllTests.java
ADD /directory/testsuite/trunk/ldaptests/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/add/BinaryDataAddTest.java

Alex Karasulu added a comment - 03/Nov/05 12:09 PM
I think we can close this but let's get some confirmation.

Alex Karasulu made changes - 03/Nov/05 12:09 PM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Stefan Zoerner added a comment - 03/Nov/05 07:43 PM
I have created a new test case in the testsuite to demonstrate that this problem does not occur anymore:
    http://svn.apache.org/viewcvs.cgi?rev=330524&view=rev
It creates (inetOrg)person entries with userPassword and jpegPhoto attributes, one method is exactly the one already attached here. Afterwards it reads the entries and checks whether the data has been modified by the server (as described in the issue here).

If I use the current server.xml from here
    http://svn.apache.org/viewcvs.cgi/directory/apacheds/trunk/main/server.xml
the test is successful (it is not for 0.9.3, therefore the test is ok, I think). I was also able to use Softerra LDAP Administrator and attach my photo to an inetOrgPerson entry via its UI functionality. What a beautiful me, the image is not corrupted if I read it back. That didn't work in previous versions, as well.

I still face problems if I do not use the server.xml described above, but start the server main without configuration (i.e. the default config from the jar is used). The test case above fails. I have to figure out, what the difference between the configurations is ...

Anyway, Great work, Emmanuel + Alex! This was my favorite error for ages ...

Stefan Zoerner added a comment - 04/Nov/05 04:30 AM
Alex had the following idea in an IRC:

Rather than doing definition of binary attributes via configuration we can at the startup of the server scan all the schema looking for binary attributes, then we can assemble this information.

This would help people not to forget defining there attributes as binary in two places (schema + configuration).

Repository Revision Date User Message
ASF #330978 Sat Nov 05 07:20:26 UTC 2005 akarasulu changes ...

 o touched up DIREVE-163
 o server now sets the JNDI parameter java.naming.ldap.attributes.binary by
   using the schema of the server - the human readable property of the
   attributeTypes in the system are used to determine if the attribute is
   binary
 o the server takes the union of the schema information along with the values
   provided in this parameter
 o the server replaces or adds this property key as a Set object
 o the ldap-common MessageDecoder code can detect if a Set is used and
   will use that to feed the providers a set
Files Changed
MODIFY /directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/schema/bootstrap/SystemSyntaxProducer.java
MODIFY /directory/apacheds/trunk/server-unit
MODIFY /directory/shared/ldap/trunk/apache2-provider/src/main/java/org/apache/asn1new/ldap/TwixProvider.java
MODIFY /directory/shared/ldap/trunk/apache-provider/src/main/java/org/apache/ldap/common/berlib/asn1/SnickersDecoder.java
MODIFY /directory/apacheds/trunk/server-main/server.xml
MODIFY /directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/message/MessageDecoder.java
MODIFY /directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/schema/SchemaService.java
MODIFY /directory/shared/ldap/trunk/apache-provider/src/main/java/org/apache/ldap/common/berlib/asn1/SnickersProvider.java
MODIFY /directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/schema/SchemaUtils.java
MODIFY /directory/shared/ldap/trunk/apache2-provider/src/main/java/org/apache/asn1new/ldap/TwixDecoder.java
MODIFY /directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/DefaultDirectoryService.java
MODIFY /directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/message/spi/Provider.java

Alex Karasulu added a comment - 05/Nov/05 04:27 PM
I finished up this enhancement on commit 330978. Now the server uses the schema to set the value for this binary attribute. It will also merge attributes if users provide this in the server.xml to force the treatment of non-binary attributes as binary.

Alex Karasulu made changes - 10/Feb/06 12:26 PM
Affects Version/s pre-1.0 [ 12310782 ]
Project Directory Server [ 10516 ] Directory ApacheDS [ 12310260 ]
Affects Version/s 0.9 [ 11003 ]
Key DIREVE-163 DIRSERVER-251
Fix Version/s 1.0-RC1 [ 12310230 ]
Fix Version/s 1.0-RC1 [ 12310780 ]
Emmanuel Lecharny added a comment - 21/Apr/07 11:09 AM
Closing all issues created in 2005 and before which are marked resolved

Emmanuel Lecharny made changes - 21/Apr/07 11:09 AM
Status Resolved [ 5 ] Closed [ 6 ]