Spring源码分析【9】-SpringSecurity密码Remove原理

来源:互联网 发布:mac 压缩包 加密 编辑:程序博客网 时间:2024/06/02 10:47

很明显代码已经说了认证完成移除credentials和其他某些安全数据

// Authentication is complete. Remove credentials and other secret data
// from authentication

org.springframework.security.authentication.ProviderManager.authenticate



package org.springframework.security.authentication.UsernamePasswordAuthenticationToken.eraseCredentials



org.springframework.security.authentication.AbstractAuthenticationToken.eraseCredentials



eraseSecret需要接口判断

getCredentials()就是密码



getPrincipal()得到的是userInfo


这个userinfo就是CustomUserDetailsService implements UserDetailsService中的函数

public UserDetails loadUserByUsername(String username)返回的UserDetails


UserInfo中的重写的eraseCredentials



第三次eraseSecret是不行的,因为类型不对



回到上一步



这里定义的



回到主调用,这时候密码相关的信息都null了


0 0
原创粉丝点击