views:

1020

answers:

2

Hi folks

I am screwed with the spring security configuration issue

Here is my configuration

    <security:global-method-security pre-post-annotations="enabled" />

<security:http auto-config="true">
    <security:intercept-url pattern="/dologin"     access="ROLE_USER,ROLE_ANONYMOUS" />
    <security:form-login login-processing-url="/security_check" login-page="/onlogin" always-use-default-target="false" authentication-failure-url="/onlogin" default-target-url="/home"  />
    <security:logout invalidate-session="true" logout-url="/logout" logout-success-url="/onlogout" />
    <security:remember-me />
    <security:http-basic/>
</security:http>

<security:authentication-manager alias="authenticationManager">
    <security:authentication-provider ref="daoAuthenticationProvider"/>
</security:authentication-manager>

<bean id="anonymousAuthenticationProvider"
    class="org.springframework.security.authentication.AnonymousAuthenticationProvider">
    <property name="key" value="badgerbadgerbadger" />
</bean>

<bean id="daoAuthenticationProvider"
    class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
    <property name="userDetailsService" ref="userDetailsService" />
</bean>

My problem is that when a request comes for authentication; I find there are only two providers registered.

org.springframework.security.authentication.AnonymousAuthenticationProvider@8fe4ad
org.springframework.security.authentication.RememberMeAuthenticationProvider@1db9cb9

What might me going wrong? Please describe?

A: 

I believe you need to identify your custom provider to spring security by using the security:custom-authentication-provider tag.

For example:

<bean id="daoAuthenticationProvider"
     class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
    <security:custom-authentication-provider />
    <property name="userDetailsService" ref="userDetailsService" />
</bean>

You may need that on your anonymousAuthenticationProvider bean also.

Donal Boyle
Hi Donal Boyle,I am using spring-security version 3.0. and it does not have any tag like <security:custom-authentication-provider />I have tried to find out what happens when a security tag is found in the configuration file. But there is no any result for my expedite. Now I have chosen to go for completely bean definition based configuration. I will tell you about any thing relevant found on this topic
vijay.shad
A: 

Try the following:

<security:authentication-manager>
    <security:authentication-provider user-service-ref="userDetailsService"/>
</security:authentication-manager>
lexicore

related questions