@ParametersAreNonnullByDefault public interface RemoteDirectory extends Attributes
Implementations will be provided an directoryId and Map of attributes.
Implementations of RemoteDirectory may throw an OperationNotSupportedException, if the operation is not supported, and the method declares that it may throw an OperationFailedException. Implementations should not knowingly throw a RuntimeException unless it really is a programming error - e.g. attempting to search for users using a group query.
Modifier and Type | Method and Description |
---|---|
Group |
addGroup(GroupTemplate group)
Adds a
group to the directory store. |
void |
addGroupToGroup(String childGroup,
String parentGroup)
Adds a group as a member of a parent group.
|
User |
addUser(UserTemplate user,
PasswordCredential credential)
Deprecated.
|
UserWithAttributes |
addUser(UserTemplateWithAttributes user,
PasswordCredential credential)
Adds a
user to the directory store. |
void |
addUserToGroup(String username,
String groupName)
Adds a user as a member of a group.
|
User |
authenticate(String name,
PasswordCredential credential)
Authenticates a
user with the directory store. |
BoundedCount |
countDirectMembersOfGroup(String groupName,
int querySizeHint)
Count the direct members of a group in the remote directory.
|
void |
expireAllPasswords()
Sets the
UserConstants.REQUIRES_PASSWORD_CHANGE attribute to true for
all users in the directory using bulk operations |
Group |
findGroupByName(String name)
Finds the
group that matches the supplied name . |
GroupWithAttributes |
findGroupWithAttributesByName(String name)
Finds the
group that matches the supplied name . |
User |
findUserByExternalId(String externalId)
Finds the user that matches the supplied
externalId . |
User |
findUserByName(String name)
Finds the
user that matches the supplied name . |
UserWithAttributes |
findUserWithAttributesByName(String name)
Finds the
user that matches the supplied name . |
RemoteDirectory |
getAuthoritativeDirectory() |
String |
getDescriptiveName()
Returns a descriptive name for the type of directory.
|
long |
getDirectoryId()
Gets the internal unique
directoryId of the directory store. |
default Optional<Set<String>> |
getLocallyFilteredGroupNames()
Returns locally filtered group names.
|
Iterable<Membership> |
getMemberships()
Get an iterable view of the available group memberships.
|
default AvatarReference |
getUserAvatarByName(String username,
int sizeHint)
Return an avatar, if available, for the named user.
|
boolean |
isGroupDirectGroupMember(String childGroup,
String parentGroup)
Determines if a group is a direct member of another group.
|
boolean |
isRolesDisabled()
Deprecated.
|
boolean |
isUserDirectGroupMember(String username,
String groupName)
Determines if a user is a direct member of a group.
|
void |
removeGroup(String name)
Removes the
group that matches the supplied name . |
void |
removeGroupAttributes(String groupName,
String attributeName)
Removes all the values for a single attribute key for a group.
|
void |
removeGroupFromGroup(String childGroup,
String parentGroup)
Removes a group as a member of a parent group.
|
void |
removeUser(String name)
Removes the
user that matches the supplied name . |
void |
removeUserAttributes(String username,
String attributeName)
Removes all the values for a single attribute key for a user.
|
void |
removeUserFromGroup(String username,
String groupName)
Removes a user as a member of a group.
|
Group |
renameGroup(String oldName,
String newName)
Renames a
group . |
User |
renameUser(String oldName,
String newName)
Renames a
user . |
<T> List<T> |
searchGroupRelationships(MembershipQuery<T> query)
Searches for membership information.
|
<T> List<T> |
searchGroups(EntityQuery<T> query)
Searches for
groups that match the supplied query criteria. |
<T> List<T> |
searchUsers(EntityQuery<T> query)
Searches for
users that match the supplied query criteria. |
void |
setAttributes(Map<String,String> attributes)
When a directory store is loaded, the attributes map will be
set by the Crowd framework.
|
void |
setDirectoryId(long directoryId)
When a directory store is loaded, the
directoryId will be set by the
crowd framework. |
void |
storeGroupAttributes(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(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 |
supportsInactiveAccounts()
Return true if this directory supports inactive users and groups.
|
boolean |
supportsNestedGroups()
Allows us to only display nested-group related UI for directories that support it.
|
boolean |
supportsPasswordExpiration()
Return true if this directory supports manually expiring passwords.
|
boolean |
supportsSettingEncryptedCredential()
If this method returns true, then calling
updateUserCredential(String, PasswordCredential) or
addUser(com.atlassian.crowd.model.user.UserTemplate, com.atlassian.crowd.embedded.api.PasswordCredential)
with a PasswordCredential instance where PasswordCredential.isEncryptedCredential() returns true
and the instance is not equal to PasswordCredential.NONE will succeed; otherwise, it will fail. |
void |
testConnection()
Test if a connection to the directory server can be established.
|
Group |
updateGroup(GroupTemplate group)
Updates the
group . |
User |
updateUser(UserTemplate user)
Updates the
user . |
void |
updateUserCredential(String username,
PasswordCredential credential)
|
default User |
updateUserFromRemoteDirectory(User remoteUser) |
default User |
userAuthenticated(String username) |
getKeys, getValue, getValues, isEmpty
long getDirectoryId()
directoryId
of the directory store.directoryId
.void setDirectoryId(long directoryId)
directoryId
will be set by the
crowd framework.directoryId
- The unique directoryId
of the DirectoryImpl
stored in the database.@Nonnull String getDescriptiveName()
void setAttributes(Map<String,String> attributes)
The Map is immutable and implementations are required to maintain immutability.
attributes
- attributes map.@Nonnull User findUserByName(String name) throws UserNotFoundException, OperationFailedException
user
that matches the supplied name
.name
- the name of the user (username).UserNotFoundException
- a user with the supplied name does not exist.OperationFailedException
- underlying directory implementation failed to execute the operation.@Nonnull UserWithAttributes findUserWithAttributesByName(String name) throws UserNotFoundException, OperationFailedException
user
that matches the supplied name
.name
- the name of the user (username).UserNotFoundException
- a user with the supplied name does not exist.OperationFailedException
- underlying directory implementation failed to execute the operation.@Nonnull User findUserByExternalId(String externalId) throws UserNotFoundException, OperationFailedException
externalId
.
This is an optional method that may not be implemented on all directory types.
Currently it is implemented for LDAP and Internal directories but not Crowd directories.externalId
- the externalId of the userexternalId
.UserNotFoundException
- a user with the supplied externalId does not exist.OperationFailedException
- underlying directory implementation failed to execute the operation.findUserByName(String)
@Nonnull User authenticate(String name, PasswordCredential credential) throws UserNotFoundException, InactiveAccountException, InvalidAuthenticationException, ExpiredCredentialException, OperationFailedException
user
with the directory store.name
- The name of the user (username).credential
- The supplied credentials (password).InactiveAccountException
- The supplied user is inactive.InvalidAuthenticationException
- Authentication with the provided credentials failed.UserNotFoundException
- The user with the supplied name does not exist.ExpiredCredentialException
- The user's credentials have expired. The user must change their credentials in order to successfully authenticate.OperationFailedException
- underlying directory implementation failed to execute the operation.@Nonnull @Deprecated User addUser(UserTemplate user, PasswordCredential credential) throws InvalidUserException, InvalidCredentialException, UserAlreadyExistsException, OperationFailedException
addUser(com.atlassian.crowd.model.user.UserTemplateWithAttributes, com.atlassian.crowd.embedded.api.PasswordCredential)
instead. Since v2.9.user
to the directory store.user
- template of the user to add.credential
- a password, or PasswordCredential.NONE
for an account that cannot login with any passwordInvalidUserException
- The supplied user is invalid.InvalidCredentialException
- The supplied credential is invalid.UserAlreadyExistsException
- The user already existsOperationFailedException
- underlying directory implementation failed to execute the operation.supportsSettingEncryptedCredential()
UserWithAttributes addUser(UserTemplateWithAttributes user, PasswordCredential credential) throws InvalidUserException, InvalidCredentialException, UserAlreadyExistsException, OperationFailedException
user
to the directory store.user
- template of the user to add.credential
- a password, or PasswordCredential.NONE
for an account that cannot login with any passwordInvalidUserException
- The supplied user is invalid.InvalidCredentialException
- The supplied credential is invalid.UserAlreadyExistsException
- The user already existsOperationFailedException
- underlying directory implementation failed to execute the operation.supportsSettingEncryptedCredential()
@Nonnull User updateUser(UserTemplate user) throws InvalidUserException, UserNotFoundException, OperationFailedException
user
.user
- The user to update.UserNotFoundException
- the user does not exist in the directory store.InvalidUserException
- the supplied user is invalid.OperationFailedException
- underlying directory implementation failed to execute the operation.void updateUserCredential(String username, PasswordCredential credential) throws UserNotFoundException, InvalidCredentialException, OperationFailedException
username
- The name of the user (username).credential
- The new credential (password).UserNotFoundException
- The user does not exist.InvalidCredentialException
- The supplied credential is invalid.OperationFailedException
- underlying directory implementation failed to execute the operation.supportsSettingEncryptedCredential()
@Nonnull User renameUser(String oldName, String newName) throws UserNotFoundException, InvalidUserException, UserAlreadyExistsException, OperationFailedException
user
.oldName
- name of existing user.newName
- desired name of user.UserNotFoundException
- if the user with the existing name does not exist.InvalidUserException
- if the new username is invalid.UserAlreadyExistsException
- if the newName already exists.OperationFailedException
- if the underlying directory implementation failed to execute the operation.void storeUserAttributes(String username, Map<String,Set<String>> attributes) throws UserNotFoundException, OperationFailedException
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
Attributes with values of empty sets are not added (these attributes are effectively removed).
username
- name of user to update.attributes
- new or updated attributes (attributes that don't need changing should not appear in this Map).UserNotFoundException
- user with supplied username does not exist.OperationFailedException
- underlying directory implementation failed to execute the operation.void removeUserAttributes(String username, String attributeName) throws UserNotFoundException, OperationFailedException
username
- name of the user to update.attributeName
- name of attribute to remove.UserNotFoundException
- user with supplied username does not exist.OperationFailedException
- underlying directory implementation failed to execute the operation.void removeUser(String name) throws UserNotFoundException, OperationFailedException
user
that matches the supplied name
.name
- The name of the user (username).UserNotFoundException
- The user does not exist.OperationFailedException
- underlying directory implementation failed to execute the operation.@Nonnull <T> List<T> searchUsers(EntityQuery<T> query) throws OperationFailedException
users
that match the supplied query criteria.
The users will be returned in a stable order including across pagination boundaries (excluding modification).
query
- EntityQuery for Entity.USER.List<User
>
or List<String
>
of users/usernames
matching the search criteria. An empty List
will be returned
if no users matching the criteria are found.OperationFailedException
- if the underlying directory implementation failed to execute the operationIllegalArgumentException
- if the query is not a valid user query@Nonnull Group findGroupByName(String name) throws GroupNotFoundException, OperationFailedException
group
that matches the supplied name
.name
- the name of the group.GroupNotFoundException
- a group with the supplied name does not exist.OperationFailedException
- underlying directory implementation failed to execute the operation.@Nonnull GroupWithAttributes findGroupWithAttributesByName(String name) throws GroupNotFoundException, OperationFailedException
group
that matches the supplied name
.name
- the name of the group.GroupNotFoundException
- a group with the supplied name does not exist.OperationFailedException
- underlying directory implementation failed to execute the operation.@Nonnull Group addGroup(GroupTemplate group) throws InvalidGroupException, OperationFailedException
group
to the directory store.group
- template of the group to add.InvalidGroupException
- The supplied group is invalid or it already exists in the directory.OperationFailedException
- underlying directory implementation failed to execute the operation.@Nonnull Group updateGroup(GroupTemplate group) throws InvalidGroupException, GroupNotFoundException, ReadOnlyGroupException, OperationFailedException
group
.group
- The group to update.GroupNotFoundException
- the group does not exist in the directory store.InvalidGroupException
- the supplied group is invalid.ReadOnlyGroupException
- the group is read-onlyOperationFailedException
- underlying directory implementation failed to execute the operation.@Nonnull Group renameGroup(String oldName, String newName) throws GroupNotFoundException, InvalidGroupException, OperationFailedException
group
.oldName
- name of existing group.newName
- desired name of group.GroupNotFoundException
- if the group with the existing name does not exist.InvalidGroupException
- if the new group name is invalid or already exists in the directory.OperationFailedException
- if the underlying directory implementation failed to execute the operation.void storeGroupAttributes(String groupName, Map<String,Set<String>> attributes) throws GroupNotFoundException, OperationFailedException
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
Attributes with values of empty sets are not added (these attributes are effectively removed).
groupName
- name of group to update.attributes
- new or updated attributes (attributes that don't need changing should not appear in this Map).GroupNotFoundException
- group with supplied groupName does not exist.OperationFailedException
- underlying directory implementation failed to execute the operation.void removeGroupAttributes(String groupName, String attributeName) throws GroupNotFoundException, OperationFailedException
groupName
- name of the group to update.attributeName
- name of attribute to remove.GroupNotFoundException
- group with supplied groupName does not exist.OperationFailedException
- underlying directory implementation failed to execute the operation.void removeGroup(String name) throws GroupNotFoundException, ReadOnlyGroupException, OperationFailedException
group
that matches the supplied name
.name
- The name of the group.GroupNotFoundException
- The group does not exist.ReadOnlyGroupException
- if the group is read-only and not allowed to be deleted.OperationFailedException
- underlying directory implementation failed to execute the operation.@Nonnull <T> List<T> searchGroups(EntityQuery<T> query) throws OperationFailedException
groups
that match the supplied query criteria.
The groups will be returned in a stable order including across pagination boundaries (excluding modification).
query
- EntityQuery for Entity.GROUP.List<Group>
or List<String>
of groups/groupnames
matching the search criteria. An empty List
will be returned
if no groups matching the criteria are found.OperationFailedException
- if the underlying directory implementation failed to execute the operationIllegalArgumentException
- if the query is not a valid group queryboolean isUserDirectGroupMember(String username, String groupName) throws OperationFailedException
username
- name of user.groupName
- name of group.true
iff the user is a direct member of the group.OperationFailedException
- underlying directory implementation failed to execute the operation.boolean isGroupDirectGroupMember(String childGroup, String parentGroup) throws OperationFailedException
childGroup
- name of child group.parentGroup
- name of parent group.true
iff the childGroup is a direct member of the parentGroup.OperationFailedException
- underlying directory implementation failed to execute the operation.@Nonnull BoundedCount countDirectMembersOfGroup(String groupName, int querySizeHint) throws OperationFailedException
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 the provided group.void addUserToGroup(String username, String groupName) throws GroupNotFoundException, UserNotFoundException, ReadOnlyGroupException, OperationFailedException, MembershipAlreadyExistsException
childGroup
will
appear as members of parentGroup
to querying applications.username
- The user that will become a member of groupName
groupName
- The group that will gain a new member.GroupNotFoundException
- If the group cannot be found.UserNotFoundException
- If the user cannot be found.ReadOnlyGroupException
- If the group is read-onlyMembershipAlreadyExistsException
- if the user is already a member of the groupOperationFailedException
- underlying directory implementation failed to execute the operation.void addGroupToGroup(String childGroup, String parentGroup) throws GroupNotFoundException, InvalidMembershipException, ReadOnlyGroupException, OperationFailedException, MembershipAlreadyExistsException
parentGroup
- The group that will gain a new memberchildGroup
- The group that will become a member of parentGroup
GroupNotFoundException
- One or both of the groups cannot be found.InvalidMembershipException
- if the childGroup and parentGroup exist but are of different GroupTypes.ReadOnlyGroupException
- if either of the groups are read-onlyMembershipAlreadyExistsException
- if the child group is already a child of the parent groupOperationFailedException
- underlying directory implementation failed to execute the operation.void removeUserFromGroup(String username, String groupName) throws GroupNotFoundException, UserNotFoundException, MembershipNotFoundException, ReadOnlyGroupException, OperationFailedException
groupName
- The group that will lose the member.username
- The user that will be removed from parentGroup
GroupNotFoundException
- If the group cannot be found.UserNotFoundException
- If the user cannot be found.MembershipNotFoundException
- if the user is not a direct member of the group.ReadOnlyGroupException
- if the group is read-onlyOperationFailedException
- underlying directory implementation failed to execute the operation.void removeGroupFromGroup(String childGroup, String parentGroup) throws GroupNotFoundException, InvalidMembershipException, MembershipNotFoundException, ReadOnlyGroupException, OperationFailedException
parentGroup
- The group that will lose the member.childGroup
- The group that will be removed from parentGroup
GroupNotFoundException
- One or both of the groups cannot be found.InvalidMembershipException
- if the childGroup and parentGroup exist but are of different GroupTypes.MembershipNotFoundException
- if the childGroup is not a direct member of the parentGroup.ReadOnlyGroupException
- if the groups are read-onlyOperationFailedException
- underlying directory implementation failed to execute the operation.@Nonnull <T> List<T> searchGroupRelationships(MembershipQuery<T> query) throws OperationFailedException
query
- query for memberships.OperationFailedException
- underlying directory implementation failed to execute the operation.IllegalArgumentException
- if the query is not a valid membership queryvoid testConnection() throws OperationFailedException
OperationFailedException
- underlying directory implementation failed to execute the operation.boolean supportsInactiveAccounts()
boolean supportsNestedGroups()
boolean supportsPasswordExpiration()
boolean supportsSettingEncryptedCredential()
updateUserCredential(String, PasswordCredential)
or
addUser(com.atlassian.crowd.model.user.UserTemplate, com.atlassian.crowd.embedded.api.PasswordCredential)
with a PasswordCredential
instance where PasswordCredential.isEncryptedCredential()
returns true
and the instance is not equal to PasswordCredential.NONE
will succeed; otherwise, it will fail.@Deprecated boolean isRolesDisabled()
@Nonnull Iterable<Membership> getMemberships() throws OperationFailedException
Get an iterable view of the available group memberships. This may be implemented as a single remote call or separate calls, depending on the directory.
If there is a failure in the underlying retrieval, the iterator may throw
Membership.MembershipIterationException
at runtime.
If the directory does not have a bulk call interface then a typical implementation would be:
return new DirectoryMembershipsIterable(this);
OperationFailedException
- if the underlying directory implementation failed to execute the operation@Nonnull RemoteDirectory getAuthoritativeDirectory()
void expireAllPasswords() throws OperationFailedException
UserConstants.REQUIRES_PASSWORD_CHANGE
attribute to true for
all users in the directory using bulk operationsOperationFailedException
@Nullable default AvatarReference getUserAvatarByName(String username, int sizeHint) throws UserNotFoundException, OperationFailedException
sizeHint
- a hint in pixels for the context in which this will be usednull
if none is availableUserNotFoundException
OperationFailedException
@ExperimentalApi default User updateUserFromRemoteDirectory(User remoteUser) throws OperationFailedException, UserNotFoundException
@ExperimentalApi default User userAuthenticated(String username) throws OperationFailedException, UserNotFoundException, InactiveAccountException
@ExperimentalApi default Optional<Set<String>> getLocallyFilteredGroupNames()
Locally filtered groups are groups filtered on Crowd side, in opposite to groups filtered externally, i.e. using LDAP filter. Group names are case insensitive.
Note: Nested group memberships will not be resolved for the groups by this method.
Copyright © 2021 Atlassian. All rights reserved.