Apache Directory Project - [jira] Commented: (DIRLDAP-77) ClassCastException when performing 'compare' on userPas

This is Interesting: Free IT Magazines  
Home > Archive > Apache Directory Project > December 2005 > [jira] Commented: (DIRLDAP-77) ClassCastException when performing 'compare' on userPas





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author [jira] Commented: (DIRLDAP-77) ClassCastException when performing 'compare' on userPas
Emmanuel Lecharny (JIRA)

2005-12-08, 5:45 pm

[ http://issues.apache.org/jira/brows...comments#actio=
n_12359736 ]=20

Emmanuel Lecharny commented on DIRLDAP-77:
------------------------------------------

ok, I thought that reqVal was a byte[].

However, by bad.

But this is not enough ;) We have to get byte[] from the String supposing i=
t's UTF-8 encoded :

....
=09else
=09{
=09=09byte[] attrVal =3D (byte[])attrValObj;
=09=09
=09=09if ( reqVal instanceof byte[] )=20
=09=09{
=09=09=09return Arrays.equals( attrVal, (byte[])reqVal );
=09=09}
=09=09else if ( reqVal instanceof String )
=09=09{
=09=09=09return Arrays.equals( attrVal, StringUtils.getBytesUtf8( (=
String)reqVal ) );
=09=09}
=09}
....


Can you test this? It should work ok, even when using striings like "l=C3=
=A9charny".

And if it's ok, the next thing I need is a patch, so that I can fix the cod=
e and commit it. I don not have any test case, so I can't commit it as is ;=
)

The best would be that you provide a testcase, so I can check the modificat=
ion by myself !!

Thanks a lot, Luke.



> ClassCastException when performing 'compare' on userPassword
> ------------------------------------------------------------
>
> Key: DIRLDAP-77
> URL: http://issues.apache.org/jira/browse/DIRLDAP-77
> Project: Directory LDAP
> Type: Bug
> Reporter: Luke Taylor


>
> Using the latest 0.9.4 snapshots and also code checked out and built toda=

y - (but had to include an older version of Mina with the latter due to Cla=
ssNotFoundExceptions for MessageHandler ):
> I'm making a call to apache-ds to perform a comparison operation on a use=

r's password and I'm get a ClassCastException at line 369 of DefaultDirecto=
ryPartitionNexus:
> String attrVal =3D ( String ) normalizer.normalize( attr.get(=

ii ) );
> when attr is userPassword (a byte array) and the normalizer is a no-op, s=

