org.apache.jetspeed.security.spi.impl.ldap
Class LdapPrincipalDaoImpl

java.lang.Object
  extended by org.apache.jetspeed.security.spi.impl.ldap.AbstractLdapDao
      extended by org.apache.jetspeed.security.spi.impl.ldap.LdapPrincipalDaoImpl
All Implemented Interfaces:
LdapPrincipalDao, LdapReadOnlyPrincipalDao
Direct Known Subclasses:
LdapGroupDaoImpl, LdapMemberShipDaoImpl, LdapRoleDaoImpl, LdapUserPrincipalDaoImpl

public abstract class LdapPrincipalDaoImpl
extends AbstractLdapDao
implements LdapPrincipalDao

Author:
Mike Long , David Le Strat
See Also:
LdapPrincipalDao

Field Summary
private static org.apache.commons.logging.Log logger
          The logger.
 
Fields inherited from class org.apache.jetspeed.security.spi.impl.ldap.AbstractLdapDao
ctx
 
Constructor Summary
LdapPrincipalDaoImpl()
           Default constructor.
LdapPrincipalDaoImpl(LdapBindingConfig ldapConfig)
           Initializes the dao.
 
Method Summary
private  void buildPrincipal(Collection principals, SearchResult searchResult)
           
private  Principal[] convertPrincipalListToArray(Collection principals)
           Converts a list of principals to an array of principals.
 String convertUidToLdapAcceptableName(String fullPath)
           Converts the uid to an ldap acceptable name.
private  String convertUidWithoutSlashes(String uid)
           Returns a well formed uid for LDAP.
 void create(String principalUid)
           Makes a new ldap entry for the specified principal.
protected abstract  Attributes defineLdapAttributes(String principalUid)
           A template method for defining the attributes for a particular LDAP class.
 void delete(String principalUid)
           Deletes a ldap entry for the specified principal.
private  void enumerateOverSearchResults(NamingEnumeration searchResults, Collection principals)
           Build the user principal by enumerating through the search results.
 Principal[] find(String principalUid, String principalType)
           Search the ldap directory for the principal.
protected  Attribute getAttribute(String attributeName, Attributes userAttributes)
           
protected abstract  String getDnSuffix()
           Builds the dn suffix.
protected  String getGroupDN(String groupPrincipalUid)
           
protected  String getGroupDN(String groupPrincipalUid, boolean includeBaseDN)
           
protected  String getRoleDN(String rolePrincipalUid)
           
protected  String getRoleDN(String rolePrincipalUid, boolean includeBaseDN)
           
protected  String getSearchDomain()
           The domain in wich to perform a search
protected abstract  String getUidAttributeForPrincipal()
           Builds the dn suffix.
protected  String getUserDN(String userPrincipalUid)
           
protected  String getUserDN(String userPrincipalUid, boolean includeBaseDN)
           
protected abstract  Principal makePrincipal(String principalUid)
           A template method for creating a concrete principal object.
protected  String[] parseAttr(String attr, String replace)
           
 
Methods inherited from class org.apache.jetspeed.security.spi.impl.ldap.AbstractLdapDao
bindToServer, getAttributes, getEntryPrefix, getGroupAttributes, getGroupFilter, getGroupFilterBase, getGroupIdAttribute, getGroupMembershipAttribute, getGroupMembershipForRoleAttribute, getGroupObjectClasses, getGroupObjectRequiredAttributeClasses, getGroupUidAttribute, getKnownAttributes, getObjectClasses, getRoleAttributes, getRoleFilter, getRoleFilterBase, getRoleGroupMembershipForRoleAttribute, getRoleIdAttribute, getRoleMembershipAttribute, getRoleObjectClasses, getRoleObjectRequiredAttributeClasses, getRoleUidAttribute, getRootContext, getSearchScope, getSearchSuffix, getSubcontextName, getUidAttribute, getUserAttributes, getUserFilter, getUserFilterBase, getUserGroupMembershipAttribute, getUserIdAttribute, getUserObjectClasses, getUserPasswordAttribute, getUserRoleMembershipAttribute, getUserUidAttribute, lookupByUid, searchByWildcardedUid, searchGroupByWildcardedUid, searchRoleByWildcardedUid, setSearchControls, validateDn, validatePassword, validateUid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.jetspeed.security.spi.impl.ldap.LdapReadOnlyPrincipalDao
lookupByUid
 

Field Detail

logger

private static final org.apache.commons.logging.Log logger
The logger.

Constructor Detail

LdapPrincipalDaoImpl

public LdapPrincipalDaoImpl()
                     throws org.apache.jetspeed.security.SecurityException

Default constructor.

Throws:
org.apache.jetspeed.security.SecurityException - A SecurityException.

LdapPrincipalDaoImpl

public LdapPrincipalDaoImpl(LdapBindingConfig ldapConfig)
                     throws org.apache.jetspeed.security.SecurityException

Initializes the dao.

