views:

34

answers:

1

Hi,

I'm trying to set up the LDAP Spring Security. And I've stucked with some strange exception:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_filterChainList'
...
No UserDetailsService registered

My security-config.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sec="http://www.springframework.org/schema/security"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.4.xsd"&gt;

    <sec:global-method-security secured-annotations="enabled"
                access-decision-manager-ref="accessDecisionManager" />

    <sec:http auto-config="true">
        <sec:intercept-url pattern="/css/**" filters="none" />
        <sec:intercept-url pattern="/js/**" filters="none" />
        <sec:intercept-url pattern="/img/**" filters="none" />

        <sec:intercept-url pattern="/login" access="IS_AUTHENTICATED_ANONYMOUSLY" />
        <sec:intercept-url pattern="/login" access="IS_AUTHENTICATED_ANONYMOUSLY" method="POST" />
        <sec:intercept-url pattern="/uzivatel/registrace" access="IS_AUTHENTICATED_ANONYMOUSLY" />

        <sec:intercept-url pattern="/**" access="ROLE_UZIVATEL" />

        <sec:form-login default-target-url="/vlakna" login-page="/login"  />
    </sec:http>

    <bean id="accessDecisionManager" class="org.springframework.security.vote.ConsensusBased">
        <property name="decisionVoters">
            <list>
                <ref bean="rightsAccessDecisionVoter" />
            </list>
        </property>
    </bean>

    <bean id="contextSource" class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
        <constructor-arg value="ldap://111.111.111.111"/>
        <property name="userDn" value="cn=auth-user,ou=System,dc=sh,dc=company,dc=com"/>
        <property name="password" value="secret"/>
    </bean>

    <bean id="ldapAuthProvider" class="org.springframework.security.providers.ldap.LdapAuthenticationProvider">
        <sec:custom-authentication-provider/>
        <constructor-arg>
            <bean class="org.springframework.security.providers.ldap.authenticator.BindAuthenticator">
                <constructor-arg ref="contextSource"/>
                <property name="userSearch">
                    <bean id="userSearch" class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch">
                      <constructor-arg index="0" value="ou=People,dc=sh,dc=company,dc=com"/>
                      <constructor-arg index="1" value="(uid={0})"/>
                      <constructor-arg index="2" ref="contextSource" />
                    </bean>
                </property>
                <property name="userDnPatterns">
                    <list><value>uid={0},ou=people</value></list>
                </property>
                <property name="userAttributes">
                    <list><value></value></list>
                </property>
            </bean>
        </constructor-arg>
        <constructor-arg>
            <bean class="cz.rohan.dusps.services.UzivatelAuthoritiesPopulator" />
        </constructor-arg>
    </bean>

    <bean id="rightsAccessDecisionVoter" class="com.company.RightsAccessDecisionVoter" />
</beans>

I thought that it should take "ldapAuthProvider" as an user details service but it doesn't. Does anybody see any problem in my config?

Thanks for any help, Mateo

A: 

I think...

<bean id="ldapAuthProvider" class="org.springframework.security.providers.ldap.LdapAuthenticationProvider">
<security:custom-authentication-provider />
// MISSING ABOVE
<property name="userDetailsService" ref="ldapUserDetailsService" />
.....
Aaron Saunders
Doesn't work for me:-( I think I have to register this bean somehow outside but I don't know how:-/
mateo
you are missing the userDetailsService bean i do not see it in your configuration
Aaron Saunders
You are right, I've forgot to add this code: <bean id="userDetailsService" class="com.company.services.DuspsUserDetailService" /> But anyway, thanks for help!!!:-)
mateo
u r welcome, can you mark it correct so others can benefit
Aaron Saunders