org.apache.james.user.ldap
Class ReadOnlyLDAPUser

java.lang.Object
  extended by org.apache.james.user.ldap.ReadOnlyLDAPUser
All Implemented Interfaces:
Serializable, User

public class ReadOnlyLDAPUser
extends Object
implements User, Serializable

Encapsulates the details of a user as taken from an LDAP compliant directory. Instances of this class are only applicable to the ReadOnlyUsersLDAPRepository or its subclasses. Consequently it does not permit the mutation of user details. It is intended purely as an encapsulation of the user information as held in the LDAP directory, and as a means of authenticating the user against the LDAP server. Consequently invocations of the contract method User.setPassword(String) always returns false.

See Also:
SimpleLDAPConnection, ReadOnlyUsersLDAPRepository, Serialized Form

Constructor Summary
ReadOnlyLDAPUser(String userName, String userDN, LdapContext ldapContext)
          Constructs an instance for the given user-details, and which will authenticate against the given host.
 
Method Summary
 String getUserName()
          Fulfils the contract User.getUserName().
 boolean setPassword(String newPass)
          Implementation of contract User.setPassword(String), which is provided for compliance purposes only.
 boolean verifyPassword(String password)
          Verifies that the password supplied is actually the user's password, by attempting to rebind to a copy of the LDAP server context using the user's username and the supplied password.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReadOnlyLDAPUser

public ReadOnlyLDAPUser(String userName,
                        String userDN,
                        LdapContext ldapContext)
                 throws NamingException
Constructs an instance for the given user-details, and which will authenticate against the given host.

Parameters:
userName - The user-identifier/name. This is the value with which the field #userName will be initialised, and which will be returned by invoking getUserName().
userDN - The distinguished (unique-key) of the user details as stored on the LDAP directory.
ldapContext - The context for the LDAP server on which the user details are held. This is also the host against which the user will be authenticated, when verifyPassword(String) is invoked.
Throws:
NamingException
Method Detail

getUserName

public String getUserName()
Fulfils the contract User.getUserName(). It returns the value of the field #userName. This is generally the value from which the user email address is built, by appending the domain name to it.

Specified by:
getUserName in interface User
Returns:
The user's identifier or name.

setPassword

public boolean setPassword(String newPass)
Implementation of contract User.setPassword(String), which is provided for compliance purposes only. Instances of this type mirror LDAP data and do not perform any updates to the directory. Consequently, this method always returns false and does not do any work.

Specified by:
setPassword in interface User
Returns:
False

verifyPassword

public boolean verifyPassword(String password)
Verifies that the password supplied is actually the user's password, by attempting to rebind to a copy of the LDAP server context using the user's username and the supplied password.

Specified by:
verifyPassword in interface User
Parameters:
password - The password to validate.
Returns:
True if a connection can successfully be established to the LDAP host using the user's id and the supplied password, and False otherwise.


Copyright © 2002-2012 The Apache Software Foundation. All Rights Reserved.