I am using Spring Security 3.0.2, and I cannot find a way to load anonymous user roles from the database (I have dynamic roles where roles can be shared with everyone).
I tried using a custom anonymousAuthenticationProvider, but this provider is never called. Here is my configuration:
<http auto-config="false">
<logout invalidate-session="true" logout-success-url="/page/welcome" />
<remember-me />
<anonymous username="_GUEST_" granted-authority="ROLE_GUEST" key="anonymousKey" />
<form-login login-page="/page/login" authentication-failure-url="/page/login?fail=1" default-target-url="/page/welcome" />
</http>
<authentication-manager alias="authenticationManager">
<authentication-provider ref="anonymousAuthenticationProvider"></authentication-provider>
<authentication-provider user-service-ref="accountDetails">
<password-encoder ref="passwordEncoder">
<salt-source user-property="xxxx" />
</password-encoder>
</authentication-provider>
</authentication-manager>
<beans:bean id="accountDetails" class="com.mysite.AccountDetailsImpl" />
<beans:bean id="passwordEncoder" class="org.springframework.security.authentication.encoding.ShaPasswordEncoder">
<beans:constructor-arg value="512" />
</beans:bean>
<beans:bean id="anonymousAuthenticationProvider" class="com.my.site.security.CustomAnonymousAuthenticationProvider">
<beans:property name="key" value="anonymousKey" />
</beans:bean>
My anonymousAuthenticationProvider is never called, so I cannot load user credentials from the database. When I log in, my utility accountDetails is called, and I can load roles from the database for the user, I want the same for the anonymous user.
How can i do this? thank