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

java.lang.Object
  extended by com.atlassian.crowd.integration.directory.connector.SpringLDAPConnector
All Implemented Interfaces:
RemoteDirectory
Direct Known Subclasses:
MicrosoftActiveDirectory, OpenLDAP, SunONE

public abstract class SpringLDAPConnector
extends Object
implements RemoteDirectory


Field Summary
protected  Map attributes
          Attributes for the entity.
protected static int DEFAULT_PAGE_SIZE
           
protected  LDAPPropertiesMapper ldapPropertiesMapper
           
protected  LdapTemplate ldapTemplate
           
static String NAME
          The name of the server: Microsoft Active Directory.
protected static String PRINCIPAL_NO_VALID_PASSWORD
          Exception message when unable to process a supplied password credential.
 
Fields inherited from interface com.atlassian.crowd.integration.directory.RemoteDirectory
DIRECTORY_TYPE
 
Constructor Summary
SpringLDAPConnector()
           
 
Method Summary
protected  void addContainerObject(DirectoryContainer containerObject, String baseDN, String objectType, String nameAttribute, String memberAttribute, String descriptionAttribute)
           
 RemoteGroup addGroup(RemoteGroup group)
          Adds a group to the directory store.
protected  Attributes addPrincipalGeneric(RemotePrincipal principal)
          Translates a principal into LDAP attributes.
 void addPrincipalToGroup(String principal, String group)
          Adds a principal to a group.
 void addPrincipalToRole(String name, String unsubscribedRole)
          Adds a principal to a role.
 RemoteRole addRole(RemoteRole role)
          Adds a role to the directory store.
 RemotePrincipal authenticate(String name, PasswordCredential[] credentials)
          Authenticates a principal verses the directory store.
protected  String buildDN(String name, String baseDN, String objectFilter, String nameAttribute)
           
 RemoteGroup findGroupByName(String name)
          Finds the group that matches the supplied name.
 List findGroupMemberships(String principal)
          Returns a list of group names that a principal is a member of.
 RemotePrincipal findPrincipalByName(String name)
          Finds the principal that matches the supplied name.
 RemoteRole findRoleByName(String name)
          Finds the role that matches the supplied name.
 List findRoleMemberships(String principalName)
          Returns a list of role names that a principal is a member of.
 Map getAttributes()
          Gets the attributes of the entity.
 String getDirectoryType()
          Returns the DIRECTORY_TYPE name of the implementation.
protected  String getGroupDN(String name)
           
 long getID()
          Gets the internal unique ID of the directory store.
 LDAPPropertiesMapper getLdapPropertiesMapper()
           
protected  String getPrincipalDN(String name)
           
protected  String getRoleDN(String name)
           
 boolean isGroupMember(String group, String principal)
          Checks if a principal is a member of a group.
protected  boolean isMemeber(String objectFilter, String containerObjectDN, String memberAttribute, String principalDN)
           
 boolean isRoleMember(String role, String principal)
          Checks if a principal is a member of a role.
 void removeGroup(String name)
          Removes the role that matches the supplied name.
 void removePrincipal(String name)
          Removes the principal that matches the supplied name.
 void removePrincipalFromGroup(String name, String unsubscribedGroup)
          Removes a principal from a group.
 void removePrincipalFromRole(String name, String removeRole)
          Removes a principal from a role.
 void removeRole(String name)
          Removes the group that matches the supplied name.
 List searchGroups(SearchContext searchContext)
          Searches for all principals who match the supplied search criteria.
 List searchPrincipals(SearchContext searchContext)
          Search for all principals who match the supplied search criteria.
 List searchRoles(SearchContext searchContext)
          Search for all roles who match the supplied search criteria.
 void setAttributes(Map attributes)
          Sets the attributes of the entity.
 void setID(long ID)
          When a directory store is loaded, the ID will be set by the crowd framework.
 void setLdapPropertiesMapper(LDAPPropertiesMapper ldapPropertiesMapper)
           
 void testConnection()
          Test if a connection to the directory server can be established.
 RemoteGroup updateGroup(RemoteGroup group)
          Updates the group by the name attribute.
 RemotePrincipal updatePrincipal(RemotePrincipal principal)
          Updates the principal by the name attribute.
 void updatePrincipalCredential(String name, PasswordCredential credential)
          Updates the password credential for a principal.
 RemoteRole updateRole(RemoteRole role)
          Updates the role by the name attribute.
 
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
addPrincipal
 

