public class DefaultUserPasswordService<P extends PasswordToken,U extends User,D extends com.broadleafcommerce.data.tracking.core.mapping.BusinessTypeAware & com.broadleafcommerce.data.tracking.core.mapping.ModelMapperMappable> extends Object implements UserPasswordService<P,U>
Modifier and Type | Field and Description |
---|---|
static String |
RESET_PASSWORD_PURPOSE |
Constructor and Description |
---|
DefaultUserPasswordService(UserService<U> userService,
org.springframework.security.crypto.password.PasswordEncoder passwordEncoder,
UserMessagingService<U> messageService,
ResetPasswordFormValidator<P> resetPasswordFormValidator,
ChangePasswordFormValidator changePasswordFormValidator,
UserLockoutService userLockoutService,
PasscodeService<P,U> passcodeService) |
Modifier and Type | Method and Description |
---|---|
boolean |
changePassword(ChangePasswordForm changePasswordForm,
org.springframework.validation.BindingResult errors)
From the provided
ChangePasswordForm , attempt to change the user's password. |
boolean |
createResetPasswordToken(String clientId,
String username)
Creates a reset password token for the specified user, if they exist.
|
protected boolean |
createResetPasswordTokenForUser(U user,
String clientId) |
boolean |
createTokenForUser(String clientId,
String username)
Creates a token for the specified user, if they exist.
|
protected ChangePasswordFormValidator |
getChangePasswordFormValidator() |
protected U |
getCurrentlyAuthenticatedUser()
Retrieve the current (already authenticated) user who is attempting to change their password
|
protected UserMessagingService<U> |
getMessageService() |
protected PasscodeService<P,U> |
getPasscodeService() |
protected org.springframework.security.crypto.password.PasswordEncoder |
getPasswordEncoder() |
protected ResetPasswordFormValidator<P> |
getResetPasswordFormValidator() |
protected Optional<U> |
getUserByClientIdAndUsername(String clientId,
String username) |
protected UserLockoutService |
getUserLockoutService() |
protected UserService<U> |
getUserService() |
boolean |
resetPassword(ResetPasswordForm resetPasswordForm,
org.springframework.validation.BindingResult errors)
From the provided
ResetPasswordForm , attempt to reset the user's password. |
org.springframework.security.core.userdetails.UserDetails |
updatePassword(org.springframework.security.core.userdetails.UserDetails user,
String encodedPassword) |
U |
updatePasswordForUser(U user,
String password,
String clientId)
Send a password change notification email and update the user's password.
|
protected Optional<P> |
useToken(U user,
String token)
Defer to the PasscodeService to validate the password reset token.
|
public static final String RESET_PASSWORD_PURPOSE
public DefaultUserPasswordService(UserService<U> userService, org.springframework.security.crypto.password.PasswordEncoder passwordEncoder, UserMessagingService<U> messageService, ResetPasswordFormValidator<P> resetPasswordFormValidator, ChangePasswordFormValidator changePasswordFormValidator, UserLockoutService userLockoutService, PasscodeService<P,U> passcodeService)
public boolean resetPassword(ResetPasswordForm resetPasswordForm, org.springframework.validation.BindingResult errors)
UserPasswordService
ResetPasswordForm
, attempt to reset the user's password. If a
failure occurs, errors will be populated on BindingResult
and `false` is returned.
Otherwise, return `true`.resetPassword
in interface UserPasswordService<P extends PasswordToken,U extends User>
resetPasswordForm
- The form to use to reset the user's password.errors
- The object to hold any errors that might occur.ResetPasswordForm
passed validation in order for the
password to be reset.public boolean changePassword(ChangePasswordForm changePasswordForm, org.springframework.validation.BindingResult errors)
UserPasswordService
ChangePasswordForm
, attempt to change the user's password. If a
failure occurs, errors will be populated on BindingResult
and `false` is returned.
Otherwise, return `true`.changePassword
in interface UserPasswordService<P extends PasswordToken,U extends User>
changePasswordForm
- The form to use to change the user's password.errors
- The object to hold any errors that might occur.ChangePasswordForm
passed validation in order for the
password to be changed.public boolean createTokenForUser(String clientId, String username) throws AccountLockedException
UserPasswordService
createTokenForUser
in interface UserPasswordService<P extends PasswordToken,U extends User>
clientId
- The AuthorizedClient.getId()
to verify againstusername
- The username of the user for which to validate and create a token.AccountLockedException
- if user is locked and unable to reset their passwordpublic boolean createResetPasswordToken(String clientId, String username) throws AccountLockedException
UserPasswordService
createResetPasswordToken
in interface UserPasswordService<P extends PasswordToken,U extends User>
clientId
- The AuthorizedClient.getId()
to verify againstusername
- The username of the user for which to validate and create a token.AccountLockedException
- if user is locked and unable to reset their passwordprotected boolean createResetPasswordTokenForUser(U user, String clientId) throws AccountLockedException
AccountLockedException
protected Optional<P> useToken(U user, String token)
Optional.empty()
.user
- The user on which to validate and use the tokentoken
- The token to validate against a password resetpublic org.springframework.security.core.userdetails.UserDetails updatePassword(org.springframework.security.core.userdetails.UserDetails user, String encodedPassword)
updatePassword
in interface org.springframework.security.core.userdetails.UserDetailsPasswordService
public U updatePasswordForUser(U user, String password, String clientId)
UserPasswordService
updatePasswordForUser
in interface UserPasswordService<P extends PasswordToken,U extends User>
user
- The user who's password to update.password
- The new password for the user.clientId
- The clientId from the request.protected U getCurrentlyAuthenticatedUser()
protected Optional<U> getUserByClientIdAndUsername(String clientId, String username)
protected UserService<U> getUserService()
protected org.springframework.security.crypto.password.PasswordEncoder getPasswordEncoder()
protected UserMessagingService<U> getMessageService()
protected ResetPasswordFormValidator<P> getResetPasswordFormValidator()
protected ChangePasswordFormValidator getChangePasswordFormValidator()
protected UserLockoutService getUserLockoutService()
protected PasscodeService<P,U> getPasscodeService()
Copyright © 2021. All rights reserved.