Package com.atlassian.crowd.embedded.api
Interface CrowdService
- All Known Subinterfaces:
UnfilteredCrowdService
- All Known Implementing Classes:
CrowdServiceImpl
public interface CrowdService
Provides the interface for performing User and Group operations in Crowd for applications embedding Crowd.
User.getDirectoryId() is ignored in all methods having User in the parameter list. Null parameters
for methods may throw NullPointerException or IllegalArgumentException.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionAdds agroupto the directory store.booleanaddGroupToGroup(Group childGroup, Group parentGroup) Adds a group as a member of a parent group.Deprecated.addUser(UserWithAttributes user, String credential) Adds auserto the directory store.booleanaddUserToGroup(User user, Group group) Adds a user as a member of a group.authenticate(String name, String credential) Authenticates auserwith the given credential.Gets details of the possible operations that can be performed onnew users.Finds thegroupthat matches the suppliedname.getGroupWithAttributes(String name) Finds thegroupthat matches the suppliedname.getRemoteUser(String name) Returns theuserthat matches the suppliednamefrom a remote directory.Returns theuserthat matches the suppliedname.getUserWithAttributes(String name) Returns theuserthat matches the suppliedname.booleanisGroupDirectGroupMember(Group childGroup, Group parentGroup) Determines if a group is a direct member of another group.booleanisGroupMemberOfGroup(Group childGroup, Group parentGroup) Returnstrueif thechildGroupis a direct or indirect (nested) member of theparentGroup.booleanisGroupMemberOfGroup(String childGroupName, String parentGroupName) ReturnstrueifchildGroupNameis a direct or indirect (nested) member ofparentGroupName.booleanisUserDirectGroupMember(User user, Group group) Determines if a user is a direct member of a group.booleanisUserMemberOfGroup(User user, Group group) Returnstrueif the user is a direct or indirect (nested) member of the group.booleanisUserMemberOfGroup(String userName, String groupName) Returnstrueif the user is a direct or indirect (nested) member of the group.voidremoveAllGroupAttributes(Group group) Removes all group attributes.voidremoveAllUserAttributes(User user) Remove all attributes for a user.booleanremoveGroup(Group group) Removes thegroupthat matches the suppliedname.voidremoveGroupAttribute(Group group, String attributeName) Removes all the values for a single attribute key for a group.booleanremoveGroupFromGroup(Group childGroup, Group parentGroup) Removes a group as a member of a parent group.booleanremoveUser(User user) Removes theuserthat matches the suppliedname.voidremoveUserAttribute(User user, String attributeName) Removes all the values for a single attribute key for a user.booleanremoveUserFromGroup(User user, Group group) Removes a user as a member of a group.renameUser(User user, String newUsername) Renames theUser.<T> Iterable<T>Searches for entities (e.g.voidsetGroupAttribute(Group group, String attributeName, String attributeValue) Adds or updates a group's attributes with the new attributes.voidsetGroupAttribute(Group group, String attributeName, Set<String> attributeValues) Adds or updates a group's attributes with the newattributes.voidsetUserAttribute(User user, String attributeName, String attributeValue) Adds or updates a user's attribute with the new attribute value.voidsetUserAttribute(User user, String attributeName, Set<String> attributeValues) Adds or updates a user's attribute with the new attribute values.setUserStatusLocally(String username, boolean userActiveInternally) Deactivates/Activates theUserin the internal directory.updateGroup(Group group) Updates thegroup.updateUser(User user) Updates theUser.voidupdateUserCredential(User user, String credential) userAuthenticated(String name) Acts as if the user has just authenticated.verifyCredentials(String name, String credential) Verifies credentials for auser.
-
Method Details
-
authenticate
User authenticate(String name, String credential) throws FailedAuthenticationException, OperationFailedException Authenticates auserwith the given credential.- Parameters:
name- The name of the user (username).credential- The supplied credential to authenticate with- Returns:
- The populated user if the authentication is valid.
- Throws:
FailedAuthenticationException- Authentication with the provided credentials failed. It may indicate that the user does not exist or the user's account is inactive or the credentials are incorrectInactiveAccountException- The supplied user is inactive.ExpiredCredentialException- The user's credentials have expired. The user must change their credentials in order to successfully authenticate.AccountNotFoundException- User with the given name could not be foundOperationFailedException- underlying directory implementation failed to execute the operation.
-
verifyCredentials
User verifyCredentials(String name, String credential) throws FailedAuthenticationException, OperationFailedException Verifies credentials for auser. This API can be used in case of two-step verification for user credential verification without fully authenticating the user.- Parameters:
name- The name of the user (username).credential- The supplied credential to authenticate with- Returns:
- The populated user if the credentials are valid.
- Throws:
FailedAuthenticationException- Authentication with the provided credentials failed. It may indicate that the user does not exist or the user's account is inactive or the credentials are incorrectInactiveAccountException- The supplied user is inactive.ExpiredCredentialException- The user's credentials have expired. The user must change their credentials in order to successfully authenticate.AccountNotFoundException- User with the given name could not be foundOperationFailedException- underlying directory implementation failed to execute the operation.- Since:
- 6.2.0
-
getUser
Returns theuserthat matches the suppliedname.- Parameters:
name- the name of the user (username). Does not allow null, blank or empty strings.- Returns:
- user entity or
nullif the user is not found
-
getRemoteUser
Returns theuserthat matches the suppliednamefrom a remote directory. Note that this may potentially cause a remote call to a authentication service.- Parameters:
name- the name of the user (username). Does not allow null, blank or empty strings.- Returns:
- user entity or
nullif the user is not found
-
userAuthenticated
@ExperimentalApi User userAuthenticated(String name) throws UserNotFoundException, OperationFailedException, InactiveAccountException Acts as if the user has just authenticated. Depending on the configuration it might update the user details from a remote directory. Usually this happens as a part ofauthenticate(String, String), but this could be called if the user was authenticated in a different way.- Parameters:
name- the username for the authenticated user- Returns:
- the current state of the authenticated user
- Throws:
UserNotFoundException- when the user doesn't existInactiveAccountException- when the user account is inactiveOperationFailedException- when one of the post-authentication operation fails
-
getUserWithAttributes
Returns theuserthat matches the suppliedname.- Parameters:
name- the name of the user (username).- Returns:
- user entity with attributes or
nullif the user is not found
-
getGroup
Finds thegroupthat matches the suppliedname.- Parameters:
name- the name of the group.- Returns:
- group entity,
nullif not found.
-
getGroupWithAttributes
Finds thegroupthat matches the suppliedname.- Parameters:
name- the name of the group.- Returns:
- group entity with attributes,
nullif not found.
-
search
-
isUserMemberOfGroup
Returnstrueif the user is a direct or indirect (nested) member of the group.- Parameters:
userName- user to inspect.groupName- group to inspect.- Returns:
trueif and only if the user is a direct or indirect (nested) member of the group. If the user or group cannot found, thenfalseis returned.- See Also:
-
isUserMemberOfGroup
Returnstrueif the user is a direct or indirect (nested) member of the group.- Parameters:
user- user to inspect.group- group to inspect.- Returns:
trueif and only if the user is a direct or indirect (nested) member of the group, otherwise false. If the user or group cannot found, thenfalseis returned.- See Also:
-
isGroupMemberOfGroup
ReturnstrueifchildGroupNameis a direct or indirect (nested) member ofparentGroupName.- Parameters:
childGroupName- name of child group to inspect.parentGroupName- name of parent group to inspect.- Returns:
trueif and only if thechildGroupNameis a direct or indirect (nested) member of theparentGroupName. If any of the groups cannot found, thenfalseis returned.
-
isGroupMemberOfGroup
Returnstrueif thechildGroupis a direct or indirect (nested) member of theparentGroup.- Parameters:
childGroup- group to inspect.parentGroup- group to inspect.- Returns:
trueif and only if thechildGroupis a direct or indirect (nested) member of theparentGroup. If any of the groups cannot found, thenfalseis returned.
-
addUser
@Deprecated User addUser(User user, String credential) throws InvalidUserException, InvalidCredentialException, OperationNotPermittedException, OperationFailedException Deprecated.UseaddUser(UserWithAttributes, String)instead. Since v2.9Adds auserto the directory store. The user must have non-null names and email address.- Parameters:
user- template of the user to add.credential- password. May not be null or blank.- Returns:
- the added user retrieved from the underlying store.
- Throws:
InvalidUserException- The supplied user's details are invalid and/or incomplete.InvalidCredentialException- The supplied credential is invalid, this may be due the credential not matching required directory constraints.OperationNotPermittedException- if the directory has been configured to not allow the operation to be performedOperationFailedException- if the operation failed for any other reason
-
addUser
UserWithAttributes addUser(UserWithAttributes user, String credential) throws InvalidUserException, InvalidCredentialException, OperationNotPermittedException, OperationFailedException Adds auserto the directory store. The user must have non-null names and email address.- Parameters:
user- template of the user to add.credential- password. May not be null or blank.- Returns:
- the added user retrieved from the underlying store.
- Throws:
InvalidUserException- The supplied user's details are invalid and/or incomplete.InvalidCredentialException- The supplied credential is invalid, this may be due the credential not matching required directory constraints.OperationNotPermittedException- if the directory has been configured to not allow the operation to be performedOperationFailedException- if the operation failed for any other reason
-
updateUser
User updateUser(User user) throws UserNotFoundException, InvalidUserException, OperationNotPermittedException, OperationFailedException Updates theUser. The user must have non-null names and email address.- Parameters:
user- The user to update.- Returns:
- the updated user retrieved from the underlying store. This might be a new object instance, depending on the underlying
Directory - Throws:
UserNotFoundException- if the supplied user does not exist in thedirectory.InvalidUserException- The supplied user's details are invalid and/or incomplete.OperationNotPermittedException- if the directory has been configured to not allow the operation to be performedOperationFailedException- underlying directory implementation failed to execute the operation.
-
setUserStatusLocally
User setUserStatusLocally(String username, boolean userActiveInternally) throws UserNotFoundException, InvalidUserException, OperationNotPermittedException, OperationFailedException, DirectoryNotFoundException Deactivates/Activates theUserin the internal directory.- Parameters:
username- The user to Deactivate/Activate.userActiveInternally- Operation to Deactivate/Activate.- Returns:
- the updated user retrieved from the underlying store. This might be a new object instance, depending on the underlying
Directory - Throws:
UserNotFoundException- if the supplied user does not exist in thedirectory.InvalidUserException- The supplied user's details are invalid and/or incomplete.OperationNotPermittedException- if the directory has been configured to not allow the operation to be performedOperationFailedException- underlying directory implementation failed to execute the operation.DirectoryNotFoundException- Since:
- 6.1.0
-
renameUser
User renameUser(User user, String newUsername) throws UserNotFoundException, InvalidUserException, OperationNotPermittedException, OperationFailedException Renames theUser.- Parameters:
user- user to rename.newUsername- new username of the renamed user.- Returns:
- the renamed User.
- Throws:
UserNotFoundException- if the supplied user does not exist.InvalidUserException- if the new username does not meet the username requirements for an associated directory.OperationNotPermittedException- if the directory has been configured to not allow the operation to be performed.OperationFailedException- underlying directory implementation failed to execute the operation.UnsupportedOperationException- underlying directory implementation does not support user renaming.
-
updateUserCredential
void updateUserCredential(User user, String credential) throws UserNotFoundException, InvalidCredentialException, OperationNotPermittedException, OperationFailedException - Parameters:
user- The name of the user (username).credential- The new credential (password). May not be null or blank.- Throws:
InvalidCredentialException- The supplied credential is invalid, this may be due the credential not matching required directory constraints.UserNotFoundException- if the supplied user does not exist in thedirectory.OperationNotPermittedException- if the directory has been configured to not allow the operation to be performedOperationFailedException- underlying directory implementation failed to execute the operation.
-
setUserAttribute
void setUserAttribute(User user, String attributeName, String attributeValue) throws UserNotFoundException, OperationNotPermittedException, OperationFailedException Adds or updates a user's attribute with the new attribute value. The attributes represents new or updated attributes and does not replace existing attributes unless the key of an attribute matches the key of an existing attribute. This will not remove any attributes.- Parameters:
user- user to update.attributeName- the name of the attributeattributeValue- the new value of the attribute; any existing values will be replaced- Throws:
UserNotFoundException- the supplied user does not exist.OperationNotPermittedException- if the directory has been configured to not allow the operation to be performedOperationFailedException- underlying directory implementation failed to execute the operation.
-
setUserAttribute
void setUserAttribute(User user, String attributeName, Set<String> attributeValues) throws UserNotFoundException, OperationNotPermittedException, OperationFailedException Adds or updates a user's attribute with the new attribute values. The attributes represents new or updated attributes and does not replace existing attributes unless the key of an attribute matches the key of an existing. This will not remove any attributes.- Parameters:
user- user to update.attributeName- the name of the attributeattributeValues- the new set of values; any existing values will be replaced- Throws:
UserNotFoundException- the supplied user does not exist.OperationNotPermittedException- if the directory has been configured to not allow the operation to be performedOperationFailedException- underlying directory implementation failed to execute the operation.
-
removeUserAttribute
void removeUserAttribute(User user, String attributeName) throws UserNotFoundException, OperationNotPermittedException, OperationFailedException Removes all the values for a single attribute key for a user.- Parameters:
user- user to update.attributeName- name of attribute to remove.- Throws:
UserNotFoundException- user with supplied username does not exist.OperationNotPermittedException- if the directory has been configured to not allow the operation to be performedOperationFailedException- underlying directory implementation failed to execute the operation.
-
removeAllUserAttributes
void removeAllUserAttributes(User user) throws UserNotFoundException, OperationNotPermittedException, OperationFailedException Remove all attributes for a user.- Parameters:
user- user to update.- Throws:
UserNotFoundException- user with supplied username does not exist.OperationNotPermittedException- if the directory has been configured to not allow the operation to be performedOperationFailedException- underlying directory implementation failed to execute the operation.
-
removeUser
Removes theuserthat matches the suppliedname.- Parameters:
user- user to remove.- Returns:
true</tt> if the user was removed as a result of this call, <tt>falseif the user does not exist.- Throws:
OperationNotPermittedException- if the directory has been configured to not allow the operation to be performedOperationFailedException- underlying directory implementation failed to execute the operation.
-
addGroup
Group addGroup(Group group) throws InvalidGroupException, OperationNotPermittedException, OperationFailedException Adds agroupto the directory store.- Parameters:
group- template of the group to add.- Returns:
- the added group retrieved from the underlying store.
- Throws:
InvalidGroupException- if the group already exists in ANY associated directory or the group template does not have the required properties populated.OperationNotPermittedException- if the directory has been configured to not allow the operation to be performedOperationFailedException- underlying directory implementation failed to execute the operation.
-
updateGroup
Group updateGroup(Group group) throws GroupNotFoundException, InvalidGroupException, OperationNotPermittedException, OperationFailedException Updates thegroup.- Parameters:
group- The group to update.- Returns:
- the updated group retrieved from the underlying store.
- Throws:
GroupNotFoundException- if group with given name does not exist in ANY assigned directory.InvalidGroupException- the supplied group is invalid.OperationNotPermittedException- if the directory has been configured to not allow the operation to be performedOperationFailedException- underlying directory implementation failed to execute the operation.
-
setGroupAttribute
void setGroupAttribute(Group group, String attributeName, String attributeValue) throws GroupNotFoundException, OperationNotPermittedException, OperationFailedException Adds or updates a group's attributes with the new attributes. The attributes represents new or updated attributes and does not replace existing attributes unless the key of an attribute matches the key of an existing. This will not remove any attributes.- Parameters:
group- name of group to update.attributeName- the name up the attribute to add or updateattributeValue- the value of the attribute- Throws:
GroupNotFoundException- if thegroupcould not be foundOperationNotPermittedException- if the directory has been configured to not allow the operation to be performedOperationFailedException- underlying directory implementation failed to execute the operation.
-
setGroupAttribute
void setGroupAttribute(Group group, String attributeName, Set<String> attributeValues) throws GroupNotFoundException, OperationNotPermittedException, OperationFailedException Adds or updates a group's attributes with the newattributes. The attributes represents new or updated attributes and does not replace existing attributes unless the key of an attribute matches the key of an existing. This will not remove any attributes.- Parameters:
group- name of group to update.attributeName- the name up the attribute to add or updateattributeValues- a set of values to update- Throws:
GroupNotFoundException- if thegroupcould not be foundOperationNotPermittedException- if the directory has been configured to not allow the operation to be performedOperationFailedException- underlying directory implementation failed to execute the operation.
-
removeGroupAttribute
void removeGroupAttribute(Group group, String attributeName) throws GroupNotFoundException, OperationNotPermittedException, OperationFailedException Removes all the values for a single attribute key for a group.- Parameters:
group- to update.attributeName- name of attribute to remove.- Throws:
GroupNotFoundException- if thegroupcould not be foundOperationNotPermittedException- if the directory has been configured to not allow the operation to be performedOperationFailedException- underlying directory implementation failed to execute the operation.
-
removeAllGroupAttributes
void removeAllGroupAttributes(Group group) throws GroupNotFoundException, OperationNotPermittedException, OperationFailedException Removes all group attributes.- Parameters:
group- to update.- Throws:
GroupNotFoundException- if thegroupcould not be foundOperationNotPermittedException- if the directory has been configured to not allow the operation to be performedOperationFailedException- underlying directory implementation failed to execute the operation.
-
removeGroup
Removes thegroupthat matches the suppliedname.- Parameters:
group- to remove- Returns:
true</tt> if the group was removed as a result of this call, <tt>falseif the group does not exist.- Throws:
OperationNotPermittedException- if the directory does not allow removal of this groupOperationFailedException- underlying directory implementation failed to execute the operation.
-
addUserToGroup
boolean addUserToGroup(User user, Group group) throws GroupNotFoundException, UserNotFoundException, OperationNotPermittedException, OperationFailedException Adds a user as a member of a group. This means that all user members ofchildGroupwill appear as members ofparentGroupto querying applications.- Parameters:
user- The user that will become a member of thegroupgroup- The group that will gain a new member.- Returns:
true</tt> if the user was added to the group as a result of this call, <tt>falseif the user is already a member of the group.- Throws:
UserNotFoundException- if theusercould not be foundGroupNotFoundException- if thegroupcould not be foundOperationNotPermittedException- if the directory has been configured to not allow the operation to be performedOperationFailedException- underlying directory implementation failed to execute the operation.
-
addGroupToGroup
boolean addGroupToGroup(Group childGroup, Group parentGroup) throws GroupNotFoundException, OperationNotPermittedException, InvalidMembershipException, OperationFailedException Adds a group as a member of a parent group. Cyclic group membership are allowed (mainly because LDAP allows it) but not recommended. I.e. group A can have group B as its member and group B can have group A as its member at the same time.- Parameters:
childGroup- The group that will become a member ofparentGroupparentGroup- The group that will gain a new member- Returns:
true</tt> if the child group was added to the parent group as a result of this call, <tt>falseif the group is already a member of the group.- Throws:
GroupNotFoundException- if any of the group could not be found. UseGroupNotFoundException.getGroupName()to find out which group wasn't foundOperationNotPermittedException- if the directory has been configured to not allow the operation to be performedInvalidMembershipException- If the relationship would cause a circular reference.OperationFailedException- underlying directory implementation failed to execute the operation.
-
removeUserFromGroup
boolean removeUserFromGroup(User user, Group group) throws GroupNotFoundException, UserNotFoundException, OperationNotPermittedException, OperationFailedException Removes a user as a member of a group.- Parameters:
group- The group that will lose the member.user- The user that will be removed from thegroup- Returns:
true</tt> if the user was removed from the group as a result of this call, <tt>falseif the user is not a member of the group.- Throws:
UserNotFoundException- if theusercould not be foundGroupNotFoundException- if thegroupcould not be foundOperationNotPermittedException- if the directory has been configured to not allow the operation to be performedOperationFailedException- if the operation failed for any other reason
-
removeGroupFromGroup
boolean removeGroupFromGroup(Group childGroup, Group parentGroup) throws GroupNotFoundException, OperationNotPermittedException, OperationFailedException Removes a group as a member of a parent group.- Parameters:
childGroup- The group that will be removed fromparentGroupparentGroup- The group that will lose the member.- Returns:
true</tt> if childGroup was removed from parentGroup as a result of this call, <tt>falseif childGroup is not a member of the parentGroup.- Throws:
GroupNotFoundException- if any of the groups could not be found. UseGroupNotFoundException.getGroupName()to find out which group wasn't foundOperationNotPermittedException- if the directory has been configured to not allow the operation to be performedOperationFailedException- if the operation failed for any other reason
-
isUserDirectGroupMember
Determines if a user is a direct member of a group.- Parameters:
user- the user for whom to check the group membershipgroup- the group theuseris believed to belong to- Returns:
trueif the user is a direct member of the group,falseotherwise (including if the user and/or group could not be found)- Throws:
OperationFailedException- underlying directory implementation failed to execute the operation.
-
isGroupDirectGroupMember
boolean isGroupDirectGroupMember(Group childGroup, Group parentGroup) throws OperationFailedException Determines if a group is a direct member of another group.- Parameters:
childGroup- the group for which to check theparentGroupmembershipparentGroup- the group thechildGroupis believed to belong to- Returns:
trueif thechildGroupis a direct member of theparentGroup,falseotherwise (including if neither group could be found)- Throws:
OperationFailedException- underlying directory implementation failed to execute the operation.
-
getCapabilitiesForNewUsers
UserCapabilities getCapabilitiesForNewUsers()Gets details of the possible operations that can be performed onnew users.Those capabilities reflects a specific moment in time and are subject to change if any user directory is added, removed or re-ordered.
- Returns:
- the capabilities a new user will have
- See Also:
-
addUser(UserWithAttributes, String)instead.