Expresso 5-5-0

com.jcorporate.expresso.ext.ldap
Class UserLDAP

java.lang.Object
  extended bycom.jcorporate.expresso.ext.ldap.UserLDAP
All Implemented Interfaces:
LookupInterface, UserInfo

public class UserLDAP
extends Object
implements UserInfo

UserLDAP is an LDAP-aware implementation of the UserInfo object - this allows user information to be retrieved from an LDAP server, as opposed to simply retrieved from the database. In order for this implementation to work, the following properties must be set in the properties file for the specific db/context to be user with LDAP: ldapServer: the URL to the LDAP context via JNDI (e.g. ldap://localhost:389) ldapUser: The username to use to access the LDAP server (cn=Directory Manager) ldapPassword: The password to use when accessing the LDAP server (e.g. pass) ldapRoot: The root for the entries we look up (e.g. o=javacorp.com) Creation date: (9/18/00 1:55:15 PM)

Version:
$Revision: 1.13 $ $Date: 2004/03/26 02:54:34 $
Author:
Michael Nash

Constructor Summary
UserLDAP()
          UserLDAP constructor comment.
 
Method Summary
 void add()
          Adds the current UserInfo object into the repository
 void delete()
          Deletes the User (Not implemented)
 boolean find()
          Find the LDAP user
 String getAccountStatus()
          Retrieve the current account status.
 Vector getAllUsers()
          Returns a Vector of all the UserInfo objects in the repository
 DirContext getContext()
          Most often used for testing to peak into things.
 String getCreateDate()
          Returns the date that this UserInfo object was created
 String getDataContext()
          gets the DB context; can return null
 String getDBName()
          Return the name of the context/database connection that this DB object is using.
 String getEmail()
          Returns the email address for this user
 String getEmailAuthCode()
          Here we generate an authorization code that would be hard for someone to guess.
 String getEmailValCode()
          Retrieve the validation code required for authorization by email
 String getField(String fieldName)
          getField method comment.
 Enumeration getFieldList()
           
 Vector getGroups()
          Get the groups associated with this User
 String getLoginName()
          Returns the login name of this user
 String getPassword()
          Returns the password for this user
 String getPrimaryGroup()
          the primary group of this user is appropriate for unix-like purposes, such as setting the group for a file permission
 boolean getRegComplete()
          Returns the status of whether extended registration has been completed or not Valid values are "Y" or "N"
 String getRegistrationDomain()
          Returns the unique integer for the registration domain that this user belongs to
 String getRoot()
           
 int getUid()
          Returns the user id for this user
 String getUpdateDate()
          Returns the date that this UserInfo object was last modified
 String getUserName()
          Returns the descriptive string for this user
 Vector getValues()
          Method to return a Vector of ValidValue This method may be implemented by objects that want to provide a list of valid values for other DB objects.
 void notify(String subject, String message)
          Send this user a notification via e-mail.
 boolean passwordEquals(String tryPassword)
          Checks if the supplied password equals the one on file
 String randomPassword()
          Generate a random password
 void retrieve()
          retrieve method comment.
 void sendAuthEmail()
          Sends an Authorization Email to a new User.
 void sendFollowUpEmail()
          Once a user has validated his email address through the email validation servlet, the user will receive this message giving previously requested username/password.
 void setAccountStatus(String name)
          Sets the current status of the account - "A" (active), "D" (disabled), "I" (inactive)
 void setCreateDate(String name)
           
 void setDBName(String newDBName)
          Sets the data context for this user
 void setEmail(String name)
          Sets the email address
 void setEmailAuthCode(String name)
           
 void setEmailValCode(String code)
          Sets the code required for auth. via email
 void setLoginName(String name)
          Sets the login name
 void setPassword(String password)
          Sets the password
 void setRegComplete(boolean status)
          Sets the extended registration complete flag - "Y" or "N"
 void setRegistrationDomain(String domain)
          Sets the registration domain
 void setUid(int uid)
          Sets the user UID
 void setUpdateDate(String name)
           
 void setUserName(String name)
          Sets the user name
 void update()
          update method comment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserLDAP

public UserLDAP()
UserLDAP constructor comment.

Method Detail

add

public void add()
         throws DBException
Description copied from interface: UserInfo
Adds the current UserInfo object into the repository

Specified by:
add in interface UserInfo
Throws:
DBException

delete

public void delete()
            throws DBException
Deletes the User (Not implemented)

Specified by:
delete in interface UserInfo
Throws:
DBException

find

public boolean find()
             throws DBException
Find the LDAP user

Specified by:
find in interface UserInfo
Returns:
true if found
Throws:
DBException

getAccountStatus

public String getAccountStatus()
                        throws DBException
Description copied from interface: UserInfo
Retrieve the current account status. Valid values are "A" (active), "I" (inactive), "D" (disabled)

Specified by:
getAccountStatus in interface UserInfo
Returns:
java.lang.String
Throws:
DBException - If the find fails

getAllUsers

public Vector getAllUsers()
                   throws DBException
Description copied from interface: UserInfo
Returns a Vector of all the UserInfo objects in the repository

Specified by:
getAllUsers in interface UserInfo
Returns:
java.util.Vector
Throws:
DBException - If there is an error during the retrieval

getCreateDate

public String getCreateDate()
                     throws DBException
Description copied from interface: UserInfo
Returns the date that this UserInfo object was created

Specified by:
getCreateDate in interface UserInfo
Returns:
java.lang.String
Throws:
DBException - If there is an error during the retrieval

getContext

public DirContext getContext()
Most often used for testing to peak into things.

Returns:
the Directory Context

getEmail

public String getEmail()
                throws DBException
Description copied from interface: UserInfo
Returns the email address for this user

Specified by:
getEmail in interface UserInfo
Returns:
java.lang.String
Throws:
DBException - If there is an error during the retrieval

getEmailAuthCode

public String getEmailAuthCode()
                        throws DBException
Here we generate an authorization code that would be hard for someone to guess. The idea is that the person has to check the email sent to them to get this number, and then click on the specially encoded URL to ensure that he/she actually is checking the email account used at registration. The little trick of getting the time in milliseconds that the person registered, multiplying by some constant, and then rounding, is extremely weak. We need a better method of generating a unique code that will "play nice" in a query string. Creation date: (8/8/00 3:00:41 PM) author Adam Rossi, PlatinumSolutions, Inc.

Specified by:
getEmailAuthCode in interface UserInfo
Returns:
java.lang.String
Throws:
DBException

getEmailValCode

public String getEmailValCode()
                       throws DBException
Description copied from interface: UserInfo
Retrieve the validation code required for authorization by email

Specified by:
getEmailValCode in interface UserInfo
Returns:
java.lang.String
Throws:
DBException - If the find fails

getField

public String getField(String fieldName)
                throws DBException
getField method comment.

Specified by:
getField in interface UserInfo
Parameters:
fieldName - The field name to retrieve
Returns:
The field string
Throws:
DBException

getFieldList

public Enumeration getFieldList()
                         throws DBException
Returns:
java.util.Enumeration
Throws:
DBException - upon Error

getGroups

public Vector getGroups()
                 throws DBException
Get the groups associated with this User

Specified by:
getGroups in interface UserInfo
Returns:
The group list
Throws:
DBException

getLoginName

public String getLoginName()
                    throws DBException
Description copied from interface: UserInfo
Returns the login name of this user

Specified by:
getLoginName in interface UserInfo
Returns:
java.lang.String
Throws:
DBException - If there is an error during the retrieval

getPassword

public String getPassword()
                   throws DBException
Description copied from interface: UserInfo
Returns the password for this user

Specified by:
getPassword in interface UserInfo
Returns:
java.lang.String
Throws:
DBException - If there is an error during the retrieval

getRegComplete

public boolean getRegComplete()
                       throws DBException
Description copied from interface: UserInfo
Returns the status of whether extended registration has been completed or not Valid values are "Y" or "N"

Specified by:
getRegComplete in interface UserInfo
Returns:
java.lang.String
Throws:
DBException - If there is an error during the retrieval

getRegistrationDomain

public String getRegistrationDomain()
                             throws DBException
Description copied from interface: UserInfo
Returns the unique integer for the registration domain that this user belongs to

Specified by:
getRegistrationDomain in interface UserInfo
Returns:
java.lang.String
Throws:
DBException - If the underlying User implementation throws the same

getRoot

public String getRoot()

getUid

public int getUid()
           throws DBException
Description copied from interface: UserInfo
Returns the user id for this user

Specified by:
getUid in interface UserInfo
Returns:
java.lang.String
Throws:
DBException - If there is an error during the retrieval

getUpdateDate

public String getUpdateDate()
                     throws DBException
Description copied from interface: UserInfo
Returns the date that this UserInfo object was last modified

Specified by:
getUpdateDate in interface UserInfo
Returns:
java.lang.String
Throws:
DBException - If there is an error during the retrieval

getUserName

public String getUserName()
                   throws DBException
Description copied from interface: UserInfo
Returns the descriptive string for this user

Specified by:
getUserName in interface UserInfo
Returns:
java.lang.String
Throws:
DBException - If there is an error during the retrieval

notify

public void notify(String subject,
                   String message)
            throws DBException
Send this user a notification via e-mail.

Parameters:
subject - Subject of the e-mail
message - Message to send in body of e-mail
Throws:
DBException - If the mail message cannot be sent

passwordEquals

public boolean passwordEquals(String tryPassword)
                       throws DBException
Checks if the supplied password equals the one on file

Specified by:
passwordEquals in interface UserInfo
Parameters:
tryPassword - The password to check
Returns:
true if the tryPassword equals the one on file
Throws:
DBException

randomPassword

public String randomPassword()
Generate a random password

Returns:
a random password of printable characters

retrieve

public void retrieve()
              throws DBException
retrieve method comment.

Specified by:
retrieve in interface UserInfo
Throws:
DBException

sendAuthEmail

public void sendAuthEmail()
                   throws DBException
Sends an Authorization Email to a new User. The user must click on the link encoded in this email before his account will be activated.

Specified by:
sendAuthEmail in interface UserInfo
Throws:
DBException

sendFollowUpEmail

public void sendFollowUpEmail()
                       throws DBException
Once a user has validated his email address through the email validation servlet, the user will receive this message giving previously requested username/password. Creation date: (8/8/00 11:44:26 PM) author: Adam Rossi, PlatinumSolutions, Inc.

Specified by:
sendFollowUpEmail in interface UserInfo
Throws:
DBException - The exception description.

setAccountStatus

public void setAccountStatus(String name)
                      throws DBException
Description copied from interface: UserInfo
Sets the current status of the account - "A" (active), "D" (disabled), "I" (inactive)

Specified by:
setAccountStatus in interface UserInfo
Parameters:
name - java.lang.String
Throws:
DBException - If there is an error

setCreateDate

public void setCreateDate(String name)
                   throws DBException
Throws:
DBException

setDBName

public void setDBName(String newDBName)
               throws DBException
Sets the data context for this user

Specified by:
setDBName in interface UserInfo
Parameters:
newDBName - The new data context
Throws:
DBException

setEmail

public void setEmail(String name)
              throws DBException
Description copied from interface: UserInfo
Sets the email address

Specified by:
setEmail in interface UserInfo
Parameters:
name - java.lang.String
Throws:
DBException - If there is an error

setEmailAuthCode

public void setEmailAuthCode(String name)
                      throws DBException
Throws:
DBException

setEmailValCode

public void setEmailValCode(String code)
                     throws DBException
Description copied from interface: UserInfo
Sets the code required for auth. via email

Specified by:
setEmailValCode in interface UserInfo
Parameters:
code - java.lang.String
Throws:
DBException - If there is an error

setLoginName

public void setLoginName(String name)
                  throws DBException
Description copied from interface: UserInfo
Sets the login name

Specified by:
setLoginName in interface UserInfo
Parameters:
name - java.lang.String
Throws:
DBException - If there is an error

setPassword

public void setPassword(String password)
                 throws DBException
Description copied from interface: UserInfo
Sets the password

Specified by:
setPassword in interface UserInfo
Parameters:
password - java.lang.String
Throws:
DBException - If there is an error

setRegComplete

public void setRegComplete(boolean status)
                    throws DBException
Description copied from interface: UserInfo
Sets the extended registration complete flag - "Y" or "N"

Specified by:
setRegComplete in interface UserInfo
Parameters:
status - java.lang.String
Throws:
DBException - If there is an error

setRegistrationDomain

public void setRegistrationDomain(String domain)
Description copied from interface: UserInfo
Sets the registration domain

Specified by:
setRegistrationDomain in interface UserInfo
Parameters:
domain - java.lang.String
See Also:
RegistrationDomain

setUid

public void setUid(int uid)
            throws DBException
Description copied from interface: UserInfo
Sets the user UID

Specified by:
setUid in interface UserInfo
Parameters:
uid - The uid of the user
Throws:
DBException - If there is an error

setUpdateDate

public void setUpdateDate(String name)
                   throws DBException
Throws:
DBException

setUserName

public void setUserName(String name)
                 throws DBException
Description copied from interface: UserInfo
Sets the user name

Specified by:
setUserName in interface UserInfo
Parameters:
name - java.lang.String
Throws:
DBException - If there is an error

update

public void update()
            throws DBException
update method comment.

Specified by:
update in interface UserInfo
Throws:
DBException

getValues

public Vector getValues()
                 throws DBException
Method to return a Vector of ValidValue This method may be implemented by objects that want to provide a list of valid values for other DB objects. It is strongly recommended that the valid value list be cached (via the CacheManager) for performance. The naming convention used in Expresso is to store the ValidValue list with a cache name the same as the db objects class name with ".validValues" appended

Specified by:
getValues in interface LookupInterface
Returns:
The vector of values
Throws:
DBException

getDBName

public String getDBName()
Return the name of the context/database connection that this DB object is using. If none is set, then we are using the "default" database/context.

Specified by:
getDBName in interface UserInfo
Returns:
a String containing the name of the DBName to use.

getDataContext

public String getDataContext()
gets the DB context; can return null

Specified by:
getDataContext in interface UserInfo

getPrimaryGroup

public String getPrimaryGroup()
                       throws DBException
the primary group of this user is appropriate for unix-like purposes, such as setting the group for a file permission

Specified by:
getPrimaryGroup in interface UserInfo
Returns:
name of the primary group of this user; null if no group is found
Throws:
DBException

Expresso 5-5-0

Please see www.jcorporate.com for information about new Expresso releases.