directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Emmanuel Lecharny (JIRA)" <>
Subject [jira] [Commented] (DIRAPI-320) ClassCastException on Objects.equals(Value,Value) for userPassword attribute
Date Thu, 13 Sep 2018 09:42:00 GMT


Emmanuel Lecharny commented on DIRAPI-320:

Note that the {{cn=schema,cn=config}} backend is only visible when you use {{slapd.d}}, and
not {{slapd.conf}}.

That being said, many schema objects are hidden by {{OpenLDAP}}. It's a policy that has been
around for years (almost 2 decades...). The idea is that schema objects that are not well
defined in RFCs should not be exposed. This is a problem when you want to design a schema
aware client (see [this thread|]).

So how should we deal with this ? Ideally speaking, what we need is a {{OpenLDAPSchemaLoader}},
that deals with those issues :-) The biggest issue here is that we use internal constructs
({{Normalizer}}, {{SyntaxChecker}} and {{Comparator}}) that aren't defined in any LDAP RFC.
IMO, they should be used whatever the server you connect to, which is not the case. This [schema
picture|] shows the relation of
those three elements with the other schema elements ({{LdapSyntax}} and {{MatchingRule}}).
The link is done using the {{OID}}, so it's easy to retrieve the correct {{Comparator}} knowing
the {{MatchingRule}}'s syntax. For instance :

{noformat:title=telephoneNumberSubstringsMatch MacthingRule}
( NAME 'telephoneNumberSubstringsMatch' SYNTAX )


{noformat:title=Substring Assertion Syntax}
( DESC 'Substring Assertion' )

are implicitely linked. Their associated {{SyntaxChecker}} has the very same OID:

public final class SubstringAssertionSyntaxChecker extends SyntaxChecker
     * A static instance of SubstringAssertionSyntaxChecker
    public static final SubstringAssertionSyntaxChecker INSTANCE = 
        new SubstringAssertionSyntaxChecker( SchemaConstants.SUBSTRING_ASSERTION_SYNTAX );

(There is no associated {{Comparator}} and {{Normalizer}}, we use a noOp {{Normalizer}} and
a standard comparator).

That means we could load all the existing {{SyntaxCheckers}} beforehand, and attach them to
the newly created 'fake' {{LdapSyntax}} when they are hidden by the server. Same thing for
{{Comparators}} and {{Normalizers}}.

That would make the loaded schema working in all case.

I'll check how costly would be such an approach. Now, the problem will also arise for AD,
and any other LDAP server we would like to get teh schema from - and the fact that so many
LDAP servers simply don't implement the RFCs properly is a real troublemaker ;-/ -

Interesting problem :-)

> ClassCastException on Objects.equals(Value,Value) for userPassword attribute
> ----------------------------------------------------------------------------
>                 Key: DIRAPI-320
>                 URL:
>             Project: Directory Client API
>          Issue Type: Bug
>    Affects Versions: 2.0.0.AM2
>            Reporter: Pavel Zlámal
>            Priority: Minor
> When I use _JarLdifSchemaLoader_ it seems to load _userPassword_ attribute type with
different Comparator than when I load it from LDAP connection (openLDAP in my case).
> Then If I call:
> {code:java}
> Objects.equals(val, attribute.get())
> {code}
> to check if value passed to my method is the first in the attribute, I get _ClassCastException_,
since it tries to pass _String_ (normalized value) to the _ByteArrayComparator._
> When I use Schema only loaded from connection, then it works, since it uses _ComparableComparator._
> {code:java}
> java.lang.ClassCastException: java.lang.String cannot be cast to [B
>     at
>     at
>     at java.util.Objects.equals(
> {code}
> So there is probably bug in schema ldif included in JAR or in equals() implementation
of Value.

This message was sent by Atlassian JIRA

View raw message