@Transactional public class DirectoryManagerGeneric extends Object implements DirectoryManager
Constructor and Description |
---|
DirectoryManagerGeneric(DirectoryDao directoryDao,
ApplicationDAO applicationDAO,
MultiEventPublisher eventPublisher,
PermissionManager permissionManager,
DirectoryInstanceLoader directoryInstanceLoader,
DirectorySynchroniser directorySynchroniser,
DirectoryPollerManager directoryPollerManager,
com.atlassian.beehive.ClusterLockService lockService,
SynchronisationStatusManager synchronisationStatusManager,
BeforeGroupRemoval beforeGroupRemoval,
Optional<NestedGroupsCacheProvider> nestedGroupsCacheProvider) |
Modifier and Type | Method and Description |
---|---|
BulkAddResult<Group> |
addAllGroups(long directoryId,
Collection<GroupTemplate> groups,
boolean overwrite)
Will add a collection of Group to the directory specified by the passed in
directoryId param. |
BulkAddResult<User> |
addAllUsers(long directoryId,
Collection<UserTemplateWithCredentialAndAttributes> users,
boolean overwrite)
Will add a collection of users to the directory specified by the passed in
directoryId param. |
BulkAddResult<String> |
addAllUsersToGroup(long directoryId,
Collection<String> userNames,
String groupName)
A bulk version of
DirectoryManager.addUserToGroup(long, String, String) . |
Directory |
addDirectory(Directory directory)
Adds the given directory.
|
Group |
addGroup(long directoryId,
GroupTemplate group)
Adds a Group to the directory specified by the passed in
directoryId . |
void |
addGroupToGroup(long directoryId,
String childGroup,
String parentGroup)
Adds an existing child group as direct member of an existing parent group in the directory specified by the passed in
directoryId . |
User |
addUser(long directoryId,
UserTemplate user,
PasswordCredential credential)
Adds a
User to the directory specified by the passed in directoryId . |
UserWithAttributes |
addUser(long directoryId,
UserTemplateWithAttributes user,
PasswordCredential credential)
Adds a
UserWithAttributes to the directory specified by the passed in directoryId . |
void |
addUserToGroup(long directoryId,
String username,
String groupName)
Adds an existing user as a direct member of an existing group in the directory specified by the passed in
directoryId . |
User |
authenticateUser(long directoryId,
String username,
PasswordCredential passwordCredential) |
BoundedCount |
countDirectMembersOfGroup(long directoryId,
String groupName,
int querySizeHint)
Count the direct members of a group in the provided directory with an upper bound.
|
void |
expireAllPasswords(long directoryId)
Sets the
UserConstants.REQUIRES_PASSWORD_CHANGE attribute to true for
all users in the directory |
Set<String> |
filterNestedUserMembersOfGroups(long directoryId,
Set<String> userNames,
Set<String> groupNames)
Returns names of users who are (nested) members of any of the specified groups.
|
List<Directory> |
findAllDirectories()
Returns a List of all directories in the system.
|
List<Application> |
findAuthorisedApplications(long directoryId,
List<String> groupNames)
Finds all applications that a user from a given directory belonging to the specified groups can authenticate to.
|
Directory |
findDirectoryById(long directoryId)
Returns a Directory based on the passed in
directoryId . |
Directory |
findDirectoryByName(String name)
Finds a directory given the supplied
name . |
Group |
findGroupByName(long directoryId,
String groupName)
Returns the group matching the supplied groupName in the directory specified by the passed in
directoryId .. |
GroupWithAttributes |
findGroupWithAttributesByName(long directoryId,
String groupName)
Returns the group with all attributes matching the supplied groupName in the directory specified by the passed in
directoryId .. |
User |
findRemoteUserByName(Long directoryId,
String username)
Returns the user matching the supplied username in the authoritative remote directory specified by the
passed in
directoryId |
User |
findUserByExternalId(long directoryId,
String externalId)
Returns the user matching the supplied external ID in the directory specified by the passed in
directoryId . |
User |
findUserByName(long directoryId,
String username)
Returns the user matching the supplied username in the directory specified by the passed in
directoryId .. |
UserWithAttributes |
findUserWithAttributesByExternalId(long directoryId,
String externalId)
Returns the user (with attributes) matching the supplied external ID in the directory specified by the
passed in
directoryId . |
UserWithAttributes |
findUserWithAttributesByName(long directoryId,
String username)
Returns the user with all attributes matching the supplied username in the directory specified by the passed in
directoryId .. |
DirectorySynchronisationInformation |
getDirectorySynchronisationInformation(long directoryId)
Retrieves the sync info for the directory - last sync start time & duration, current sync start time (if directory is currently synchronising)
|
SynchronisationMode |
getSynchronisationMode(long directoryId)
Returns the preferred synchronisation mode defined for the directory if
synchronisable , else null |
AvatarReference |
getUserAvatarByName(long directoryId,
String username,
int sizeHint)
Return an avatar, if available, for the named user in the specified directory.
|
boolean |
isGroupDirectGroupMember(long directoryId,
String childGroup,
String parentGroup)
Returns
true if the childGroup is a direct member of the parentGroup in the directory specified by the passed in directoryId . |
boolean |
isGroupNestedGroupMember(long directoryId,
String childGroupName,
String parentGroupName)
Returns
true if the childGroup is a direct or indirect (nested) member of the parentGroup in the directory specified by the passed in directoryId . |
boolean |
isSynchronisable(long directoryId)
Returns true if the underlying directory implementation supports manual synchronisation of the directory's local cache.
|
boolean |
isSynchronising(long directoryId)
Returns true if the given Directory is currently synchronising.
|
boolean |
isUserDirectGroupMember(long directoryId,
String username,
String groupName)
Returns
true if the user is a direct member of the group in the directory specified by the passed in directoryId . |
boolean |
isUserNestedGroupMember(long directoryId,
String username,
Set<String> groupNames)
Returns
true if the user is a direct or indirect (nested) member of any of the specified groups in the directory specified by the passed in directoryId . |
boolean |
isUserNestedGroupMember(long directoryId,
String username,
String groupName)
Returns
true if the user is a direct or indirect (nested) member of the group in the directory specified by the passed in directoryId . |
void |
removeDirectory(Directory directory)
Removes a given directory and all its associated entities and mappings.
|
void |
removeGroup(long directoryId,
String groupName)
Removes a group matching the supplied groupName in the directory specified by the passed in
directoryId . |
void |
removeGroupAttributes(long directoryId,
String groupName,
String attributeName)
Removes a group's attribute values in the directory specified by the passed in
directoryId . |
void |
removeGroupFromGroup(long directoryId,
String childGroup,
String parentGroup)
Removes an existing child group from being a direct member of an existing parent group in the directory specified by the passed in
directoryId . |
void |
removeUser(long directoryId,
String username)
Removes a user matching the supplied username in the directory specified by the passed in
directoryId . |
void |
removeUserAttributes(long directoryId,
String username,
String attributeName)
Removes a user's attribute values in the directory specified by the passed in
directoryId . |
void |
removeUserFromGroup(long directoryId,
String username,
String groupName)
Removes an existing user from being a direct member of an existing group in the directory specified by the passed in
directoryId . |
Group |
renameGroup(long directoryId,
String oldGroupname,
String newGroupname)
Renames a group in the directory specified by the passed in
directoryId . |
User |
renameUser(long directoryId,
String oldUsername,
String newUsername)
Renames a user in the directory specified by the passed in
directoryId . |
<T> List<T> |
searchDirectGroupRelationships(long directoryId,
MembershipQuery<T> query)
Searches for direct group relationships in the directory specified by the passed in
directoryId . |
List<Directory> |
searchDirectories(EntityQuery<Directory> query)
Returns a List of Directories matching the search query.
|
<T> List<T> |
searchGroups(long directoryId,
EntityQuery<T> query)
Returns a list of groups matching the given query in the directory specified by the passed in
directoryId . |
<T> List<T> |
searchNestedGroupRelationships(long directoryId,
MembershipQuery<T> query)
Searches for direct and indirect (nested) group relationships in the directory specified by the passed in
directoryId . |
<T> List<T> |
searchUsers(long directoryId,
EntityQuery<T> query)
Returns a list of users matching the given query in the directory specified by the passed in
directoryId . |
void |
storeGroupAttributes(long directoryId,
String groupName,
Map<String,Set<String>> attributes)
Adds or updates a group's attributes with the new Map of attribute values in the directory specified by the passed in
directoryId . |
void |
storeUserAttributes(long directoryId,
String username,
Map<String,Set<String>> attributes)
Adds or updates a user's attributes with the new Map of attribute values in the directory specified by the passed in
directoryId . |
boolean |
supportsExpireAllPasswords(long directoryId)
Returns true if the underlying directory implementation supports expiring passwords
|
boolean |
supportsNestedGroups(long directoryId)
Returns true if the underlying directory implementation supports nested groups.
|
void |
synchroniseCache(long directoryId,
SynchronisationMode mode)
Requests that this directory should update its cache by synchronising with the remote User data.
|
void |
synchroniseCache(long directoryId,
SynchronisationMode mode,
boolean runInBackground)
Requests that this directory should update its cache by synchronising with the remote User data.
|
Directory |
updateDirectory(Directory directory)
Updates the passed in directory.
|
Group |
updateGroup(long directoryId,
GroupTemplate group)
Updates a group with the supplied template and returns the updated group retrieved from the directory specified by the passed in
directoryId . |
User |
updateUser(long directoryId,
UserTemplate user)
Updates a user with the supplied template and returns the updated user retrieved from the directory specified by the passed in
directoryId . |
void |
updateUserCredential(long directoryId,
String username,
PasswordCredential credential)
This will update the user's credential in the given directory specified by the passed in
directoryId . |
User |
updateUserFromRemoteDirectory(User remoteUser)
Updates the user details for the specified user based on the details in the remote directory.
|
User |
userAuthenticated(long directoryId,
String username) |
public DirectoryManagerGeneric(DirectoryDao directoryDao, ApplicationDAO applicationDAO, MultiEventPublisher eventPublisher, PermissionManager permissionManager, DirectoryInstanceLoader directoryInstanceLoader, DirectorySynchroniser directorySynchroniser, DirectoryPollerManager directoryPollerManager, com.atlassian.beehive.ClusterLockService lockService, SynchronisationStatusManager synchronisationStatusManager, BeforeGroupRemoval beforeGroupRemoval, Optional<NestedGroupsCacheProvider> nestedGroupsCacheProvider)
public Directory addDirectory(Directory directory) throws DirectoryInstantiationException
DirectoryManager
addDirectory
in interface DirectoryManager
directory
- the Directory to addDirectoryInstantiationException
- if there was an error instantiating the directorypublic Directory findDirectoryById(long directoryId) throws DirectoryNotFoundException
DirectoryManager
directoryId
.findDirectoryById
in interface DirectoryManager
directoryId
- the id of the directory to findDirectoryNotFoundException
- is thrown if the Directory cannot be found.public List<Directory> findAllDirectories()
DirectoryManager
findAllDirectories
in interface DirectoryManager
public List<Directory> searchDirectories(EntityQuery<Directory> query)
DirectoryManager
searchDirectories
in interface DirectoryManager
query
- the context to search onpublic Directory findDirectoryByName(String name) throws DirectoryNotFoundException
DirectoryManager
name
.findDirectoryByName
in interface DirectoryManager
name
- the name of the directoryname
DirectoryNotFoundException
- if no Directory is foundpublic Directory updateDirectory(Directory directory) throws DirectoryNotFoundException
DirectoryManager
updateDirectory
in interface DirectoryManager
directory
- the directory with updated attributesDirectoryNotFoundException
- if no Directory is foundpublic void removeDirectory(Directory directory) throws DirectoryNotFoundException, DirectoryCurrentlySynchronisingException
DirectoryManager
removeDirectory
in interface DirectoryManager
directory
- the directory to removeDirectoryNotFoundException
- if the directory cannot be foundDirectoryCurrentlySynchronisingException
- if the directory is currently synchronisingpublic boolean supportsNestedGroups(long directoryId) throws DirectoryInstantiationException, DirectoryNotFoundException
DirectoryManager
supportsNestedGroups
in interface DirectoryManager
directoryId
- ID of directory.DirectoryInstantiationException
- if there was an error instantiating the directoryDirectoryNotFoundException
- if the directory could not be found.public boolean isSynchronisable(long directoryId) throws DirectoryInstantiationException, DirectoryNotFoundException
DirectoryManager
That is if we keep a local cache that is periodically updated from the remote server.
If a directory is synchronisable (i.e. isSynchronisable
returns true
, it is safe to cast the
directory with the given ID into a SynchronisableDirectory
.
isSynchronisable
in interface DirectoryManager
directoryId
- ID of directory.DirectoryInstantiationException
- if there was an error instantiating the directoryDirectoryNotFoundException
- if the directory could not be found.public SynchronisationMode getSynchronisationMode(long directoryId) throws DirectoryInstantiationException, DirectoryNotFoundException
DirectoryManager
synchronisable
, else null
getSynchronisationMode
in interface DirectoryManager
directoryId
- ID of the directorySynchronisationMode
for a synchronisable directory, null
otherwise.DirectoryInstantiationException
DirectoryNotFoundException
public void synchroniseCache(long directoryId, SynchronisationMode mode) throws OperationFailedException, DirectoryNotFoundException
DirectoryManager
If a synchronisation is currently in progress when this method is called, then this method does nothing.
synchroniseCache
in interface DirectoryManager
directoryId
- ID of directory.mode
- the mode of the synchronisationOperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryNotFoundException
- if the directory could not be found.public void synchroniseCache(long directoryId, SynchronisationMode mode, boolean runInBackground) throws OperationFailedException, DirectoryNotFoundException
DirectoryManager
If a synchronisation is currently in progress when this method is called, then this method does nothing if runInBackGround is true, otherwise it will throw OperationFailedException.
synchroniseCache
in interface DirectoryManager
directoryId
- ID of directory.mode
- the mode of the synchronisationrunInBackground
- If True the synchronise will happen asynchronously.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryNotFoundException
- if the directory could not be found.public boolean isSynchronising(long directoryId) throws DirectoryInstantiationException, DirectoryNotFoundException
DirectoryManager
isSynchronising
in interface DirectoryManager
directoryId
- ID of directory.DirectoryInstantiationException
- if there was an error instantiating the directoryDirectoryNotFoundException
- if the directory could not be foundpublic DirectorySynchronisationInformation getDirectorySynchronisationInformation(long directoryId) throws DirectoryInstantiationException, DirectoryNotFoundException
DirectoryManager
getDirectorySynchronisationInformation
in interface DirectoryManager
directoryId
- ID of directoryDirectoryInstantiationException
- if there was an error instantiating the directoryDirectoryNotFoundException
- if the directory could not be found.public User authenticateUser(long directoryId, String username, PasswordCredential passwordCredential) throws OperationFailedException, InactiveAccountException, InvalidAuthenticationException, ExpiredCredentialException, DirectoryNotFoundException, UserNotFoundException
authenticateUser
in interface DirectoryManager
directoryId
- the id of the directory to authenticate againstusername
- the username to use for authenticationpasswordCredential
- the credential to use for authenticationOperationFailedException
- underlying directory implementation failed to execute the operation.InactiveAccountException
- if the user account is inactiveInvalidAuthenticationException
- if authentication with the provided credentials failedExpiredCredentialException
- if the credentials of the user have expired.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.UserNotFoundException
- if no user with the supplied username exists in the directorypublic User userAuthenticated(long directoryId, String username) throws OperationFailedException, DirectoryNotFoundException, UserNotFoundException, InactiveAccountException
userAuthenticated
in interface DirectoryManager
OperationFailedException
DirectoryNotFoundException
UserNotFoundException
InactiveAccountException
public User findUserByName(long directoryId, String username) throws OperationFailedException, DirectoryNotFoundException, UserNotFoundException
DirectoryManager
directoryId
..findUserByName
in interface DirectoryManager
directoryId
- ID of the directory to search.username
- username of the user to retrieve.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.UserNotFoundException
- if no user with the supplied username exists in the directoryDirectoryManager.findUserWithAttributesByName(long, String)
public UserWithAttributes findUserWithAttributesByName(long directoryId, String username) throws OperationFailedException, DirectoryNotFoundException, UserNotFoundException
DirectoryManager
directoryId
..findUserWithAttributesByName
in interface DirectoryManager
directoryId
- ID of the directory to search.username
- username of the user to retrieve.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.UserNotFoundException
- if no user with the supplied username exists in the directoryDirectoryManager.findUserByName(long, String)
public <T> List<T> searchUsers(long directoryId, EntityQuery<T> query) throws OperationFailedException, DirectoryNotFoundException
DirectoryManager
directoryId
.
The users will be returned in a stable order including across pagination boundaries (excluding modification).
searchUsers
in interface DirectoryManager
directoryId
- ID of the directory to search.query
- query to exectute.User
entities or String
usernames matching the query criteria.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.public User addUser(long directoryId, UserTemplate user, PasswordCredential credential) throws InvalidCredentialException, InvalidUserException, OperationFailedException, DirectoryPermissionException, DirectoryNotFoundException, UserAlreadyExistsException
DirectoryManager
User
to the directory specified by the passed in directoryId
.addUser
in interface DirectoryManager
directoryId
- ID of the directory to add the user to.user
- a UserTemplate
of the user to be added.credential
- the password credential of the user (unencrypted).InvalidCredentialException
- if the user's credential does not meet the validation requirements for the given directory.InvalidUserException
- if the user template does not have the required properties populated.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryPermissionException
- if the directory is not allowed to perform operations of type OperationType.CREATE_USER
.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.UserAlreadyExistsException
- if the user already exists in the given directorypublic UserWithAttributes addUser(long directoryId, UserTemplateWithAttributes user, PasswordCredential credential) throws InvalidCredentialException, InvalidUserException, OperationFailedException, DirectoryPermissionException, DirectoryNotFoundException, UserAlreadyExistsException
DirectoryManager
UserWithAttributes
to the directory specified by the passed in directoryId
.addUser
in interface DirectoryManager
directoryId
- ID of the directory to add the user to.user
- a UserTemplateWithAttributes
of the user to be added.credential
- the password credential of the user (unencrypted).InvalidCredentialException
- if the user's credential does not meet the validation requirements for the given directory.InvalidUserException
- if the user template does not have the required properties populated.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryPermissionException
- if the directory is not allowed to perform operations of type OperationType.CREATE_USER
.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.UserAlreadyExistsException
- if the user already exists in the given directorypublic User updateUser(long directoryId, UserTemplate user) throws OperationFailedException, DirectoryPermissionException, InvalidUserException, DirectoryNotFoundException, UserNotFoundException
DirectoryManager
directoryId
.
This method cannot be used to rename the user, update the user's credentials or update the user's custom attributes.
updateUser
in interface DirectoryManager
directoryId
- ID of the directory to find and update the user.user
- template of the user to update.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryPermissionException
- if the directory is not allowed to perform operations of type OperationType.UPDATE_USER
.InvalidUserException
- the user template does not have the required properties populated.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.UserNotFoundException
- if no user with the supplied username exists in the directoryDirectoryManager.renameUser(long, String, String)
,
DirectoryManager.updateUserCredential(long, String, com.atlassian.crowd.embedded.api.PasswordCredential)
,
DirectoryManager.storeUserAttributes(long, String, java.util.Map)
,
DirectoryManager.removeUserAttributes(long, String, String)
public User renameUser(long directoryId, String oldUsername, String newUsername) throws OperationFailedException, DirectoryPermissionException, InvalidUserException, DirectoryNotFoundException, UserNotFoundException, UserAlreadyExistsException
DirectoryManager
directoryId
.renameUser
in interface DirectoryManager
directoryId
- ID of the directory to find and update the user.oldUsername
- current username of the user.newUsername
- desired username of the user.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryPermissionException
- if the directory is not allowed to perform operations of type OperationType.UPDATE_USER
.InvalidUserException
- if the new username does not meet the username requirements of the directoryDirectoryNotFoundException
- if the directory with the given directoryId cannot be found.UserNotFoundException
- if no user with the supplied username exists in the directoryUserAlreadyExistsException
- if the newUsername user already exists in the given directorypublic void storeUserAttributes(long directoryId, String username, Map<String,Set<String>> attributes) throws OperationFailedException, DirectoryPermissionException, DirectoryNotFoundException, UserNotFoundException
DirectoryManager
directoryId
.
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.
storeUserAttributes
in interface DirectoryManager
directoryId
- ID of the directory to find and update the user.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.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryPermissionException
- if the directory is not allowed to perform operations of type OperationType.UPDATE_USER_ATTRIBUTE
.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.UserNotFoundException
- if no user with the supplied username exists in the directoryDirectoryManager.updateUser(long, com.atlassian.crowd.model.user.UserTemplate)
public void removeUserAttributes(long directoryId, String username, String attributeName) throws OperationFailedException, DirectoryPermissionException, DirectoryNotFoundException, UserNotFoundException
DirectoryManager
directoryId
.removeUserAttributes
in interface DirectoryManager
directoryId
- ID of the directory to find and update the user.username
- username of the user to update.attributeName
- all attribute values for this key will be removed from the user.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryPermissionException
- if the directory is not allowed to perform operations of type OperationType.UPDATE_USER_ATTRIBUTE
.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.UserNotFoundException
- if no user with the supplied username exists in the directoryDirectoryManager.updateUser(long, com.atlassian.crowd.model.user.UserTemplate)
public void updateUserCredential(long directoryId, String username, PasswordCredential credential) throws OperationFailedException, DirectoryPermissionException, InvalidCredentialException, DirectoryNotFoundException, UserNotFoundException
DirectoryManager
directoryId
.updateUserCredential
in interface DirectoryManager
directoryId
- ID of the directory to find and update the user.username
- username of the user to update.credential
- the new password credential for the user (unencrypted).OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryPermissionException
- if the directory is not allowed to perform operations of type OperationType.UPDATE_USER
.InvalidCredentialException
- if the new credential does not meet the requirements for the given directory.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.UserNotFoundException
- if no user with the supplied username exists in the directorypublic void removeUser(long directoryId, String username) throws DirectoryPermissionException, OperationFailedException, DirectoryNotFoundException, UserNotFoundException
DirectoryManager
directoryId
.removeUser
in interface DirectoryManager
directoryId
- ID of the directory to remove the user from.username
- username of the user to remove.DirectoryPermissionException
- if the directory is not allowed to perform operations of type OperationType.DELETE_USER
.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.UserNotFoundException
- if no user with the supplied username exists in the directorypublic Group findGroupByName(long directoryId, String groupName) throws OperationFailedException, GroupNotFoundException, DirectoryNotFoundException
DirectoryManager
directoryId
..findGroupByName
in interface DirectoryManager
directoryId
- ID of the directory to search.groupName
- groupName of the group to retrieve.OperationFailedException
- underlying directory implementation failed to execute the operation.GroupNotFoundException
- if no group with the supplied groupName exists in the directoryDirectoryNotFoundException
- if the directory with the given directoryId cannot be found.DirectoryManager.findGroupWithAttributesByName(long, String)
public GroupWithAttributes findGroupWithAttributesByName(long directoryId, String groupName) throws OperationFailedException, GroupNotFoundException, DirectoryNotFoundException
DirectoryManager
directoryId
..findGroupWithAttributesByName
in interface DirectoryManager
directoryId
- ID of the directory to search.groupName
- groupName of the group to retrieve.OperationFailedException
- underlying directory implementation failed to execute the operation.GroupNotFoundException
- if no group with the supplied groupName exists in the directoryDirectoryNotFoundException
- if the directory with the given directoryId cannot be found.DirectoryManager.findGroupByName(long, String)
public <T> List<T> searchGroups(long directoryId, EntityQuery<T> query) throws OperationFailedException, DirectoryNotFoundException
DirectoryManager
directoryId
.
The groups will be returned in a stable order including across pagination boundaries (excluding modification).
searchGroups
in interface DirectoryManager
directoryId
- ID of the directory to search.query
- query to exectute.Group
entities or String
groupNames matching the query criteria.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.public Group addGroup(long directoryId, GroupTemplate group) throws InvalidGroupException, OperationFailedException, DirectoryPermissionException, DirectoryNotFoundException
DirectoryManager
directoryId
.addGroup
in interface DirectoryManager
directoryId
- ID of the directory to add the group to.group
- a template of the group to be added.InvalidGroupException
- if the group already exists in the given directory.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryPermissionException
- if the directory is not allowed to perform operations of type OperationType.CREATE_GROUP
.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found after the add operation.public Group updateGroup(long directoryId, GroupTemplate group) throws OperationFailedException, DirectoryPermissionException, InvalidGroupException, DirectoryNotFoundException, GroupNotFoundException, ReadOnlyGroupException
DirectoryManager
directoryId
.
This method cannot be used to rename the group, update the group's credentials or update the group's custom attributes.
updateGroup
in interface DirectoryManager
directoryId
- ID of the directory to find and update the group.group
- template of the group to update.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryPermissionException
- if the directory is not allowed to perform operations of type OperationType.UPDATE_GROUP
.InvalidGroupException
- if the group template does not have the required properties populated.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.GroupNotFoundException
- if no group with the supplied groupName exists in the directoryReadOnlyGroupException
- if the group is read-onlyDirectoryManager.renameGroup(long, String, String)
,
DirectoryManager.storeGroupAttributes(long, String, java.util.Map)
,
DirectoryManager.removeGroupAttributes(long, String, String)
public Group renameGroup(long directoryId, String oldGroupname, String newGroupname) throws OperationFailedException, DirectoryPermissionException, InvalidGroupException, DirectoryNotFoundException, GroupNotFoundException
DirectoryManager
directoryId
.renameGroup
in interface DirectoryManager
directoryId
- ID of the directory to find and update the group.oldGroupname
- current groupName of the group.newGroupname
- desired groupName of the group.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryPermissionException
- if the directory is not allowed to perform operations of type OperationType.UPDATE_GROUP
.InvalidGroupException
- if the new groupName does not meet the groupName requirements of the directory or if a group already exists with the new groupName.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.GroupNotFoundException
- if the group with the oldGroupname does not exist in the directory or if the directory with the given directoryId cannot be found.public void storeGroupAttributes(long directoryId, String groupName, Map<String,Set<String>> attributes) throws OperationFailedException, DirectoryPermissionException, DirectoryNotFoundException, GroupNotFoundException
DirectoryManager
directoryId
.
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.
storeGroupAttributes
in interface DirectoryManager
directoryId
- ID of the directory to find and update the group.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.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryPermissionException
- if the directory is not allowed to perform operations of type OperationType.UPDATE_GROUP_ATTRIBUTE
.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.GroupNotFoundException
- if no group with the supplied groupName exists in the directoryDirectoryManager.updateGroup(long, com.atlassian.crowd.model.group.GroupTemplate)
public void removeGroupAttributes(long directoryId, String groupName, String attributeName) throws OperationFailedException, DirectoryPermissionException, DirectoryNotFoundException, GroupNotFoundException
DirectoryManager
directoryId
.removeGroupAttributes
in interface DirectoryManager
directoryId
- ID of the directory to find and update the group.groupName
- groupName of the group to update.attributeName
- all attribute values for this key will be removed from the group.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryPermissionException
- if the directory is not allowed to perform operations of type OperationType.UPDATE_GROUP_ATTRIBUTE
.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.GroupNotFoundException
- if no group with the supplied groupName exists in the directoryDirectoryManager.updateGroup(long, com.atlassian.crowd.model.group.GroupTemplate)
public void removeGroup(long directoryId, String groupName) throws DirectoryPermissionException, OperationFailedException, DirectoryNotFoundException, GroupNotFoundException, ReadOnlyGroupException
DirectoryManager
directoryId
.removeGroup
in interface DirectoryManager
directoryId
- ID of the directory to remove the group from.groupName
- groupName of the group to remove.DirectoryPermissionException
- if the directory is not allowed to perform operations of type OperationType.DELETE_GROUP
.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.GroupNotFoundException
- if no group with the supplied groupName exists in the directoryReadOnlyGroupException
- if the group is read-onlypublic boolean isUserDirectGroupMember(long directoryId, String username, String groupName) throws OperationFailedException, DirectoryNotFoundException
DirectoryManager
true
if the user is a direct member of the group in the directory specified by the passed in directoryId
.isUserDirectGroupMember
in interface DirectoryManager
directoryId
- ID of the directory to inspect membership information.username
- name of the user to inspect.groupName
- name of the group to inspect.true
if and only if the user is a direct member of the group. If the group or user does not exist in the directory, false
is returned.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.public boolean isGroupDirectGroupMember(long directoryId, String childGroup, String parentGroup) throws OperationFailedException, DirectoryNotFoundException
DirectoryManager
true
if the childGroup is a direct member of the parentGroup in the directory specified by the passed in directoryId
.isGroupDirectGroupMember
in interface DirectoryManager
directoryId
- ID of the directory to inspect membership information.childGroup
- name of the group to inspect.parentGroup
- name of the group to inspect.true
if and only if the childGroup is a direct member of the parentGroup. If either group does not exist in the directory, false
is returned.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.public void addUserToGroup(long directoryId, String username, String groupName) throws DirectoryPermissionException, OperationFailedException, DirectoryNotFoundException, GroupNotFoundException, UserNotFoundException, ReadOnlyGroupException, MembershipAlreadyExistsException
DirectoryManager
directoryId
.addUserToGroup
in interface DirectoryManager
directoryId
- ID of the directory to add membership information.username
- username of the user.groupName
- name of the group.DirectoryPermissionException
- if the directory is not allowed to perform operations of type OperationType.UPDATE_GROUP
.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.GroupNotFoundException
- if the group does not exist in the directoryUserNotFoundException
- if the user does not exist in the directoryReadOnlyGroupException
- if the group is read-onlyMembershipAlreadyExistsException
- if the user is already a member of the grouppublic void addGroupToGroup(long directoryId, String childGroup, String parentGroup) throws DirectoryPermissionException, OperationFailedException, InvalidMembershipException, NestedGroupsNotSupportedException, DirectoryNotFoundException, GroupNotFoundException, ReadOnlyGroupException, MembershipAlreadyExistsException
DirectoryManager
directoryId
.addGroupToGroup
in interface DirectoryManager
directoryId
- ID of the directory to add membership information.childGroup
- name of child group.parentGroup
- name of the parent group.DirectoryPermissionException
- if the directory is not allowed to perform operations of type OperationType.UPDATE_GROUP
.OperationFailedException
- underlying directory implementation failed to execute the operation.InvalidMembershipException
- GroupType of childGroup does not match parentGroup.NestedGroupsNotSupportedException
- If the directory does not support nested groups.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.GroupNotFoundException
- if the group does not exist in the directoryReadOnlyGroupException
- if the group is read-onlyMembershipAlreadyExistsException
- if the child group is already a child of the parent grouppublic void removeUserFromGroup(long directoryId, String username, String groupName) throws DirectoryPermissionException, OperationFailedException, MembershipNotFoundException, DirectoryNotFoundException, GroupNotFoundException, UserNotFoundException, ReadOnlyGroupException
DirectoryManager
directoryId
.removeUserFromGroup
in interface DirectoryManager
directoryId
- ID of the directory to add membership information.username
- username of the user.groupName
- name of the group.DirectoryPermissionException
- if the directory is not allowed to perform operations of type OperationType.UPDATE_GROUP
.OperationFailedException
- underlying directory implementation failed to execute the operation.MembershipNotFoundException
- user is not a direct member of group.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.GroupNotFoundException
- if the group does not exist in the directoryUserNotFoundException
- if the user does not exist in the directoryReadOnlyGroupException
- if the group is read-onlypublic void removeGroupFromGroup(long directoryId, String childGroup, String parentGroup) throws DirectoryPermissionException, OperationFailedException, InvalidMembershipException, MembershipNotFoundException, DirectoryNotFoundException, GroupNotFoundException, ReadOnlyGroupException
DirectoryManager
directoryId
.removeGroupFromGroup
in interface DirectoryManager
directoryId
- ID of the directory to add membership information.childGroup
- name of child group.parentGroup
- name of the parent group.DirectoryPermissionException
- if the directory is not allowed to perform operations of type OperationType.UPDATE_GROUP
.OperationFailedException
- underlying directory implementation failed to execute the operation.InvalidMembershipException
- GroupType of childGroup does not match parentGroup.MembershipNotFoundException
- group is not a direct member of group.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.GroupNotFoundException
- if the group does not exist in the directoryReadOnlyGroupException
- if the group is read-onlypublic <T> List<T> searchDirectGroupRelationships(long directoryId, MembershipQuery<T> query) throws OperationFailedException, DirectoryNotFoundException
DirectoryManager
directoryId
.searchDirectGroupRelationships
in interface DirectoryManager
directoryId
- ID of the directory to inspect membership information.query
- membership query.User
entities,
Group
entites,
String
usernames or String
group names matching the query criteria. If there are no
results, returns an empty List.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.public BoundedCount countDirectMembersOfGroup(long directoryId, String groupName, int querySizeHint) throws OperationFailedException, DirectoryNotFoundException
DirectoryManager
countDirectMembersOfGroup
in interface DirectoryManager
groupName
- the name of the group to search forquerySizeHint
- hinting at the maximum number of memberships that should be counted. The directory that
implements this may choose to count less or more. This is a user provided suggestion for potential efficiency.OperationFailedException
- if we failed to count the number of memberships for that group in the given directory.DirectoryNotFoundException
- if a directory for the provided id could not be found.@Transactional(readOnly=true) public boolean isUserNestedGroupMember(long directoryId, String username, String groupName) throws OperationFailedException, DirectoryNotFoundException
DirectoryManager
true
if the user is a direct or indirect (nested) member of the group in the directory specified by the passed in directoryId
.
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.
isUserNestedGroupMember
in interface DirectoryManager
directoryId
- ID of the directory to inspect membership information.username
- name of the user to inspect.groupName
- name of the group to inspect.true
if 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, false
is returned.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.@Transactional(readOnly=true) public boolean isUserNestedGroupMember(long directoryId, String username, Set<String> groupNames) throws OperationFailedException, DirectoryNotFoundException
DirectoryManager
true
if the user is a direct or indirect (nested) member of any of the specified groups in the directory specified by the passed in directoryId
.
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.
isUserNestedGroupMember
in interface DirectoryManager
directoryId
- ID of the directory to inspect membership information.username
- name of the user to inspect.groupNames
- names of the group to inspect.true
if and only if the user is a direct or indirect (nested) member of any of the specified groups.
If the groups or user do not exist in the directory, false
is returned.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.@Transactional(readOnly=true) public Set<String> filterNestedUserMembersOfGroups(long directoryId, Set<String> userNames, Set<String> groupNames) throws OperationFailedException, DirectoryNotFoundException
DirectoryManager
filterNestedUserMembersOfGroups
in interface DirectoryManager
directoryId
- ID of the directory to inspect membership information.userNames
- names of users to inspect.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.@Transactional(readOnly=true) public boolean isGroupNestedGroupMember(long directoryId, String childGroupName, String parentGroupName) throws OperationFailedException, DirectoryNotFoundException
DirectoryManager
true
if the childGroup is a direct or indirect (nested) member of the parentGroup in the directory specified by the passed in directoryId
.
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.
isGroupNestedGroupMember
in interface DirectoryManager
directoryId
- ID of the directory to inspect membership information.childGroupName
- name of the user to inspect.parentGroupName
- name of the group to inspect.true
if and only if the childGroup is a direct or indirect (nested) member of the parentGruop. If either group does not exist in the directory, false
is returned.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.@Transactional(readOnly=true) public <T> List<T> searchNestedGroupRelationships(long directoryId, MembershipQuery<T> query) throws OperationFailedException, DirectoryNotFoundException
DirectoryManager
directoryId
.
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.
searchNestedGroupRelationships
in interface DirectoryManager
directoryId
- ID of the directory to inspect membership information.query
- membership query.User
entities,
Group
entites,
String
usernames or String
group names matching the query criteria.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.public BulkAddResult<User> addAllUsers(long directoryId, Collection<UserTemplateWithCredentialAndAttributes> users, boolean overwrite) throws DirectoryPermissionException, OperationFailedException, DirectoryNotFoundException
DirectoryManager
directoryId
param.
If adding a particular user fails then this user will be skipped and the error will be reported in the logs and the BulkAddResult object.
If the underlying directory supports
bulk adding of entities (ie. implements InternalRemoteDirectory
),
it may be faster than manual iteration of each entity.
addAllUsers
in interface DirectoryManager
directoryId
- the directory to add the User too.users
- the templates of the users to add.overwrite
- true
if you want to remove any existing user matching a username in the users to add prior to adding the user.
false
if you want to skip over users that already exist (same username exists).DirectoryPermissionException
- if the directory is not allowed to perform operations of type OperationType.CREATE_USER
.
or if the overwrite
is true
and the directory is not allowed to perform operations of type
OperationType.DELETE_USER
OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.public BulkAddResult<Group> addAllGroups(long directoryId, Collection<GroupTemplate> groups, boolean overwrite) throws DirectoryPermissionException, OperationFailedException, DirectoryNotFoundException
DirectoryManager
directoryId
param.
If adding a group fails then this user will be skipped and the error will be reported in the logs and the BulkAddResult object.
If the underlying directory supports
bulk adding of entities (ie. implements InternalRemoteDirectory
),
it may be faster than manual iteration of each entity.
addAllGroups
in interface DirectoryManager
directoryId
- the directory to add the Group too.groups
- the Groups to add.overwrite
- true
if you want to remove any existing group matching a username in the groups to add prior to adding the group.
false
if you want to skip over groups that already exist (same group name exists).DirectoryPermissionException
- if the directory is not allowed to perform operations of type OperationType.CREATE_GROUP
.
or if the overwrite
is true
and the directory is not allowed to perform operations of type
OperationType.DELETE_GROUP
OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.public BulkAddResult<String> addAllUsersToGroup(long directoryId, Collection<String> userNames, String groupName) throws DirectoryPermissionException, OperationFailedException, DirectoryNotFoundException, GroupNotFoundException
DirectoryManager
DirectoryManager.addUserToGroup(long, String, String)
.
If creating a particular membership fails, it will be skipped and the error will be reported in the logs and the BulkAddResult object.
If the underlying directory supports bulk adding of entities
(ie. implements InternalRemoteDirectory
),
it may be faster than manual iteration of each entity.
addAllUsersToGroup
in interface DirectoryManager
directoryId
- the directory to add the membership to.userNames
- usernames of users to add membership to.groupName
- name of group to add users to.DirectoryPermissionException
- if the directory is not allowed to perform operations of type OperationType.UPDATE_GROUP
.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.GroupNotFoundException
- if the groupName did not resolve to a grouppublic User findUserByExternalId(long directoryId, String externalId) throws DirectoryNotFoundException, UserNotFoundException, OperationFailedException
DirectoryManager
directoryId
.findUserByExternalId
in interface DirectoryManager
directoryId
- ID of the directory to search.externalId
- external Id of the user to retrieve.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.UserNotFoundException
- if no user with the supplied external ID exists in the directoryOperationFailedException
- underlying directory implementation failed to execute the operation.public UserWithAttributes findUserWithAttributesByExternalId(long directoryId, String externalId) throws DirectoryNotFoundException, UserNotFoundException, OperationFailedException
DirectoryManager
directoryId
.findUserWithAttributesByExternalId
in interface DirectoryManager
directoryId
- ID of the directory to search.externalId
- external Id of the user to retrieve.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.UserNotFoundException
- if no user with the supplied external ID exists in the directoryOperationFailedException
- underlying directory implementation failed to execute the operation.public void expireAllPasswords(long directoryId) throws OperationFailedException, DirectoryNotFoundException
DirectoryManager
UserConstants.REQUIRES_PASSWORD_CHANGE
attribute to true for
all users in the directoryexpireAllPasswords
in interface DirectoryManager
OperationFailedException
DirectoryNotFoundException
public boolean supportsExpireAllPasswords(long directoryId) throws DirectoryInstantiationException, DirectoryNotFoundException
DirectoryManager
supportsExpireAllPasswords
in interface DirectoryManager
directoryId
- ID of directory.DirectoryInstantiationException
- if there was an error instantiating the directoryDirectoryNotFoundException
- if the directory could not be found.public AvatarReference getUserAvatarByName(long directoryId, String username, int sizeHint) throws UserNotFoundException, OperationFailedException, DirectoryNotFoundException
DirectoryManager
getUserAvatarByName
in interface DirectoryManager
sizeHint
- a hint in pixels for the context in which this will be usednull
if none is availableUserNotFoundException
OperationFailedException
DirectoryNotFoundException
@Nonnull public User findRemoteUserByName(Long directoryId, String username) throws OperationFailedException, DirectoryNotFoundException, UserNotFoundException
DirectoryManager
directoryId
findRemoteUserByName
in interface DirectoryManager
directoryId
- ID of the directory to search its remote authoriative directoryusername
- username of the user to retrieve.OperationFailedException
- underlying directory implementation failed to execute the operation.DirectoryNotFoundException
- if the directory with the given directoryId cannot be found.UserNotFoundException
- if no user with the supplied username exists in the directoryDirectoryManager.findUserWithAttributesByName(long, String)
public User updateUserFromRemoteDirectory(User remoteUser) throws OperationFailedException, DirectoryNotFoundException, UserNotFoundException
DirectoryManager
DirectoryManager.authenticateUser(long, String, PasswordCredential)
, but in case the user is
authenticated in another way, it might be useful to update the user's data.
Currently includes:
- creating the user if he doesn't exist locally yet
- renaming the user if the name has changed in remote
- optionally updating the user group memberships, depending on the directory configurationupdateUserFromRemoteDirectory
in interface DirectoryManager
remoteUser
- the remote user to update forOperationFailedException
DirectoryNotFoundException
UserNotFoundException
public List<Application> findAuthorisedApplications(long directoryId, List<String> groupNames)
DirectoryManager
findAuthorisedApplications
in interface DirectoryManager
directoryId
- directory id of the user.groupNames
- group memberships of the user in the particular directory.Copyright © 2020 Atlassian. All rights reserved.