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

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

public abstract class AbstractLdapDao
extends Object

Abstract ldap dao.

Author:
Mike Long , David Le Strat

Field Summary
protected  LdapContext ctx
          Reference to remote server context
private  LdapBindingConfig ldapBindingConfig
          The ldap binding configuration.
private static org.apache.commons.logging.Log logger
           
 
Constructor Summary
AbstractLdapDao()
           Default constructor.
AbstractLdapDao(LdapBindingConfig ldapConfig)
           Initializes the dao.
 
Method Summary
protected  void bindToServer(String rootDn, String rootPassword)
           Binds to the ldap server.
protected abstract  String[] getAttributes()
           
protected abstract  String getEntryPrefix()
           A template method that returns the LDAP entry prefix of the concrete DAO.
private  String getFirstDnForUid(NamingEnumeration searchResults)
           Gets the first matching user for the given uid.
protected  String[] getGroupAttributes()
           
protected  String getGroupFilter()
           Returns the default Group suffix dn.
protected  String getGroupFilterBase()
           Returns the default Group suffix dn.
protected  String getGroupIdAttribute()
           
protected  String getGroupMembershipAttribute()
           
protected  String getGroupMembershipForRoleAttribute()
           
protected  String[] getGroupObjectClasses()
           Returns the default Group suffix dn.
protected  String getGroupObjectRequiredAttributeClasses()
           
protected  String getGroupUidAttribute()
           
protected  String[] getKnownAttributes()
           
protected abstract  String[] getObjectClasses()
           
protected  String[] getRoleAttributes()
           
protected  String getRoleFilter()
           Returns the default Group suffix dn.
protected  String getRoleFilterBase()
           Returns the default Group suffix dn.
protected  String getRoleGroupMembershipForRoleAttribute()
           
protected  String getRoleIdAttribute()
           
protected  String getRoleMembershipAttribute()
           
protected  String[] getRoleObjectClasses()
           Returns the default Group suffix dn.
protected  String getRoleObjectRequiredAttributeClasses()
           
protected  String getRoleUidAttribute()
           
protected  String getRootContext()
           Returns the root context.
protected abstract  String getSearchDomain()
           The domain in wich to perform a search
protected  int getSearchScope()
           
protected abstract  String getSearchSuffix()
           A template method that returns the LDAP entry prefix of the concrete DAO.
protected  String getSubcontextName(String dn)
           Gets the sub context name.
protected  String getUidAttribute()
           
protected  String[] getUserAttributes()
           
protected  String getUserFilter()
           
protected  String getUserFilterBase()
           Returns the default Group suffix dn.
protected  String getUserGroupMembershipAttribute()
           
protected  String getUserIdAttribute()
           
protected  String[] getUserObjectClasses()
           
protected  String getUserPasswordAttribute()
           
protected  String getUserRoleMembershipAttribute()
           
protected  String getUserUidAttribute()
           
 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  NamingEnumeration searchGroupByWildcardedUid(String filter, SearchControls cons)
           Search uid by wild card.
protected  NamingEnumeration searchRoleByWildcardedUid(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

logger

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

ldapBindingConfig

private LdapBindingConfig ldapBindingConfig
The ldap binding configuration.


ctx

protected LdapContext ctx
Reference to remote server context

Constructor Detail

AbstractLdapDao

public AbstractLdapDao()

Default constructor.


AbstractLdapDao

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

Initializes the dao.

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

bindToServer

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

Binds to the ldap server.

Parameters:
rootDn -
rootPassword -
Throws:
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)
                   throws org.apache.jetspeed.security.SecurityException

Validate the domain name.

Parameters:
dn - The domain name.
Throws:
org.apache.jetspeed.security.SecurityException

validatePassword

protected void validatePassword(String password)
                         throws org.apache.jetspeed.security.SecurityException

Valiate the users password.

Parameters:
password - The user.
Throws:
org.apache.jetspeed.security.SecurityException

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)
                    throws org.apache.jetspeed.security.SecurityException

Validate the uid.

Parameters:
uid - The uid.
Throws:
org.apache.jetspeed.security.SecurityException

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.

searchGroupByWildcardedUid

protected NamingEnumeration searchGroupByWildcardedUid(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.

searchRoleByWildcardedUid

protected NamingEnumeration searchRoleByWildcardedUid(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.

getGroupFilterBase

protected String getGroupFilterBase()

Returns the default Group suffix dn.

Returns:
The defaultDnSuffix.

getGroupObjectClasses

protected String[] getGroupObjectClasses()

Returns the default Group suffix dn.

Returns:
The defaultDnSuffix.

getRoleFilterBase

protected String getRoleFilterBase()

Returns the default Group suffix dn.

Returns:
The defaultDnSuffix.

getRoleObjectClasses

protected String[] getRoleObjectClasses()

Returns the default Group suffix dn.

Returns:
The defaultDnSuffix.

getUserFilterBase

protected String getUserFilterBase()

Returns the default Group suffix dn.

Returns:
The defaultDnSuffix.

getGroupFilter

protected String getGroupFilter()

Returns the default Group suffix dn.

Returns:
The defaultDnSuffix.

getRoleFilter

protected String getRoleFilter()

Returns the default Group suffix dn.

Returns:
The defaultDnSuffix.

getRootContext

protected String getRootContext()

Returns the root context.

Returns:
The root context.

getEntryPrefix

protected abstract String getEntryPrefix()

A template method that returns the LDAP entry prefix of the concrete DAO.

TODO : this should be in spring config

Returns:
a String containing the LDAP entry prefix name.

getSearchSuffix

protected abstract String getSearchSuffix()

A template method that returns the LDAP entry prefix of the concrete DAO.

TODO : this should be in spring config

Returns:
a String containing the LDAP entry prefix name.

getSearchDomain

protected abstract String getSearchDomain()

The domain in wich to perform a search

TODO : this should be in spring config

Returns:
a String containing the LDAP entry prefix name.

getUserFilter

protected String getUserFilter()

getUserObjectClasses

protected String[] getUserObjectClasses()

getGroupMembershipAttribute

protected String getGroupMembershipAttribute()

getUserGroupMembershipAttribute

protected String getUserGroupMembershipAttribute()

getGroupMembershipForRoleAttribute

protected String getGroupMembershipForRoleAttribute()

getRoleGroupMembershipForRoleAttribute

protected String getRoleGroupMembershipForRoleAttribute()

getRoleMembershipAttribute

protected String getRoleMembershipAttribute()

getUserRoleMembershipAttribute

protected String getUserRoleMembershipAttribute()

getRoleIdAttribute

protected String getRoleIdAttribute()

getGroupIdAttribute

protected String getGroupIdAttribute()

getUserIdAttribute

protected String getUserIdAttribute()

getUidAttribute

protected String getUidAttribute()

getSearchScope

protected int getSearchScope()

getRoleUidAttribute

protected String getRoleUidAttribute()

getGroupUidAttribute

protected String getGroupUidAttribute()

getUserUidAttribute

protected String getUserUidAttribute()

getGroupObjectRequiredAttributeClasses

protected String getGroupObjectRequiredAttributeClasses()

getRoleObjectRequiredAttributeClasses

protected String getRoleObjectRequiredAttributeClasses()

getUserAttributes

protected String[] getUserAttributes()

getGroupAttributes

protected String[] getGroupAttributes()

getRoleAttributes

protected String[] getRoleAttributes()

getUserPasswordAttribute

protected String getUserPasswordAttribute()

getKnownAttributes

protected String[] getKnownAttributes()

getObjectClasses

protected abstract String[] getObjectClasses()

getAttributes

protected abstract String[] getAttributes()


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