Parameters:
ldapConfig - Holds the ldap binding configuration.
Throws:
org.apache.jetspeed.security.SecurityException - A SecurityException.
Method Detail

makePrincipal

protected abstract Principal makePrincipal(String principalUid)

A template method for creating a concrete principal object.

Parameters:
principalUid - The principal uid.
Returns:
A concrete principal object.

defineLdapAttributes

protected abstract Attributes defineLdapAttributes(String principalUid)

A template method for defining the attributes for a particular LDAP class.

Parameters:
principalUid - The principal uid.
Returns:
The LDAP attributes object for the particular class.

create

public void create(String principalUid)
            throws org.apache.jetspeed.security.SecurityException
Description copied from interface: LdapPrincipalDao

Makes a new ldap entry for the specified principal.

Specified by:
create in interface LdapPrincipalDao
Parameters:
principalUid - The principal uid.
Throws:
org.apache.jetspeed.security.SecurityException - Throws a SecurityException.
See Also:
LdapPrincipalDao.create(java.lang.String)

getDnSuffix

protected abstract String getDnSuffix()

Builds the dn suffix.

Returns:
The dn suffix.

getUidAttributeForPrincipal

protected abstract String getUidAttributeForPrincipal()

Builds the dn suffix.

Returns:
The dn suffix.

delete

public void delete(String principalUid)
            throws org.apache.jetspeed.security.SecurityException
Description copied from interface: LdapPrincipalDao

Deletes a ldap entry for the specified principal.

Specified by:
delete in interface LdapPrincipalDao
Parameters:
principalUid - The principal uid.
Throws:
org.apache.jetspeed.security.SecurityException - Throws a SecurityException.
See Also:
LdapPrincipalDao.delete(java.lang.String)

convertUidToLdapAcceptableName

public String convertUidToLdapAcceptableName(String fullPath)
Description copied from interface: LdapPrincipalDao

Converts the uid to an ldap acceptable name.

Specified by:
convertUidToLdapAcceptableName in interface LdapPrincipalDao
Parameters:
fullPath - The uid.
Returns:
The converted name.
See Also:
LdapPrincipalDao.convertUidToLdapAcceptableName(java.lang.String)

convertUidWithoutSlashes

private String convertUidWithoutSlashes(String uid)

Returns a well formed uid for LDAP.

Parameters:
uid - The uid.
Returns:
The well formed uid.

find

public Principal[] find(String principalUid,
                        String principalType)
                 throws org.apache.jetspeed.security.SecurityException
Description copied from interface: LdapPrincipalDao

Search the ldap directory for the principal.

Specified by:
find in interface LdapPrincipalDao
Parameters:
principalUid - The uid value of the principal.
principalType - The type of principal.
Returns:
All the objects of this LDAP class type.
Throws:
org.apache.jetspeed.security.SecurityException
See Also:
LdapPrincipalDao.find(java.lang.String, java.lang.String)

convertPrincipalListToArray

private Principal[] convertPrincipalListToArray(Collection principals)

Converts a list of principals to an array of principals.

Parameters:
principals - The list of principals.
Returns:
The array of principals.

enumerateOverSearchResults

private void enumerateOverSearchResults(NamingEnumeration searchResults,
                                        Collection principals)
                                 throws NamingException

Build the user principal by enumerating through the search results.

Parameters:
searchResults - The NamingEnumeration of results.
principals - The collection of user principals.
Throws:
NamingException - Throws a NamingException.

buildPrincipal

private void buildPrincipal(Collection principals,
                            SearchResult searchResult)
                     throws NamingException
Parameters:
principals - The collection of principals.
searchResult - The SearchResult
Throws:
NamingException - Throws a NamingException.

getAttribute

protected Attribute getAttribute(String attributeName,
                                 Attributes userAttributes)
                          throws NamingException
Parameters:
attributeName - The attribute name.
userAttributes - The user Attributes.
Returns:
The Attribute.
Throws:
NamingException - Throws a NamingException.

getSearchDomain

protected String getSearchDomain()
Description copied from class: AbstractLdapDao

The domain in wich to perform a search

TODO : this should be in spring config

Specified by:
getSearchDomain in class AbstractLdapDao
Returns:
a String containing the LDAP entry prefix name.

parseAttr

protected String[] parseAttr(String attr,
                             String replace)

getGroupDN

protected String getGroupDN(String groupPrincipalUid)

getGroupDN

protected String getGroupDN(String groupPrincipalUid,
                            boolean includeBaseDN)

getRoleDN

protected String getRoleDN(String rolePrincipalUid)

getRoleDN

protected String getRoleDN(String rolePrincipalUid,
                           boolean includeBaseDN)

getUserDN

protected String getUserDN(String userPrincipalUid)

getUserDN

protected String getUserDN(String userPrincipalUid,
                           boolean includeBaseDN)


Copyright © 1999-2007 Apache Software Foundation. All Rights Reserved.