SpringSecurity源码中核心类

SpringSecurity源码

第一部分 核心类

  • SecurityBuilder
  • HttpSecurity
  • WebSecurity
  • SecurityFilterChain
  • FilterChainProxy

SecurityBuilder是安全构架器,HttpSecurity和WebSecurity都是SecurityBuilder的实现类,HttpSecurity通过build()构建了一个SecurityFilterChain调用链。 WebSecurity构建了一个FilterChainProxy,他是一个Filter过滤器,其内部维护了一个filterChains(SecurityFilterChain的链表),doFilter执行时,利用装饰器模式+责任链模式先调用SecurityFilterChain,再调用原生chain.doFilter(req, resp)继续执行

第二部分核心类

  • HttpSecurity内容
  • SecurityConfigurer
  • AbstractConfiguredSecurityBuilder

SecurityBuilder用来构建安全对象,安全对象包括:ttpSecurity、FilterChainProxy、AuthenticationManager、SecurityConfigurer用来配置安全对象构建器(SecurityBuilder),典型的有

FormLoginConfigurer、CsrfConfigurer

第三部分

  • Authentication

  • AuthenticationManage

  • AuthenticationManageBuilder

  • ProviderManager

  • AuthenticationProvider

    其中Authentication为认证信息,AuthenticationManage可以用来认证,其中有一个重要的方法 Authentication authenticate(Authentication authentication),AuthenticationManagerBuilder用来构建

    AuthenticationManager的,即ProviderManager,是一个重要的ProviderManager 实现类。即ProviderManager中存储了AuthenticationProvider集合,认证的时候 先查看是否support,是的话,开始认证

第四部分

  • UserDetailsService
  • DaoAuthenticationProvider
  • AbstractUserDetailsAuthenticationProvider
  • UsernamePasswordAuthenticationFilter
  • FormLoginConfigurer

用户名密码登录所使用到的类,UserDetailsService用来加载用户信息的,DaoAuthenticationProvider是一个provider(结合UserDetailsService进行加载用户信息),用来做认证的,AbstractUserDetailsAuthenticationProvider是DaoAuthenticationprovider的父类。UsernamePasswordAuthenticationFilter是一个过滤器,生成一个认证对象,在通过providerManager来进行认证,核心就是利用DaoAuthenticationProvider来进行认证。FormLoginConfigurer用于配置用户名密码相关信息,通过http来进行配置。

第五部分

  • SecurityContext
  • SecurityContextHolder
  • SecurityContextPersistenceFilter
  • SecurityContextRepository
  • SecurityContextConfigurer
相关推荐
工业互联网专业2 小时前
基于django+vue的健身房管理系统-vue
vue.js·python·django·毕业设计·源码·课程设计·健身房管理系统
顾林海5 天前
Android Native 内存泄漏检测全解析:从原理到工具的深度实践
android·面试·性能优化·源码·android虚拟内存
工业互联网专业6 天前
基于Android的一周穿搭APP的设计与实现 _springboot+vue
android·vue.js·spring boot·毕业设计·源码·课程设计·一周穿搭app
工业互联网专业8 天前
基于Android的跳蚤市场_springboot+vue
android·vue.js·spring boot·毕业设计·源码·课程设计·跳蚤市场
工业互联网专业10 天前
基于Android的记录生活APP_springboot+vue
android·vue.js·spring boot·毕业设计·源码·课程设计·记录生活app
工业互联网专业14 天前
基于Android的个人健康管理系统APP
android·java·vue.js·spring boot·毕业设计·源码·课程设计
xiezhr14 天前
SpringBoot3整合SpringSecurity6(五)自定义登陆页面
java·spring·springboot3·springsecurity
工业互联网专业20 天前
基于springboot+vue的病例管理系统
java·vue.js·spring boot·毕业设计·源码·课程设计·病例管理系统
大叔_爱编程23 天前
p024基于Django的网上购物系统的设计与实现
python·django·vue·毕业设计·源码·课程设计·网上购物系统
工业互联网专业24 天前
基于springboot+vue的机场乘客服务系统
java·vue.js·spring boot·毕业设计·源码·课程设计·机场乘客服务系统