Class UserServiceImpl
java.lang.Object
org.craftercms.studio.impl.v2.service.security.UserServiceImpl
- All Implemented Interfaces:
UserService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionchangePassword(String username, String current, String newPassword) User changes passwordcreateUser(User user) protected StringdecryptToken(String hashedToken) deleteUserProperties(String siteId, List<String> propertiesToDelete) Delete properties for the given site & current uservoiddeleteUsers(List<Long> userIds, List<String> usernames) enableUsers(List<Long> userIds, List<String> usernames, boolean enabled) voidforgotPassword(String username) Forgot password feature for given usernamegetAllUsers(String keyword, int offset, int limit, String sort) Get paginated list of all users filtered by keywordgetAllUsersForSite(long orgId, String siteId, String keyword, int offset, int limit, String sort) Get paginated list of all users for site filtered by keywordintgetAllUsersForSiteTotal(long orgId, String siteId, String keyword) Get total number of users for site filtered by keywordintgetAllUsersTotal(String keyword) Get total number of users filtered by keywordGet global permissions of the current authenticated userGet permissions of the current authenticated user for given sitegetForgotPasswordToken(String username) Get aforgot password token for given usernamegetUserByIdOrUsername(long userId, String username) getUserProperties(String siteId) Get the properties for the given site & the current usergetUserSiteRoles(long userId, String username, String site) getUserSites(long userId, String username) hasCurrentUserGlobalPermissions(List<String> permissions) Check if the current authenticated user has given global permissionshasCurrentUserSitePermissions(String site, List<String> permissions) Check if the current authenticated user has given permissions for given sitebooleanresetPassword(String username, String newPassword) Admin resets the user passwordvoidsetAccessTokenServiceInternal(AccessTokenServiceInternal accessTokenServiceInternal) voidsetAuditServiceInternal(AuditServiceInternal auditServiceInternal) voidsetConfigurationService(ConfigurationService configurationService) voidsetEncryptor(org.craftercms.commons.crypto.TextEncryptor encryptor) voidsetEntitlementValidator(org.craftercms.commons.entitlements.validator.EntitlementValidator entitlementValidator) voidsetForgotPasswordTaskFactory(org.springframework.beans.factory.ObjectFactory<ForgotPasswordTaskFactory> forgotPasswordTaskFactory) voidsetGeneralLockService(GeneralLockService generalLockService) voidsetGroupServiceInternal(GroupServiceInternal groupServiceInternal) voidsetInstanceService(InstanceService instanceService) setPassword(String token, String newPassword) Set user password - forgot password tokenvoidsetSecurityService(SecurityService securityService) voidsetSecurityServiceV2(SecurityService securityServiceV2) voidsetSessionRegistry(org.springframework.security.core.session.SessionRegistry sessionRegistry) voidsetSiteService(SiteService siteService) voidsetStudioConfiguration(StudioConfiguration studioConfiguration) voidsetTaskExecutor(org.springframework.core.task.TaskExecutor taskExecutor) voidsetUserServiceInternal(UserServiceInternal userServiceInternal) voidupdateUser(User user) updateUserProperties(String siteId, Map<String, String> propertiesToUpdate) Update or add properties for the given site & the current userprotected booleanvalidateDecryptedToken(String decryptedToken) booleanvalidateToken(String token) Validate forgot password token
-
Constructor Details
-
UserServiceImpl
public UserServiceImpl()
-
-
Method Details
-
getAllUsersForSite
public List<UserResponse> getAllUsersForSite(long orgId, String siteId, String keyword, int offset, int limit, String sort) throws ServiceLayerException Description copied from interface:UserServiceGet paginated list of all users for site filtered by keyword- Specified by:
getAllUsersForSitein interfaceUserService- Parameters:
orgId- organization identifiersiteId- site identifierkeyword- keyword to filter usersoffset- offset for paginationlimit- limit number of users to return per pagesort- sort order- Returns:
- requested page of list of users
- Throws:
ServiceLayerException
-
getAllUsers
public List<UserResponse> getAllUsers(String keyword, int offset, int limit, String sort) throws ServiceLayerException Description copied from interface:UserServiceGet paginated list of all users filtered by keyword- Specified by:
getAllUsersin interfaceUserService- Parameters:
keyword- keyword to filter usersoffset- offset for paginationlimit- limit number of users to return per pagesort- sort order- Returns:
- requested page of list of users
- Throws:
ServiceLayerException
-
getAllUsersForSiteTotal
public int getAllUsersForSiteTotal(long orgId, String siteId, String keyword) throws ServiceLayerException Description copied from interface:UserServiceGet total number of users for site filtered by keyword- Specified by:
getAllUsersForSiteTotalin interfaceUserService- Parameters:
orgId- organization identifiersiteId- site identifierkeyword- keyword to filter users- Returns:
- total number of users for site filtered by keyword
- Throws:
ServiceLayerException
-
getAllUsersTotal
Description copied from interface:UserServiceGet total number of users filtered by keyword- Specified by:
getAllUsersTotalin interfaceUserService- Parameters:
keyword- keyword to filter user- Returns:
- total number of users filtered by keyword
- Throws:
ServiceLayerException
-
createUser
public UserResponse createUser(User user) throws UserAlreadyExistsException, ServiceLayerException, AuthenticationException - Specified by:
createUserin interfaceUserService- Throws:
UserAlreadyExistsExceptionServiceLayerExceptionAuthenticationException
-
updateUser
public void updateUser(User user) throws ServiceLayerException, UserNotFoundException, AuthenticationException, UserExternallyManagedException - Specified by:
updateUserin interfaceUserService- Throws:
ServiceLayerExceptionUserNotFoundExceptionAuthenticationExceptionUserExternallyManagedException
-
deleteUsers
public void deleteUsers(List<Long> userIds, List<String> usernames) throws ServiceLayerException, AuthenticationException, UserNotFoundException, UserExternallyManagedException - Specified by:
deleteUsersin interfaceUserService- Throws:
ServiceLayerExceptionAuthenticationExceptionUserNotFoundExceptionUserExternallyManagedException
-
getUserByIdOrUsername
public User getUserByIdOrUsername(long userId, String username) throws ServiceLayerException, UserNotFoundException - Specified by:
getUserByIdOrUsernamein interfaceUserService- Throws:
ServiceLayerExceptionUserNotFoundException
-
enableUsers
public List<UserResponse> enableUsers(List<Long> userIds, List<String> usernames, boolean enabled) throws ServiceLayerException, UserNotFoundException, AuthenticationException, UserExternallyManagedException - Specified by:
enableUsersin interfaceUserService- Throws:
ServiceLayerExceptionUserNotFoundExceptionAuthenticationExceptionUserExternallyManagedException
-
getUserSites
public List<Site> getUserSites(long userId, String username) throws ServiceLayerException, UserNotFoundException - Specified by:
getUserSitesin interfaceUserService- Throws:
ServiceLayerExceptionUserNotFoundException
-
getUserSiteRoles
public List<String> getUserSiteRoles(long userId, String username, String site) throws ServiceLayerException, UserNotFoundException - Specified by:
getUserSiteRolesin interfaceUserService- Throws:
ServiceLayerExceptionUserNotFoundException
-
getCurrentUser
- Specified by:
getCurrentUserin interfaceUserService- Throws:
AuthenticationException
-
getCurrentUserSites
- Specified by:
getCurrentUserSitesin interfaceUserService- Throws:
AuthenticationExceptionServiceLayerException
-
getCurrentUserSiteRoles
public List<String> getCurrentUserSiteRoles(String site) throws AuthenticationException, ServiceLayerException - Specified by:
getCurrentUserSiteRolesin interfaceUserService- Throws:
AuthenticationExceptionServiceLayerException
-
forgotPassword
Description copied from interface:UserServiceForgot password feature for given username- Specified by:
forgotPasswordin interfaceUserService- Parameters:
username- user that forgot password
-
getForgotPasswordToken
Description copied from interface:UserServiceGet aforgot password token for given username- Specified by:
getForgotPasswordTokenin interfaceUserService- Parameters:
username-- Returns:
-
decryptToken
-
changePassword
public UserResponse changePassword(String username, String current, String newPassword) throws PasswordDoesNotMatchException, UserExternallyManagedException, ServiceLayerException, AuthenticationException, UserNotFoundException Description copied from interface:UserServiceUser changes password- Specified by:
changePasswordin interfaceUserService- Parameters:
username- usernamecurrent- current passwordnewPassword- new password- Returns:
- user whose password is successfully changed
- Throws:
PasswordDoesNotMatchException- password does not match with storedUserExternallyManagedException- user is externally managedServiceLayerException- general service errorAuthenticationException- authentication errorUserNotFoundException- user not found
-
setPassword
public UserResponse setPassword(String token, String newPassword) throws UserNotFoundException, UserExternallyManagedException, ServiceLayerException Description copied from interface:UserServiceSet user password - forgot password token- Specified by:
setPasswordin interfaceUserService- Parameters:
token- forgot password tokennewPassword- new password- Returns:
- uses whose password is successfully set
- Throws:
UserNotFoundException- user not foundUserExternallyManagedException- user is externally managedServiceLayerException- general service error
-
validateToken
public boolean validateToken(String token) throws UserNotFoundException, UserExternallyManagedException, ServiceLayerException Description copied from interface:UserServiceValidate forgot password token- Specified by:
validateTokenin interfaceUserService- Parameters:
token- forgot password token to validate- Returns:
- true if token is valid otherwise false
- Throws:
UserNotFoundException- user not foundUserExternallyManagedException- user is externally managedServiceLayerException- general service error
-
validateDecryptedToken
protected boolean validateDecryptedToken(String decryptedToken) throws UserNotFoundException, ServiceLayerException, UserExternallyManagedException -
resetPassword
public boolean resetPassword(String username, String newPassword) throws UserNotFoundException, ServiceLayerException Description copied from interface:UserServiceAdmin resets the user password- Specified by:
resetPasswordin interfaceUserService- Parameters:
username- usernamenewPassword- new password- Returns:
- true if user's password is successfully reset
- Throws:
UserNotFoundException- user not foundServiceLayerException- general service error
-
getUserProperties
Description copied from interface:UserServiceGet the properties for the given site & the current user- Specified by:
getUserPropertiesin interfaceUserService- Parameters:
siteId- the id of the site- Returns:
- the current properties
- Throws:
ServiceLayerException- if there is any error fetching the properties
-
updateUserProperties
public Map<String,String> updateUserProperties(String siteId, Map<String, String> propertiesToUpdate) throws ServiceLayerExceptionDescription copied from interface:UserServiceUpdate or add properties for the given site & the current user- Specified by:
updateUserPropertiesin interfaceUserService- Parameters:
siteId- the id of the sitepropertiesToUpdate- the properties to update or add- Returns:
- the updated properties
- Throws:
ServiceLayerException- if there is any error updating or fetching the properties
-
deleteUserProperties
public Map<String,String> deleteUserProperties(String siteId, List<String> propertiesToDelete) throws ServiceLayerException Description copied from interface:UserServiceDelete properties for the given site & current user- Specified by:
deleteUserPropertiesin interfaceUserService- Parameters:
siteId- the id of the sitepropertiesToDelete- the list of keys to delete- Returns:
- the updated properties
- Throws:
ServiceLayerException- if there is any error deleting or fetching the properties
-
getCurrentUserSitePermissions
public List<String> getCurrentUserSitePermissions(String site) throws ServiceLayerException, UserNotFoundException, ExecutionException Description copied from interface:UserServiceGet permissions of the current authenticated user for given site- Specified by:
getCurrentUserSitePermissionsin interfaceUserService- Parameters:
site- site identifier- Returns:
- Throws:
ServiceLayerExceptionUserNotFoundExceptionExecutionException
-
hasCurrentUserSitePermissions
public Map<String,Boolean> hasCurrentUserSitePermissions(String site, List<String> permissions) throws ServiceLayerException, UserNotFoundException, ExecutionException Description copied from interface:UserServiceCheck if the current authenticated user has given permissions for given site- Specified by:
hasCurrentUserSitePermissionsin interfaceUserService- Parameters:
site- site identifierpermissions- list of permissions to check- Returns:
- map with values true or false for each given permission
- Throws:
ServiceLayerExceptionUserNotFoundExceptionExecutionException
-
getCurrentUserGlobalPermissions
public List<String> getCurrentUserGlobalPermissions() throws ServiceLayerException, UserNotFoundException, ExecutionExceptionDescription copied from interface:UserServiceGet global permissions of the current authenticated user- Specified by:
getCurrentUserGlobalPermissionsin interfaceUserService- Returns:
- Throws:
ServiceLayerExceptionUserNotFoundExceptionExecutionException
-
hasCurrentUserGlobalPermissions
public Map<String,Boolean> hasCurrentUserGlobalPermissions(List<String> permissions) throws ServiceLayerException, UserNotFoundException, ExecutionException Description copied from interface:UserServiceCheck if the current authenticated user has given global permissions- Specified by:
hasCurrentUserGlobalPermissionsin interfaceUserService- Parameters:
permissions- list of permissions to check- Returns:
- map with values true or false for each given permission
- Throws:
ServiceLayerExceptionUserNotFoundExceptionExecutionException
-
setUserServiceInternal
-
setConfigurationService
-
setGroupServiceInternal
-
setSiteService
-
setEntitlementValidator
public void setEntitlementValidator(org.craftercms.commons.entitlements.validator.EntitlementValidator entitlementValidator) -
setGeneralLockService
-
setSecurityService
-
setStudioConfiguration
-
setAuditServiceInternal
-
setAccessTokenServiceInternal
-
setInstanceService
-
setEncryptor
public void setEncryptor(org.craftercms.commons.crypto.TextEncryptor encryptor) -
setSecurityServiceV2
-
setSessionRegistry
public void setSessionRegistry(org.springframework.security.core.session.SessionRegistry sessionRegistry) -
setTaskExecutor
public void setTaskExecutor(org.springframework.core.task.TaskExecutor taskExecutor) -
setForgotPasswordTaskFactory
public void setForgotPasswordTaskFactory(org.springframework.beans.factory.ObjectFactory<ForgotPasswordTaskFactory> forgotPasswordTaskFactory)
-