Spring Security : UserDetailsPasswordService

本文介绍了Spring Security 5.1版本中新增的UserDetailsPasswordService接口,该接口允许实现类修改用户账号密码,具体如InMemoryUserDetailsManager的实现。文章详细解释了接口的方法updatePassword,用于更改指定用户的密码,并更新到持久化用户存储中。

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

概述

介绍

UserDetailsPasswordServiceSpring Security5.1版本开始提供的一个接口。它定义了实现类要提供可以修改用户账号密码的能力。

比如InMemoryUserDetailsManager就实现了接口UserDetailsPasswordService,可以对自己管理的用户账号的密码进行修改。

继承关系

UserDetailsPasswordService

源代码

源代码版本 : Spring Security 5.1.4.RELEASE

package org.springframework.security.core.userdetails;

/**
 * An API for changing a UserDetails password.
 * @author Rob Winch
 * @since 5.1
 */
public interface UserDetailsPasswordService {

	/**
	 * Modify the specified user's password. This should change the user's password in the
	 * persistent user repository (datbase, LDAP etc).
	 *
	 * @param user the user to modify the password for
	 * @param newPassword the password to change to
	 * @return the updated UserDetails with the new password
	 */
	UserDetails updatePassword(UserDetails user, String newPassword);
}

参考文章

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值