Spring Security : 概念模型接口 UserDetailsManager 用户详情管理器

本文围绕Spring Security Core 5.1.4.RELEASE版本,介绍了用于抽象建模用户详情管理的概念模型接口。该接口继承自其他接口,是能力扩展。定义了根据用户名获取用户详情能力,还增加创建、更新、删除用户账号等能力。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

概述

介绍

UserDetailsManagerSpring 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)

继承关系

UserDetailsService

源代码

源代码版本 : 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);

}

参考文章

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值