com.atlassian.crowd.directory
Class RemoteCrowdDirectory

java.lang.Object
  extended by com.atlassian.crowd.directory.RemoteCrowdDirectory
All Implemented Interfaces:
RemoteDirectory, Attributes

public class RemoteCrowdDirectory
extends java.lang.Object
implements RemoteDirectory

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
static java.lang.String APPLICATION_NAME
          Directory attribute key for application name
static java.lang.String APPLICATION_PASSWORD
          Directory attribute key for application password
protected  AttributeValuesHolder attributes
           
static java.lang.String CROWD_HTTP_MAX_CONNECTIONS
          Directory attribute key for max connections.
static java.lang.String CROWD_HTTP_PROXY_HOST
          Directory attribute key for http proxy host.
static java.lang.String CROWD_HTTP_PROXY_PASSWORD
          Directory attribute key for http proxy password.
static java.lang.String CROWD_HTTP_PROXY_PORT
          Directory attribute key for http proxy port.
static java.lang.String CROWD_HTTP_PROXY_USERNAME
          Directory attribute key for http proxy username.
static java.lang.String CROWD_HTTP_TIMEOUT
          Directory attribute key for http timeout.
static java.lang.String CROWD_SERVER_URL
          Directory attribute key for remote Crowd server URL
static java.lang.String DESCRIPTIVE_NAME
           
 
Constructor Summary
RemoteCrowdDirectory(CrowdClientFactory crowdClientFactory)
          Creates a new RemoteCrowdDirectory using the given CrowdClientFactory.
 
Method Summary
 Group addGroup(GroupTemplate group)
           
 void addGroupToGroup(java.lang.String childGroup, java.lang.String parentGroup)
           
 User addUser(UserTemplate user, PasswordCredential credential)
           
 void addUserToGroup(java.lang.String username, java.lang.String groupName)
           
 User authenticate(java.lang.String username, PasswordCredential credential)
           
 Group findGroupByName(java.lang.String name)
           
 GroupWithAttributes findGroupWithAttributesByName(java.lang.String name)
           
 User findUserByName(java.lang.String name)
           
 UserWithAttributes findUserWithAttributesByName(java.lang.String name)
           
 RemoteDirectory getAuthoritativeDirectory()
           
protected  ClientProperties getClientProperties()
           
 java.lang.String getCurrentEventToken()
          Returns a token that can be used for querying events that have happened after the token was generated.
 java.lang.String getDescriptiveName()
           
 long getDirectoryId()
           
 java.util.Set<java.lang.String> getKeys()
           
 java.lang.Iterable<Membership> getMemberships()
           
 Events getNewEvents(java.lang.String eventToken)
          Returns an events object which contains a new eventToken and events that happened after the given eventToken was generated.
 java.lang.String getValue(java.lang.String name)
           
 java.util.Set<java.lang.String> getValues(java.lang.String name)
           
 boolean isEmpty()
           
 boolean isGroupDirectGroupMember(java.lang.String childGroup, java.lang.String parentGroup)
           
 boolean isRolesDisabled()
           
 boolean isUserDirectGroupMember(java.lang.String username, java.lang.String groupName)
           
 void removeGroup(java.lang.String groupname)
           
 void removeGroupAttributes(java.lang.String groupName, java.lang.String attributeName)
           
 void removeGroupFromGroup(java.lang.String childGroup, java.lang.String parentGroup)
           
 void removeUser(java.lang.String username)
           
 void removeUserAttributes(java.lang.String username, java.lang.String attributeName)
           
 void removeUserFromGroup(java.lang.String username, java.lang.String groupName)
           
 Group renameGroup(java.lang.String oldName, java.lang.String newName)
           
 User renameUser(java.lang.String oldName, java.lang.String newName)
           
<T> java.util.List<T>
searchGroupRelationships(MembershipQuery<T> query)
           
<T> java.util.List<T>
searchGroups(EntityQuery<T> query)
           
<T> java.util.List<T>
searchUsers(EntityQuery<T> query)
           
 void setAttributes(java.util.Map<java.lang.String,java.lang.String> attributes)
          Called by the DirectoryInstanceLoader after constructing an InternalDirectory.
 void setDirectoryId(long directoryId)
           
 void storeGroupAttributes(java.lang.String groupName, java.util.Map<java.lang.String,java.util.Set<java.lang.String>> attributes)
           
 void storeUserAttributes(java.lang.String username, java.util.Map<java.lang.String,java.util.Set<java.lang.String>> attributes)
           
 boolean supportsInactiveAccounts()
          Remote crowd directories always support inactive accounts.
 boolean supportsNestedGroups()
           
 void testConnection()
           
 Group updateGroup(GroupTemplate group)
           
 User updateUser(UserTemplate user)
           
 void updateUserCredential(java.lang.String username, PasswordCredential credential)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DESCRIPTIVE_NAME

