开发者

How can I configure Spring Security to use custom AuthenticationManager implementation?

What I have is:

<authentication-manager alias="authenticationManager">
    <authentication-provider user-service-ref="securityService"/>
</authentication-manager>

As I understand, the default AuthenticationManager implementation is used. I need to override its method authenticate. Is there a way to provide my own AuthenticationManager implement开发者_Python百科ation?


You need to specify a customAuthenticationProvider first, like this:-

<bean id="customAuthenticationProvider" class="your.project.CustomAuthenticationProviderImpl">
    <property name="userDetailsService" ref="userDetailsService" />
    ...
</bean>

<security:authentication-manager>
    <security:authentication-provider ref="customAuthenticationProvider" />
</security:authentication-manager>

Then, your custom authentication provider can extends Spring Security's AbstractUserDetailsAuthenticationProvider where you can place your custom authentication code.

public class CustomAuthenticationProviderImpl extends AbstractUserDetailsAuthenticationProvider {
    ...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