2010-10-01 135 views
1

我我特林使用LDAP在WebLogic Server身份驗證,但我一直有這樣的問題:Spring Security的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 

我的安全應用程序的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> 

任何幫助將apreciated,

Ths a Lot !!!

Vinidog

回答

2

<ldap-authentication-provider>配置LdapAuthenticationProvider本身,所以你不需要ldapAuthProvider作爲一個單獨的bean。

所以,你應該使用<ldap-authentication-provider>作爲docs descibed:

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

或者使用通過<authentication-provider>手動創建一個單獨的bean提供者:

<authentication-provider ref = "ldapAuthProvider" />. 
相關問題