public static final java.lang.String DESCRIPTIVE_NAME
See Also:
Constant Field Values

APPLICATION_NAME

public static final java.lang.String APPLICATION_NAME
Directory attribute key for application name

See Also:
Constant Field Values

APPLICATION_PASSWORD

public static final java.lang.String APPLICATION_PASSWORD
Directory attribute key for application password

See Also:
Constant Field Values

CROWD_SERVER_URL

public static final java.lang.String CROWD_SERVER_URL
Directory attribute key for remote Crowd server URL

See Also:
Constant Field Values

CROWD_HTTP_TIMEOUT

public static final java.lang.String CROWD_HTTP_TIMEOUT
Directory attribute key for http timeout.

See Also:
Constant Field Values

CROWD_HTTP_MAX_CONNECTIONS

public static final java.lang.String CROWD_HTTP_MAX_CONNECTIONS
Directory attribute key for max connections.

See Also:
Constant Field Values

CROWD_HTTP_PROXY_HOST

public static final java.lang.String CROWD_HTTP_PROXY_HOST
Directory attribute key for http proxy host.

See Also:
Constant Field Values

CROWD_HTTP_PROXY_PORT

public static final java.lang.String CROWD_HTTP_PROXY_PORT
Directory attribute key for http proxy port.

See Also:
Constant Field Values

CROWD_HTTP_PROXY_USERNAME

public static final java.lang.String CROWD_HTTP_PROXY_USERNAME
Directory attribute key for http proxy username.

See Also:
Constant Field Values

CROWD_HTTP_PROXY_PASSWORD

public static final java.lang.String CROWD_HTTP_PROXY_PASSWORD
Directory attribute key for http proxy password.

See Also:
Constant Field Values

attributes

protected AttributeValuesHolder attributes
Constructor Detail

RemoteCrowdDirectory

public RemoteCrowdDirectory(CrowdClientFactory crowdClientFactory)
Creates a new RemoteCrowdDirectory using the given CrowdClientFactory.

Parameters:
crowdClientFactory - factory for creating a CrowdClient
Method Detail

getDirectoryId

public long getDirectoryId()
Specified by:
getDirectoryId in interface RemoteDirectory

setDirectoryId

public void setDirectoryId(long directoryId)
Specified by:
setDirectoryId in interface RemoteDirectory

findUserByName

public User findUserByName(java.lang.String name)
                    throws UserNotFoundException,
                           OperationFailedException
Specified by:
findUserByName in interface RemoteDirectory
Throws:
UserNotFoundException
OperationFailedException

findUserWithAttributesByName

public UserWithAttributes findUserWithAttributesByName(java.lang.String name)
                                                throws UserNotFoundException,
                                                       OperationFailedException
Specified by:
findUserWithAttributesByName in interface RemoteDirectory
Throws:
UserNotFoundException
OperationFailedException

authenticate

public User authenticate(java.lang.String username,
                         PasswordCredential credential)
                  throws UserNotFoundException,
                         InactiveAccountException,
                         InvalidAuthenticationException,
                         ExpiredCredentialException,
                         OperationFailedException
Specified by:
authenticate in interface RemoteDirectory
Throws:
UserNotFoundException
InactiveAccountException
InvalidAuthenticationException
ExpiredCredentialException
OperationFailedException

addUser

public User addUser(UserTemplate user,
                    PasswordCredential credential)
             throws InvalidUserException,
                    InvalidCredentialException,
                    OperationFailedException
Specified by:
addUser in interface RemoteDirectory
Throws:
InvalidUserException
InvalidCredentialException
OperationFailedException

updateUser

public User updateUser(UserTemplate user)
                throws InvalidUserException,
                       UserNotFoundException,
                       OperationFailedException
Specified by:
updateUser in interface RemoteDirectory
Throws:
InvalidUserException
UserNotFoundException
OperationFailedException

updateUserCredential

public void updateUserCredential(java.lang.String username,
                                 PasswordCredential credential)
                          throws UserNotFoundException,
                                 InvalidCredentialException,
                                 OperationFailedException
Specified by:
updateUserCredential in interface RemoteDirectory
Throws:
UserNotFoundException
InvalidCredentialException
OperationFailedException

renameUser

public User renameUser(java.lang.String oldName,
                       java.lang.String newName)
                throws UserNotFoundException,
                       InvalidUserException
