com.atlassian.crowd.integration.directory.cache
Class LDAPDirectoryCache

java.lang.Object
  extended by com.atlassian.crowd.integration.directory.cache.DefaultDirectoryCache
      extended by com.atlassian.crowd.integration.directory.cache.LDAPDirectoryCache
All Implemented Interfaces:
DirectoryCache, com.atlassian.event.EventListener
Direct Known Subclasses:
MicrosoftActiveDirectoryCache

public class LDAPDirectoryCache
extends DefaultDirectoryCache

In addition to DefaultDirectoryCache caches, the LDAPDirectoryCache adds the following:

1. dn -> entityType, entityName : dn mappings for groups and users only (NOT roles), as they can be members of containers (groups and roles) this stores null if cache doesn't know the mapping and false if the cache knows that the dn maps to nothing useful 2. entityType, entityName -> dn : the reverse mapping


Field Summary
protected  net.sf.ehcache.Cache dnToEntityIdentifierCache
           
protected  net.sf.ehcache.Cache entityIdentifierToDnCache
           
 
Fields inherited from class com.atlassian.crowd.integration.directory.cache.DefaultDirectoryCache
cacheManager, directoryId, groupCache, groupChildGroupsCache, groupGroupMembershipExistsCache, groupNamesCache, groupParentGroupsCache, groupUsersCache, logger, maxElementsInMemoryPerSubCache, userCache, userGroupMembershipExistsCache, userGroupsCache, userNamesCache
 
Constructor Summary
LDAPDirectoryCache(long directoryID, net.sf.ehcache.CacheManager ehcacheManager, int maxElementsInMemoryPerSubCache)
           
 
Method Summary
protected  void doClear()
           
protected  void doClose()
           
protected  java.lang.String getDn(DirectoryEntity directoryEntity)
           
protected  java.lang.String getDnForEntityIdentifier(EntityIdentifier identifier)
           
 EntityIdentifier getEntityIdentifierForDn(java.lang.String dn)
          Finds the cached entity identifier for the supplied DN.
 Group getGroup(java.lang.String groupName)
          Returns the cached Group matching the directoryID and groupName.
 User getUser(java.lang.String userName)
          Returns the cached User matching the directoryID and username.
protected  void removeDnMapping(EntityType type, java.lang.String name)
           
 void removeDnMapping(java.lang.String dn)
           
 void removeGroup(java.lang.String groupName)
          Removes a group (if it exists in the cache), along with any existing relationships of the group to users or groups.
 void removeUser(java.lang.String userName)
          Removes a user (if it exists in the cache), along with any existing relationships of the user to groups or roles.
protected  void storeDnMapping(DirectoryEntity entity)
           
 void storeGroup(Group group)
          Stores a clone of the supplied group object in the cache.
 void storeUser(User user)
          Stores a clone of the supplied user object in the cache.
protected  void updateGroupMembersFromMemberDNs(Group group)
           
 
Methods inherited from class com.atlassian.crowd.integration.directory.cache.DefaultDirectoryCache
addMembership, addRelationship, clear, close, createAndConfigureCache, doHandleEvent, getAllEntityNames, getAllEntityNamesAsList, getAllGroupNames, getAllUserNames, getCompleteRelationshipsAsList, getEntity, getFromCache, getGroupMembershipsOfGroup, getGroupMembershipsOfUser, getGroupMembersOfGroup, getHandledEventClasses, getKey, getKeys, getRelationships, getRelationshipsAsList, getStatistics, getUserMembersOfGroup, handleEvent, isEventForThisCache, isGroupGroupMember, isMember, isUserGroupMember, lockRead, lockWrite, removeAllRelations, removeCache, removeEntity, removeGroupAsGroupMember, removeMembership, removeRelationship, removeUserAsGroupMember, setGroupAsGroupMember, setMembershipFlag, setUserAsGroupMember, storeAllEntityNames, storeAllGroupNames, storeAllUserNames, storeEntity, storeGroupMembershipsOfGroup, storeGroupMembershipsOfUser, storeGroupMembersOfGroup, storeMembers, storeMemberships, storeUserMembersOfGroup, unlockRead, unlockWrite
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dnToEntityIdentifierCache

protected final net.sf.ehcache.Cache dnToEntityIdentifierCache

entityIdentifierToDnCache

protected final net.sf.ehcache.Cache entityIdentifierToDnCache
Constructor Detail

LDAPDirectoryCache

