public class CrowdServiceImpl extends Object implements UnfilteredCrowdService
Constructor and Description |
---|
CrowdServiceImpl(ApplicationFactory applicationFactory,
ApplicationService applicationService,
DirectoryInstanceLoader directoryInstanceLoader) |
Modifier and Type | Method and Description |
---|---|
Group |
addGroup(Group group)
Adds a
group to the directory store. |
boolean |
addGroupToGroup(Group childGroup,
Group parentGroup)
Adds a group as a member of a parent group.
|
User |
addUser(User user,
String credential)
Adds a
user to the directory store. |
UserWithAttributes |
addUser(UserWithAttributes user,
String credential)
Adds a
user to the directory store. |
boolean |
addUserToGroup(User user,
Group group)
Adds a user as a member of a group.
|
User |
authenticate(String name,
String credential)
Authenticates a
user with the given credential. |
UserCapabilities |
getCapabilitiesForNewUsers()
Gets details of the possible operations that can be performed on
new users . |
Group |
getGroup(String name)
Finds the
group that matches the supplied name . |
GroupWithAttributes |
getGroupWithAttributes(String name)
Finds the
group that matches the supplied name . |
User |
getRemoteUser(String username)
Returns the
user that matches the supplied name from a remote directory. |
User |
getUser(String name)
Returns the
user that matches the supplied name . |
UserWithAttributes |
getUserWithAttributes(String name)
Returns the
user that matches the supplied name . |
boolean |
isGroupDirectGroupMember(Group childGroup,
Group parentGroup)
Determines if a group is a direct member of another group.
|
boolean |
isGroupMemberOfGroup(Group childGroup,
Group parentGroup)
Returns
true if the childGroup is a direct or indirect (nested) member of the parentGroup . |
boolean |
isGroupMemberOfGroup(String childGroupName,
String parentGroupName)
Returns
true if childGroupName is a direct or indirect (nested) member of parentGroupName . |
boolean |
isUserDirectGroupMember(User user,
Group group)
Determines if a user is a direct member of a group.
|
boolean |
isUserMemberOfGroup(String userName,
String groupName)
Returns
true if the user is a direct or indirect (nested) member of the group. |
boolean |
isUserMemberOfGroup(User user,
Group group)
Returns
true if the user is a direct or indirect (nested) member of the group. |
void |
removeAllGroupAttributes(Group group)
Removes all group attributes.
|
void |
removeAllUserAttributes(User user)
Remove all attributes for a user.
|
boolean |
removeGroup(Group group)
Removes the
group that matches the supplied name . |
void |
removeGroupAttribute(Group group,
String attributeName)
Removes all the values for a single attribute key for a group.
|
boolean |
removeGroupFromGroup(Group childGroup,
Group parentGroup)
Removes a group as a member of a parent group.
|
boolean |
removeUser(User user)
Removes the
user that matches the supplied name . |
void |
removeUserAttribute(User user,
String attributeName)
Removes all the values for a single attribute key for a user.
|
boolean |
removeUserFromGroup(User user,
Group group)
Removes a user as a member of a group.
|
User |
renameUser(User user,
String newUsername)
Renames the
User . |
<T> Iterable<T> |
search(Query<T> query)
Searches for entities (e.g.
|
void |
setGroupAttribute(Group group,
String attributeName,
Set<String> attributeValues)
Adds or updates a group's attributes with the new
attributes . |
void |
setGroupAttribute(Group group,
String attributeName,
String attributeValue)
Adds or updates a group's attributes with the new attributes.
|
void |
setUserAttribute(User user,
String attributeName,
Set<String> attributeValues)
Adds or updates a user's attribute with the new attribute values.
|
void |
setUserAttribute(User user,
String attributeName,
String attributeValue)
Adds or updates a user's attribute with the new attribute value.
|
Group |
updateGroup(Group group)
Updates the
group . |
User |
updateUser(User user)
Updates the
User . |
void |
updateUserCredential(User user,
String credential)
|
User |
userAuthenticated(String username)
Acts as if the user has just authenticated.
|
public CrowdServiceImpl(ApplicationFactory applicationFactory, ApplicationService applicationService, DirectoryInstanceLoader directoryInstanceLoader)
public User authenticate(String name, String credential) throws FailedAuthenticationException, OperationFailedException
CrowdService
user
with the given credential.authenticate
in interface CrowdService
name
- The name of the user (username).credential
- The supplied credential to authenticate withFailedAuthenticationException
- 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.public User getUser(String name)
CrowdService
user
that matches the supplied name
.getUser
in interface CrowdService
name
- the name of the user (username). Does not allow null, blank or empty strings.null
if the user is not found@Nullable public User getRemoteUser(@Nonnull String username)
CrowdService
user
that matches the supplied name
from a remote directory.
Note that this may potentially cause a remote call to a authentication service.getRemoteUser
in interface CrowdService
username
- the name of the user (username). Does not allow null, blank or empty strings.null
if the user is not foundpublic User userAuthenticated(String username) throws UserNotFoundException, OperationFailedException, InactiveAccountException
CrowdService
CrowdService.authenticate(String, String)
, but this could be called if the user
was authenticated in a different way.userAuthenticated
in interface CrowdService
username
- the username for the authenticated userUserNotFoundException
- when the user doesn't existOperationFailedException
- when one of the post-authentication operation failsInactiveAccountException
- when the user account is inactivepublic UserWithAttributes getUserWithAttributes(String name)
CrowdService
user
that matches the supplied name
.getUserWithAttributes
in interface CrowdService
name
- the name of the user (username).null
if the user is not foundpublic Group getGroup(String name)
CrowdService
group
that matches the supplied name
.getGroup
in interface CrowdService
name
- the name of the group.null
if not found.public GroupWithAttributes getGroupWithAttributes(String name)
CrowdService
group
that matches the supplied name
.getGroupWithAttributes
in interface CrowdService
name
- the name of the group.null
if not found.public <T> Iterable<T> search(Query<T> query)
CrowdService
Group
or User
) of type <T>
that match the supplied search query.
Search return types must be either String
, User
or Group
.search
in interface CrowdService
query
- Query for a given entity (e.g. Group
or User
)T
matching the search query. An Iterable
containing no results will be
returned if there are no matches for the query.public boolean isUserMemberOfGroup(String userName, String groupName)
CrowdService
true
if the user is a direct or indirect (nested) member of the group.isUserMemberOfGroup
in interface CrowdService
userName
- user to inspect.groupName
- group to inspect.true
if and only if the user is a direct or indirect (nested) member of the group.
If the user or group cannot found, then false
is returned.CrowdService.isUserMemberOfGroup(User, Group)
public boolean isUserMemberOfGroup(User user, Group group)
CrowdService
true
if the user is a direct or indirect (nested) member of the group.isUserMemberOfGroup
in interface CrowdService
user
- user to inspect.group
- group to inspect.true
if and only if the user is a direct or indirect (nested) member of the group, otherwise false.
If the user or group cannot found, then false
is returned.CrowdService.isUserMemberOfGroup(String, String)
public boolean isGroupMemberOfGroup(String childGroupName, String parentGroupName)
CrowdService
true
if childGroupName
is a direct or indirect (nested) member of parentGroupName
.isGroupMemberOfGroup
in interface CrowdService
childGroupName
- name of child group to inspect.parentGroupName
- name of parent group to inspect.true
if and only if the childGroupName
is a direct or indirect (nested) member of the parentGroupName
.
If any of the groups cannot found, then false
is returned.public boolean isGroupMemberOfGroup(Group childGroup, Group parentGroup)
CrowdService
true
if the childGroup
is a direct or indirect (nested) member of the parentGroup
.isGroupMemberOfGroup
in interface CrowdService
childGroup
- group to inspect.parentGroup
- group to inspect.true
if and only if the childGroup
is a direct or indirect (nested) member of the parentGroup
.
If any of the groups cannot found, then false
is returned.public User addUser(User user, String credential) throws InvalidUserException, InvalidCredentialException, OperationNotPermittedException, OperationFailedException
CrowdService
user
to the directory store. The user must have non-null names and email address.addUser
in interface CrowdService
user
- template of the user to add.credential
- password. May not be null or blank.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 reasonpublic UserWithAttributes addUser(UserWithAttributes user, String credential) throws InvalidUserException, InvalidCredentialException, OperationNotPermittedException, OperationFailedException
CrowdService
user
to the directory store. The user must have non-null names and email address.addUser
in interface CrowdService
user
- template of the user to add.credential
- password. May not be null or blank.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 reasonpublic User updateUser(User user) throws UserNotFoundException, InvalidUserException, OperationNotPermittedException, OperationFailedException
CrowdService
User
. The user must have non-null names and email address.updateUser
in interface CrowdService
user
- The user to update.Directory
UserNotFoundException
- if the supplied user does not exist in the directory
.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.public User renameUser(User user, String newUsername) throws UserNotFoundException, InvalidUserException, OperationNotPermittedException, OperationFailedException
CrowdService
User
.renameUser
in interface CrowdService
user
- user to rename.newUsername
- new username of the renamed user.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.public void updateUserCredential(User user, String credential) throws UserNotFoundException, InvalidCredentialException, OperationNotPermittedException, OperationFailedException
CrowdService
updateUserCredential
in interface CrowdService
user
- The name of the user (username).credential
- The new credential (password). May not be null or blank.UserNotFoundException
- if the supplied user does not exist in the directory
.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
- underlying directory implementation failed to execute the operation.public void setUserAttribute(User user, String attributeName, String attributeValue) throws UserNotFoundException, OperationNotPermittedException, OperationFailedException
CrowdService
setUserAttribute
in interface CrowdService
user
- user to update.attributeName
- the name of the attributeattributeValue
- the new value of the attribute; any existing values will be replacedUserNotFoundException
- 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.public void setUserAttribute(User user, String attributeName, Set<String> attributeValues) throws UserNotFoundException, OperationNotPermittedException, OperationFailedException
CrowdService
setUserAttribute
in interface CrowdService
user
- user to update.attributeName
- the name of the attributeattributeValues
- the new set of values; any existing values will be replacedUserNotFoundException
- 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.public void removeUserAttribute(User user, String attributeName) throws UserNotFoundException, OperationNotPermittedException, OperationFailedException
CrowdService
removeUserAttribute
in interface CrowdService
user
- user to update.attributeName
- name of attribute to remove.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.public void removeAllUserAttributes(User user) throws UserNotFoundException, OperationNotPermittedException, OperationFailedException
CrowdService
removeAllUserAttributes
in interface CrowdService
user
- user to update.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.public boolean removeUser(User user) throws OperationNotPermittedException, OperationFailedException
CrowdService
user
that matches the supplied name
.removeUser
in interface CrowdService
user
- user to remove.OperationNotPermittedException
- if the directory has been configured to not allow the operation to be performedOperationFailedException
- underlying directory implementation failed to execute the operation.public Group addGroup(Group group) throws InvalidGroupException, OperationNotPermittedException, OperationFailedException
CrowdService
group
to the directory store.addGroup
in interface CrowdService
group
- template of the group to add.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.public Group updateGroup(Group group) throws InvalidGroupException, OperationNotPermittedException, GroupNotFoundException, OperationFailedException
CrowdService
group
.updateGroup
in interface CrowdService
group
- The group to update.InvalidGroupException
- the supplied group is invalid.OperationNotPermittedException
- if the directory has been configured to not allow the operation to be performedGroupNotFoundException
- if group with given name does not exist in ANY assigned directory.OperationFailedException
- underlying directory implementation failed to execute the operation.public void setGroupAttribute(Group group, String attributeName, String attributeValue) throws GroupNotFoundException, OperationNotPermittedException, OperationFailedException
CrowdService
setGroupAttribute
in interface CrowdService
group
- name of group to update.attributeName
- the name up the attribute to add or updateattributeValue
- the value of the attributeGroupNotFoundException
- if the group
could 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.public void setGroupAttribute(Group group, String attributeName, Set<String> attributeValues) throws GroupNotFoundException, OperationNotPermittedException, OperationFailedException
CrowdService
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.setGroupAttribute
in interface CrowdService
group
- name of group to update.attributeName
- the name up the attribute to add or updateattributeValues
- a set of values to updateGroupNotFoundException
- if the group
could 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.public void removeGroupAttribute(Group group, String attributeName) throws GroupNotFoundException, OperationNotPermittedException, OperationFailedException
CrowdService
removeGroupAttribute
in interface CrowdService
group
- to update.attributeName
- name of attribute to remove.GroupNotFoundException
- if the group
could 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.public void removeAllGroupAttributes(Group group) throws GroupNotFoundException, OperationNotPermittedException, OperationFailedException
CrowdService
removeAllGroupAttributes
in interface CrowdService
group
- to update.GroupNotFoundException
- if the group
could 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.public boolean removeGroup(Group group) throws OperationNotPermittedException, GroupNotFoundException, OperationFailedException
CrowdService
group
that matches the supplied name
.removeGroup
in interface CrowdService
group
- to removeOperationNotPermittedException
- if the directory does not allow removal of this groupOperationFailedException
- underlying directory implementation failed to execute the operation.GroupNotFoundException
public boolean addUserToGroup(User user, Group group) throws GroupNotFoundException, UserNotFoundException, OperationNotPermittedException, OperationFailedException
CrowdService
childGroup
will
appear as members of parentGroup
to querying applications.addUserToGroup
in interface CrowdService
user
- The user that will become a member of the group
group
- The group that will gain a new member.GroupNotFoundException
- if the group
could not be foundUserNotFoundException
- if the user
could 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.public boolean addGroupToGroup(Group childGroup, Group parentGroup) throws GroupNotFoundException, OperationNotPermittedException, InvalidMembershipException, OperationFailedException
CrowdService
addGroupToGroup
in interface CrowdService
childGroup
- The group that will become a member of parentGroup
parentGroup
- The group that will gain a new memberGroupNotFoundException
- if any of the group could not be found. Use GroupNotFoundException.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.public boolean removeUserFromGroup(User user, Group group) throws GroupNotFoundException, UserNotFoundException, OperationNotPermittedException, MembershipNotFoundException, OperationFailedException
CrowdService
removeUserFromGroup
in interface CrowdService
user
- The user that will be removed from the group
group
- The group that will lose the member.GroupNotFoundException
- if the group
could not be foundUserNotFoundException
- if the user
could not be foundOperationNotPermittedException
- if the directory has been configured to not allow the operation to be performedOperationFailedException
- if the operation failed for any other reasonMembershipNotFoundException
public boolean removeGroupFromGroup(Group childGroup, Group parentGroup) throws GroupNotFoundException, OperationNotPermittedException, MembershipNotFoundException, OperationFailedException
CrowdService
removeGroupFromGroup
in interface CrowdService
childGroup
- The group that will be removed from parentGroup
parentGroup
- The group that will lose the member.GroupNotFoundException
- if any of the groups could not be found. Use GroupNotFoundException.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 reasonMembershipNotFoundException
public boolean isUserDirectGroupMember(User user, Group group) throws OperationFailedException
CrowdService
isUserDirectGroupMember
in interface CrowdService
user
- the user for whom to check the group membershipgroup
- the group the user
is believed to belong totrue
if the user is a direct member of the group, false
otherwise
(including if the user and/or group could not be found)OperationFailedException
- underlying directory implementation failed to execute the operation.public boolean isGroupDirectGroupMember(Group childGroup, Group parentGroup) throws OperationFailedException
CrowdService
isGroupDirectGroupMember
in interface CrowdService
childGroup
- the group for which to check the parentGroup
membershipparentGroup
- the group the childGroup
is believed to belong totrue
if the childGroup
is a direct member of the parentGroup
, false
otherwise
(including if neither group could be found)OperationFailedException
- underlying directory implementation failed to execute the operation.public UserCapabilities getCapabilitiesForNewUsers()
CrowdService
new users
.
Those capabilities reflects a specific moment in time and are subject to change if any user directory is added, removed or re-ordered.
getCapabilitiesForNewUsers
in interface CrowdService
CrowdService.addUser(User, String)
Copyright © 2021 Atlassian. All rights reserved.