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

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

public abstract class LdapPrincipalDaoImpl
extends AbstractLdapDao
implements LdapPrincipalDao

Author:
Mike Long
See Also:
LdapPrincipalDao

Field Summary
private static org.apache.commons.logging.Log LOG
          The logger.
protected static String UID_ATTR_NAME
          The uid attribute name.
 
Fields inherited from class org.apache.jetspeed.security.spi.impl.ldap.AbstractLdapDao
ctx, defaultDnSuffix, rootContext, rootDn, rootPassword
 
Constructor Summary
LdapPrincipalDaoImpl()
           Default constructor.
LdapPrincipalDaoImpl(String ldapServerName, String rootDn, String rootPassword, String rootContext, String defaultDnSuffix)
           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.
protected  String convertUidFromLdapAcceptableName(String uid)
           Convert the uid back from the ldap acceptable name.
protected  String convertUidToLdapAcceptableName(String uid)
           Converts the uid to an ldap acceptable name.
 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)
           Search the ldap directory for the principal.
protected  Attribute getAttribute(String attributeName, Attributes userAttributes)
           
protected abstract  Principal makePrincipal(String principalUid)
           A template method for creating a concrete principal object.
 
Methods inherited from class org.apache.jetspeed.security.spi.impl.ldap.AbstractLdapDao
bindToServer, getObjectClass, getSubcontextName, lookupByUid, searchByWildcardedUid, 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

LOG

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


UID_ATTR_NAME

protected static final String UID_ATTR_NAME
The uid attribute name.

See Also:
Constant Field Values
Constructor Detail

LdapPrincipalDaoImpl

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

Default constructor.

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

LdapPrincipalDaoImpl

public LdapPrincipalDaoImpl(String ldapServerName,
                            String rootDn,
                            String rootPassword,
                            String rootContext,
                            String defaultDnSuffix)
                     throws NamingException,
                            org.apache.jetspeed.security.SecurityException

Initializes the dao.

Parameters:
ldapServerName - The server name.
rootDn - The root domain.
rootPassword - The root password.
rootContext - The root context.
defaultDnSuffix - The default suffix.
Throws:
NamingException - A NamingException.
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)

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

protected String convertUidToLdapAcceptableName(String uid)

Converts the uid to an ldap acceptable name.

Parameters:
uid - The uid.
Returns:
The converted name.

convertUidFromLdapAcceptableName

protected String convertUidFromLdapAcceptableName(String uid)

Convert the uid back from the ldap acceptable name.

Parameters:
uid - The uid.
Returns:
The converted back name.

find

public Principal[] find(String principalUid)
                 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. If empty this method
Returns:
All the objects of this LDAP class type.
Throws:
org.apache.jetspeed.security.SecurityException
See Also:
LdapPrincipalDao.find(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.


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