Package com.atlassian.crowd.directory
Class RemoteCrowdDirectory
java.lang.Object
com.atlassian.crowd.directory.RemoteCrowdDirectory
- All Implemented Interfaces:
RemoteDirectory,Attributes
A
RemoteDirectory that allows integration with a remote Crowd server.
This class performs all directory operations against a remote Crowd server. The remote Crowd server sees this class as an application.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDirectory attribute key for application namestatic final StringOAuth2 configuration id to be used for the applicationstatic final StringDirectory attribute key for application passwordprotected AttributeValuesHolderstatic final StringDirectory attribute key for the authentication method (AuthenticationMethod).static final StringDirectory attribute key for max connections.static final StringDirectory attribute key for http proxy host.static final StringDirectory attribute key for http proxy password.static final StringDirectory attribute key for http proxy port.static final StringDirectory attribute key for http proxy username.static final StringDirectory attribute key for http timeout.static final StringDirectory attribute key for remote Crowd server URLstatic final String -
Constructor Summary
ConstructorsConstructorDescriptionRemoteCrowdDirectory(com.atlassian.crowd.service.factory.CrowdClientFactory crowdClientFactory, ClientCredentialsTokenHandlerSupplier tokenHandlerSupplier) Creates a new RemoteCrowdDirectory using the given CrowdClientFactory. -
Method Summary
Modifier and TypeMethodDescriptionaddGroup(GroupTemplate group) voidaddGroupToGroup(String childGroup, String parentGroup) addUser(UserTemplate user, PasswordCredential credential) addUser(UserTemplateWithAttributes user, PasswordCredential credential) voidaddUserToGroup(String username, String groupName) authenticate(String username, PasswordCredential credential) countDirectMembersOfGroup(String groupName, int querySizeHint) voidfindGroupByName(String name) findUserByExternalId(String externalId) findUserByName(String name) protected com.atlassian.crowd.service.client.ClientPropertiescom.atlassian.crowd.service.client.CrowdClientAccess the Crowd client used for communication with the remote Crowd directory, intended for internal reuse only.Returns a token that can be used for querying events that have happened after the token was generated.longgetKeys()getNewEvents(String eventToken) Returns an events object which contains a new eventToken and events that happened after the giveneventTokenwas generated.booleanisEmpty()booleanisGroupDirectGroupMember(String childGroup, String parentGroup) booleanbooleanisUserDirectGroupMember(String username, String groupName) voidremoveGroup(String groupname) voidremoveGroupAttributes(String groupName, String attributeName) voidremoveGroupFromGroup(String childGroup, String parentGroup) voidremoveUser(String username) voidremoveUserAttributes(String username, String attributeName) voidremoveUserFromGroup(String username, String groupName) renameGroup(String oldName, String newName) renameUser(String oldName, String newName) <T> List<T> searchGroupRelationships(MembershipQuery<T> query) <T> List<T> searchGroups(EntityQuery<T> query) <T> List<T> searchUsers(EntityQuery<T> query) voidsetAttributes(Map<String, String> attributes) Called by theDirectoryInstanceLoaderafter constructing an InternalDirectory.voidsetDirectoryId(long directoryId) voidvoidbooleanRemote crowd directories always support inactive accounts.booleanbooleanbooleanvoidupdateGroup(GroupTemplate group) updateUser(UserTemplate user) voidupdateUserCredential(String username, PasswordCredential credential) userAuthenticated(String username) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.atlassian.crowd.directory.RemoteDirectory
authenticate, getLocallyFilteredGroupNames, getUserAvatarByName, updateUserFromRemoteDirectory
-
Field Details
-
DESCRIPTIVE_NAME
- See Also:
-
APPLICATION_NAME
Directory attribute key for application name- See Also:
-
APPLICATION_PASSWORD
Directory attribute key for application password- See Also:
-
APPLICATION_OAUTH2_CLIENT_CONFIG_ID
OAuth2 configuration id to be used for the application- Since:
- 7.0.0
- See Also:
-
CROWD_SERVER_URL
Directory attribute key for remote Crowd server URL- See Also:
-
AUTHENTICATION_METHOD_ATTRIBUTE
Directory attribute key for the authentication method (AuthenticationMethod).- See Also:
-
CROWD_HTTP_TIMEOUT
Directory attribute key for http timeout.- See Also:
-
CROWD_HTTP_MAX_CONNECTIONS
Directory attribute key for max connections.- See Also:
-
CROWD_HTTP_PROXY_HOST
Directory attribute key for http proxy host.- See Also:
-
CROWD_HTTP_PROXY_PORT
Directory attribute key for http proxy port.- See Also:
-
CROWD_HTTP_PROXY_USERNAME
Directory attribute key for http proxy username.- See Also:
-
CROWD_HTTP_PROXY_PASSWORD
Directory attribute key for http proxy password.- See Also:
-
attributes
-
-
Constructor Details
-
RemoteCrowdDirectory
public RemoteCrowdDirectory(com.atlassian.crowd.service.factory.CrowdClientFactory crowdClientFactory, ClientCredentialsTokenHandlerSupplier tokenHandlerSupplier) Creates a new RemoteCrowdDirectory using the given CrowdClientFactory.- Parameters:
crowdClientFactory- factory for creating aCrowdClient
-
-
Method Details
-
getDirectoryId
public long getDirectoryId()- Specified by:
getDirectoryIdin interfaceRemoteDirectory
-
setDirectoryId
public void setDirectoryId(long directoryId) - Specified by:
setDirectoryIdin interfaceRemoteDirectory
-
findUserByName
- Specified by:
findUserByNamein interfaceRemoteDirectory- Throws:
UserNotFoundExceptionOperationFailedException
-
findUserWithAttributesByName
public UserWithAttributes findUserWithAttributesByName(String name) throws UserNotFoundException, OperationFailedException - Specified by:
findUserWithAttributesByNamein interfaceRemoteDirectory- Throws:
UserNotFoundExceptionOperationFailedException
-
findUserByExternalId
public User findUserByExternalId(String externalId) throws UserNotFoundException, OperationFailedException - Specified by:
findUserByExternalIdin interfaceRemoteDirectory- Throws:
UserNotFoundExceptionOperationFailedException
-
authenticate
public User authenticate(String username, PasswordCredential credential) throws UserNotFoundException, InactiveAccountException, InvalidAuthenticationException, ExpiredCredentialException, OperationFailedException - Specified by:
authenticatein interfaceRemoteDirectory- Throws:
UserNotFoundExceptionInactiveAccountExceptionInvalidAuthenticationExceptionExpiredCredentialExceptionOperationFailedException
-
addUser
public User addUser(UserTemplate user, PasswordCredential credential) throws InvalidUserException, InvalidCredentialException, OperationFailedException - Specified by:
addUserin interfaceRemoteDirectory- Throws:
InvalidUserExceptionInvalidCredentialExceptionOperationFailedException
-
addUser
public UserWithAttributes addUser(UserTemplateWithAttributes user, PasswordCredential credential) throws InvalidUserException, InvalidCredentialException, OperationFailedException - Specified by:
addUserin interfaceRemoteDirectory- Throws:
InvalidUserExceptionInvalidCredentialExceptionOperationFailedException
-
expireAllPasswords
- Specified by:
expireAllPasswordsin interfaceRemoteDirectory- Throws:
OperationFailedException
-
updateUser
public User updateUser(UserTemplate user) throws InvalidUserException, UserNotFoundException, OperationFailedException - Specified by:
updateUserin interfaceRemoteDirectory- Throws:
InvalidUserExceptionUserNotFoundExceptionOperationFailedException
-
updateUserCredential
public void updateUserCredential(String username, PasswordCredential credential) throws UserNotFoundException, InvalidCredentialException, OperationFailedException - Specified by:
updateUserCredentialin interfaceRemoteDirectory- Throws:
UserNotFoundExceptionInvalidCredentialExceptionOperationFailedException
-
renameUser
public User renameUser(String oldName, String newName) throws UserNotFoundException, InvalidUserException, OperationFailedException - Specified by:
renameUserin interfaceRemoteDirectory- Throws:
UserNotFoundExceptionInvalidUserExceptionOperationFailedException
-
storeUserAttributes
public void storeUserAttributes(String username, Map<String, Set<String>> attributes) throws UserNotFoundException, OperationFailedException- Specified by:
storeUserAttributesin interfaceRemoteDirectory- Throws:
UserNotFoundExceptionOperationFailedException
-
removeUserAttributes
public void removeUserAttributes(String username, String attributeName) throws UserNotFoundException, OperationFailedException - Specified by:
removeUserAttributesin interfaceRemoteDirectory- Throws:
UserNotFoundExceptionOperationFailedException
-
removeUser
- Specified by:
removeUserin interfaceRemoteDirectory- Throws:
UserNotFoundExceptionOperationFailedException
-
searchUsers
- Specified by:
searchUsersin interfaceRemoteDirectory- Throws:
OperationFailedException
-
findGroupByName
- Specified by:
findGroupByNamein interfaceRemoteDirectory- Throws:
GroupNotFoundExceptionOperationFailedException
-
findGroupWithAttributesByName
public GroupWithAttributes findGroupWithAttributesByName(String name) throws GroupNotFoundException, OperationFailedException - Specified by:
findGroupWithAttributesByNamein interfaceRemoteDirectory- Throws:
GroupNotFoundExceptionOperationFailedException
-
addGroup
- Specified by:
addGroupin interfaceRemoteDirectory- Throws:
InvalidGroupExceptionOperationFailedException
-
updateGroup
public Group updateGroup(GroupTemplate group) throws InvalidGroupException, GroupNotFoundException, OperationFailedException - Specified by:
updateGroupin interfaceRemoteDirectory- Throws:
InvalidGroupExceptionGroupNotFoundExceptionOperationFailedException
-
renameGroup
public Group renameGroup(String oldName, String newName) throws GroupNotFoundException, InvalidGroupException, OperationFailedException - Specified by:
renameGroupin interfaceRemoteDirectory- Throws:
GroupNotFoundExceptionInvalidGroupExceptionOperationFailedException
-
storeGroupAttributes
public void storeGroupAttributes(String groupName, Map<String, Set<String>> attributes) throws GroupNotFoundException, OperationFailedException- Specified by:
storeGroupAttributesin interfaceRemoteDirectory- Throws:
GroupNotFoundExceptionOperationFailedException
-
removeGroupAttributes
public void removeGroupAttributes(String groupName, String attributeName) throws GroupNotFoundException, OperationFailedException - Specified by:
removeGroupAttributesin interfaceRemoteDirectory- Throws:
GroupNotFoundExceptionOperationFailedException
-
removeGroup
- Specified by:
removeGroupin interfaceRemoteDirectory- Throws:
GroupNotFoundExceptionOperationFailedException
-
searchGroups
- Specified by:
searchGroupsin interfaceRemoteDirectory- Throws:
OperationFailedException
-
isUserDirectGroupMember
public boolean isUserDirectGroupMember(String username, String groupName) throws OperationFailedException - Specified by:
isUserDirectGroupMemberin interfaceRemoteDirectory- Throws:
OperationFailedException
-
isGroupDirectGroupMember
public boolean isGroupDirectGroupMember(String childGroup, String parentGroup) throws OperationFailedException - Specified by:
isGroupDirectGroupMemberin interfaceRemoteDirectory- Throws:
OperationFailedException
-
countDirectMembersOfGroup
public BoundedCount countDirectMembersOfGroup(String groupName, int querySizeHint) throws OperationFailedException - Specified by:
countDirectMembersOfGroupin interfaceRemoteDirectory- Throws:
OperationFailedException
-
addUserToGroup
public void addUserToGroup(String username, String groupName) throws GroupNotFoundException, UserNotFoundException, OperationFailedException, MembershipAlreadyExistsException - Specified by:
addUserToGroupin interfaceRemoteDirectory- Throws:
GroupNotFoundExceptionUserNotFoundExceptionOperationFailedExceptionMembershipAlreadyExistsException
-
addGroupToGroup
public void addGroupToGroup(String childGroup, String parentGroup) throws GroupNotFoundException, InvalidMembershipException, OperationFailedException, MembershipAlreadyExistsException - Specified by:
addGroupToGroupin interfaceRemoteDirectory- Throws:
GroupNotFoundExceptionInvalidMembershipExceptionOperationFailedExceptionMembershipAlreadyExistsException
-
removeUserFromGroup
public void removeUserFromGroup(String username, String groupName) throws GroupNotFoundException, UserNotFoundException, MembershipNotFoundException, OperationFailedException - Specified by:
removeUserFromGroupin interfaceRemoteDirectory- Throws:
GroupNotFoundExceptionUserNotFoundExceptionMembershipNotFoundExceptionOperationFailedException
-
removeGroupFromGroup
public void removeGroupFromGroup(String childGroup, String parentGroup) throws GroupNotFoundException, InvalidMembershipException, MembershipNotFoundException, OperationFailedException - Specified by:
removeGroupFromGroupin interfaceRemoteDirectory- Throws:
GroupNotFoundExceptionInvalidMembershipExceptionMembershipNotFoundExceptionOperationFailedException
-
searchGroupRelationships
public <T> List<T> searchGroupRelationships(MembershipQuery<T> query) throws OperationFailedException - Specified by:
searchGroupRelationshipsin interfaceRemoteDirectory- Throws:
OperationFailedException
-
getCurrentEventToken
public String getCurrentEventToken() throws OperationFailedException, IncrementalSynchronisationNotAvailableExceptionReturns a token that can be used for querying events that have happened after the token was generated.If the event token has not changed since the last call to this method, it is guaranteed that no new events have been received.
The format of event token is implementation specific and can change without a warning.
- Returns:
- token that can be used for querying events that have happened after the token was generated
- Throws:
UnsupportedCrowdApiException- if the remote server does not support this operationOperationFailedException- if the operation has failed for any other reason, including invalid argumentsIncrementalSynchronisationNotAvailableException- if the application cannot provide incremental synchronisation
-
getNewEvents
public Events getNewEvents(String eventToken) throws EventTokenExpiredException, OperationFailedException Returns an events object which contains a new eventToken and events that happened after the giveneventTokenwas generated.If for any reason event store is unable to retrieve events that happened after the event token was generated, an
EventTokenExpiredExceptionwill be thrown. The caller is then expected to callgetCurrentEventToken()again before asking for new events.- Parameters:
eventToken- event token that was retrieved by a call togetCurrentEventToken()orgetNewEvents(String)- Returns:
- events object which contains a new eventToken and events that happened after the given
eventTokenwas generated - Throws:
EventTokenExpiredException- if events that happened after the event token was generated can not be retrievedUnsupportedCrowdApiException- if the remote server does not support this operationOperationFailedException- if the operation has failed for any other reason, including invalid arguments
-
testConnection
- Specified by:
testConnectionin interfaceRemoteDirectory- Throws:
OperationFailedException
-
supportsInactiveAccounts
public boolean supportsInactiveAccounts()Remote crowd directories always support inactive accounts.- Specified by:
supportsInactiveAccountsin interfaceRemoteDirectory- Returns:
- true
-
supportsNestedGroups
public boolean supportsNestedGroups()- Specified by:
supportsNestedGroupsin interfaceRemoteDirectory
-
supportsPasswordExpiration
public boolean supportsPasswordExpiration()- Specified by:
supportsPasswordExpirationin interfaceRemoteDirectory
-
supportsSettingEncryptedCredential
public boolean supportsSettingEncryptedCredential()- Specified by:
supportsSettingEncryptedCredentialin interfaceRemoteDirectory
-
isRolesDisabled
public boolean isRolesDisabled()- Specified by:
isRolesDisabledin interfaceRemoteDirectory
-
getDescriptiveName
- Specified by:
getDescriptiveNamein interfaceRemoteDirectory
-
setAttributes
Called by theDirectoryInstanceLoaderafter constructing an InternalDirectory.- Specified by:
setAttributesin interfaceRemoteDirectory- Parameters:
attributes- attributes map.
-
getValues
- Specified by:
getValuesin interfaceAttributes
-
getValue
- Specified by:
getValuein interfaceAttributes
-
getKeys
- Specified by:
getKeysin interfaceAttributes
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceAttributes
-
getAuthoritativeDirectory
- Specified by:
getAuthoritativeDirectoryin interfaceRemoteDirectory
-
getClientProperties
protected com.atlassian.crowd.service.client.ClientProperties getClientProperties() throws com.atlassian.oauth2.client.api.storage.token.exception.UnrecoverableTokenException, com.atlassian.oauth2.client.api.storage.token.exception.RecoverableTokenException- Throws:
com.atlassian.oauth2.client.api.storage.token.exception.UnrecoverableTokenExceptioncom.atlassian.oauth2.client.api.storage.token.exception.RecoverableTokenException
-
getCrowdClient
public com.atlassian.crowd.service.client.CrowdClient getCrowdClient() throws OperationFailedExceptionAccess the Crowd client used for communication with the remote Crowd directory, intended for internal reuse only.- Throws:
OperationFailedException
-
getMemberships
- Specified by:
getMembershipsin interfaceRemoteDirectory- Throws:
OperationFailedException
-
userAuthenticated
public User userAuthenticated(String username) throws OperationFailedException, UserNotFoundException, InactiveAccountException - Specified by:
userAuthenticatedin interfaceRemoteDirectory- Throws:
OperationFailedExceptionUserNotFoundExceptionInactiveAccountException
-