Specified by:
renameUser in interface RemoteDirectory
Throws:
UserNotFoundException
InvalidUserException

storeUserAttributes

public void storeUserAttributes(java.lang.String username,
                                java.util.Map<java.lang.String,java.util.Set<java.lang.String>> attributes)
                         throws UserNotFoundException,
                                OperationFailedException
Specified by:
storeUserAttributes in interface RemoteDirectory
Throws:
UserNotFoundException
OperationFailedException

removeUserAttributes

public void removeUserAttributes(java.lang.String username,
                                 java.lang.String attributeName)
                          throws UserNotFoundException,
                                 OperationFailedException
Specified by:
removeUserAttributes in interface RemoteDirectory
Throws:
UserNotFoundException
OperationFailedException

removeUser

public void removeUser(java.lang.String username)
                throws UserNotFoundException,
                       OperationFailedException
Specified by:
removeUser in interface RemoteDirectory
Throws:
UserNotFoundException
OperationFailedException

searchUsers

public <T> java.util.List<T> searchUsers(EntityQuery<T> query)
                              throws OperationFailedException
Specified by:
searchUsers in interface RemoteDirectory
Throws:
OperationFailedException

findGroupByName

public Group findGroupByName(java.lang.String name)
                      throws GroupNotFoundException,
                             OperationFailedException
Specified by:
findGroupByName in interface RemoteDirectory
Throws:
GroupNotFoundException
OperationFailedException

findGroupWithAttributesByName

public GroupWithAttributes findGroupWithAttributesByName(java.lang.String name)
                                                  throws GroupNotFoundException,
                                                         OperationFailedException
Specified by:
findGroupWithAttributesByName in interface RemoteDirectory
Throws:
GroupNotFoundException
OperationFailedException

addGroup

public Group addGroup(GroupTemplate group)
               throws InvalidGroupException,
                      OperationFailedException
Specified by:
addGroup in interface RemoteDirectory
Throws:
InvalidGroupException
OperationFailedException

updateGroup

public Group updateGroup(GroupTemplate group)
                  throws InvalidGroupException,
                         GroupNotFoundException,
                         OperationFailedException
Specified by:
updateGroup in interface RemoteDirectory
Throws:
InvalidGroupException
GroupNotFoundException
OperationFailedException

renameGroup

public Group renameGroup(java.lang.String oldName,
                         java.lang.String newName)
                  throws GroupNotFoundException,
                         InvalidGroupException,
                         OperationFailedException
Specified by:
renameGroup in interface RemoteDirectory
Throws:
GroupNotFoundException
InvalidGroupException
OperationFailedException

storeGroupAttributes

public void storeGroupAttributes(java.lang.String groupName,
                                 java.util.Map<java.lang.String,java.util.Set<java.lang.String>> attributes)
                          throws GroupNotFoundException,
                                 OperationFailedException
Specified by:
storeGroupAttributes in interface RemoteDirectory
Throws:
GroupNotFoundException
OperationFailedException

removeGroupAttributes

public void removeGroupAttributes(java.lang.String groupName,
                                  java.lang.String attributeName)
                           throws GroupNotFoundException,
                                  OperationFailedException
Specified by:
removeGroupAttributes in interface RemoteDirectory
Throws:
GroupNotFoundException
OperationFailedException

removeGroup

public void removeGroup(java.lang.String groupname)
                 throws GroupNotFoundException,
                        OperationFailedException
Specified by:
removeGroup in interface RemoteDirectory
Throws:
GroupNotFoundException
OperationFailedException

searchGroups

public <T> java.util.List<T> searchGroups(EntityQuery<T> query)
                               throws OperationFailedException
Specified by:
searchGroups in interface RemoteDirectory
Throws:
OperationFailedException

isUserDirectGroupMember

public boolean isUserDirectGroupMember(java.lang.String username,
                                       java.lang.String groupName)
                                throws OperationFailedException
Specified by:
isUserDirectGroupMember in interface RemoteDirectory
Throws:
OperationFailedException

isGroupDirectGroupMember

public boolean isGroupDirectGroupMember(java.lang.String childGroup,
                                        java.lang.String parentGroup)
                                 throws OperationFailedException
Specified by:
isGroupDirectGroupMember in interface RemoteDirectory
Throws:
OperationFailedException

addUserToGroup

public void addUserToGroup(java.lang.String username,
                           java.lang.String groupName)
                    throws GroupNotFoundException,
                           UserNotFoundException,
                           OperationFailedException
