com.atlassian.crowd.integration.directory.connector
Class SpringLDAPConnector

java.lang.Object
  extended by com.atlassian.crowd.integration.directory.connector.SpringLDAPConnector
All Implemented Interfaces:
LDAPDirectory, RemoteDirectory, AttributeAware, org.springframework.context.ApplicationContextAware
Direct Known Subclasses:
RFC2307Directory, RFC4519Directory

public abstract class SpringLDAPConnector
extends Object
implements LDAPDirectory, org.springframework.context.ApplicationContextAware


Field Summary
protected  org.springframework.context.ApplicationContext applicationContext
           
protected  AttributeValuesHolder attributes
           
protected  org.springframework.ldap.core.support.LdapContextSource contextSource
           
static int DEFAULT_PAGE_SIZE
           
protected  com.atlassian.event.EventManager eventManager
           
protected  LDAPPropertiesMapper ldapPropertiesMapper
           
protected  LDAPQueryTranslater ldapQueryTranslater
           
protected  org.springframework.ldap.core.LdapTemplate ldapTemplate
           
protected  org.apache.log4j.Logger logger
           
protected  Converter nameConverter
           
protected  SearchDN searchDN
           
 
Constructor Summary
SpringLDAPConnector()
           
 
Method Summary
protected  void addDefaultSnToUserAttributes(Attributes attrs, String defaultSnValue)
          A default install of many directory servers (inc.
protected  void addDefaultValueToUserAttributesForAttribute(String attributeName, Attributes attrs, String defaultValue)
           
 Group addGroup(GroupTemplate group)
          Adds a group to the directory store.
 LDAPUserWithAttributes addUser(UserTemplate user, PasswordCredential credential)
          Adds a user to the directory store.
protected  LdapName asLdapName(String dn, Class objectType)
          This method is required to wrap DN's into LdapNames as spring-ldap doesn't correctly handle operations with String dn arguments.
 User authenticate(String name, PasswordCredential credential)
          Authenticates a user with the directory store.
protected abstract  String encodePassword(String unencodedPassword)
          Given an plain-text password, encodes/encrypts it according to the settings required by the particular directory connector.
<T extends LDAPDirectoryEntity>
T
findEntityByDN(String dn, Class<T> entityClass)
          Finds a directory entity (principal, group or role) by their distinguished name.
protected
<T extends LDAPDirectoryEntity>
T
findEntityByDN(String dn, String baseDN, String filter, org.springframework.ldap.core.ContextMapper contextMapper, Class<T> entityClass)
           
 LDAPGroupWithAttributes findGroupByName(String name)
          Finds the group that matches the supplied name.
protected  LDAPGroupWithAttributes findGroupByNameAndType(String name, GroupType groupType)
           
 LDAPGroupWithAttributes findGroupWithAttributesByName(String name)
          Finds the group that matches the supplied name.
 LDAPUserWithAttributes findUserByName(String name)
          Finds the user that matches the supplied name.
 LDAPUserWithAttributes findUserWithAttributesByName(String name)
          Finds the user that matches the supplied name.
 String getAttribute(String name)
           
 boolean getAttributeAsBoolean(String name, boolean defaultValue)
           
 long getAttributeAsLong(String name, long defaultValue)
           
 Set<String> getAttributeNames()
           
 List<String> getAttributes(String name)
           
protected  Hashtable<String,String> getBaseEnvironmentProperties()
          Returns the properties used to set up the Ldap ContextSource.
 org.springframework.ldap.core.support.LdapContextSource getContextSource()
          Exposed so that delegated directories can get a handle on the underlying LDAP context.
protected  List<AttributeMapper> getCustomGroupAttributeMappers()
          As a minimum, this SHOULD provide an attribute mapper that maps the group members attribute (if available).
protected  List<AttributeMapper> getCustomUserAttributeMappers()
           
 long getDirectoryId()
          Gets the internal unique directoryId of the directory store.
protected  Encoder getEncoder()
          Returns an Encoder that escapes LDAP special characters for use in object names and in DNs.
 org.springframework.ldap.core.ContextMapper getGroupContextMapper(GroupType groupType)
          Returns a ContextMapper ready to translate LDAP objects into Groups and fetches all member objects
protected  String getInitialGroupMemberDN()
          Returns the default container member DN.
 LDAPPropertiesMapper getLdapPropertiesMapper()
           
protected  Attributes getNewGroupAttributes(Group group)
           
protected  void getNewGroupDirectorySpecificAttributes(Group group, Attributes attributes)
           
protected  Attributes getNewUserAttributes(User user, PasswordCredential credential)
          Translates the User into LDAP attributes, in preparation for creating a new user.
protected  void getNewUserDirectorySpecificAttributes(User user, Attributes attributes)
          Overridden by sub-classes to add any additional attributes they need when creating a new user.
 SearchDN getSearchDN()
           
protected  String getStandardisedDN(Name dn)
           
protected  SearchControls getSubTreeSearchControl()
           
 org.springframework.ldap.core.ContextMapper getUserContextMapper()
          Returns a ContextMapper that can transform a Context into a User.
 boolean hasAttribute(String name)
           
protected  org.springframework.ldap.core.CollectingNameClassPairCallbackHandler pageSearchResults(Name baseDN, String filter, org.springframework.ldap.core.ContextMapper contextMapper, SearchControls searchControls, org.springframework.ldap.core.DirContextProcessor ldapRequestControls, int maxResults)
          Performs a paged results search on an LDAP directory server searching using the LDAP paged results control option to fetch results in chunks rather than all at once.
 void removeGroup(String name)
          Removes the group that matches the supplied name.
 void removeGroupAttributes(String groupName, String attributeName)
          Removes all the values for a single attribute key for a group.
 void removeUser(String name)
          Removes the user that matches the supplied name.
 void removeUserAttributes(String username, String attributeName)
          Removes all the values for a single attribute key for a user.
 Group renameGroup(String oldName, String newName)
          Renames a group.
 User renameUser(String oldName, String newName)
          Renames a user.
protected  List searchEntities(Name baseDN, String filter, org.springframework.ldap.core.ContextMapper contextMapper, int startIndex, int maxResults)
          Executes a search with paging if paged results is supported.
protected  List searchEntitiesWithRequestControls(Name baseDN, String filter, org.springframework.ldap.core.ContextMapper contextMapper, SearchControls searchControls, org.springframework.ldap.core.DirContextProcessor ldapRequestControls, int startIndex, int maxResults)
           
protected  List<LDAPGroupWithAttributes> searchGroupObjects(EntityQuery query)
           
protected  List<LDAPGroupWithAttributes> searchGroupObjectsOfSpecifiedGroupType(EntityQuery query)
          This method expects that the query contains a non-null groupType in the entityDescriptor.
 List searchGroupRelationships(MembershipQuery query)
          Searches for membership information.
protected abstract  List searchGroupRelationshipsWithGroupTypeSpecified(MembershipQuery query)
          Execute the search for group relationships given that a group of type GROUP or LEGACY_ROLE has been specified in the EntityDescriptor for the group(s).
 List searchGroups(EntityQuery query)
          Searches for groups that match the supplied query criteria.
protected  List<LDAPUserWithAttributes> searchUserObjects(EntityQuery query)
           
 List searchUsers(EntityQuery query)
          Searches for users that match the supplied query criteria.
 void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
           
 void setAttributes(Map<String,String> attributes)
          Called by the DirectoryInstanceLoader after constructing an InternalDirectory.
 void setDirectoryId(long id)
          Called by the DirectoryInstanceLoader after constructing an InternalDirectory.
 void setEventManager(com.atlassian.event.EventManager eventManager)
           
 void setLdapQueryTranslater(LDAPQueryTranslater ldapQueryTranslater)
           
 void storeGroupAttributes(String groupName, Map<String,List<String>> attributes)
          Adds or updates a group's attributes with the new Map of attribute values in the directory specified by the passed in directoryId.
 void storeUserAttributes(String username, Map<String,List<String>> attributes)
          Adds or updates a user's attributes with the new Map of attribute values in the directory specified by the passed in directoryId.
 boolean supportsNestedGroups()
          Allows us to only display nested-group related UI for directories that support it.
 void testConnection()
          Test if a connection to the directory server can be established.
 Group updateGroup(GroupTemplate group)
          Updates the group.
 User updateUser(UserTemplate user)
          Updates the user.
 void updateUserCredential(String name, PasswordCredential credential)
          Updates the password for a user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.atlassian.crowd.integration.directory.RemoteDirectory
addGroupToGroup, addUserToGroup, getDescriptiveName, isGroupDirectGroupMember, isUserDirectGroupMember, removeGroupFromGroup, removeUserFromGroup
 

Field Detail

DEFAULT_PAGE_SIZE

public static final int DEFAULT_PAGE_SIZE
See Also:
Constant Field Values

logger

protected final org.apache.log4j.Logger logger

attributes

protected AttributeValuesHolder attributes

ldapTemplate

protected org.springframework.ldap.core.LdapTemplate ldapTemplate

ldapPropertiesMapper

protected LDAPPropertiesMapper ldapPropertiesMapper

contextSource

protected org.springframework.ldap.core.support.LdapContextSource contextSource

nameConverter

protected Converter nameConverter

searchDN

protected SearchDN searchDN

applicationContext

protected org.springframework.context.ApplicationContext applicationContext

ldapQueryTranslater

protected LDAPQueryTranslater ldapQueryTranslater

eventManager

protected com.atlassian.event.EventManager eventManager
Constructor Detail

SpringLDAPConnector

public SpringLDAPConnector()
Method Detail

getDirectoryId

public long getDirectoryId()
Description copied from interface: RemoteDirectory
Gets the internal unique directoryId of the directory store.

Specified by:
getDirectoryId in interface RemoteDirectory
Returns:
The directoryId.

setDirectoryId

public void setDirectoryId(long id)
Called by the DirectoryInstanceLoader after constructing an InternalDirectory.

Specified by:
setDirectoryId in interface RemoteDirectory
Parameters:
id - The unique id of the Directory stored in the database.

setAttributes

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

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

getContextSource

public org.springframework.ldap.core.support.LdapContextSource getContextSource()
Exposed so that delegated directories can get a handle on the underlying LDAP context.

Returns:
LdapContextSource.

getLdapPropertiesMapper

public LDAPPropertiesMapper getLdapPropertiesMapper()

getAttributes

public List<String> getAttributes(String name)
Specified by:
getAttributes in interface AttributeAware
Parameters:
name - attribute name.
Returns:
collection of attribute values or an empty list if the attribute with the given name does not exist.

getAttribute

public String getAttribute(String name)
Specified by:
getAttribute in interface AttributeAware
Parameters:
name - attribute name.
Returns:
single attribute value or null if the attribute with the given name does not exist. If multiple attribute values exist, any one could be returned.

getAttributeAsLong

public long getAttributeAsLong(String name,
                               long defaultValue)

getAttributeAsBoolean

public boolean getAttributeAsBoolean(String name,
                                     boolean defaultValue)

getAttributeNames

public Set<String> getAttributeNames()
Specified by:
getAttributeNames in interface AttributeAware
Returns:
set of attribute names.

hasAttribute

public boolean hasAttribute(String name)
Specified by:
hasAttribute in interface AttributeAware
Parameters:
name - attribute name.
Returns:
true if an only if the user has an attribute with the supplied name and has one or more values.

getSearchDN

public SearchDN getSearchDN()

getSubTreeSearchControl

protected SearchControls getSubTreeSearchControl()

getEncoder

protected Encoder getEncoder()
Returns an Encoder that escapes LDAP special characters for use in object names and in DNs.

Returns:

getBaseEnvironmentProperties

protected Hashtable<String,String> getBaseEnvironmentProperties()
Returns the properties used to set up the Ldap ContextSource.

Returns:

pageSearchResults

protected org.springframework.ldap.core.CollectingNameClassPairCallbackHandler pageSearchResults(Name baseDN,
                                                                                                 String filter,
                                                                                                 org.springframework.ldap.core.ContextMapper contextMapper,
                                                                                                 SearchControls searchControls,
                                                                                                 org.springframework.ldap.core.DirContextProcessor ldapRequestControls,
                                                                                                 int maxResults)
Performs a paged results search on an LDAP directory server searching using the LDAP paged results control option to fetch results in chunks rather than all at once.

Parameters:
baseDN - The DN to beging the search from.
filter - The search filter.
contextMapper - Maps from LDAP search results into objects such as Groups.
searchControls - The LDAP search scope type.
ldapRequestControls - Any LDAP request controls (set to null if you do not need additional request controls for the search).
maxResults - maximum number of results to return. Set to -1 if no result limiting is desired (WARNING: doing so is obviously a hazard).
Returns:
The search results.

searchEntities

protected List searchEntities(Name baseDN,
                              String filter,
                              org.springframework.ldap.core.ContextMapper contextMapper,
                              int startIndex,
                              int maxResults)
Executes a search with paging if paged results is supported.

Parameters:
baseDN - base DN of search.
filter - encoded LDAP search filter.
contextMapper - directory context to object mapper.
startIndex - index to start at. Set to 0 to start from the first result.
maxResults - maximum number of results to return. Set to -1 if no result limiting is desired (WARNING: doing so is obviously a hazard).
Returns:
list of entities of type corresponding to the contextMapper's output.

searchEntitiesWithRequestControls

protected List searchEntitiesWithRequestControls(Name baseDN,
                                                 String filter,
                                                 org.springframework.ldap.core.ContextMapper contextMapper,
                                                 SearchControls searchControls,
                                                 org.springframework.ldap.core.DirContextProcessor ldapRequestControls,
                                                 int startIndex,
                                                 int maxResults)

getUserContextMapper

public org.springframework.ldap.core.ContextMapper getUserContextMapper()
Returns a ContextMapper that can transform a Context into a User.

Returns:

getCustomUserAttributeMappers

protected List<AttributeMapper> getCustomUserAttributeMappers()
Returns:
a collection of custom attribbute mappers. By default just return an empty list.

getGroupContextMapper

public org.springframework.ldap.core.ContextMapper getGroupContextMapper(GroupType groupType)
Returns a ContextMapper ready to translate LDAP objects into Groups and fetches all member objects

Returns:

getCustomGroupAttributeMappers

protected List<AttributeMapper> getCustomGroupAttributeMappers()
As a minimum, this SHOULD provide an attribute mapper that maps the group members attribute (if available).

Returns:
collection of custom attribute mappers (cannot be null but can be an empty list).

findUserByName

public LDAPUserWithAttributes findUserByName(String name)
                                      throws ObjectNotFoundException
Description copied from interface: RemoteDirectory
Finds the user that matches the supplied name.

Specified by:
findUserByName in interface RemoteDirectory
Parameters:
name - the name of the user (username).
Returns:
user entity.
Throws:
ObjectNotFoundException - a user with the supplied name does not exist.

findUserWithAttributesByName

public LDAPUserWithAttributes findUserWithAttributesByName(String name)
                                                    throws ObjectNotFoundException
Description copied from interface: RemoteDirectory
Finds the user that matches the supplied name.

Specified by:
findUserWithAttributesByName in interface RemoteDirectory
Parameters:
name - the name of the user (username).
Returns:
user entity with attributes.
Throws:
ObjectNotFoundException - a user with the supplied name does not exist.

searchUserObjects

protected List<LDAPUserWithAttributes> searchUserObjects(EntityQuery query)

removeUser

public void removeUser(String name)
                throws ObjectNotFoundException
Description copied from interface: RemoteDirectory
Removes the user that matches the supplied name.

Specified by:
removeUser in interface RemoteDirectory
Parameters:
name - The name of the user (username).
Throws:
ObjectNotFoundException - The user does not exist.

updateUserCredential

public void updateUserCredential(String name,
                                 PasswordCredential credential)
                          throws ObjectNotFoundException,
                                 InvalidCredentialException
Description copied from interface: RemoteDirectory
Updates the password for a user.

Specified by:
updateUserCredential in interface RemoteDirectory
Parameters:
name - The name of the user (username).
credential - The new credential (password).
Throws:
ObjectNotFoundException - The user does not exist.
InvalidCredentialException - The supplied credential is invalid.

renameUser

public User renameUser(String oldName,
                       String newName)
                throws ObjectNotFoundException,
                       InvalidUserException
Description copied from interface: RemoteDirectory
Renames a user.

Specified by:
renameUser in interface RemoteDirectory
Parameters:
oldName - name of existing user.
newName - desired name of user.
Returns:
renamed user.
Throws:
ObjectNotFoundException - if the user with the existing name does not exist.
InvalidUserException - if the new username is invalid or already exists in the directory.

storeUserAttributes

public void storeUserAttributes(String username,
                                Map<String,List<String>> attributes)
                         throws ObjectNotFoundException
Description copied from interface: RemoteDirectory
Adds or updates a user's attributes with the new Map of attribute values in the directory specified by the passed in directoryId.

The attributes map represents new or updated attributes and does not replace existing attributes unless the key of an attribute matches the key of an existing

Specified by:
storeUserAttributes in interface RemoteDirectory
Parameters:
username - name of user to update.
attributes - new or updated attributes (attributes that don't need changing should not appear in this Map).
Throws:
ObjectNotFoundException - user with supplied username does not exist.

removeUserAttributes

public void removeUserAttributes(String username,
                                 String attributeName)
                          throws ObjectNotFoundException
Description copied from interface: RemoteDirectory
Removes all the values for a single attribute key for a user.

Specified by:
removeUserAttributes in interface RemoteDirectory
Parameters:
username - name of the user to update.
attributeName - name of attribute to remove.
Throws:
ObjectNotFoundException - user with supplied username does not exist.

getNewUserAttributes

protected Attributes getNewUserAttributes(User user,
                                          PasswordCredential credential)
                                   throws InvalidCredentialException,
                                          org.springframework.ldap.NamingException
Translates the User into LDAP attributes, in preparation for creating a new user.

Parameters:
user - The user object to translate into LDAP attributes
credential - raw password.
Returns:
An Attributes object populated with directory-specific information.
Throws:
InvalidCredentialException - The password, if supplied, was invalid in some manner.
org.springframework.ldap.NamingException - If the User could not be translated to an Attributes

getNewUserDirectorySpecificAttributes

protected void getNewUserDirectorySpecificAttributes(User user,
                                                     Attributes attributes)
Overridden by sub-classes to add any additional attributes they need when creating a new user. addBlankSnToUserAttributes.

Parameters:
user - The (potential) source of information that needs to be added
attributes - The attributes to add directory-specific information to

addUser

public LDAPUserWithAttributes addUser(UserTemplate user,
                                      PasswordCredential credential)
                               throws InvalidUserException,
                                      InvalidCredentialException,
                                      ObjectNotFoundException
Description copied from interface: RemoteDirectory
Adds a user to the directory store.

Specified by:
addUser in interface RemoteDirectory
Parameters:
user - template of the user to add.
credential - password. May be null, since JIRA creates a user in two steps (user THEN password)
Returns:
the added user retrieved from the underlying store.
Throws:
InvalidUserException - The supplied user is invalid.
InvalidCredentialException - The supplied credential is invalid.
ObjectNotFoundException - The user could not be looked up after creation or the directory with the ID of user.directoryId does not exist.

addDefaultSnToUserAttributes

protected void addDefaultSnToUserAttributes(Attributes attrs,
                                            String defaultSnValue)
A default install of many directory servers (inc. Sun DSEE 6.2 and Apache DS 1.0.2) requires the following to be set before user creation is allowed: objectClass -> inetorgperson cn -> sn -> If a call is being made from an external system (eg JIRA), the user is created with the bare minimum of attributes, then later updated. We need to make sure to add sn if it's not present in the information provided.

Parameters:
attrs - The LDAP user attributes to be checked and potentially updated.
defaultSnValue - default lastname/surname value

addDefaultValueToUserAttributesForAttribute

protected void addDefaultValueToUserAttributesForAttribute(String attributeName,
                                                           Attributes attrs,
                                                           String defaultValue)

findEntityByDN

public <T extends LDAPDirectoryEntity> T findEntityByDN(String dn,
                                                        Class<T> entityClass)
                                             throws ObjectNotFoundException
Description copied from interface: LDAPDirectory
Finds a directory entity (principal, group or role) by their distinguished name.

The object class of an entity is used to determine the entity type.

If an object represents both a group and role, then the object is mapped to a group.

No sub-tree restrictions are applied.

Specified by:
findEntityByDN in interface LDAPDirectory
Parameters:
dn - standardised disinguished name.
entityClass - class of the entity to find (either LDAPUserWithAttributes or LDAPGroupWithAttributes).
Returns:
directory entity corresponding to DN.
Throws:
ObjectNotFoundException - if a user/group does not exist at the specified DN or the DN does not exist in the directory. This will also be thrown if the entity DOES exist but does not match the base DN or object filter for the entity type.

findEntityByDN

protected <T extends LDAPDirectoryEntity> T findEntityByDN(String dn,
                                                           String baseDN,
                                                           String filter,
                                                           org.springframework.ldap.core.ContextMapper contextMapper,
                                                           Class<T> entityClass)
                                                throws ObjectNotFoundException,
                                                       InvalidNameException
Throws:
ObjectNotFoundException
InvalidNameException

updateUser

public User updateUser(UserTemplate user)
                throws ObjectNotFoundException
Description copied from interface: RemoteDirectory
Updates the user.

Specified by:
updateUser in interface RemoteDirectory
Parameters:
user - The user to update.
Returns:
the updated user retrieved from the underlying store.
Throws:
ObjectNotFoundException - the user does not exist in the directory store.

searchUsers

public List searchUsers(EntityQuery query)
Description copied from interface: RemoteDirectory
Searches for users that match the supplied query criteria.

Specified by:
searchUsers in interface RemoteDirectory
Parameters:
query - EntityQuery for Entity.USER.
Returns:
List<User> or List<String> of users/usernames matching the search criteria. An empty List will be returned if no users matching the criteria are found.

authenticate

public User authenticate(String name,
                         PasswordCredential credential)
                  throws InvalidAuthenticationException,
                         ObjectNotFoundException
Description copied from interface: RemoteDirectory
Authenticates a user with the directory store.

Specified by:
authenticate in interface RemoteDirectory
Parameters:
name - The name of the user (username).
credential - The supplied credentials (password).
Returns:
The populated user if the authentication is valid.
Throws:
InvalidAuthenticationException - Authentication with the provided credentials failed.
ObjectNotFoundException - The user wth the supplied name does not exist.

findGroupByName

public LDAPGroupWithAttributes findGroupByName(String name)
                                        throws ObjectNotFoundException
Description copied from interface: RemoteDirectory
Finds the group that matches the supplied name.

Specified by:
findGroupByName in interface RemoteDirectory
Parameters:
name - the name of the group.
Returns:
group entity.
Throws:
ObjectNotFoundException - a group with the supplied name does not exist.

findGroupWithAttributesByName

public LDAPGroupWithAttributes findGroupWithAttributesByName(String name)
                                                      throws ObjectNotFoundException
Description copied from interface: RemoteDirectory
Finds the group that matches the supplied name.

Specified by:
findGroupWithAttributesByName in interface RemoteDirectory
Parameters:
name - the name of the group.
Returns:
group entity with attributes.
Throws:
ObjectNotFoundException - a group with the supplied name does not exist.

findGroupByNameAndType

protected LDAPGroupWithAttributes findGroupByNameAndType(String name,
                                                         GroupType groupType)
                                                  throws ObjectNotFoundException
Throws:
ObjectNotFoundException

searchGroupObjectsOfSpecifiedGroupType

protected List<LDAPGroupWithAttributes> searchGroupObjectsOfSpecifiedGroupType(EntityQuery query)
This method expects that the query contains a non-null groupType in the entityDescriptor.

Parameters:
query - search query.
Returns:
list of results.

searchGroupObjects

protected List<LDAPGroupWithAttributes> searchGroupObjects(EntityQuery query)

searchGroups

public List searchGroups(EntityQuery query)
Description copied from interface: RemoteDirectory
Searches for groups that match the supplied query criteria.

Specified by:
searchGroups in interface RemoteDirectory
Parameters:
query - EntityQuery for Entity.GROUP.
Returns:
List or List of groups/groupnames matching the search criteria. An empty List will be returned if no groups matching the criteria are found.

getNewGroupAttributes

protected Attributes getNewGroupAttributes(Group group)
                                    throws org.springframework.ldap.NamingException
Throws:
org.springframework.ldap.NamingException

getNewGroupDirectorySpecificAttributes

protected void getNewGroupDirectorySpecificAttributes(Group group,
                                                      Attributes attributes)

getInitialGroupMemberDN

protected String getInitialGroupMemberDN()
Returns the default container member DN.

If this method returns null, no member DN will be added.

Returns:
empty member.

addGroup

public Group addGroup(GroupTemplate group)
               throws InvalidGroupException,
                      ObjectNotFoundException
Description copied from interface: RemoteDirectory
Adds a group to the directory store.

Specified by:
addGroup in interface RemoteDirectory
Parameters:
group - template of the group to add.
Returns:
the added group retrieved from the underlying store.
Throws:
InvalidGroupException - The supplied group is invalid.
ObjectNotFoundException - The group could not be looked up after creation or the directory with the ID of group.directoryId does not exist.

updateGroup

public Group updateGroup(GroupTemplate group)
                  throws ObjectNotFoundException
Description copied from interface: RemoteDirectory
Updates the group.

Specified by:
updateGroup in interface RemoteDirectory
Parameters:
group - The group to update.
Returns:
the updated group retrieved from the underlying store.
Throws:
ObjectNotFoundException - the group does not exist in the directory store.

removeGroup

public void removeGroup(String name)
                 throws ObjectNotFoundException
Description copied from interface: RemoteDirectory
Removes the group that matches the supplied name.

Specified by:
removeGroup in interface RemoteDirectory
Parameters:
name - The name of the group.
Throws:
ObjectNotFoundException - The group does not exist.

renameGroup

public Group renameGroup(String oldName,
                         String newName)
                  throws ObjectNotFoundException,
                         InvalidGroupException
Description copied from interface: RemoteDirectory
Renames a group.

Specified by:
renameGroup in interface RemoteDirectory
Parameters:
oldName - name of existing group.
newName - desired name of group.
Returns:
renamed group.
Throws:
ObjectNotFoundException - if the group with the existing name does not exist.
InvalidGroupException - if the new groupname is invalid or already exists in the directory.

storeGroupAttributes

public void storeGroupAttributes(String groupName,
                                 Map<String,List<String>> attributes)
                          throws ObjectNotFoundException
Description copied from interface: RemoteDirectory
Adds or updates a group's attributes with the new Map of attribute values in the directory specified by the passed in directoryId.

The attributes map represents new or updated attributes and does not replace existing attributes unless the key of an attribute matches the key of an existing

Specified by:
storeGroupAttributes in interface RemoteDirectory
Parameters:
groupName - name of group to update.
attributes - new or updated attributes (attributes that don't need changing should not appear in this Map).
Throws:
ObjectNotFoundException - group with supplied groupName does not exist.

removeGroupAttributes

public void removeGroupAttributes(String groupName,
                                  String attributeName)
                           throws ObjectNotFoundException
Description copied from interface: RemoteDirectory
Removes all the values for a single attribute key for a group.

Specified by:
removeGroupAttributes in interface RemoteDirectory
Parameters:
groupName - name of the group to update.
attributeName - name of attribute to remove.
Throws:
ObjectNotFoundException - group with supplied groupName does not exist.

searchGroupRelationships

public List searchGroupRelationships(MembershipQuery query)
Description copied from interface: RemoteDirectory
Searches for membership information.

Specified by:
searchGroupRelationships in interface RemoteDirectory
Parameters:
query - query for memberships.
Returns:
a List of Users or Groups or Strings depending on the query criteria. An empty List if there are no results.

searchGroupRelationshipsWithGroupTypeSpecified

protected abstract List searchGroupRelationshipsWithGroupTypeSpecified(MembershipQuery query)
Execute the search for group relationships given that a group of type GROUP or LEGACY_ROLE has been specified in the EntityDescriptor for the group(s).

Parameters:
query - membership query with all GroupType's not null.
Returns:
list of members or memberships depending on the query.

encodePassword

protected abstract String encodePassword(String unencodedPassword)
                                  throws InvalidCredentialException
Given an plain-text password, encodes/encrypts it according to the settings required by the particular directory connector.

Parameters:
unencodedPassword - The password to be transformed
Returns:
An encoded password, suitable for passing to the directory
Throws:
InvalidCredentialException - If the password could not be converted.

supportsNestedGroups

public boolean supportsNestedGroups()
Description copied from interface: RemoteDirectory
Allows us to only display nested-group related UI for directories that support it.

Specified by:
supportsNestedGroups in interface RemoteDirectory
Returns:
true if the directory can handle having a group added to a group.

testConnection

public void testConnection()
                    throws DirectoryAccessException
Description copied from interface: RemoteDirectory
Test if a connection to the directory server can be established.

Specified by:
testConnection in interface RemoteDirectory
Throws:
DirectoryAccessException - An unknown wire exception occurred.

getStandardisedDN

protected String getStandardisedDN(Name dn)

asLdapName

protected LdapName asLdapName(String dn,
                              Class objectType)
                       throws ObjectNotFoundException
This method is required to wrap DN's into LdapNames as spring-ldap doesn't correctly handle operations with String dn arguments. This mainly affects the escaping of slashes in DNs. The resulting javax.naming.Name is not designed to be used for caching or comparisons, rather, it is to be used for direct calls into spring-ldap's ldapTemplate.

Parameters:
dn - string version of DN.
objectType - incase there is a problem converting the dn into an LdapName an ONFE with this type will be thrown.
Returns:
LdapName for use with spring-ldap.
Throws:
ObjectNotFoundException - underlying InvalidNameException.

setApplicationContext

public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
Specified by:
setApplicationContext in interface org.springframework.context.ApplicationContextAware

setEventManager

public void setEventManager(com.atlassian.event.EventManager eventManager)

setLdapQueryTranslater

public void setLdapQueryTranslater(LDAPQueryTranslater ldapQueryTranslater)


Copyright © 2009 Atlassian Pty Ltd. All Rights Reserved.