Field Detail

attributes

protected Map attributes
Attributes for the entity.


NAME

public static final String NAME
The name of the server: Microsoft Active Directory.

See Also:
Constant Field Values

PRINCIPAL_NO_VALID_PASSWORD

protected static final String PRINCIPAL_NO_VALID_PASSWORD
Exception message when unable to process a supplied password credential.

See Also:
Constant Field Values

DEFAULT_PAGE_SIZE

protected static int DEFAULT_PAGE_SIZE

ldapTemplate

protected LdapTemplate ldapTemplate

ldapPropertiesMapper

protected LDAPPropertiesMapper ldapPropertiesMapper
Constructor Detail

SpringLDAPConnector

public SpringLDAPConnector()
Method Detail

getID

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

Specified by:
getID in interface RemoteDirectory
Returns:
The ID.

setID

public void setID(long ID)
Description copied from interface: RemoteDirectory
When a directory store is loaded, the ID will be set by the crowd framework.

Specified by:
setID in interface RemoteDirectory
Parameters:
ID - The ID.

getDirectoryType

public String getDirectoryType()
Description copied from interface: RemoteDirectory
Returns the DIRECTORY_TYPE name of the implementation.

Specified by:
getDirectoryType in interface RemoteDirectory
Returns:
The name of the implementation.

getLdapPropertiesMapper

public LDAPPropertiesMapper getLdapPropertiesMapper()

setLdapPropertiesMapper

public void setLdapPropertiesMapper(LDAPPropertiesMapper ldapPropertiesMapper)

getAttributes

public Map getAttributes()
Gets the attributes of the entity.

Specified by:
getAttributes in interface RemoteDirectory
Returns:
The attributes.

setAttributes

public void setAttributes(Map attributes)
Sets the attributes of the entity.

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

buildDN

protected String buildDN(String name,
                         String baseDN,
                         String objectFilter,
                         String nameAttribute)
                  throws ObjectNotFoundException
Throws:
ObjectNotFoundException

getPrincipalDN

protected String getPrincipalDN(String name)
                         throws ObjectNotFoundException
Throws:
ObjectNotFoundException

getGroupDN

protected String getGroupDN(String name)
                     throws ObjectNotFoundException
Throws:
ObjectNotFoundException

getRoleDN

protected String getRoleDN(String name)
                    throws ObjectNotFoundException
Throws:
ObjectNotFoundException

addPrincipalGeneric

protected Attributes addPrincipalGeneric(RemotePrincipal principal)
Translates a principal into LDAP attributes.

Parameters:
principal - The principal.
Returns:
The LDAP attributes.

addContainerObject

protected void addContainerObject(DirectoryContainer containerObject,
                                  String baseDN,
                                  String objectType,
                                  String nameAttribute,
                                  String memberAttribute,
                                  String descriptionAttribute)
                           throws RemoteException
Throws:
RemoteException

addGroup

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

Specified by:
addGroup in interface RemoteDirectory
Parameters:
group - The group to add.
Returns:
The group with any updated attributes.
Throws:
InvalidGroupException - The supplied group is invalid.
RemoteException - An unknown remote exception occured.

authenticate

public RemotePrincipal authenticate(String name,
                                    PasswordCredential[] credentials)
                             throws RemoteException,
                                    InvalidPrincipalException,
                                    InactiveAccountException,
                                    InvalidAuthenticationException
Description copied from interface: RemoteDirectory
Authenticates a principal verses the directory store.

Specified by:
authenticate in interface RemoteDirectory
Parameters:
name - The name of the principal.
credentials - The supplied credentials.
Returns:
The populated principal if the authentication is valid.
Throws:
RemoteException - An unknown remote exception occured.
InvalidPrincipalException - The supplied principal is invalid.
InactiveAccountException - The supplied principal is inactive.
InvalidAuthenticationException - The supplied authentication is invalid.

isMemeber

protected boolean isMemeber(String objectFilter,
                            String containerObjectDN,
                            String memberAttribute,
                            String principalDN)
                     throws NamingException
Throws:
NamingException

isGroupMember

