Class ApplicationServiceGeneric
- All Implemented Interfaces:
ApplicationService
- Direct Known Subclasses:
RecoveryModeAwareApplicationService
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.atlassian.crowd.manager.application.ApplicationService
ApplicationService.MembershipsIterable -
Constructor Summary
ConstructorsConstructorDescriptionApplicationServiceGeneric(DirectoryManager directoryManager, SearchStrategyFactory searchStrategyFactory, PermissionManager permissionManager, com.atlassian.event.api.EventPublisher eventPublisher, EventStore eventStore, WebhookRegistry webhookRegistry, AvatarProvider avatarProvider, AuthenticationOrderOptimizer authenticationOrderOptimizer, ApplicationFactory applicationFactory, AccessFilterFactory accessFilterFactory, CrowdDarkFeatureManager crowdDarkFeatureManager) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAllUsers(Application application, Collection<UserTemplateWithCredentialAndAttributes> userTemplates) Adds the user to THE FIRST permissible active directory.addGroup(Application application, GroupTemplate group) Adds the group to ALL the active permissible directories.voidaddGroupToGroup(Application application, String childGroupName, String parentGroupName) Makes groups matching the given name (childGroupName) direct members of the group (parentGroupName) across ALL active directories.addUser(Application application, UserTemplate user, PasswordCredential credential) Adds the user to the first permissible active directory.addUser(Application application, UserTemplateWithAttributes user, PasswordCredential credential) Adds the user to the first permissible active directory.voidaddUserToGroup(Application application, String username, String groupName) Makes the primary user of the given username a direct member of the group on the directory where the primary user resides.authenticateUser(Application application, UserAuthenticationContext userAuthenticationContext) Will attempt to authenticate the given user against the application.authenticateUser(Application application, String username, PasswordCredential passwordCredential) Will attempt to authenticate the given user against the application.<T> PagedSearcher<T>createPagedGroupSearcher(Application application, EntityQuery<T> query) Creates paged group searcher for a given group query.<T> PagedSearcher<T>createPagedUserSearcher(Application application, EntityQuery<T> query) Creates paged user searcher for a given user query.voidexpireAllPasswords(Application application) Expires all passwords for all directories which are part of this application, regardless of group mapping.findGroupByName(Application application, String name) Returns the first group with the matching groupname from all the active directories assigned to the application.findGroupWithAttributesByName(Application application, String name) Returns the first group with the matching groupname from all the active directories assigned to the application.findRemoteUserByName(Application application, String username) Returns the first user with the matching username from all active directories authoratiative remote directory.findUserByKey(Application application, String key) Returns the user with a matching key from all the active directories assigned to the application.findUserByName(Application application, String name) Returns the first user with the matching username from all the active directories assigned to the application.findUserWithAttributesByKey(Application application, String key) Returns the user with a matching key from all the active directories assigned to the application.findUserWithAttributesByName(Application application, String name) Returns the first user with the matching username from all the active directories assigned to the application.findWebhookById(Application application, long webhookId) Retrieves a Webhook by its identifier.getActiveDirectories(Application application) Given anapplication, retrieve all active directories associated with it.getCapabilitiesForNewUsers(Application application) Gets the expected capabilities fornew users.getCurrentEventToken(Application application) Returns a token that can be used for querying events that have happened after the token was generated.getMemberships(Application application) Returns all memberships for the given application.getNewEvents(Application application, String eventToken) Returns an events object which contains a new eventToken and events that happened after the giveneventTokenwas generated.getUserAvatar(Application application, String username, int sizeHint) Gets an avatar for this user, if one is available.getUserAvatarLink(Application application, String username, int sizeHint) Gets a URL for an avatar for this user, if one is available.booleanisGroupDirectGroupMember(Application application, String childGroup, String parentGroup) Returnstrueif the childGroup is a direct member of the parentGroup in any of the application's assigned directories.booleanisGroupNestedGroupMember(Application application, String childGroup, String parentGroup) Returnstrueif the childGroup is a direct or indirect (nested) member of the parentGroup in any of the application's active assigned directories.booleanisUserAuthorised(Application application, User user) Returnstrueif the user is permitted to attempt authentication with the application.booleanisUserAuthorised(Application application, String username) Returnstrueif the user is permitted to attempt authentication with the application.booleanisUserDirectGroupMember(Application application, String username, String groupName) Returnstrueif the user is a direct member of the group in the directory of the first user found with the specified username.booleanisUserNestedGroupMember(Application application, String username, String groupName) Returnstrueif the user is a direct or indirect (nested) member of the group in the directory of the first user found with the specified username.registerWebhook(Application application, String endpointUrl, String token) Registers a Webhook associated to the application.voidremoveGroup(Application application, String groupname) Removes ALL groups from each of the application's assigned directories that are active.voidremoveGroupAttributes(Application application, String groupname, String attributeName) Removes a group's attribute values for all active permissible directories assigned to the application.voidremoveGroupFromGroup(Application application, String childGroupName, String parentGroupName) Makes child group matching the given name not members of the parent group across ALL active directories.voidremoveUser(Application application, String username) Removes the user from the first active directory they are found in.voidremoveUserAttributes(Application application, String username, String attributeName) Removes a user's attribute values for the first active directory containing this username.voidremoveUserFromGroup(Application application, String username, String groupName) Makes the primary user of the given username no longer a member of the group on the directory where the primary user resides.renameUser(Application application, String oldUserName, String newUsername) Renames the user in the first active directory the users exists in.<T> List<T>searchDirectGroupRelationships(Application application, MembershipQuery<T> query) Searches for direct group relationships in any of the application's active assigned directories.<T> List<T>searchGroups(Application application, EntityQuery<T> query) Returns a List<Group> matching the search criteria defined in the query for ALL of the active directories assigned to the application.<T> List<T>searchNestedGroupRelationships(Application application, MembershipQuery<T> query) Searches for direct and indirect (nested) group relationships in any of the application's active assigned directories.<T> List<T>searchUsers(Application application, EntityQuery<T> query) Returns a List<User> or List<String> matching the search criteria defined in the query for ALL of the active directories assigned to the application.setUserStatusLocally(Application application, String username, boolean userActiveInternally) Set the user's active status in the first active directory the User belongsvoidstoreGroupAttributes(Application application, String groupname, Map<String, Set<String>> attributes) Adds or updates a group's attributes with the new Map of attribute values for all active permissible directories assigned to the application.voidstoreUserAttributes(Application application, String username, Map<String, Set<String>> attributes) Adds or updates a user's attributes with the new Map of attribute values for the first active directory containing this username.voidunregisterWebhook(Application application, long webhookId) Unregisters a Webhook.updateGroup(Application application, GroupTemplate group) Updates the group in ALL the active permissible directories.updateUser(Application application, UserTemplate user) Updates the user in the first active directory the User belongs.voidupdateUserCredential(Application application, String username, PasswordCredential credential) Updates the credentials of the first matching user from all the active directories assigned to the application.userAuthenticated(Application application, String username) validateUpdateUser(Application application, UserTemplate user)
-
Constructor Details
-
ApplicationServiceGeneric
public ApplicationServiceGeneric(DirectoryManager directoryManager, SearchStrategyFactory searchStrategyFactory, PermissionManager permissionManager, com.atlassian.event.api.EventPublisher eventPublisher, EventStore eventStore, WebhookRegistry webhookRegistry, AvatarProvider avatarProvider, AuthenticationOrderOptimizer authenticationOrderOptimizer, ApplicationFactory applicationFactory, AccessFilterFactory accessFilterFactory, CrowdDarkFeatureManager crowdDarkFeatureManager)
-
-
Method Details
-
authenticateUser
public User authenticateUser(Application application, String username, PasswordCredential passwordCredential) throws OperationFailedException, InactiveAccountException, InvalidAuthenticationException, ExpiredCredentialException, UserNotFoundException Description copied from interface:ApplicationServiceWill attempt to authenticate the given user against the application. The logic should start by going through directories defined in the application one by one, trying to authenticate user against each directory. When an authentication against directory is positive, the method returns the user. Otherwise, an exception indicating the reason will be thrown. In case that some of the underlying directories cannot perform the operation at the time of authentication, either by technical failures or the application not having the right permission to query the directory, as indicated byOperationFailedExceptionbeing thrown, the authentication logic will skip those directories, instead relying on the operative ones, in the order defined in the application's directory mappings. However, if the user, still, cannot be authenticated against any remaining directories, we suspect one of the bad directories must have held the user account, in which caseOperationFailedException, which indicates the underlying cause of the first failing directory, will be thrown from this method.- Specified by:
authenticateUserin interfaceApplicationService- Parameters:
application- the application to authenticate againstusername- the username to authenticate againstpasswordCredential- the password to use for authentication- Returns:
- A user if the user can successfully authenticate.
- Throws:
OperationFailedException- underlying directory implementation failed to execute the operation.InactiveAccountException- if the users account is marked as inactiveInvalidAuthenticationException- if authentication with the provided credentials failed, or potentially the user does not exist.ExpiredCredentialException- if the users credentials have expiredUserNotFoundException
-
authenticateUser
public User authenticateUser(Application application, UserAuthenticationContext userAuthenticationContext) throws OperationFailedException, InactiveAccountException, InvalidAuthenticationException, ExpiredCredentialException, UserNotFoundException Description copied from interface:ApplicationServiceWill attempt to authenticate the given user against the application. The logic should start by going through directories defined in the application one by one, trying to authenticate user against each directory. When an authentication against directory is positive, the method returns the user. Otherwise, an exception indicating the reason will be thrown. In case that some of the underlying directories cannot perform the operation at the time of authentication, either by technical failures or the application not having the right permission to query the directory, as indicated byOperationFailedExceptionbeing thrown, the authentication logic will skip those directories, instead relying on the operative ones, in the order defined in the application's directory mappings. However, if the user, still, cannot be authenticated against any remaining directories, we suspect one of the bad directories must have held the user account, in which caseOperationFailedException, which indicates the underlying cause of the first failing directory, will be thrown from this method.- Specified by:
authenticateUserin interfaceApplicationService- Parameters:
application- the application to authenticate againstuserAuthenticationContext- the authentication details for the user- Returns:
- A user if the user can successfully authenticate.
- Throws:
OperationFailedException- underlying directory implementation failed to execute the operation.InactiveAccountException- if the users account is marked as inactiveInvalidAuthenticationException- if authentication with the provided credentials failed, or potentially the user does not exist.ExpiredCredentialException- if the users credentials have expiredUserNotFoundException
-
isUserAuthorised
Description copied from interface:ApplicationServiceReturnstrueif the user is permitted to attempt authentication with the application. If the user could not be found, thenfalseis returned.For a user to have access to an application:
- the Application must be active.
- and either:
- the User is stored in a directory which is associated to the Application and the "allow all to authenticate" flag is true.
- the User is a member of a Group that is allowed to authenticate with the Application and both the User and Group are from the same RemoteDirectory.
- Specified by:
isUserAuthorisedin interfaceApplicationService- Parameters:
application- application user is authenticating againstusername- username- Returns:
true</tt> if the user is permitted to attempt authentication with the application, otherwise <tt>false. If the user could not be found,falsewill be returned.
-
isUserAuthorised
Description copied from interface:ApplicationServiceReturnstrueif the user is permitted to attempt authentication with the application. If the user could not be found, thenfalseis returned.For a user to have access to an application:
- the Application must be active.
- and either:
- the User is stored in a directory which is associated to the Application and the "allow all to authenticate" flag is true.
- the User is a member of a Group that is allowed to authenticate with the Application and both the User and Group are from the same RemoteDirectory.
- Specified by:
isUserAuthorisedin interfaceApplicationService- Parameters:
application- application user is authenticating againstuser- the user that will be checked- Returns:
true</tt> if the user is permitted to attempt authentication with the application, otherwise <tt>false. If the user could not be found,falsewill be returned.
-
addAllUsers
public void addAllUsers(Application application, Collection<UserTemplateWithCredentialAndAttributes> userTemplates) throws ApplicationPermissionException, OperationFailedException, BulkAddFailedException Description copied from interface:ApplicationServiceAdds the user to THE FIRST permissible active directory.If no directories have CREATE_USER permission, an
ApplicationPermissionExceptionis thrown.- Specified by:
addAllUsersin interfaceApplicationService- Parameters:
application- add to application's assigned directories.userTemplates- the users to add.- Throws:
ApplicationPermissionException- thrown when no CREATE USER permission for any of the directories.OperationFailedException- underlying directory implementation failed to execute the operation.BulkAddFailedException- throw when it failed to create a user in of the directories.
-
findUserByName
Description copied from interface:ApplicationServiceReturns the first user with the matching username from all the active directories assigned to the application.The directories are searched in the order they are assigned to the application.
- Specified by:
findUserByNamein interfaceApplicationService- Parameters:
application- search application's assigned directories.name- the username of the user to find.- Returns:
- first matching user.
- Throws:
UserNotFoundException- user not found in any of the directories.
-
findRemoteUserByName
public User findRemoteUserByName(Application application, String username) throws UserNotFoundException Description copied from interface:ApplicationServiceReturns the first user with the matching username from all active directories authoratiative remote directory. This method may perform a remote call and thus relies on the response times of remote directories.The directories are searched in the order they are assigned to the application.
- Specified by:
findRemoteUserByNamein interfaceApplicationService- Parameters:
application- search application's assigned directories.username- the username of the user to find.- Returns:
- first matching user.
- Throws:
UserNotFoundException- user not found in any of the directories.
-
findUserByKey
Description copied from interface:ApplicationServiceReturns the user with a matching key from all the active directories assigned to the application.- Specified by:
findUserByKeyin interfaceApplicationService- Parameters:
application- application that is looking up the user.key- user key to look up by.- Returns:
- matching user.
- Throws:
UserNotFoundException- if the canonical user with the given key is not found in the active directories mapped to the application.
-
findUserWithAttributesByKey
public UserWithAttributes findUserWithAttributesByKey(Application application, String key) throws UserNotFoundException Description copied from interface:ApplicationServiceReturns the user with a matching key from all the active directories assigned to the application.- Specified by:
findUserWithAttributesByKeyin interfaceApplicationService- Parameters:
application- application that is looking up the user.key- user key to look up by.- Returns:
- matching user, with attributes.
- Throws:
UserNotFoundException- if the canonical user with the given key is not found in the active directories mapped to the application.
-
findUserWithAttributesByName
public UserWithAttributes findUserWithAttributesByName(Application application, String name) throws UserNotFoundException Description copied from interface:ApplicationServiceReturns the first user with the matching username from all the active directories assigned to the application.The directories are searched in the order they are assigned to the application.
- Specified by:
findUserWithAttributesByNamein interfaceApplicationService- Parameters:
application- search application's assigned directories.name- the username of the user to find.- Returns:
- first matching user.
- Throws:
UserNotFoundException- user not found in any of the directories.
-
addUser
public User addUser(Application application, UserTemplate user, PasswordCredential credential) throws InvalidUserException, OperationFailedException, InvalidCredentialException, ApplicationPermissionException Description copied from interface:ApplicationServiceAdds the user to the first permissible active directory.If the user exists in ANY of the application's active assigned directories, then an
InvalidUserExceptionwill be thrown.If the add operation fails on the directory because of permission restrictions, an ApplicationPermissionException is thrown If ALL directories permissions fail, an
ApplicationPermissionExceptionis thrown.If the add operation fails on a directory for any other reason, such as directory failure, update failure, etc., an Exception is thrown immediately.
Returns the added user from the directory operation.
- Specified by:
addUserin interfaceApplicationService- Parameters:
application- add to application's assigned directories.user- a template of the user to be added. The directoryId of the UserTemplate is ignored, and will be mutated for each directoryMapping.credential- the password credential of the user (unencrypted).- Returns:
- the added user returned from
ApplicationService.findUserByName(com.atlassian.crowd.model.application.Application, String). - Throws:
InvalidUserException- if the user already exists in ANY associated directory or the user template does not have the required properties populated.OperationFailedException- underlying directory implementation failed to execute the operation.InvalidCredentialException- if the user's credential does not meet the validation requirements for an associated directory.ApplicationPermissionException- if none of the application's associated directories are allowed to perform operations of typeOperationType.CREATE_USER.
-
addUser
public UserWithAttributes addUser(Application application, UserTemplateWithAttributes user, PasswordCredential credential) throws InvalidUserException, OperationFailedException, InvalidCredentialException, ApplicationPermissionException Description copied from interface:ApplicationServiceAdds the user to the first permissible active directory.If the user exists in ANY of the application's active assigned directories, then an
InvalidUserExceptionwill be thrown.If the add operation fails on the directory because of permission restrictions, an ApplicationPermissionException is thrown If ALL directories permissions fail, an
ApplicationPermissionExceptionis thrown.If the add operation fails on a directory for any other reason, such as directory failure, update failure, etc., an Exception is thrown immediately.
Returns the added user from the directory operation.
- Specified by:
addUserin interfaceApplicationService- Parameters:
application- add to application's assigned directories.user- a template of the user to be added. The directoryId of theUserTemplateWithAttributesis ignored, and will be mutated for each directoryMapping.credential- the password credential of the user (unencrypted).- Returns:
- the added user returned from
ApplicationService.findUserWithAttributesByName(com.atlassian.crowd.model.application.Application, String). - Throws:
InvalidUserException- if the user already exists in ANY associated directory or the user template does not have the required properties populated.OperationFailedException- underlying directory implementation failed to execute the operation.InvalidCredentialException- if the user's credential does not meet the validation requirements for an associated directory.ApplicationPermissionException- if none of the application's associated directories are allowed to perform operations of typeOperationType.CREATE_USER.
-
validateUpdateUser
public User validateUpdateUser(Application application, UserTemplate user) throws InvalidUserException, OperationFailedException, ApplicationPermissionException, UserNotFoundException -
updateUser
public User updateUser(Application application, UserTemplate user) throws InvalidUserException, OperationFailedException, ApplicationPermissionException, UserNotFoundException Description copied from interface:ApplicationServiceUpdates the user in the first active directory the User belongs.If the user does not exist in ANY of the application's active assigned directories, then a
UserNotFoundExceptionwill be thrown.If the update operation is not allowed on the User's directory, an
ApplicationPermissionExceptionis thrown.If the update operation fails on a directory for any other reason, such as directory failure, update failure, etc., an Exception is thrown immediately.
Returns the updated User.
- Specified by:
updateUserin interfaceApplicationService- Parameters:
application- application with assigned directories to operate on.user- a template of the user to be added. The directoryId of the UserTemplate is ignored, and directories searched for the given username.- Returns:
- the updated User.
- Throws:
InvalidUserException- if the user template does not have the required properties populated.OperationFailedException- underlying directory implementation failed to execute the operation.ApplicationPermissionException- if the User's directory is not allowed to perform operations of typeOperationType.UPDATE_USER.UserNotFoundException- user does not exist in any of the associated active directories of the application.
-
setUserStatusLocally
public User setUserStatusLocally(@Nonnull Application application, String username, boolean userActiveInternally) throws InvalidUserException, OperationFailedException, UserNotFoundException, DirectoryNotFoundException Description copied from interface:ApplicationServiceSet the user's active status in the first active directory the User belongsIf the user does not exist in ANY of the application's assigned directories, then a
UserNotFoundExceptionwill be thrown.If setting the active flag fails for any other reason, such as directory failure, update failure, etc., an Exception is thrown immediately.
Returns the updated User.
- Specified by:
setUserStatusLocallyin interfaceApplicationService- Parameters:
application- application with assigned directories to operate on.username- username for which active status change is needed.userActiveInternally- Whether to activate/deactivate the user- Returns:
- the updated User.
- Throws:
InvalidUserException- if the user template does not have the required properties populated.OperationFailedException- underlying directory implementation failed to execute the operation.UserNotFoundException- user does not exist in internal directory of the application.DirectoryNotFoundException
-
renameUser
public User renameUser(Application application, String oldUserName, String newUsername) throws UserNotFoundException, OperationFailedException, ApplicationPermissionException, InvalidUserException Description copied from interface:ApplicationServiceRenames the user in the first active directory the users exists in.If the user does not exist in ANY of the application's active assigned directories, then a
UserNotFoundExceptionwill be thrown.If the rename operation is not allowed on the User's directory, an
ApplicationPermissionExceptionis thrown.If the rename operation fails on a directory for any other reason, such as directory failure, update failure, etc., an Exception is thrown immediately.
Returns the renamed User.
- Specified by:
renameUserin interfaceApplicationService- Parameters:
application- application with assigned directories to operate on.oldUserName- current username of the user to rename.newUsername- new username of the renamed user.- Returns:
- the renamed User.
- Throws:
UserNotFoundException- user does not exist in any of the associated active directories of the application.OperationFailedException- underlying directory implementation failed to execute the operation.ApplicationPermissionException- if the User's directory is not allowed to perform operations of typeOperationType.UPDATE_USER.InvalidUserException- if the new username does not meet the username requirements for an associated directory.
-
updateUserCredential
public void updateUserCredential(Application application, String username, PasswordCredential credential) throws OperationFailedException, InvalidCredentialException, ApplicationPermissionException, UserNotFoundException Description copied from interface:ApplicationServiceUpdates the credentials of the first matching user from all the active directories assigned to the application.Thus, the method only operates on the same user returned from a call to findUserByName.
- Specified by:
updateUserCredentialin interfaceApplicationService- Parameters:
application- update in application's assigned directories.username- name of user.credential- new (unencrypted) credentials.- Throws:
OperationFailedException- underlying directory implementation failed to execute the operation.InvalidCredentialException- if the user's credential does not meet the validation requirements for an associated directory.ApplicationPermissionException- if the first directory in which the user is found doesn't have the permission to perform operations of typeOperationType.UPDATE_USER.UserNotFoundException- if no user with the given name exists in ANY assigned directory.
-
storeUserAttributes
public void storeUserAttributes(Application application, String username, Map<String, Set<String>> attributes) throws OperationFailedException, ApplicationPermissionException, UserNotFoundExceptionDescription copied from interface:ApplicationServiceAdds or updates a user's attributes with the new Map of attribute values for the first active directory containing this username.The attributes map represents new or updated attributes and does not replace existing attributes unless the key of an attribute matches the key of an existing attribute on the user.
This method does not update primary field attributes like firstName, lastName, etc.
If the user does not exist in ANY of the application's assigned directories, then a
UserNotFoundExceptionwill be thrown.If the directory does not have UPDATE_USER permission, an
ApplicationPermissionExceptionis thrown.If the update operation fails on a directory for any other reason, such as directory failure, update failure, etc., an Exception is thrown immediately.
- Specified by:
storeUserAttributesin interfaceApplicationService- Parameters:
application- application with assigned directories to operate on.username- username of the user to update.attributes- map of one-to-many attribute-values. All attribute keys are treated as new or updated attributes.- Throws:
OperationFailedException- underlying directory implementation failed to execute the operation.ApplicationPermissionException- if the User's directory does not have permission to perform operations of typeOperationType.UPDATE_USER_ATTRIBUTE.UserNotFoundException- if the user with the supplied username does not exist in ANY assigned directory.
-
removeUserAttributes
public void removeUserAttributes(Application application, String username, String attributeName) throws OperationFailedException, ApplicationPermissionException, UserNotFoundException Description copied from interface:ApplicationServiceRemoves a user's attribute values for the first active directory containing this username.If the user does not exist in ANY of the application's assigned directories, then a
UserNotFoundExceptionwill be thrown.If the directory does not have UPDATE_USER permission, an
ApplicationPermissionExceptionis thrown.If the update operation fails on a directory for any other reason, such as directory failure, update failure, etc., an Exception is thrown immediately.
- Specified by:
removeUserAttributesin interfaceApplicationService- Parameters:
application- application with assigned directories to operate on.username- username of the user to update.attributeName- all attribute values for this key will be removed from the user.- Throws:
OperationFailedException- underlying directory implementation failed to execute the operation.ApplicationPermissionException- if the User's directory does not have permission to perform operations of typeOperationType.UPDATE_USER_ATTRIBUTE.UserNotFoundException- if the user with the supplied username does not exist in ANY assigned directory.
-
removeUser
public void removeUser(Application application, String username) throws OperationFailedException, ApplicationPermissionException, UserNotFoundException Description copied from interface:ApplicationServiceRemoves the user from the first active directory they are found in.If the user does not exist in ANY of the application's assigned directories, then a
UserNotFoundExceptionwill be thrown.If the remove operation fails because of permission restrictions, an ApplicationPermissionException is thrown.
- Specified by:
removeUserin interfaceApplicationService- Parameters:
application- remove from application's assigned directories.username- the name of the user to remove.- Throws:
OperationFailedException- underlying directory implementation failed to execute the operation.ApplicationPermissionException- if the User's directory does not have permission to perform operations of typeOperationType.DELETE_USER.UserNotFoundException- if user with given name does not exist in ANY assigned directory.
-
searchUsers
Description copied from interface:ApplicationServiceReturns a List<User> or List<String> matching the search criteria defined in the query for ALL of the active directories assigned to the application.The users will be returned in a stable order including across pagination boundaries (excluding modification).
- Specified by:
searchUsersin interfaceApplicationService- Parameters:
application- search application's assigned directories.query- the search query.- Returns:
- List<User> user objects or List<String> usernames, depending on the query.
-
findGroupByName
Description copied from interface:ApplicationServiceReturns the first group with the matching groupname from all the active directories assigned to the application.The directories are searched in the order they are assigned to the application.
- Specified by:
findGroupByNamein interfaceApplicationService- Parameters:
application- search application's assigned directories.name- the groupname of the group to find.- Returns:
- first matching group.
- Throws:
GroupNotFoundException- group not found in any of the directories.
-
findGroupWithAttributesByName
public GroupWithAttributes findGroupWithAttributesByName(Application application, String name) throws GroupNotFoundException Description copied from interface:ApplicationServiceReturns the first group with the matching groupname from all the active directories assigned to the application.The directories are searched in the order they are assigned to the application.
- Specified by:
findGroupWithAttributesByNamein interfaceApplicationService- Parameters:
application- search application's assigned directories.name- the groupname of the group to find.- Returns:
- first matching group.
- Throws:
GroupNotFoundException- group not found in any of the directories.
-
addGroup
public Group addGroup(Application application, GroupTemplate group) throws InvalidGroupException, OperationFailedException, ApplicationPermissionException Description copied from interface:ApplicationServiceAdds the group to ALL the active permissible directories.If the group exists in ANY of the application's active assigned directories, then an
InvalidGroupExceptionwill be thrown.If the add operation fails on a directory because of permissioning restrictions, an INFO message is logged. If ALL directories permissions fail, an
ApplicationPermissionExceptionis thrown.If the add operation fails on a directory for any other reason, such as directory failure, update failure, etc., an Exception is thrown immediately.
Returns the group from the first directory containing the group.
- Specified by:
addGroupin interfaceApplicationService- Parameters:
application- add to application's assigned directories.group- a template of the group to be added. The directoryId of the GroupTemplate is ignored, and will be mutated for each directoryMapping.- Returns:
- the added group returned from
ApplicationService.findGroupByName(com.atlassian.crowd.model.application.Application, String). - Throws:
InvalidGroupException- if the group already exists in ANY associated directory or the group template does not have the required properties populated.OperationFailedException- underlying directory implementation failed to execute the operation.ApplicationPermissionException- if none of the application's associated directories are allowed to perform operations of typeOperationType.CREATE_GROUP.
-
updateGroup
public Group updateGroup(Application application, GroupTemplate group) throws InvalidGroupException, OperationFailedException, ApplicationPermissionException, GroupNotFoundException Description copied from interface:ApplicationServiceUpdates the group in ALL the active permissible directories.If the group does not exist in ANY of the application's assigned directories, then a
GroupNotFoundExceptionwill be thrown.If the update operation fails on a directory because of permissioning restrictions, an INFO message is logged. If ALL directories permissions fail, an
ApplicationPermissionExceptionis thrown.If the update operation fails on a directory for any other reason, such as directory failure, update failure, etc., an Exception is thrown immediately.
Returns the group from the first directory containing the group.
- Specified by:
updateGroupin interfaceApplicationService- Parameters:
application- application with assigned directories to operate on.group- a template of the group to be added. The directoryId of the GroupTemplate is ignored, and will be mutated for each directoryMapping.- Returns:
- the added group returned from
ApplicationService.findGroupByName(com.atlassian.crowd.model.application.Application, String). - Throws:
InvalidGroupException- if the group already exists in ANY associated directory or the group template does not have the required properties populated.OperationFailedException- underlying directory implementation failed to execute the operation.ApplicationPermissionException- if none of the application's associated directories are allowed to perform operations of typeOperationType.UPDATE_GROUP.GroupNotFoundException- group does not exist in any of the associated directories of the application.
-
storeGroupAttributes
public void storeGroupAttributes(Application application, String groupname, Map<String, Set<String>> attributes) throws OperationFailedException, ApplicationPermissionException, GroupNotFoundExceptionDescription copied from interface:ApplicationServiceAdds or updates a group's attributes with the new Map of attribute values for all active permissible directories assigned to the application.The attributes map represents new or updated attributes and does not replace existing attributes unless the key of an attribute matches the key of an existing attribute on the group.
This method does not update primary field attributes like firstName, lastName, etc.
If the group does not exist in ANY of the application's assigned directories, then a
GroupNotFoundExceptionwill be thrown.If the update operation fails on a directory because of permissioning restrictions, an INFO message is logged. If ALL directories permissions fail, an
ApplicationPermissionExceptionis thrown.If the update operation fails on a directory for any other reason, such as directory failure, update failure, etc., an Exception is thrown immediately.
- Specified by:
storeGroupAttributesin interfaceApplicationService- Parameters:
application- application with assigned directories to operate on.groupname- groupname of the group to update.attributes- map of one-to-many attribute-values. All attribute keys are treated as new or updated attributes.- Throws:
OperationFailedException- underlying directory implementation failed to execute the operation.ApplicationPermissionException- if none of the application's associated directories are allowed to perform operations of typeOperationType.UPDATE_GROUP_ATTRIBUTE.GroupNotFoundException- if the group with the supplied groupname does not exist in ANY assigned directory.
-
removeGroupAttributes
public void removeGroupAttributes(Application application, String groupname, String attributeName) throws OperationFailedException, ApplicationPermissionException, GroupNotFoundException Description copied from interface:ApplicationServiceRemoves a group's attribute values for all active permissible directories assigned to the application.If the group does not exist in ANY of the application's assigned directories, then a
GroupNotFoundExceptionwill be thrown.If the update operation fails on a directory because of permissioning restrictions, an INFO message is logged. If ALL directories permissions fail, an
ApplicationPermissionExceptionis thrown.If the update operation fails on a directory for any other reason, such as directory failure, update failure, etc., an Exception is thrown immediately.
- Specified by:
removeGroupAttributesin interfaceApplicationService- Parameters:
application- application with assigned directories to operate on.groupname- groupname of the group to update.attributeName- all attribute values for this key will be removed from the group.- Throws:
OperationFailedException- underlying directory implementation failed to execute the operation.ApplicationPermissionException- if none of the application's associated directories are allowed to perform operations of typeOperationType.UPDATE_GROUP_ATTRIBUTE.GroupNotFoundException- if the group with the supplied groupname does not exist in ANY assigned directory.
-
removeGroup
public void removeGroup(Application application, String groupname) throws OperationFailedException, ApplicationPermissionException, GroupNotFoundException Description copied from interface:ApplicationServiceRemoves ALL groups from each of the application's assigned directories that are active.If the group doesn't exist in ANY of the application's assigned directories that are active, then a GroupNotFoundException will be thrown.
If the remove operation fails on a directory because of permissioning restrictions, an INFO message is logged. If ALL directories permissions fail, a ApplicationPermissionException is thrown.
If the remove operation fails on a directory for any other reason, such as directory failure, update failure, etc., an Exception is thrown immediately.
- Specified by:
removeGroupin interfaceApplicationService- Parameters:
application- remove from application's assigned directories.groupname- the name of the group to remove.- Throws:
OperationFailedException- underlying directory implementation failed to execute the operation.ApplicationPermissionException- if none of the application's associated directories are allowed to perform operations of typeOperationType.DELETE_GROUP.GroupNotFoundException- if group with given name does not exist in ANY assigned directory.
-
searchGroups
Description copied from interface:ApplicationServiceReturns a List<Group> matching the search criteria defined in the query for ALL of the active directories assigned to the application.The groups will be returned in a stable order including across pagination boundaries (excluding modification).
- Specified by:
searchGroupsin interfaceApplicationService- Parameters:
application- search application's assigned directories.query- the search query.- Returns:
- List<Group> group objects or List<String> groupnames, depending on the query.
-
addUserToGroup
public void addUserToGroup(Application application, String username, String groupName) throws OperationFailedException, ApplicationPermissionException, UserNotFoundException, GroupNotFoundException, MembershipAlreadyExistsException Description copied from interface:ApplicationServiceMakes the primary user of the given username a direct member of the group on the directory where the primary user resides.A user exists in one individual directory, however a group is thought to "span" all directories (users from different directories can belong to the same group). With this in mind, if the group does not exist in the User's directory (but does already exist), then this method will attempt to automatically add the group to that directory for you.
- Specified by:
addUserToGroupin interfaceApplicationService- Parameters:
application- modify groups in application's assigned directories.username- username of the user.groupName- name of the group.- Throws:
OperationFailedException- underlying directory implementation failed to execute the operation.ApplicationPermissionException- if the application's directory where the primary user resides does not allow operations of typeOperationType.UPDATE_GROUPor the group is readonly.UserNotFoundException- when the user cannot be found in ANY directoryGroupNotFoundException- when the group cannot be found in ANY directoryMembershipAlreadyExistsException- if the user is already a member of the group
-
addGroupToGroup
public void addGroupToGroup(Application application, String childGroupName, String parentGroupName) throws OperationFailedException, ApplicationPermissionException, GroupNotFoundException, InvalidMembershipException, MembershipAlreadyExistsException Description copied from interface:ApplicationServiceMakes groups matching the given name (childGroupName) direct members of the group (parentGroupName) across ALL active directories.- Specified by:
addGroupToGroupin interfaceApplicationService- Parameters:
application- modify groups in the application's assigned directories.childGroupName- name of child group.parentGroupName- name of parent group.- Throws:
OperationFailedException- underlying directory implementation failed to execute the operation.ApplicationPermissionException- if we were unable to create the membership in any directory. This is based on Edit permissions, Create permissions, and whether Nested Groups is supported by the individual directories.GroupNotFoundException- when the parent or child group do not existInvalidMembershipException- The child and parent are of different group types or would cause a circular reference.MembershipAlreadyExistsException- if the child group is already a child of the parent group
-
removeUserFromGroup
public void removeUserFromGroup(Application application, String username, String groupName) throws OperationFailedException, ApplicationPermissionException, MembershipNotFoundException, UserNotFoundException, GroupNotFoundException Description copied from interface:ApplicationServiceMakes the primary user of the given username no longer a member of the group on the directory where the primary user resides.- Specified by:
removeUserFromGroupin interfaceApplicationService- Parameters:
application- modify groups in application's assigned directories.username- username of the user.groupName- name of the group.- Throws:
OperationFailedException- underlying directory implementation failed to execute the operation.ApplicationPermissionException- if the application's directory where the primary user resides does not allow operations of typeOperationType.UPDATE_GROUP.MembershipNotFoundException- if the user is not a direct member of the group in an assigned directory.UserNotFoundException- when the user cannot be found in ANY directoryGroupNotFoundException- when the group does not exist in the directory where the primary user resides.
-
removeGroupFromGroup
public void removeGroupFromGroup(Application application, String childGroupName, String parentGroupName) throws OperationFailedException, ApplicationPermissionException, MembershipNotFoundException, GroupNotFoundException Description copied from interface:ApplicationServiceMakes child group matching the given name not members of the parent group across ALL active directories.- Specified by:
removeGroupFromGroupin interfaceApplicationService- Parameters:
application- modify groups in application's assigned directories.childGroupName- name of child group.parentGroupName- name of parent group.- Throws:
OperationFailedException- underlying directory implementation failed to execute the operation.ApplicationPermissionException- if none of the application's associated directories are allowed to perform operations of typeOperationType.UPDATE_GROUP.MembershipNotFoundException- if the user is not a direct member of the group in an assigned directory.GroupNotFoundException- when the child group cannot be found in ANY directory OR when ALL child groups are in directories which don't have the requested parent group.
-
isUserDirectGroupMember
Description copied from interface:ApplicationServiceReturnstrueif the user is a direct member of the group in the directory of the first user found with the specified username.- Specified by:
isUserDirectGroupMemberin interfaceApplicationService- Parameters:
application- search groups in application's assigned directories.username- name of the user to inspect.groupName- name of the group to inspect.- Returns:
trueif and only if the user is a direct member of the group. If the group or user does not exist in any directory,falseis returned.
-
isGroupDirectGroupMember
public boolean isGroupDirectGroupMember(Application application, String childGroup, String parentGroup) Description copied from interface:ApplicationServiceReturnstrueif the childGroup is a direct member of the parentGroup in any of the application's assigned directories.- Specified by:
isGroupDirectGroupMemberin interfaceApplicationService- Parameters:
application- search groups in application's assigned directories.childGroup- name of the group to inspect.parentGroup- name of the group to inspect.- Returns:
trueif and only if the childGroup is a direct member of the parentGroup. If either group does not exist in any directory,falseis returned.
-
isUserNestedGroupMember
Description copied from interface:ApplicationServiceReturnstrueif the user is a direct or indirect (nested) member of the group in the directory of the first user found with the specified username.If the directory does not support nested groups, this call will be equivalent to
DirectoryManager.isUserDirectGroupMember(long, String, String).WARNING: this method could be very slow if the underlying RemoteDirectory does not employ caching.
See CWD-1485 for explanation of logic in amalgamation.
Nesting is not resolved across directories.
- Specified by:
isUserNestedGroupMemberin interfaceApplicationService- Parameters:
application- search groups in application's assigned directories.username- name of the user to inspect.groupName- name of the group to inspect.- Returns:
trueif and only if the user is a direct or indirect (nested) member of the group. If the group or user does not exist in the directory,falseis returned.
-
isGroupNestedGroupMember
public boolean isGroupNestedGroupMember(Application application, String childGroup, String parentGroup) Description copied from interface:ApplicationServiceReturnstrueif the childGroup is a direct or indirect (nested) member of the parentGroup in any of the application's active assigned directories.If the directory does not support nested groups, this call will be equivalent to
DirectoryManager.isGroupDirectGroupMember(long, String, String).WARNING: this method could be very slow if the underlying RemoteDirectory does not employ caching.
See CWD-1485 for explanation of logic in amalgamation.
Nesting is not resolved across directories.
- Specified by:
isGroupNestedGroupMemberin interfaceApplicationService- Parameters:
application- search groups in application's assigned directories.childGroup- name of the user to inspect.parentGroup- name of the group to inspect.- Returns:
trueif and only if the childGroup is a direct or indirect (nested) member of the parentGroup. If either group does not exist in the directory,falseis returned.
-
searchDirectGroupRelationships
public <T> List<T> searchDirectGroupRelationships(Application application, MembershipQuery<T> query) Description copied from interface:ApplicationServiceSearches for direct group relationships in any of the application's active assigned directories. When searching for the groups an entity is a member of, themembership aggregation semanticwill determine whether only the owning directory (whenfalse) or all directories (whentrue) will be searched.- Specified by:
searchDirectGroupRelationshipsin interfaceApplicationService- Parameters:
application- search groups in application's assigned directories.query- membership query.- Returns:
- List of
Userentities,Groupentities,Stringusernames orStringgroup names matching the query criteria.
-
searchNestedGroupRelationships
public <T> List<T> searchNestedGroupRelationships(Application application, MembershipQuery<T> query) Description copied from interface:ApplicationServiceSearches for direct and indirect (nested) group relationships in any of the application's active assigned directories.If the directory does not support nested groups, this call will be equivalent to
DirectoryManager.searchDirectGroupRelationships(long, com.atlassian.crowd.search.query.membership.MembershipQuery).WARNING: this method could be very slow if the underlying RemoteDirectory does not employ caching.
When searching for the groups a user is a member of only the directory of the user (as determined by findUserByName) is searched. When searching for memberships of a group or groups a group is a member of all directories are searched and the results amalgamated.
- Specified by:
searchNestedGroupRelationshipsin interfaceApplicationService- Parameters:
application- search groups in application's assigned directories.query- membership query.- Returns:
- List of
Userentities,Groupentities,Stringusernames orStringgroup names matching the query criteria.
-
getCurrentEventToken
public String getCurrentEventToken(Application application) throws IncrementalSynchronisationNotAvailableException Description copied from interface:ApplicationServiceReturns a token that can be used for querying events that have happened after the token was generated.If the event token has not changed since the last call to this method, it is guaranteed that no new events have been received.
The format of event token is implementation specific and can change without a warning.
- Specified by:
getCurrentEventTokenin interfaceApplicationService- Parameters:
application- current application- Returns:
- token that can be used for querying events that have happened after the token was generated
- Throws:
IncrementalSynchronisationNotAvailableException- if the application cannot provide incremental synchronisation
-
getNewEvents
public Events getNewEvents(Application application, String eventToken) throws EventTokenExpiredException, OperationFailedException Description copied from interface:ApplicationServiceReturns an events object which contains a new eventToken and events that happened after the giveneventTokenwas generated.If for any reason event store is unable to retrieve events that happened after the event token was generated, an
EventTokenExpiredExceptionwill be thrown. The caller is then expected to callApplicationService.getCurrentEventToken(Application)again before asking for new events.- Specified by:
getNewEventsin interfaceApplicationService- Parameters:
application- return events visible to applicationeventToken- event token that was retrieved by a call toApplicationService.getCurrentEventToken(com.atlassian.crowd.model.application.Application)or this method- Returns:
- events object which contains a new eventToken and events that happened after the given
eventTokenwas generated - Throws:
EventTokenExpiredException- if events that happened after the event token was generated can not be retrievedOperationFailedException- if the operation has failed for any other reason, including invalid arguments
-
findWebhookById
public Webhook findWebhookById(Application application, long webhookId) throws WebhookNotFoundException, ApplicationPermissionException Description copied from interface:ApplicationServiceRetrieves a Webhook by its identifier. Identifiers are assigned when a Webhook is created.- Specified by:
findWebhookByIdin interfaceApplicationService- Parameters:
application- the application that owns the Webhook. Only the application that registered the Webhook is allowed to retrieve itwebhookId- Id of a Webhook, as returned byApplicationService.registerWebhook(com.atlassian.crowd.model.application.Application, String, String)- Returns:
- the Webhook
- Throws:
WebhookNotFoundException- if a Webhook with the given Id does not existApplicationPermissionException- if the Webhook exists, but was registered by a different application
-
registerWebhook
public Webhook registerWebhook(Application application, String endpointUrl, @Nullable String token) throws InvalidWebhookEndpointException Description copied from interface:ApplicationServiceRegisters a Webhook associated to the application.- Specified by:
registerWebhookin interfaceApplicationService- Parameters:
application- the application that owns the Webhook. Only this application will be able to unregister it later.endpointUrl- the application-provided HTTP endpoint that will be POST'ed by Crowd when new events are ready to be collected.token- the token Crowd will use to ping the Webhook endpoint (optional).- Returns:
- the new Webhook
- Throws:
InvalidWebhookEndpointException- whenendpointUrlis not a valid url
-
unregisterWebhook
public void unregisterWebhook(Application application, long webhookId) throws ApplicationPermissionException, WebhookNotFoundException Description copied from interface:ApplicationServiceUnregisters a Webhook. Only the application that created the Webhook can unregister it.- Specified by:
unregisterWebhookin interfaceApplicationService- Parameters:
application- the application that owns the Webhook.webhookId- the identifier of the Webhook that will be unregistered.- Throws:
ApplicationPermissionException- if the application is not the same that registered the Webhook.WebhookNotFoundException- if the Webhook is not found on the server
-
getCapabilitiesForNewUsers
Description copied from interface:ApplicationServiceGets the expected capabilities fornew users.Those capabilities reflects a specific moment in time and are subject to change if any user directory is added, removed or re-ordered.
- Specified by:
getCapabilitiesForNewUsersin interfaceApplicationService- Parameters:
application- the application the directories are assigned to- Returns:
- the capabilities a new user will have
- See Also:
-
getActiveDirectories
Given anapplication, retrieve all active directories associated with it.- Parameters:
application- application to query- Returns:
- list of active directories associated with
application - Since:
- 2.7.2
-
getUserAvatarLink
@Nullable public URI getUserAvatarLink(Application application, String username, int sizeHint) throws UserNotFoundException, DirectoryNotFoundException, OperationFailedException Description copied from interface:ApplicationServiceGets a URL for an avatar for this user, if one is available. This may point back to the same Crowd server or to another service. The URI should be evaluated relative to Crowd's base URL.- Specified by:
getUserAvatarLinkin interfaceApplicationServiceusername- the user to fetch an avatar for, as returned from afindmethodsizeHint- a hint in pixels for how large the image should be- Throws:
UserNotFoundExceptionDirectoryNotFoundExceptionOperationFailedException
-
getUserAvatar
@Nullable public AvatarReference getUserAvatar(Application application, String username, int sizeHint) throws UserNotFoundException, DirectoryNotFoundException, OperationFailedException Description copied from interface:ApplicationServiceGets an avatar for this user, if one is available. This may be a URL or a blob of image data. If it's a URI, it should be evaluated relative to Crowd's base URL.- Specified by:
getUserAvatarin interfaceApplicationServiceusername- the user to fetch an avatar for, as returned from afindmethodsizeHint- a hint in pixels for how large the image should be- Throws:
UserNotFoundExceptionDirectoryNotFoundExceptionOperationFailedException
-
expireAllPasswords
Description copied from interface:ApplicationServiceExpires all passwords for all directories which are part of this application, regardless of group mapping.- Specified by:
expireAllPasswordsin interfaceApplicationService- Parameters:
application- the application for which to expire all passwords in all mapped directories.- Throws:
OperationFailedException- if any of the directories fail to expire all passwords. This can lead to only some of the users having expired passwords.
-
userAuthenticated
public User userAuthenticated(Application application, String username) throws UserNotFoundException, OperationFailedException, InactiveAccountException - Specified by:
userAuthenticatedin interfaceApplicationService- Throws:
UserNotFoundExceptionOperationFailedExceptionInactiveAccountException
-
getMemberships
Description copied from interface:ApplicationServiceReturns all memberships for the given application.- Specified by:
getMembershipsin interfaceApplicationService- Parameters:
application- the application for which memberships will be returned- Returns:
- all memberships for the given application.
-
createPagedUserSearcher
public <T> PagedSearcher<T> createPagedUserSearcher(Application application, EntityQuery<T> query) throws PagingNotSupportedException Description copied from interface:ApplicationServiceCreates paged user searcher for a given user query. Use this method to avoid re-querying the same data and lower memory usage. Searcher never pre-fetches nor keeps more than requested batch size results per directory.- Specified by:
createPagedUserSearcherin interfaceApplicationService- Throws:
PagingNotSupportedException
-
createPagedGroupSearcher
public <T> PagedSearcher<T> createPagedGroupSearcher(Application application, EntityQuery<T> query) throws PagingNotSupportedException Description copied from interface:ApplicationServiceCreates paged group searcher for a given group query. Use this method to avoid re-querying the same data and lower memory usage. Searcher never pre-fetches nor keeps more than requested batch size results per directory.- Specified by:
createPagedGroupSearcherin interfaceApplicationService- Throws:
PagingNotSupportedException
-