Weblogic Server上的Spring Security LDAP

时间:2010-10-01 14:52:42

标签: spring-security weblogic

我想在Weblogic Server中使用ldap进行身份验证,但我总是遇到这个问题:

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

我的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>

我正在使用:

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

任何帮助都会被贬低,

很多!!!

Vinidog

1 个答案:

答案 0 :(得分:2)

<ldap-authentication-provider>配置LdapAuthenticationProvider本身,因此您不需要ldapAuthProvider作为单独的bean。

因此,您应该使用docs中描述的<ldap-authentication-provider>

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

或者使用<authentication-provider>

手动创建的提供程序作为单独的bean
 <authentication-provider ref = "ldapAuthProvider" />.