Class AdminSecurityServiceImpl
- All Implemented Interfaces:
AdminSecurityService
- Author:
- jfischer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AdminPermissionDao
protected AdminRoleDao
protected AdminUserDao
protected static String
protected static String
protected javax.cache.CacheManager
protected EmailService
protected BroadleafApplicationEventPublisher
protected AdminSecurityServiceExtensionManager
protected ForgotPasswordSecurityTokenDao
protected org.springframework.security.crypto.password.PasswordEncoder
This is simply a placeholder to be used by#setupPasswordEncoder()
to determine if we're using the newPasswordEncoder
or the deprecatedPasswordEncoder
protected EmailInfo
protected EmailInfo
Fields inherited from interface org.broadleafcommerce.openadmin.server.security.service.AdminSecurityService
DEFAULT_PERMISSIONS
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected String
buildCacheKey
(AdminUser adminUser, PermissionType permissionType, String ceilingEntityFullyQualifiedName) changePassword
(String username, String oldPassword, String password, String confirmPassword) Change a user's password only if oldPassword matches what's stored for that userchangePassword
(PasswordChange passwordChange) protected void
checkExistingPassword
(String unencodedPassword, AdminUser user, GenericResponse response) protected void
checkPassword
(String password, String confirmPassword, GenericResponse response) protected void
checkUser
(AdminUser user, GenericResponse response) void
Clears the cache used forAdminSecurityService.isUserQualifiedForOperationOnCeilingEntity(AdminUser, PermissionType, String)
void
deleteAdminPermission
(AdminPermission permission) void
deleteAdminRole
(AdminRole role) void
deleteAdminUser
(AdminUser user) boolean
doesOperationExistForCeilingEntity
(PermissionType permissionType, String ceilingEntityFullyQualifiedName) protected String
encodePassword
(String rawPassword) Generate an encoded password from a raw passwordprotected String
getCache()
static int
protected String
protected int
protected void
protected boolean
isPasswordValid
(String encodedPassword, String rawPassword) Determines if a password is valid by comparing it to the encoded string, salting is handled internally to thePasswordEncoder
.protected boolean
boolean
isUserQualifiedForOperationOnCeilingEntity
(AdminUser adminUser, PermissionType permissionType, String ceilingEntityFullyQualifiedName) readAdminUserByUserName
(String userName) readAdminUsersByEmail
(String email) Returns a list of admin users that match the given email.resetPasswordUsingToken
(String username, String token, String password, String confirmPassword) Updates the password for the passed in user only if the passed in token is valid for that user.saveAdminPermission
(AdminPermission permission) saveAdminRole
(AdminRole role) saveAdminUser
(AdminUser user) sendForgotUsernameNotification
(String emailAddress) Looks up the corresponding AdminUser and emails the address on file with the associated username.sendResetPasswordNotification
(String username) Generates an access token and then emails the user.static void
setPASSWORD_TOKEN_LENGTH
(int PASSWORD_TOKEN_LENGTH) void
setResetPasswordEmailInfo
(EmailInfo resetPasswordEmailInfo) void
setSendUsernameEmailInfo
(EmailInfo sendUsernameEmailInfo)
-
Field Details
-
CACHE_NAME
-
CACHE_KEY_PREFIX
-
eventPublisher
@Autowired @Qualifier("blApplicationEventPublisher") protected BroadleafApplicationEventPublisher eventPublisher -
adminRoleDao
-
adminUserDao
-
forgotPasswordSecurityTokenDao
-
adminPermissionDao
-
cacheManager
protected javax.cache.CacheManager cacheManager -
cache
-
passwordEncoderBean
protected org.springframework.security.crypto.password.PasswordEncoder passwordEncoderBeanThis is simply a placeholder to be used by
#setupPasswordEncoder()
to determine if we're using the newPasswordEncoder
or the deprecatedPasswordEncoder
-
emailService
-
resetPasswordEmailInfo
-
sendUsernameEmailInfo
-
extensionManager
-
-
Constructor Details
-
AdminSecurityServiceImpl
public AdminSecurityServiceImpl()
-
-
Method Details
-
getPASSWORD_TOKEN_LENGTH
public static int getPASSWORD_TOKEN_LENGTH() -
setPASSWORD_TOKEN_LENGTH
public static void setPASSWORD_TOKEN_LENGTH(int PASSWORD_TOKEN_LENGTH) -
getTokenExpiredMinutes
protected int getTokenExpiredMinutes() -
getResetPasswordURL
-
deleteAdminPermission
@Transactional("blTransactionManager") public void deleteAdminPermission(AdminPermission permission) - Specified by:
deleteAdminPermission
in interfaceAdminSecurityService
-
deleteAdminRole
- Specified by:
deleteAdminRole
in interfaceAdminSecurityService
-
deleteAdminUser
- Specified by:
deleteAdminUser
in interfaceAdminSecurityService
-
readAdminPermissionById
- Specified by:
readAdminPermissionById
in interfaceAdminSecurityService
-
readAdminRoleById
- Specified by:
readAdminRoleById
in interfaceAdminSecurityService
-
readAdminUserById
- Specified by:
readAdminUserById
in interfaceAdminSecurityService
-
saveAdminPermission
@Transactional("blTransactionManager") public AdminPermission saveAdminPermission(AdminPermission permission) - Specified by:
saveAdminPermission
in interfaceAdminSecurityService
-
saveAdminRole
- Specified by:
saveAdminRole
in interfaceAdminSecurityService
-
saveAdminUser
- Specified by:
saveAdminUser
in interfaceAdminSecurityService
-
clearAdminSecurityCache
public void clearAdminSecurityCache()Description copied from interface:AdminSecurityService
Clears the cache used forAdminSecurityService.isUserQualifiedForOperationOnCeilingEntity(AdminUser, PermissionType, String)
- Specified by:
clearAdminSecurityCache
in interfaceAdminSecurityService
-
generateSecurePassword
-
changePassword
@Transactional("blTransactionManager") public AdminUser changePassword(PasswordChange passwordChange) - Specified by:
changePassword
in interfaceAdminSecurityService
-
isUserQualifiedForOperationOnCeilingEntity
public boolean isUserQualifiedForOperationOnCeilingEntity(AdminUser adminUser, PermissionType permissionType, String ceilingEntityFullyQualifiedName) - Specified by:
isUserQualifiedForOperationOnCeilingEntity
in interfaceAdminSecurityService
-
buildCacheKey
protected String buildCacheKey(AdminUser adminUser, PermissionType permissionType, String ceilingEntityFullyQualifiedName) -
doesOperationExistForCeilingEntity
public boolean doesOperationExistForCeilingEntity(PermissionType permissionType, String ceilingEntityFullyQualifiedName) - Specified by:
doesOperationExistForCeilingEntity
in interfaceAdminSecurityService
-
readAdminUserByUserName
- Specified by:
readAdminUserByUserName
in interfaceAdminSecurityService
-
readAdminUsersByEmail
Description copied from interface:AdminSecurityService
Returns a list of admin users that match the given email. This could potentially return more than one user if the admin.user.requireUniqueEmailAddress property is set to false.- Specified by:
readAdminUsersByEmail
in interfaceAdminSecurityService
- Parameters:
email
- the email address to search for- Returns:
- a
List
ofAdminUser
matching the provided email address
-
readAllAdminUsers
- Specified by:
readAllAdminUsers
in interfaceAdminSecurityService
-
readAllAdminRoles
- Specified by:
readAllAdminRoles
in interfaceAdminSecurityService
-
readAllAdminPermissions
- Specified by:
readAllAdminPermissions
in interfaceAdminSecurityService
-
sendForgotUsernameNotification
@Transactional("blTransactionManager") public GenericResponse sendForgotUsernameNotification(String emailAddress) Description copied from interface:AdminSecurityService
Looks up the corresponding AdminUser and emails the address on file with the associated username.- Specified by:
sendForgotUsernameNotification
in interfaceAdminSecurityService
- Parameters:
emailAddress
- email address of user to email- Returns:
- Response can contain errors including (notFound)
-
sendResetPasswordNotification
@Transactional("blTransactionManager") public GenericResponse sendResetPasswordNotification(String username) Description copied from interface:AdminSecurityService
Generates an access token and then emails the user.- Specified by:
sendResetPasswordNotification
in interfaceAdminSecurityService
- Parameters:
username
- the username of the user to send a password reset email- Returns:
- Response can contain errors including (invalidEmail, invalidUsername, inactiveUser)
-
resetPasswordUsingToken
@Transactional("blTransactionManager") public GenericResponse resetPasswordUsingToken(String username, String token, String password, String confirmPassword) Description copied from interface:AdminSecurityService
Updates the password for the passed in user only if the passed in token is valid for that user.- Specified by:
resetPasswordUsingToken
in interfaceAdminSecurityService
- Parameters:
username
- the username of the usertoken
- a valid reset token from the emailpassword
- the new desired passwordconfirmPassword
- the password confirmation to match password- Returns:
- Response can contain errors including (invalidUsername, inactiveUser, invalidToken, invalidPassword, tokenExpired, passwordMismatch)
-
invalidateAllTokensForAdminUser
-
checkUser
-
checkPassword
-
checkExistingPassword
protected void checkExistingPassword(String unencodedPassword, AdminUser user, GenericResponse response) -
isTokenExpired
-
getSendUsernameEmailInfo
-
setSendUsernameEmailInfo
-
getResetPasswordEmailInfo
-
setResetPasswordEmailInfo
-
changePassword
@Transactional("blTransactionManager") public GenericResponse changePassword(String username, String oldPassword, String password, String confirmPassword) Description copied from interface:AdminSecurityService
Change a user's password only if oldPassword matches what's stored for that user- Specified by:
changePassword
in interfaceAdminSecurityService
- Parameters:
username
- the username to change the password foroldPassword
- the user's current passwordpassword
- the desired new passwordconfirmPassword
- the confirm password to ensure it matches password- Returns:
- Response can contain errors including (invalidUser, emailNotFound, inactiveUser, invalidPassword, passwordMismatch)
-
isPasswordValid
Determines if a password is valid by comparing it to the encoded string, salting is handled internally to thePasswordEncoder
.This method must always be called to verify if a password is valid after the original encoded password is generated due to
PasswordEncoder
randomly generating salts internally and appending them to the resulting hash.- Parameters:
encodedPassword
- the encoded passwordrawPassword
- the raw password to check against the encoded password- Returns:
- true if rawPassword matches the encodedPassword, false otherwise
-
encodePassword
Generate an encoded password from a raw passwordThis method can only be called once per password. The salt is randomly generated internally in the
PasswordEncoder
and appended to the hash to provide the resulting encoded password. Once this has been called on a password, going forward all checks for authenticity must be done byisPasswordValid(String, String)
as encoding the same password twice will result in different encoded passwords.- Parameters:
rawPassword
- the unencoded password to encode- Returns:
- the encoded password
-
getCache
-