public LDAPDirectoryCache(long directoryID,
                          net.sf.ehcache.CacheManager ehcacheManager,
                          int maxElementsInMemoryPerSubCache)
Method Detail

doClear

protected void doClear()
Overrides:
doClear in class DefaultDirectoryCache

doClose

protected void doClose()
Overrides:
doClose in class DefaultDirectoryCache

storeUser

public void storeUser(User user)
Description copied from interface: DirectoryCache
Stores a clone of the supplied user object in the cache. If a user with the same name already exists in the cache, then it is silently replaced.

Specified by:
storeUser in interface DirectoryCache
Overrides:
storeUser in class DefaultDirectoryCache
Parameters:
user - user to cache.

storeGroup

public void storeGroup(Group group)
Description copied from interface: DirectoryCache
Stores a clone of the supplied group object in the cache. If a group with the same name already exists in the cache, then it is silently replaced.

Specified by:
storeGroup in interface DirectoryCache
Overrides:
storeGroup in class DefaultDirectoryCache
Parameters:
group - group to cache.

removeUser

public void removeUser(java.lang.String userName)
Description copied from interface: DirectoryCache
Removes a user (if it exists in the cache), along with any existing relationships of the user to groups or roles. The cache entry will be marked so that subsequent calls to getUser(username) will throw an ObjectNotFoundException.

Specified by:
removeUser in interface DirectoryCache
Overrides:
removeUser in class DefaultDirectoryCache
Parameters:
userName - name of user to remove from cache.

removeGroup

public void removeGroup(java.lang.String groupName)
Description copied from interface: DirectoryCache
Removes a group (if it exists in the cache), along with any existing relationships of the group to users or groups. The cache entry will be marked so that subsequent calls to getGroup(groupName) will throw an ObjectNotFoundException.

Specified by:
removeGroup in interface DirectoryCache
Overrides:
removeGroup in class DefaultDirectoryCache
Parameters:
groupName - name of group to remove from cache.

getUser

public User getUser(java.lang.String userName)
             throws ObjectNotFoundException
Description copied from interface: DirectoryCache
Returns the cached User matching the directoryID and username. If no user has been cached, null is returned. This signifies we do not know whether the user exists or not. If it is known that the user does not exist, an ObjectNotFoundException is thrown. For example, if a user is removed, a subsequent getUser call attempting to find the removed user will throw this exception. The returning user is a clone of user object in the cache. Callers are free to mutate the clone however they want.

Specified by:
getUser in interface DirectoryCache
Overrides:
getUser in class DefaultDirectoryCache
Parameters:
userName - name of user to find.
Returns:
a clone of the cached user, if one exists, otherwise null.
Throws:
ObjectNotFoundException - if the object does not exist.

getGroup

public Group getGroup(java.lang.String groupName)
               throws ObjectNotFoundException
Description copied from interface: DirectoryCache
Returns the cached Group matching the directoryID and groupName. If no group has been cached, null is returned. This signifies we do not know whether the group exists or not. If it is known that the group does not exist, an ObjectNotFoundException is thrown. For example, if a group is removed, a subsequent getGroup call attempting to find the removed group will throw this exception. The returning group is a clone of group object in the cache. Callers are free to mutate the clone however they want.

Specified by:
getGroup in interface DirectoryCache
Overrides:
getGroup in class DefaultDirectoryCache
Parameters:
groupName - name of group to find.
Returns:
a clone of the cached group, if one exists, otherwise null.
Throws:
ObjectNotFoundException - if the object does not exist.

storeDnMapping

protected void storeDnMapping(DirectoryEntity entity)

getDn

protected java.lang.String getDn(DirectoryEntity directoryEntity)

removeDnMapping

protected void removeDnMapping(EntityType type,
                               java.lang.String name)

removeDnMapping

public void removeDnMapping(java.lang.String dn)

getEntityIdentifierForDn

public EntityIdentifier getEntityIdentifierForDn(java.lang.String dn)
                                          throws ObjectNotFoundException
Finds the cached entity identifier for the supplied DN.

Parameters:
dn -
Returns:
the entity identifier or null if there is no cache entry for the DN.
Throws:
ObjectNotFoundException - if it is known that the DN doesn't map to an Entity (User/Group).

getDnForEntityIdentifier

protected java.lang.String getDnForEntityIdentifier(EntityIdentifier identifier)

updateGroupMembersFromMemberDNs

protected void updateGroupMembersFromMemberDNs(Group group)


Copyright © 2009 Atlassian Pty Ltd. All Rights Reserved.