org.apache.lenya.ac.ldap
Class LDAPUser

java.lang.Object
  extended by org.apache.lenya.ac.impl.AbstractItem
      extended by org.apache.lenya.ac.impl.AbstractGroupable
          extended by org.apache.lenya.ac.impl.AbstractUser
              extended by org.apache.lenya.ac.file.FileUser
                  extended by org.apache.lenya.ac.ldap.LDAPUser
All Implemented Interfaces:
java.io.Serializable, Accreditable, Groupable, Identifiable, Item, User

public class LDAPUser
extends FileUser

LDAP user.

Version:
$Id: LDAPUser.java 473842 2006-11-12 01:15:20Z gregor $
See Also:
Serialized Form

Field Summary
static java.lang.String LDAP_ID
           
 
Fields inherited from class org.apache.lenya.ac.file.FileUser
EMAIL, GROUP, GROUPS, ID, PASSWORD, PASSWORD_ATTRIBUTE
 
Constructor Summary
LDAPUser()
          Creates a new LDAPUser object.
LDAPUser(java.io.File configurationDirectory)
          Creates a new LDAPUser object.
LDAPUser(java.io.File configurationDirectory, java.lang.String id, java.lang.String email, java.lang.String ldapId)
          Create an LDAPUser
 
Method Summary
 boolean authenticate(java.lang.String password)
          Authenticate a user against the directory.
 void configure(org.apache.avalon.framework.configuration.Configuration config)
          Create a new LDAPUser from a configuration
protected  org.apache.avalon.framework.configuration.Configuration createConfiguration()
          Create a configuration from the current user details.
 boolean existsUser(java.lang.String ldapId)
          Checks if a user exists.
 java.lang.String getLdapId()
          Get the ldap id
 java.lang.String getName()
          Returns the name of this object.
protected  void initialize()
          Initializes this user.
protected  void setEncryptedPassword(java.lang.String encryptedPassword)
          The LDAPUser doesn't store any passwords as they are handled by LDAP
 void setLdapId(java.lang.String string)
          Set the ldap id
 void setName(java.lang.String string)
          LDAP Users fetch their name information from the LDAP server, so we don't store it locally.
 void setPassword(java.lang.String plainTextPassword)
          The LDAPUser doesn't store any passwords as they are handled by LDAP
 
Methods inherited from class org.apache.lenya.ac.file.FileUser
delete, getConfigurationDirectory, getFile, save, setConfigurationDirectory
 
Methods inherited from class org.apache.lenya.ac.impl.AbstractUser
getEmail, getEncryptedPassword, getFullName, setEmail, setFullName
 
Methods inherited from class org.apache.lenya.ac.impl.AbstractGroupable
addedToGroup, getAccreditables, getGroups, removedFromGroup, removeFromAllGroups
 
Methods inherited from class org.apache.lenya.ac.impl.AbstractItem
equals, getDescription, getId, hashCode, isValidId, setDescription, setId, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.lenya.ac.Accreditable
getAccreditables
 
Methods inherited from interface org.apache.lenya.ac.Item
getDescription, getId, setDescription
 
Methods inherited from interface org.apache.lenya.ac.Groupable
addedToGroup, getGroups, removedFromGroup, removeFromAllGroups
 

Field Detail

LDAP_ID

public static final java.lang.String LDAP_ID
See Also:
Constant Field Values
Constructor Detail

LDAPUser

public LDAPUser()
Creates a new LDAPUser object.


LDAPUser

public LDAPUser(java.io.File configurationDirectory)
Creates a new LDAPUser object.

Parameters:
configurationDirectory - The configuration directory.

LDAPUser

public LDAPUser(java.io.File configurationDirectory,
                java.lang.String id,
                java.lang.String email,
                java.lang.String ldapId)
         throws org.apache.avalon.framework.configuration.ConfigurationException
Create an LDAPUser

Parameters:
configurationDirectory - where the user will be attached to
id - user id of LDAPUser
email - of LDAPUser
ldapId - of LDAPUser
Throws:
org.apache.avalon.framework.configuration.ConfigurationException - if the properties could not be read
Method Detail

configure

public void configure(org.apache.avalon.framework.configuration.Configuration config)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Create a new LDAPUser from a configuration

Specified by:
configure in interface Item
Overrides:
configure in class FileUser
Parameters:
config - the Configuration specifying the user details
Throws:
org.apache.avalon.framework.configuration.ConfigurationException - if the user could not be instantiated

existsUser

public boolean existsUser(java.lang.String ldapId)
                   throws AccessControlException
Checks if a user exists.

Parameters:
ldapId - The LDAP id.
Returns:
A boolean value indicating whether the user is found in the directory
Throws:
AccessControlException - when an unexpected error occurs.

initialize

protected void initialize()
Initializes this user. The current ldapId is queried in the directory, in order to retrieve additional information, such as the user name. In current implementation, only the user name is actually retrieved, but other attributes may be used in the future (such as groups ?) Note: if the user entry could not be retrieved, initialize the attributes to empty string (they are optional anyway), but do not throw an exception.


createConfiguration

protected org.apache.avalon.framework.configuration.Configuration createConfiguration()
Description copied from class: FileUser
Create a configuration from the current user details. Can be used for saving.

Overrides:
createConfiguration in class FileUser
Returns:
a Configuration
See Also:
FileUser.createConfiguration()

getLdapId

public java.lang.String getLdapId()
Get the ldap id

Returns:
the ldap id

setLdapId

public void setLdapId(java.lang.String string)
Set the ldap id

Parameters:
string - the new ldap id

authenticate

public boolean authenticate(java.lang.String password)
Authenticate a user against the directory. The principal to be authenticated is either constructed by use of the configured properties, or by lookup of this ID in the directory. This principal then attempts to authenticate against the directory with the provided password.

Specified by:
authenticate in interface User
Overrides:
authenticate in class AbstractUser
Parameters:
password - to authenticate with
Returns:
true if the given password matches the password for this user
See Also:
User.authenticate(java.lang.String)

getName

public java.lang.String getName()
Description copied from class: AbstractItem
Returns the name of this object.

Specified by:
getName in interface Item
Overrides:
getName in class AbstractItem
Returns:
A String.
See Also:
Item.getName()

setName

public void setName(java.lang.String string)
LDAP Users fetch their name information from the LDAP server, so we don't store it locally. Since we only have read access we basically can't set the name, i.e. any request to change the name is ignored.

Specified by:
setName in interface Item
Overrides:
setName in class AbstractItem
Parameters:
string - is ignored

setPassword

public void setPassword(java.lang.String plainTextPassword)
The LDAPUser doesn't store any passwords as they are handled by LDAP

Specified by:
setPassword in interface User
Overrides:
setPassword in class AbstractUser
Parameters:
plainTextPassword - is ignored

setEncryptedPassword

protected void setEncryptedPassword(java.lang.String encryptedPassword)
The LDAPUser doesn't store any passwords as they are handled by LDAP

Overrides:
setEncryptedPassword in class AbstractUser
Parameters:
encryptedPassword - is ignored


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