码迷,mamicode.com
首页 > 编程语言 > 详细

OAuth2.0学习(4-1)Spring Security OAuth2.0 - 代码分析

时间:2017-06-17 19:43:00      阅读:251      评论:0      收藏:0      [点我收藏+]

标签:detail   lte   提交   username   password   uri   rda   auth   abs   

1、org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter

             org.springframework.security.oauth2.provider.client.ClientCredentialsTokenEndpointFilter

             org.springframework.security.oauth2.client.filter.OAuth2ClientAuthenticationProcessingFilter

             org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter  登录验证(用户名密码验证)

1.1、org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter

1.2、org.springframework.security.oauth2.provider.client.ClientCredentialsTokenEndpointFilter

1.3、org.springframework.security.oauth2.client.filter.OAuth2ClientAuthenticationProcessingFilter

1.4、UsernamePasswordAuthenticationFilter

父类AbstractAuthenticationProcessingFilter中有一个AuthenticationManager接口属性,验证工作主要是通过这个AuthenticationManager接口的实例来完成的。

在默认情况下,springSecurity框架会把org.springframework.security.authentication.ProviderManager类的实例注入到该属性。

UsernamePasswordAuthenticationFilter的验证过程如下:

1. 首先过滤器会调用自身的attemptAuthentication方法,从request中取出authentication, authentication是在org.springframework.security.web.context.SecurityContextPersistenceFilter过滤器中通过捕获用户提交的登录表单中的内容生成的一个org.springframework.security.core.Authentication接口实例.

2. 拿到authentication对象后,过滤器会调用ProviderManager类的authenticate方法,并传入该对象

3.ProviderManager类的authenticate方法再调用自身的doAuthentication方法,在doAuthentication方法中会调用类中的List<AuthenticationProvider> providers集合中的各个AuthenticationProvider接口实现类中的authenticate(Authentication authentication)方法进行验证,由此可见,真正的验证逻辑是由各个各个AuthenticationProvider接口实现类来完成的,DaoAuthenticationProvider类是默认情况下注入的一个AuthenticationProvider接口实现类

4.AuthenticationProvider接口通过UserDetailsService来获取用户信息

 

OAuth2.0学习(4-1)Spring Security OAuth2.0 - 代码分析

标签:detail   lte   提交   username   password   uri   rda   auth   abs   

原文地址:http://www.cnblogs.com/lexiaofei/p/7041032.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!