public boolean isGroupMember(String group,
                             String principal)
                      throws RemoteException
Description copied from interface: RemoteDirectory
Checks if a principal is a member of a group.

Specified by:
isGroupMember in interface RemoteDirectory
Parameters:
group - The group name.
principal - The principal name.
Returns:
true if and only if the principal is a member of the group, otherwise false.
Throws:
RemoteException - An unknown remote exception occured.

searchGroups

public List searchGroups(SearchContext searchContext)
                  throws RemoteException
Description copied from interface: RemoteDirectory
Searches for all principals who match the supplied search criteria.

Specified by:
searchGroups in interface RemoteDirectory
Parameters:
searchContext - The search criteria.
Returns:
The search results.
Throws:
RemoteException - An unknown remote exception occured.

findGroupByName

public RemoteGroup findGroupByName(String name)
                            throws RemoteException,
                                   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:
The populated group.
Throws:
RemoteException - An unknown remote exception occured.
ObjectNotFoundException - The group does not exist.

updateGroup

public RemoteGroup updateGroup(RemoteGroup group)
                        throws RemoteException,
                               ObjectNotFoundException
Description copied from interface: RemoteDirectory
Updates the group by the name attribute.

Specified by:
updateGroup in interface RemoteDirectory
Parameters:
group - The group to update.
Returns:
The populated group.
Throws:
RemoteException - An unknown remote exception occured.
ObjectNotFoundException - the group does not exist.

searchRoles

public List searchRoles(SearchContext searchContext)
                 throws RemoteException
Description copied from interface: RemoteDirectory
Search for all roles who match the supplied search criteria.

Specified by:
searchRoles in interface RemoteDirectory
Parameters:
searchContext - The search criteria.
Returns:
The search results.
Throws:
RemoteException - an unknown remote exception occured.

findRoleByName

public RemoteRole findRoleByName(String name)
                          throws RemoteException,
                                 ObjectNotFoundException
Description copied from interface: RemoteDirectory
Finds the role that matches the supplied name.

Specified by:
findRoleByName in interface RemoteDirectory
Parameters:
name - The name of the role.
Returns:
The populated role.
Throws:
RemoteException - An unknown remote exception occured.
ObjectNotFoundException - The role does not exist.

addRole

public RemoteRole addRole(RemoteRole role)
                   throws InvalidRoleException,
                          RemoteException
Description copied from interface: RemoteDirectory
Adds a role to the directory store.

Specified by:
addRole in interface RemoteDirectory
Parameters:
role - The role to add.
Returns:
The role with any updated attributes.
Throws:
InvalidRoleException - The supplied role is invalid.
RemoteException - An unknown remote exception occured.

updateRole

public RemoteRole updateRole(RemoteRole role)
                      throws RemoteException,
                             ObjectNotFoundException
Description copied from interface: RemoteDirectory
Updates the role by the name attribute.

Specified by:
updateRole in interface RemoteDirectory
Parameters:
role - The role to update.
Returns:
The populated role.
Throws:
RemoteException - An unknown remote exception occured.
ObjectNotFoundException - The role does not exist.

removeGroup

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

Specified by:
removeGroup in interface RemoteDirectory
Parameters:
name - The name of the role.
Throws:
RemoteException - An unknown remote exception occured.
ObjectNotFoundException - The role does not exist.

removeRole

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

Specified by:
removeRole in interface RemoteDirectory
Parameters:
name - The name of the group.
Throws:
RemoteException - An unknown remote exception occured.
ObjectNotFoundException - The role does not exist.

searchPrincipals

public List searchPrincipals(SearchContext searchContext)
                      throws RemoteException
Description copied from interface: RemoteDirectory
Search for all principals who match the supplied search criteria.

Specified by:
searchPrincipals in interface RemoteDirectory
Parameters:
searchContext - The search criteria.
Returns:
The search results.
Throws:
RemoteException - an unknown remote exception occured.

findPrincipalByName

public RemotePrincipal findPrincipalByName(String name)
                                    throws RemoteException,
                                           ObjectNotFoundException
Description copied from interface: RemoteDirectory
Finds the principal that matches the supplied name.

Specified by:
findPrincipalByName in interface RemoteDirectory
Parameters:
name - The name of the principal.
Returns:
The populated principal.
Throws:
RemoteException - An unknown remote exception occured.
ObjectNotFoundException - The principal does not exist.

