Class UserServiceInternalImpl
- java.lang.Object
-
- org.craftercms.studio.impl.v2.service.security.internal.UserServiceInternalImpl
-
- All Implemented Interfaces:
UserServiceInternal
public class UserServiceInternalImpl extends Object implements UserServiceInternal
-
-
Constructor Summary
Constructors Constructor Description UserServiceInternalImpl(UserDAO userDao, GroupServiceInternal groupServiceInternal, StudioConfiguration studioConfiguration, SiteService siteService, SecurityService securityService, AccessTokenServiceInternal accessTokenService, RetryingDatabaseOperationFacade retryingDatabaseOperationFacade, com.google.common.cache.Cache<String,User> userCache, com.nulabinc.zxcvbn.Zxcvbn zxcvbn)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
changePassword(String username, String current, String newPassword)
User
createUser(User user)
Map<String,String>
deleteUserProperties(String siteId, List<String> propertiesToDelete)
Delete properties for the given site & current uservoid
deleteUsers(List<Long> userIds, List<String> usernames)
List<User>
enableUsers(List<Long> userIds, List<String> usernames, boolean enabled)
protected String
getActualSiteId(String siteId)
List<User>
getAllUsers(String keyword, int offset, int limit, String sort)
Get paginated list of all users filtered by keywordList<User>
getAllUsersForSite(long orgId, List<String> groupNames, String keyword, int offset, int limit, String sort)
Get paginated list of all users for site filtered by keywordint
getAllUsersForSiteTotal(long orgId, String siteId, String keyword)
Get total number of users for site filtered by keywordint
getAllUsersTotal(String keyword)
Get total number of users filtered by keywordAuthenticatedUser
getCurrentUser()
Returns the current authenticated userprotected String
getGlobalSiteName()
User
getUserByGitName(String gitName)
Get user by git name.User
getUserByIdOrUsername(long userId, String username)
List<Group>
getUserGroups(long userId, String username)
Map<String,Map<String,String>>
getUserProperties(String siteId)
Get the properties for the given site & the current userprotected Map<String,String>
getUserProperties(User user, long siteId)
List<User>
getUsersByIdOrUsername(List<Long> userIds, List<String> usernames)
protected void
invalidateCache(String username)
protected void
invalidateCache(Collection<User> users)
protected void
invalidateCache(List<String> usernames)
boolean
isUserMemberOfGroup(String username, String groupName)
boolean
setUserPassword(String username, String newPassword)
void
updateUser(User user)
Map<String,String>
updateUserProperties(String siteId, Map<String,String> propertiesToUpdate)
Update or add properties for the given site & the current userboolean
userExists(long userId, String username)
-
-
-
Constructor Detail
-
UserServiceInternalImpl
@ConstructorProperties({"userDao","groupServiceInternal","studioConfiguration","siteService","securityService","accessTokenService","retryingDatabaseOperationFacade","userCache","zxcvbn"}) public UserServiceInternalImpl(UserDAO userDao, GroupServiceInternal groupServiceInternal, StudioConfiguration studioConfiguration, SiteService siteService, SecurityService securityService, AccessTokenServiceInternal accessTokenService, RetryingDatabaseOperationFacade retryingDatabaseOperationFacade, com.google.common.cache.Cache<String,User> userCache, com.nulabinc.zxcvbn.Zxcvbn zxcvbn)
-
-
Method Detail
-
invalidateCache
protected void invalidateCache(String username)
-
invalidateCache
protected void invalidateCache(Collection<User> users)
-
getUserByIdOrUsername
@NonNull public User getUserByIdOrUsername(long userId, String username) throws ServiceLayerException, UserNotFoundException
- Specified by:
getUserByIdOrUsername
in interfaceUserServiceInternal
- Throws:
ServiceLayerException
UserNotFoundException
-
getUsersByIdOrUsername
public List<User> getUsersByIdOrUsername(List<Long> userIds, List<String> usernames) throws ServiceLayerException, UserNotFoundException
- Specified by:
getUsersByIdOrUsername
in interfaceUserServiceInternal
- Throws:
ServiceLayerException
UserNotFoundException
-
getAllUsersForSite
public List<User> getAllUsersForSite(long orgId, List<String> groupNames, String keyword, int offset, int limit, String sort) throws ServiceLayerException
Description copied from interface:UserServiceInternal
Get paginated list of all users for site filtered by keyword- Specified by:
getAllUsersForSite
in interfaceUserServiceInternal
- Parameters:
orgId
- organization identifiergroupNames
- group names for sitekeyword
- keyword to filter usersoffset
- pagination offsetlimit
- limit number of users to return per pagesort
- sort order- Returns:
- requested page of list of users
- Throws:
ServiceLayerException
-
getAllUsers
public List<User> getAllUsers(String keyword, int offset, int limit, String sort) throws ServiceLayerException
Description copied from interface:UserServiceInternal
Get paginated list of all users filtered by keyword- Specified by:
getAllUsers
in interfaceUserServiceInternal
- Parameters:
keyword
- keyword to filter usersoffset
- offset for paginationlimit
- limit number of users 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:UserServiceInternal
Get total number of users for site filtered by keyword- Specified by:
getAllUsersForSiteTotal
in interfaceUserServiceInternal
- Parameters:
orgId
- organization identifiersiteId
- site identifierkeyword
- keyword to filter users- Returns:
- total number of users for site filtered by keyword
- Throws:
ServiceLayerException
-
getAllUsersTotal
public int getAllUsersTotal(String keyword) throws ServiceLayerException
Description copied from interface:UserServiceInternal
Get total number of users filtered by keyword- Specified by:
getAllUsersTotal
in interfaceUserServiceInternal
- Parameters:
keyword
- keyword to filter user- Returns:
- total number of users filtered by keyword
- Throws:
ServiceLayerException
-
createUser
public User createUser(User user) throws UserAlreadyExistsException, ServiceLayerException
- Specified by:
createUser
in interfaceUserServiceInternal
- Throws:
UserAlreadyExistsException
ServiceLayerException
-
userExists
public boolean userExists(long userId, String username) throws ServiceLayerException
- Specified by:
userExists
in interfaceUserServiceInternal
- Throws:
ServiceLayerException
-
updateUser
public void updateUser(User user) throws UserNotFoundException, ServiceLayerException
- Specified by:
updateUser
in interfaceUserServiceInternal
- Throws:
UserNotFoundException
ServiceLayerException
-
deleteUsers
public void deleteUsers(List<Long> userIds, List<String> usernames) throws UserNotFoundException, ServiceLayerException
- Specified by:
deleteUsers
in interfaceUserServiceInternal
- Throws:
UserNotFoundException
ServiceLayerException
-
enableUsers
public List<User> enableUsers(List<Long> userIds, List<String> usernames, boolean enabled) throws ServiceLayerException, UserNotFoundException
- Specified by:
enableUsers
in interfaceUserServiceInternal
- Throws:
ServiceLayerException
UserNotFoundException
-
getUserGroups
public List<Group> getUserGroups(long userId, String username) throws UserNotFoundException, ServiceLayerException
- Specified by:
getUserGroups
in interfaceUserServiceInternal
- Throws:
UserNotFoundException
ServiceLayerException
-
isUserMemberOfGroup
public boolean isUserMemberOfGroup(String username, String groupName) throws UserNotFoundException, ServiceLayerException
- Specified by:
isUserMemberOfGroup
in interfaceUserServiceInternal
- Throws:
UserNotFoundException
ServiceLayerException
-
changePassword
public boolean changePassword(String username, String current, String newPassword) throws PasswordDoesNotMatchException, UserExternallyManagedException, ServiceLayerException
- Specified by:
changePassword
in interfaceUserServiceInternal
- Throws:
PasswordDoesNotMatchException
UserExternallyManagedException
ServiceLayerException
-
setUserPassword
public boolean setUserPassword(String username, String newPassword) throws UserNotFoundException, ServiceLayerException
- Specified by:
setUserPassword
in interfaceUserServiceInternal
- Throws:
UserNotFoundException
ServiceLayerException
-
getUserByGitName
public User getUserByGitName(String gitName) throws ServiceLayerException, UserNotFoundException
Description copied from interface:UserServiceInternal
Get user by git name. Special use case because git stores user as string of first and last name separated by ' '- Specified by:
getUserByGitName
in interfaceUserServiceInternal
- Parameters:
gitName
- first and last name separated with ' '- Returns:
- user
- Throws:
ServiceLayerException
UserNotFoundException
-
getGlobalSiteName
protected String getGlobalSiteName()
-
getUserProperties
public Map<String,Map<String,String>> getUserProperties(String siteId) throws ServiceLayerException
Description copied from interface:UserServiceInternal
Get the properties for the given site & the current user- Specified by:
getUserProperties
in interfaceUserServiceInternal
- 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 ServiceLayerException
Description copied from interface:UserServiceInternal
Update or add properties for the given site & the current user- Specified by:
updateUserProperties
in interfaceUserServiceInternal
- 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:UserServiceInternal
Delete properties for the given site & current user- Specified by:
deleteUserProperties
in interfaceUserServiceInternal
- 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
-
getCurrentUser
public AuthenticatedUser getCurrentUser() throws AuthenticationException
Description copied from interface:UserServiceInternal
Returns the current authenticated user- Specified by:
getCurrentUser
in interfaceUserServiceInternal
- Returns:
- the user if present
- Throws:
AuthenticationException
- if there is no user authenticated
-
-