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

java.lang.Object
  extended by org.apache.jetspeed.security.spi.impl.ldap.AbstractLdapDao
      extended by org.apache.jetspeed.security.spi.impl.ldap.LdapUserCredentialDaoImpl
All Implemented Interfaces:
LdapReadOnlyPrincipalDao, LdapUserCredentialDao

public class LdapUserCredentialDaoImpl
extends AbstractLdapDao
implements LdapUserCredentialDao

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

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
LdapUserCredentialDaoImpl()
           Default constructor.
LdapUserCredentialDaoImpl(LdapBindingConfig ldapConfig)
           Initializes the dao.
 
Method Summary
 boolean authenticate(String uid, String password)
           Looks up the user by the UID attribute.
 void changePassword(String uid, String password)
           Updates the password for the specified user.
private  char[] convertRawPassword(Attribute attr)
           This method converts an ascii password to a char array.
private  Attribute getAttribute(String attributeName, Attributes userAttributes)
           Get the attribute.
protected  String[] getAttributes()
           
protected  String getEntryPrefix()
           A template method that returns the LDAP entry prefix of the concrete DAO.
private  Attributes getFirstUser(NamingEnumeration results)
           Gets the first matching user.
protected  String[] getObjectClasses()
           
private  char[] getPassword(NamingEnumeration results, String uid)
           Get the password.
 char[] getPassword(String uid)
           
protected  String getSearchDomain()
           The domain in wich to perform a search
protected  String getSearchSuffix()
           A template method that returns the LDAP entry prefix of the concrete DAO.
private  void setPassword(String userDn, String password)
           Set the user's password.
 
Methods inherited from class org.apache.jetspeed.security.spi.impl.ldap.AbstractLdapDao
bindToServer, getGroupAttributes, getGroupFilter, getGroupFilterBase, getGroupIdAttribute, getGroupMembershipAttribute, getGroupMembershipForRoleAttribute, getGroupObjectClasses, getGroupObjectRequiredAttributeClasses, getGroupUidAttribute, getKnownAttributes, getRoleAttributes, getRoleFilter, getRoleFilterBase, getRoleGroupMembershipForRoleAttribute, getRoleIdAttribute, getRoleMembershipAttribute, getRoleObjectClasses, getRoleObjectRequiredAttributeClasses, getRoleUidAttribute, getRootContext, getSearchScope, 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

LdapUserCredentialDaoImpl

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

Default constructor.

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

LdapUserCredentialDaoImpl

public LdapUserCredentialDaoImpl(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

changePassword

public void changePassword(String uid,
                           String password)
                    throws org.apache.jetspeed.security.SecurityException

Updates the password for the specified user.

Specified by:
changePassword in interface LdapUserCredentialDao
Parameters:
uid - The uid.
password - The password.
Throws:
org.apache.jetspeed.security.SecurityException - A SecurityException.

authenticate

public boolean authenticate(String uid,
                            String password)
                     throws org.apache.jetspeed.security.SecurityException

Looks up the user by the UID attribute. If this lookup succeeds, this method then attempts to authenticate the user using the password, throwing an AuthenticationException if the password is incorrect or an OperationNotSupportedException if the password is empty.

Specified by:
authenticate in interface LdapUserCredentialDao
Parameters:
uid - The uid.
password - The password.
Throws:
org.apache.jetspeed.security.SecurityException - Throws a SecurityException.

getPassword

public char[] getPassword(String uid)
                   throws org.apache.jetspeed.security.SecurityException
Specified by:
getPassword in interface LdapUserCredentialDao
Parameters:
uid - The uid.
Returns:
The password.
Throws:
org.apache.jetspeed.security.SecurityException - A SecurityException.@throws SecurityException
See Also:
LdapUserCredentialDao.getPassword(java.lang.String)

setPassword

private void setPassword(String userDn,
                         String password)
                  throws NamingException

Set the user's password.

Parameters:
userDn - The user.
password - The password.
Throws:
NamingException - Throws a NamingException.

getPassword

private char[] getPassword(NamingEnumeration results,
                           String uid)
                    throws NamingException

Get the password.

Parameters:
results - The NamingEnumeration.
uid - The uid.
Returns:
The password as an array of char.
Throws:
NamingException - Throws a NamingException.

getAttribute

private Attribute getAttribute(String attributeName,
                               Attributes userAttributes)
                        throws NamingException

Get the attribute.

Parameters:
attributeName - The attribute name.
userAttributes - The user Attributes.
Returns:
The Attribute
Throws:
NamingException - Throws a NamingException.

convertRawPassword

private char[] convertRawPassword(Attribute attr)
                           throws NamingException

This method converts an ascii password to a char array. It needs to be improved to do proper unicode conversion.

Parameters:
attr - The Attribute.
Throws:
NamingException

getFirstUser

private Attributes getFirstUser(NamingEnumeration results)
                         throws NamingException

Gets the first matching user.

Parameters:
results - The results to find the user in.
Returns:
The Attributes.
Throws:
NamingException - Throws a NamingException.

getEntryPrefix

protected String getEntryPrefix()
Description copied from class: AbstractLdapDao

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

TODO : this should be in spring config

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

getSearchSuffix

protected String getSearchSuffix()
Description copied from class: AbstractLdapDao

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

TODO : this should be in spring config

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

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.

getObjectClasses

protected String[] getObjectClasses()
Specified by:
getObjectClasses in class AbstractLdapDao

getAttributes

protected String[] getAttributes()
Specified by:
getAttributes in class AbstractLdapDao


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