凭证容器
[CredentialsContainer](https://docs.spring.io/spring-security/reference/api/java/org/springframework/security/core/CredentialsContainer.html)
接口表示实现该接口的对象包含敏感数据,并且 Spring Security 在成功认证后内部使用该接口擦除认证凭据。此接口由大多数 Spring Security 内部域类实现,如 [User](https://docs.spring.io/spring-security/reference/api/java/org/springframework/security/core/userdetails/User.html)
和 [UsernamePasswordAuthenticationToken](https://docs.spring.io/spring-security/reference/api/java/org/springframework/security/authentication/UsernamePasswordAuthenticationToken.html)
。
ProviderManager
管理器会检查返回的 Authentication
是否实现了此接口。如果实现了,它会调用 eraseCredentials 方法 从对象中移除凭证。
如果你希望自定义的身份验证对象在身份验证后清除其凭证,你应该确保这些类实现了 CredentialsContainer
接口。
编写自己的 AuthenticationProvider
实现的用户应该在那里创建并返回一个合适的 Authentication
对象,但要移除任何敏感数据,而不是使用此接口。