SpringSecurity过滤链当中的UsernamePasswordAuthenticationFilter负责登陆密码验证
- AbstractAuthenticationProcessingFilter是UsernamePasswordAuthenticationFilter的父接口,接口当中就有一个this.getAuthenticationManager()方法,获取AuthenticationManager对象。
- AuthenticationManager对象当中有一个方法:Authentication authenticate(Authentication authentication) ,传入authentication对象用来密码验证。
- AuthenticationManager的子类ProviderManager实现了该方法,可能有多种验证方式,因此遍历一个集合,有一个满足就可以,代码如下
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
Class<? extends Authentication> toTest = authentication.getClass();
if (!pro