Photo LDAP update fails

Hi forum,
when an user log into the wiki, the update of the user avatar will fail with:
WARN o.x.c.l.XWikiLDAPUtils - No image readers found for provided stream.
INFO o.x.c.l.XWikiLDAPUtils - Unable to determine LDAP photo image type.

When I try to get the photo via the command line via:
ldapsearch -H ldaps://XXX -x -W -D "XXXX" -b "XXX" "(&(objectClass=user)(sAMAccountName=XXXX))" "thumbnailPhoto"
Then I get the photo.
thumbnailPhoto: /9j/4AAQSkZJRgABAQEAcwBzAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQ
EBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQE
BAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wgAR

I use version 11.10.10 of xwiki.

Looks like the authenticator get the image content but from what I understand Java is unable to find the type of that image (in which case the authenticator skips it). Hard to say if it’s a Java limitation in general or if a more recent version of Java would fix it.

What the LDAP authenticator uses to find out the type of the image can be found on https://github.com/xwiki-contrib/ldap/blob/master/ldap-authenticator/src/main/java/org/xwiki/contrib/ldap/XWikiLDAPUtils.java#L1508. If you know the image that should have been downloaded I guess the first thing that would be interesting to try is see if this code works with this code (to be sure it downloaded the right content).

If the problem is the image itself maybe we can find some library to find the image type instead of standard Java tools (it’s possible Tika have better results for example).

Thanks for the hint.
I use java-11-openjdk-headless-11.0.8.10-0.el7_8.x86_64 from CentOS 7

As I see,


OpenJDK can decode near all formats.
In my case it is an jpeg file, but I have tested it also with an png file, but the result is the same.

Exists an simply solution, to test which formats are supported by the jre?

jpeg and png in general should definitely be supported by the JRE but maybe there is something wrong with those specific images or maybe for some reason the authenticator does not receive the right data (more probably) but hard to tell more without a way to reproduce it.

Thanks for the tip with the part of the source code.

I have found some sample code in the web, with which I have tested the jvm.
This sample code will, simple read an picture and convert it to other formats.
ReadAndWriteImage.java.txt (648 Bytes)
It will work. So the jvm looks like fine.
After that I try to convert the base64 encoded file from the ldap call to an binary one. And this fails.
So it must be an problem with the ldap entry.
Now I create an new entry via:
dn: CN=XXXX
changetype: modify
replace: thumbnailPhoto
thumbnailPhoto:< file:Tux.png
and ldapmodify.
Now it works.
It looks like, that the base64 decoding call noiseless fails and then the ImageReader will be feeded with invalid data.