CredentialsContainer

CredentialsContainer 接口表示实现对象包含敏感数据,并由 Spring Security 在成功认证后内部用于擦除认证凭据。此接口由大多数 Spring Security 内部领域类实现,例如 UserUsernamePasswordAuthenticationToken

ProviderManager 管理器检查返回的 Authentication 是否实现了此接口。如果是,它会调用 eraseCredentials 方法 从对象中移除凭据。

如果您希望您的自定义认证对象在认证后擦除其凭据,您应该确保这些类实现了 CredentialsContainer 接口。

编写自己的 AuthenticationProvider 实现的用户应该在那里创建并返回一个适当的 Authentication 对象,减去任何敏感数据,而不是使用此接口。

© . This site is unofficial and not affiliated with VMware.