views:

34

answers:

1

Hi folks,

i'm tring to use ldap for authentication in Weblogic Server but I have this problems always:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '(inner bean)#8': Unsatisfied dependency expressed through constructor argument with index 0 of type [org.springframework.ldap.core.support.BaseLdapPathContextSource]: Could not convert constructor argument value of type [org.springframework.security.ldap.authentication.LdapAuthenticationProvider] to required type [org.springframework.ldap.core.support.BaseLdapPathContextSource]: Failed to convert value of type 'org.springframework.security.ldap.authentication.LdapAuthenticationProvider' to required type 'org.springframework.ldap.core.support.BaseLdapPathContextSource'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.springframework.security.ldap.authentication.LdapAuthenticationProvider] to required type [org.springframework.ldap.core.support.BaseLdapPathContextSource]: no matching editors or conversion strategy found
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:670)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:192)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:984)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:886)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
    Truncated. see log file for complete stacktrace

My security-application-context.xml:

<beans:bean id="contextSource"
            class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
      <beans:constructor-arg value="ldap://127.0.0.1:7001/DC=base_domain"/>
      <beans:property name="userDn" value="CN=Admin"/>
      <beans:property name="password" value="weblogic"/>
    </beans:bean>

    <beans:bean id="ldapAuthProvider"
        class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
      <beans:constructor-arg>
       <beans:bean class="org.springframework.security.ldap.authentication.BindAuthenticator">
         <beans:constructor-arg ref="contextSource"/>
         <beans:property name="userDnPatterns">
           <beans:list><beans:value>uid={0},ou=people</beans:value></beans:list>
         </beans:property>
       </beans:bean>
     </beans:constructor-arg>
      <beans:constructor-arg>
       <beans:bean
         class="org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator">
         <beans:constructor-arg ref="contextSource"/>
         <beans:constructor-arg value="ou=groups"/>
         <beans:property name="groupRoleAttribute" value="ou"/>
       </beans:bean>
     </beans:constructor-arg>
    </beans:bean>
<authentication-manager>
        <ldap-authentication-provider server-ref="ldapAuthProvider" />
    </authentication-manager>

I'm using:

<spring.version>3.0.0.RELEASE</spring.version>
<spring.security.version>3.0.0.RELEASE</spring.version>

ANY help will be apreciated,

Ths a Lot!!!

Vinidog

+1  A: 

<ldap-authentication-provider> configures LdapAuthenticationProvider itself, so you don't need ldapAuthProvider as a separate bean.

So, you should use either <ldap-authentication-provider> as descibed in the docs:

 <ldap-authentication-provider user-dn-pattern="uid={0},ou=people" ... />

Or use a provider created manually as a separate bean using <authentication-provider>:

 <authentication-provider ref = "ldapAuthProvider" />.
axtavt