updatePrincipal

public RemotePrincipal updatePrincipal(RemotePrincipal principal)
                                throws RemoteException,
                                       ObjectNotFoundException
Description copied from interface: RemoteDirectory
Updates the principal by the name attribute.

Specified by:
updatePrincipal in interface RemoteDirectory
Parameters:
principal - The principal to update.
Returns:
The populated principal.
Throws:
RemoteException - An unknown remote exception occured.
ObjectNotFoundException - The role does not exist.

addPrincipalToGroup

public void addPrincipalToGroup(String principal,
                                String group)
                         throws RemoteException
Description copied from interface: RemoteDirectory
Adds a principal to a group.

Specified by:
addPrincipalToGroup in interface RemoteDirectory
Parameters:
principal - The name of the principal.
group - The name of the group.
Throws:
RemoteException - An unknown wire exception occured.

removePrincipalFromGroup

public void removePrincipalFromGroup(String name,
                                     String unsubscribedGroup)
                              throws RemoteException
Description copied from interface: RemoteDirectory
Removes a principal from a group.

Specified by:
removePrincipalFromGroup in interface RemoteDirectory
Parameters:
name - The name of the principal.
unsubscribedGroup - The name of the group.
Throws:
RemoteException - An unknown wire exception occured.

addPrincipalToRole

public void addPrincipalToRole(String name,
                               String unsubscribedRole)
                        throws RemoteException
Description copied from interface: RemoteDirectory
Adds a principal to a role.

Specified by:
addPrincipalToRole in interface RemoteDirectory
Parameters:
name - The name of the principal.
unsubscribedRole - The name of the role.
Throws:
RemoteException - An unknown wire exception occured.

removePrincipalFromRole

public void removePrincipalFromRole(String name,
                                    String removeRole)
                             throws RemoteException
Description copied from interface: RemoteDirectory
Removes a principal from a role.

Specified by:
removePrincipalFromRole in interface RemoteDirectory
Parameters:
name - The name of the principal.
removeRole - The name of the role.
Throws:
RemoteException - An unknown wire exception occured.

removePrincipal

public void removePrincipal(String name)
                     throws RemoteException,
                            ObjectNotFoundException
Description copied from interface: RemoteDirectory
Removes the principal that matches the supplied name.

Specified by:
removePrincipal in interface RemoteDirectory
Parameters:
name - The name of the principal.
Throws:
RemoteException - An unknown remote exception occured.
ObjectNotFoundException - The principal does not exist.

updatePrincipalCredential

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

Specified by:
updatePrincipalCredential in interface RemoteDirectory
Parameters:
name - The name of the principal.
credential - The new credential.
Throws:
RemoteException - An unknown remote exception occured.
ObjectNotFoundException - The principal does not exist.
InvalidCredentialException - The supplied credential is invalid.

testConnection

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

Specified by:
testConnection in interface RemoteDirectory
Throws:
RemoteException - An unknown wire exception occured.

isRoleMember

public boolean isRoleMember(String role,
                            String principal)
                     throws RemoteException
Description copied from interface: RemoteDirectory
Checks if a principal is a member of a role.

Specified by:
isRoleMember in interface RemoteDirectory
Parameters:
role - The group name.
principal - The principal name.
Returns:
true if and only if the principal is a member of the role, otherwise false.
Throws:
RemoteException - An unknown remote exception occured.

findGroupMemberships

public List findGroupMemberships(String principal)
                          throws RemoteException,
                                 ObjectNotFoundException
Description copied from interface: RemoteDirectory
Returns a list of group names that a principal is a member of.

Specified by:
findGroupMemberships in interface RemoteDirectory
Returns:
List of group names.
Throws:
RemoteException - An unknown and remote exception occured.
ObjectNotFoundException

findRoleMemberships

public List findRoleMemberships(String principalName)
                         throws RemoteException,
                                ObjectNotFoundException
Description copied from interface: RemoteDirectory
Returns a list of role names that a principal is a member of.

Specified by:
findRoleMemberships in interface RemoteDirectory
Returns:
List of group names.
Throws:
RemoteException - An unknown and remote exception occured.
ObjectNotFoundException


Copyright © 2006 Atlassian Software Systems. All Rights Reserved.