o the cast to String fails.
> javax.naming.NamingException: [LDAP: error code 1 - failed to compare ent=

ry cn=3DBob,ou=3Dpeople,dc=3Dacegisecurity,
dc=3Dorg:
> org.apache.ldap.server.interceptor.InterceptorException: Unexpected excep=

tion. [Root exception is java.lang.ClassCastException: [B]
> =09at org.apache.ldap.server.interceptor.InterceptorChain.throwIntercepto=

rException(InterceptorChain.java:1368)
> =09at org.apache.ldap.server.interceptor.InterceptorChain.access$700(Inte=

rceptorChain.java:49)
> =09at org.apache.ldap.server.interceptor.InterceptorChain$Entry$1.compare=

(InterceptorChain.java:983)
> =09at org.apache.ldap.server.interceptor.BaseInterceptor.compare(BaseInte=

rceptor.java:210)
> =09at org.apache.ldap.server.interceptor.InterceptorChain$Entry$1.compare=

(InterceptorChain.java:975)
> =09at org.apache.ldap.server.interceptor.BaseInterceptor.compare(BaseInte=

rceptor.java:210)
> =09at org.apache.ldap.server.interceptor.InterceptorChain$Entry$1.compare=

(InterceptorChain.java:975)
> =09at org.apache.ldap.server.interceptor.BaseInterceptor.compare(BaseInte=

rceptor.java:210)
> =09at org.apache.ldap.server.interceptor.InterceptorChain$Entry$1.compare=

(InterceptorChain.java:975)
> =09at org.apache.ldap.server.interceptor.BaseInterceptor.compare(BaseInte=

rceptor.java:210)
> =09at org.apache.ldap.server.interceptor.InterceptorChain$Entry$1.compare=

(InterceptorChain.java:975)
> =09at org.apache.ldap.server.interceptor.BaseInterceptor.compare(BaseInte=

rceptor.java:210)
> =09at org.apache.ldap.server.interceptor.InterceptorChain$Entry$1.compare=

(InterceptorChain.java:975)
> =09at org.apache.ldap.server.interceptor.BaseInterceptor.compare(BaseInte=

rceptor.java:210)
> =09at org.apache.ldap.server.interceptor.InterceptorChain$Entry$1.compare=

(InterceptorChain.java:975)
> =09at org.apache.ldap.server.interceptor.BaseInterceptor.compare(BaseInte=

rceptor.java:210)
> =09at org.apache.ldap.server.interceptor.InterceptorChain$Entry$1.compare=

(InterceptorChain.java:975)
> =09at org.apache.ldap.server.authz.AuthorizationService.compare(Authoriza=

tionService.java:917)
> =09at org.apache.ldap.server.interceptor.InterceptorChain$Entry$1.compare=

(InterceptorChain.java:975)
> =09at org.apache.ldap.server.interceptor.BaseInterceptor.compare(BaseInte=

rceptor.java:210)
> =09at org.apache.ldap.server.interceptor.InterceptorChain$Entry$1.compare=

(InterceptorChain.java:975)
> =09at org.apache.ldap.server.normalization.NormalizationService.compare(N=

ormalizationService.java:236)
> =09at org.apache.ldap.server.interceptor.InterceptorChain.compare(Interce=

ptorChain.java:564)
> =09at org.apache.ldap.server.partition.DirectoryPartitionNexusProxy.compa=

re(DirectoryPartitionNexusProxy.java:232)
> =09at org.apache.ldap.server.partition.DirectoryPartitionNexusProxy.compa=

re(DirectoryPartitionNexusProxy.java:221)
> =09at org.apache.ldap.server.jndi.ServerLdapContext.compare(ServerLdapCon=

text.java:168)
> =09at org.apache.ldap.server.protocol.support.CompareHandler.messageRecei=

ved(CompareHandler.java:61)
> =09at org.apache.mina.handler.DemuxingIoHandler.messageReceived(DemuxingI=

oHandler.java:95)
> =09at org.apache.ldap.server.protocol.LdapProtocolProvider$LdapProtocolHa=

ndler.messageReceived(LdapProtocolProvider.java:396)
> =09at org.apache.mina.common.support.AbstractIoFilterChain$2.messageRecei=

ved(AbstractIoFilterChain.java:189)
> =09at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessag=

eReceived(AbstractIoFilterChain.java:494)
> =09at org.apache.mina.common.support.AbstractIoFilterChain.access$1000(Ab=

stractIoFilterChain.java:52)
> =09at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.me=

ssageReceived(AbstractIoFilterChain.java:761)
> =09at org.apache.mina.filter.LoggingFilter.messageReceived(LoggingFilter.=

java:87)
> =09at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessag=

eReceived(AbstractIoFilterChain.java:494)
> =09at org.apache.mina.common.support.AbstractIoFilterChain.access$1000(Ab=

stractIoFilterChain.java:52)
> =09at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.me=

ssageReceived(AbstractIoFilterChain.java:761)
> =09at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(Pr=

otocolCodecFilter.java:91)
> =09at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessag=

eReceived(AbstractIoFilterChain.java:494)
> =09at org.apache.mina.common.support.AbstractIoFilterChain.access$1000(Ab=

stractIoFilterChain.java:52)
> =09at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.me=

ssageReceived(AbstractIoFilterChain.java:761)
> =09at org.apache.mina.filter.ThreadPoolFilter.processEvent(ThreadPoolFilt=

er.java:665)
> =09at org.apache.mina.filter.ThreadPoolFilter$Worker.processEvents(Thread=

PoolFilter.java:421)
> =09at org.apache.mina.filter.ThreadPoolFilter$Worker.run(ThreadPoolFilter=

..java:376)
> Caused by: java.lang.ClassCastException: [B
> =09at org.apache.ldap.server.partition.DefaultDirectoryPartitionNexus.com=

pare(DefaultDirectoryPartitionNexus.java:369)
> =09at org.apache.ldap.server.interceptor.InterceptorChain$1.compare(Inter=

ceptorChain.java:71)
> =09at org.apache.ldap.server.interceptor.InterceptorChain$Entry$1.compare=

(InterceptorChain.java:975)
> =09... 41 more
> ]; remaining name 'cn=3DBob,ou=3Dpeople'
> =09at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3025)
> =09at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2931)
> =09at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2737)
> =09at com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1803)
> =09at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1731)
> =09at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1748)
> =09at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirC=

ontext.java:394)
> =09at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialC=

ompositeDirContext.java:376)
> =09at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialC=

ompositeDirContext.java:358)
> =09at javax.naming.directory.InitialDirContext.search(InitialDirContext.j=

ava:267)
> =09at org.acegisecurity.providers.ldap.authenticator.PasswordComparisonAu=

thenticator. doPasswordCompare(PasswordComparisonAuth
enticator.java:117)
> =09at org.acegisecurity.providers.ldap.authenticator.PasswordComparisonAu=

thenticator. authenticate(PasswordComparisonAuthentic
ator.java:81)
> =09at org.acegisecurity.providers.ldap.authenticator.PasswordComparisonAu=

thenticatorTests. testLdapCompareSucceedsWithCorrectPasswo
rd(PasswordCompari=
sonAuthenticatorTests.java:35)
> Client code is:
> SearchControls ctls =3D new SearchControls();
> ctls.setReturningAttributes(new String[0]);
> ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
> String filter =3D "(userPassword=3D{0})";
> NamingEnumeration results =3D ctx.search(dn, filter, new Object[]=

{password.getBytes()}, ctls);

--=20
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secur...nistrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com