<authentication-manager erase-credentials="false">

...

</authentication-manager>

erase-credentials默认为true,会在

public Authentication authenticate(Authentication authentication) throws AuthenticationException

返回前调用 ((CredentialsContainer)result).eraseCredentials(); 清除credentials等信息,所以我们使用

SecurityContextImpl securityContextImpl = (SecurityContextImpl) request
.getSession().getAttribute("SPRING_SECURITY_CONTEXT");
Authentication authentication = securityContextImpl.getAuthentication();
// 登录密码,未加密的
String password = (String)(authentication.getCredentials());

password总是为null。

将erase-credentials设置为false后,不会清除这些保密信息,但是建议在使用完之后自己调用eraseCredentials()清楚这些信息。

Spring Security怎样不让默认的ProviderManager清除密码等信息的更多相关文章

  1. Spring Security 5中的默认密码编码器

    1.概述 在Spring Security 4中,可以使用内存中身份验证以纯文本格式存储密码. 对版本5中的密码管理过程进行了重大改进,为密码编码和解码引入了更安全的默认机制.这意味着如果您的Spri ...

  2. spring security进阶 使用数据库中的账户和密码认证

    目录 spring security 使用数据库中的账户和密码认证 一.原理分析 二.代码实现 1.新建一个javaWeb工程 2.用户认证的实现 3.测试 三.总结 spring security ...

  3. SpringBoot集成Spring Security入门体验

    一.前言 Spring Security 和 Apache Shiro 都是安全框架,为Java应用程序提供身份认证和授权. 二者区别 Spring Security:重量级安全框架 Apache S ...

  4. Spring Security(三十二):10. Core Services

    Now that we have a high-level overview of the Spring Security architecture and its core classes, let ...

  5. Spring Security 案例实现和执行流程剖析

    Spring Security Spring Security 是 Spring 社区的一个顶级项目,也是 Spring Boot 官方推荐使用的安全框架.除了常规的认证(Authentication ...

  6. Spring Security 5.0.x 参考手册 【翻译自官方GIT-2018.06.12】

    源码请移步至:https://github.com/aquariuspj/spring-security/tree/translator/docs/manual/src/docs/asciidoc 版 ...

  7. Spring Boot:整合Spring Security

    综合概述 Spring Security 是 Spring 社区的一个顶级项目,也是 Spring Boot 官方推荐使用的安全框架.除了常规的认证(Authentication)和授权(Author ...

  8. Spring Security Architecture and Implementation(架构和实现)学习笔记

    Spring Security 关于spring-security的官网文档学习笔记,主要是第8章 Architecture and Implementation(架构和实现)内容 参考: https ...

  9. 一文带你了解 OAuth2 协议与 Spring Security OAuth2 集成!

    OAuth 2.0 允许第三方应用程序访问受限的HTTP资源的授权协议,像平常大家使用Github.Google账号来登陆其他系统时使用的就是 OAuth 2.0 授权框架,下图就是使用Github账 ...

随机推荐

  1. C# Path类常用方法

    Path 类 对包含文件或目录路径信息的 String 实例执行操作. 1.Path.GetExtension 方法 —— 返回指定的路径字符串的扩展名. public static string G ...

  2. 將sql server 2008R2 Max memory 意外設為0

    做sql server 內存Max memory 設定時大意,誤把最大值設為0,怎麼著都連不上DataBase,哪真叫個急呀,最後還是看到一條文命令把救回來了,其它很簡單急的時候就是沒想出來. 1.暫 ...

  3. 【题解】 UVa11300 Spreading the Wealth

    题目大意 圆桌旁边坐着\(n\)个人,每个人有一定数量的金币,金币的总数能被\(n\)整除.每个人可以给他左右相邻的人一些金币,最终使得每个人的金币数量相等.您的任务是求出被转手的金币的数量的最小值. ...

  4. IIS发布ASP程序问题汇总

    看异常位置,因为域的问题

  5. 【bzoj4872】[Shoi2017]分手是祝愿 期望dp

    Description Zeit und Raum trennen dich und mich. 时空将你我分开.B 君在玩一个游戏,这个游戏由 n 个灯和 n 个开关组成,给定这 n 个灯的初始状态 ...

  6. Unity---动画系统学习(5)---使用MatchTarget来匹配动画

    1. 介绍 做好了走.跑.转弯后,我们就需要来点更加高级的动画了. 我们使用自带动画学习笔记2中的FQVault动画,来控制人物FQ. 在动画学习笔记4的基础上添加Vault动画. 添加一个参数Vau ...

  7. width:100%以什么为基准的测试

    起初是遇到这样一个问题:当盒模型设为box-sizing:border-box;(移动端上经常这么干).子盒子的width:100%,子盒子的width等于父盒子contend的长度还是condend ...

  8. python创建shape

    import shapefile import json import os #shapefile="polygon.shp"; #jsonfile="社区网格.json ...

  9. ubuntu 16.04 安装googlepinyin中文输入法

    安装谷歌拼音输入法 打开终端输入: apt-get install fcitx-googlepinyin 安装完成之后,进入系统设置 安装语言包 修改输入法系统 点击“System Setting”- ...

  10. sock文件

    无论是mysql,uwsgi还是nginx都会用到sock文件 首先它是由程序自动创建的,并不是我们自己手动.它的作用是用来通信.与之相对应的是tcp socket ,一般的程序会同时支持这两种方式, ...