Specified by:
addUserToGroup in interface RemoteDirectory
Throws:
GroupNotFoundException
UserNotFoundException
OperationFailedException

addGroupToGroup

public void addGroupToGroup(java.lang.String childGroup,
                            java.lang.String parentGroup)
                     throws GroupNotFoundException,
                            InvalidMembershipException,
                            OperationFailedException
Specified by:
addGroupToGroup in interface RemoteDirectory
Throws:
GroupNotFoundException
InvalidMembershipException
OperationFailedException

removeUserFromGroup

public void removeUserFromGroup(java.lang.String username,
                                java.lang.String groupName)
                         throws GroupNotFoundException,
                                UserNotFoundException,
                                MembershipNotFoundException,
                                OperationFailedException
Specified by:
removeUserFromGroup in interface RemoteDirectory
Throws:
GroupNotFoundException
UserNotFoundException
MembershipNotFoundException
OperationFailedException

removeGroupFromGroup

public void removeGroupFromGroup(java.lang.String childGroup,
                                 java.lang.String parentGroup)
                          throws GroupNotFoundException,
                                 InvalidMembershipException,
                                 MembershipNotFoundException,
                                 OperationFailedException
Specified by:
removeGroupFromGroup in interface RemoteDirectory
Throws:
GroupNotFoundException
InvalidMembershipException
MembershipNotFoundException
OperationFailedException

searchGroupRelationships

public <T> java.util.List<T> searchGroupRelationships(MembershipQuery<T> query)
                                           throws OperationFailedException
Specified by:
searchGroupRelationships in interface RemoteDirectory
Throws:
OperationFailedException

getCurrentEventToken

public java.lang.String getCurrentEventToken()
                                      throws OperationFailedException,
                                             IncrementalSynchronisationNotAvailableException
Returns 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 operation
OperationFailedException - if the operation has failed for any other reason, including invalid arguments
IncrementalSynchronisationNotAvailableException - if the application cannot provide incremental synchronisation

getNewEvents

public Events getNewEvents(java.lang.String eventToken)
                    throws EventTokenExpiredException,
                           OperationFailedException
Returns an events object which contains a new eventToken and events that happened after the given eventToken was generated.

If for any reason event store is unable to retrieve events that happened after the event token was generated, an EventTokenExpiredException will be thrown. The caller is then expected to call getCurrentEventToken() again before asking for new events.

Parameters:
eventToken - event token that was retrieved by a call to getCurrentEventToken() or getNewEvents(String)
Returns:
events object which contains a new eventToken and events that happened after the given eventToken was generated
Throws:
EventTokenExpiredException - if events that happened after the event token was generated can not be retrieved
UnsupportedCrowdApiException - if the remote server does not support this operation
OperationFailedException - if the operation has failed for any other reason, including invalid arguments

testConnection

public void testConnection()
                    throws OperationFailedException
Specified by:
testConnection in interface RemoteDirectory
Throws:
OperationFailedException

supportsInactiveAccounts

public boolean supportsInactiveAccounts()
Remote crowd directories always support inactive accounts.

Specified by:
supportsInactiveAccounts in interface RemoteDirectory
Returns:
true

supportsNestedGroups

public boolean supportsNestedGroups()
Specified by:
supportsNestedGroups in interface RemoteDirectory

isRolesDisabled

public boolean isRolesDisabled()
Specified by:
isRolesDisabled in interface RemoteDirectory

getDescriptiveName

public java.lang.String getDescriptiveName()
Specified by:
getDescriptiveName in interface RemoteDirectory

setAttributes

public void setAttributes(java.util.Map<java.lang.String,java.lang.String> attributes)
Called by the DirectoryInstanceLoader after constructing an InternalDirectory.

Specified by:
setAttributes in interface RemoteDirectory
Parameters:
attributes - attributes map.

getValues

public java.util.Set<java.lang.String> getValues(java.lang.String name)
Specified by:
getValues in interface Attributes

getValue

public java.lang.String getValue(java.lang.String name)
Specified by:
getValue in interface Attributes

getKeys

public java.util.Set<java.lang.String> getKeys()
Specified by:
getKeys in interface Attributes

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Attributes

getAuthoritativeDirectory

public RemoteDirectory getAuthoritativeDirectory()
Specified by:
getAuthoritativeDirectory in interface RemoteDirectory

getClientProperties

protected ClientProperties getClientProperties()

getMemberships

public java.lang.Iterable<Membership> getMemberships()
                                              throws OperationFailedException
Specified by:
getMemberships in interface RemoteDirectory
Throws:
OperationFailedException


Copyright © 2012 Atlassian. All Rights Reserved.