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

java.lang.Object
  extended byorg.apache.jetspeed.security.spi.impl.ldap.AbstractLdapDao
Direct Known Subclasses:
LdapPrincipalDaoImpl, LdapUserCredentialDaoImpl

public abstract class AbstractLdapDao
extends Object

Abstract ldap dao.

Author:
Mike Long

Field Summary
protected  LdapContext ctx
          Reference to remote server context
protected  String defaultDnSuffix
          The default suffix.
private  String ldapServerName
          The ldap server name.
protected  String rootContext
          The root context.
protected  String rootDn
          The root domain.
protected  String rootPassword
          The root password.
 
Constructor Summary
AbstractLdapDao()
           Default constructor.
AbstractLdapDao(String ldapServerName, String rootDn, String rootPassword, String rootContext, String defaultDnSuffix)
           Initializes the dao.
 
Method Summary
protected  void bindToServer(String rootDn, String rootPassword)
           Binds to the ldap server.
private  String getFirstDnForUid(NamingEnumeration searchResults)
           Gets the first matching user for the given uid.
protected abstract  String getObjectClass()
           A template method that returns the LDAP object class of the concrete DAO.
protected  String getSubcontextName(String dn)
           Gets the sub context name.
 String lookupByUid(String uid)
           Searches the LDAP server for the user with the specified userid (uid attribute).
protected  NamingEnumeration searchByWildcardedUid(String filter, SearchControls cons)
           Search uid by wild card.
protected  SearchControls setSearchControls()
           
protected  void validateDn(String dn)
           Validate the domain name.
protected  void validatePassword(String password)
           Valiate the users password.
protected  void validateUid(String uid)
           Validate the uid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ldapServerName

private String ldapServerName
The ldap server name.


rootDn

protected String rootDn
The root domain.


rootPassword

protected String rootPassword
The root password.


rootContext

protected String rootContext
The root context.


defaultDnSuffix

protected String defaultDnSuffix
The default suffix.


ctx

protected LdapContext ctx
Reference to remote server context

Constructor Detail

AbstractLdapDao

public AbstractLdapDao()

Default constructor.


AbstractLdapDao

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

Initializes the dao.

Parameters:
ldapServerName - The server name.
rootDn - The root domain.
rootPassword - The root password.
rootContext - The root context.
defaultDnSuffix - The default suffix.
Method Detail

bindToServer

protected void bindToServer(String rootDn,
                            String rootPassword)
                     throws org.apache.jetspeed.security.SecurityException,
                            NamingException

Binds to the ldap server.

Parameters:
rootDn -
rootPassword -
Throws:
NamingException
org.apache.jetspeed.security.SecurityException

getSubcontextName

protected String getSubcontextName(String dn)
                            throws NamingException

Gets the sub context name.

Parameters:
dn - The domain name.
Returns:
The sub context name.
Throws:
NamingException

validateDn

protected void validateDn(String dn)

Validate the domain name.

Parameters:
dn - The domain name.

validatePassword

protected void validatePassword(String password)

Valiate the users password.

Parameters:
password - The user.

setSearchControls

protected SearchControls setSearchControls()
Returns:
The factors that determine the scope of the search and what gets returned as a result of the search.

lookupByUid

public String lookupByUid(String uid)
                   throws org.apache.jetspeed.security.SecurityException

Searches the LDAP server for the user with the specified userid (uid attribute).

Returns:
the user's DN
Throws:
org.apache.jetspeed.security.SecurityException

getFirstDnForUid

private String getFirstDnForUid(NamingEnumeration searchResults)
                         throws NamingException

Gets the first matching user for the given uid.

Parameters:
searchResults - The NamingEnumeration.
Returns:
the user's DN of the first use in the list. Null if no users were found.
Throws:
NamingException - Throws a NamingException.

validateUid

protected void validateUid(String uid)

Validate the uid.

Parameters:
uid - The uid.

searchByWildcardedUid

protected NamingEnumeration searchByWildcardedUid(String filter,
                                                  SearchControls cons)
                                           throws NamingException

Search uid by wild card.

Parameters:
filter - The filter.
cons - The SearchControls
Returns:
The NamingEnumeration
Throws:
NamingException - Throws a NamingEnumeration.

getObjectClass

protected abstract String getObjectClass()

A template method that returns the LDAP object class of the concrete DAO.

Returns:
a String containing the LDAP object class name.


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