com.atlassian.crowd.directory
Class DbCachingRemoteDirectory

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

public class DbCachingRemoteDirectory
extends java.lang.Object
implements RemoteDirectory, SynchronisableDirectory

A RemoteDirectory that provides LDAP and Crowd integration plus local storage in an internal directory for LDAP user and group attributes, and local groups for LDAP and Crowd users with local caching of remote data. The implementation delegates to an Remote directory for the "source of truth" and an internal directory for caching and some special local storage.

All the attributes for the directory itself (e.g. base DN, other configuration options) are stored on the directory instance.

Terminology used in this class:

Remote user
A user stored in the LDAP or Remote Crowd directory
Remote group
A group stored in the LDAP or Remote Crowd directory.
Local group
A group stored in the internal directory. There must not be an Remote group with the same name for a local group to exist.


Field Summary
static java.lang.String INTERNAL_USER_PASSWORD
           
 
Constructor Summary
DbCachingRemoteDirectory(RemoteDirectory remoteDirectory, InternalRemoteDirectory internalDirectory, DirectoryCacheFactory directoryCacheFactory)
           
 
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 name, 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()
           
 java.lang.String getDescriptiveName()
           
 long getDirectoryId()
           
 java.util.Set<java.lang.String> getKeys()
           
 java.lang.Iterable<Membership> getMemberships()
           
 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 name)
           
 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 name)
           
 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)
           
 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()
          This implementation will store the active flag locally in the internal directory if the active flag cannot be persisted on the underlying remote directory.
 boolean supportsNestedGroups()
           
 void synchroniseCache(SynchronisationMode mode, SynchronisationStatusManager synchronisationStatusManager)
           
 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

INTERNAL_USER_PASSWORD

public static final java.lang.String INTERNAL_USER_PASSWORD
See Also:
Constant Field Values
Constructor Detail

DbCachingRemoteDirectory

public DbCachingRemoteDirectory(RemoteDirectory remoteDirectory,
                                InternalRemoteDirectory internalDirectory,
                                DirectoryCacheFactory directoryCacheFactory)
Method Detail

getDirectoryId

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

setDirectoryId

public void setDirectoryId(long directoryId)
Specified by:
setDirectoryId 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)
Specified by:
setAttributes 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 name,
                         PasswordCredential credential)
                  throws UserNotFoundException,
                         InactiveAccountException,
                         InvalidAuthenticationException,
                         ExpiredCredentialException,
                         OperationFailedException
Specified by:
authenticate in interface RemoteDirectory
Throws:
UserNotFoundException
InactiveAccountException
InvalidAuthenticationException
ExpiredCredentialException
OperationFailedException

getMemberships

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

addUser

public User addUser(UserTemplate user,
                    PasswordCredential credential)
             throws InvalidUserException,
                    InvalidCredentialException,
                    UserAlreadyExistsException,
                    OperationFailedException
Specified by:
addUser in interface RemoteDirectory
Throws:
InvalidUserException
InvalidCredentialException
UserAlreadyExistsException
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 name)
                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,
                         ReadOnlyGroupException
Specified by:
updateGroup in interface RemoteDirectory
Throws:
InvalidGroupException
GroupNotFoundException
OperationFailedException
ReadOnlyGroupException

renameGroup

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

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 name)
                 throws GroupNotFoundException,
                        OperationFailedException,
                        ReadOnlyGroupException
Specified by:
removeGroup in interface RemoteDirectory
Throws:
GroupNotFoundException
OperationFailedException
ReadOnlyGroupException

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,
                           ReadOnlyGroupException
Specified by:
addUserToGroup in interface RemoteDirectory
Throws:
GroupNotFoundException
UserNotFoundException
OperationFailedException
ReadOnlyGroupException

addGroupToGroup

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

removeUserFromGroup

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

removeGroupFromGroup

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

searchGroupRelationships

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

testConnection

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

supportsInactiveAccounts

public boolean supportsInactiveAccounts()
This implementation will store the active flag locally in the internal directory if the active flag cannot be persisted on the underlying remote directory.

Specified by:
supportsInactiveAccounts in interface RemoteDirectory
Returns:
true if the internal directory supports inactive accounts (which it should always do).

supportsNestedGroups

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

isRolesDisabled

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

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

isEmpty

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

getKeys

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

synchroniseCache

public void synchroniseCache(SynchronisationMode mode,
                             SynchronisationStatusManager synchronisationStatusManager)
                      throws OperationFailedException
Specified by:
synchroniseCache in interface SynchronisableDirectory
Throws:
OperationFailedException

getAuthoritativeDirectory

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


Copyright © 2012 Atlassian. All Rights Reserved.