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

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

public class LdapUserCredentialDaoImpl
extends AbstractLdapDao
implements LdapUserCredentialDao

Author:
Mike Long
See Also:
LdapUserCredentialDao

Field Summary
private static org.apache.commons.logging.Log LOG
          The logger.
private static String PASSWORD_ATTR_NAME
          The password attribute.
 
Fields inherited from class org.apache.jetspeed.security.spi.impl.ldap.AbstractLdapDao
ctx, defaultDnSuffix, rootContext, rootDn, rootPassword
 
Constructor Summary
LdapUserCredentialDaoImpl()
           Default constructor.
LdapUserCredentialDaoImpl(String ldapServerName, String rootDn, String rootPassword, String rootContext, String defaultDnSuffix)
           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.
private  Attributes getFirstUser(NamingEnumeration results)
           Gets the first matching user.
protected  String getObjectClass()
           A template method that returns the LDAP object class of the concrete DAO.
private  char[] getPassword(NamingEnumeration results, String uid)
           Get the password.
 char[] getPassword(String uid)
           
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, 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.


PASSWORD_ATTR_NAME

private static final String PASSWORD_ATTR_NAME
The password attribute.

See Also:
Constant Field Values
Constructor Detail

LdapUserCredentialDaoImpl

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

Default constructor.

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

LdapUserCredentialDaoImpl

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

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.

getObjectClass

protected String getObjectClass()

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

Specified by:
getObjectClass in class AbstractLdapDao
Returns:
A String containing the LDAP object class name.


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