Spring Security : 概念模型接口 UserDetailsManager 用户详情管理器
概述
介绍
UserDetailsManager
是Spring Security
的一个概念模型接口,用于抽象建模对用户详情的管理这一概念。它继承自接口UserDetailsService
,是对UserDetailsService
接口的能力扩展。
UserDetailsService
定义了根据用户名获取用户详情的能力,UserDetailsManager
在此基础上增加定义了如下能力 :
- 创建用户账号 :
void createUser(UserDetails user)
- 更新用户账号 :
void updateUser(UserDetails user)
- 删除用户账号 :
void deleteUser(String username)
- 修改用户账号密码 :
void changePassword(String oldPassword, String newPassword)
- 判断用户账号是否存在 :
boolean userExists(String username)
继承关系
源代码
源代码版本 : Spring Security Core 5.1.4.RELEASE
package org.springframework.security.provisioning;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
/**
* An extension of the UserDetailsService which provides the ability to create new
* users and update existing ones.
*
* @author Luke Taylor
* @since 2.0
*/
public interface UserDetailsManager extends UserDetailsService {
/**
* Create a new user with the supplied details.
* 根据提供的用户详情创建一个用户账号
*/
void createUser(UserDetails user);
/**
* Update the specified user.
* 更新指定的用户账号
*/
void updateUser(UserDetails user);
/**
* Remove the user with the given login name from the system.
* 删除制定用户名的用户账号
*/
void deleteUser(String username);
/**
* Modify the current user's password. This should change the user's password in the
* persistent user repository (datbase, LDAP etc).
* 修改用户账号在存储库的密码
* @param oldPassword current password (for re-authentication if required)
* @param newPassword the password to change to
*/
void changePassword(String oldPassword, String newPassword);
/**
* Check if a user with the supplied login name exists in the system.
* 根据用户名检查一个用户账号是否存在
*/
boolean userExists(String username);
}