Expresso 5-6

com.jcorporate.expresso.services.validation
Class ValidationEntry

java.lang.Object
  extended bycom.jcorporate.expresso.services.validation.ValidationEntry
All Implemented Interfaces:
Serializable

public class ValidationEntry
extends Object
implements Serializable

This class abstracts the storing of the data that goes along with any particular validation operation. This class also provides functions for a validation request to be created in the first place. In this first incarnation, this class stores all the data using DBObjects. If warranted at a later time, the ideal way to change the functionality by making this class abstract and then implementing DBValidationEntry and XMLValidationEntry or whatever. Most of the methods in this class are "protected", so that minor changes can be handled by simply extending this class and overridining the necessary methods.

Since:
Expresso 4.0
Version:
$Revision: 1.25 $ $Date: 2004/11/17 20:48:22 $
Author:
Shash Chatterjee
See Also:
Serialized Form

Field Summary
static String AVAILABLE
          Status for available
protected  String dataContext
          default data context
static String EXPIRED
          Status for Expired
protected  String expiresAfter
          Time it expires after
protected  String jobClassName
          The Job class name
protected  String jobNumber
          The Job Number
protected  JobQueue jq
          JobQueue
protected  JobQueueParam jqp
          JobQueue parameter data object
static String NEW
          Status for new
protected  int paramNum
          current parameter number
static String PRM_EXPIRES_AFTER
          PArameter for 'Expires After'
static String PRM_VAL_CTX
          Parameter for 'Validation webapp context'
static String PRM_VAL_DESC
          Parameter for 'Validation Description'
static String PRM_VAL_PORT
          Parameter for 'Validation Port'
static String PRM_VAL_SERVER
          Parameter for 'Validation Server'
static String PRM_VAL_TITLE
          Parameter for 'Validation Title'
static String PRM_VALIDATOR
          Parameter for validator
static String SESSION_KEY
          Session validation key
protected  String valContextPath
          The validation context path
protected  String valDesc
          The default description
static String VALIDATED
          Status for Validated
protected  String validationClassName
          The validator class name
protected  String valPort
          The validation port
protected  String valServer
          The validation server
protected  String valTitle
          The validation job title
protected  String valType
          ?
protected  ValidationQueue vq
          The validation queue
static String WAITING
          Status for waiting
 
Constructor Summary
ValidationEntry(String newDbName)
          This constructor is used by classes that submit a validation request into the system.
ValidationEntry(String context, List paramsVector, JobQueue jq)
          This constructor is used by the validation job to create a validation entry from the job parameters.
ValidationEntry(String dbName, String id)
          This constructor is used, after a validation request comes in, to resurrect a validation entry from the DB.
 
Method Summary
 void addParam(String name, String value)
          Adds an application specific parameter into the validation entry Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee
 boolean codeMatches(String code)
          Function to match the code in the DB versus the code in the request.
protected static String createValidationCode()
          Create a cryptographically sound validation code for use in the validation operation [Currently generates a 256-bit random number] Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee, strengthened by Mike Rimov
 void delete()
          Deletes the validation entry and all the connected parameters
 void expiresAfter(int hr, int min, int sec)
          Method to set the time delta from current time when the request will expire if unused Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee
 Date getExpiresAt()
          Method to retrieve the absolute date/time when the request expires.
 Hashtable getParams()
          Method to return all the application-specific parameters associated with this validation request Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee
 String getStatus()
          Returns the current status of the validation request Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee
 ValidationHandler instantiateHandler()
          Utility function to instantiate the app-specific validation handler Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee
static void notifyByEmail(String dbName, String from, Vector addresses, String subject, String content)
          Insert the method's description here.
 void setContextPath(String path)
           
 void setDesc(String desc)
          Sets the description for the validation job Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee
 void setJobClassName(String name)
          Sets the name of the job class for validation requests.
 void setPort(String port)
           
 void setServer(String server)
           
 void setStatus(String newStatus)
          Sets the current status of the validation entry Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee
 void setTitle(String title)
          Set's the title of the validation entry job Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee
 void setValidationHandler(Class clazz)
          Method to set the app-specific validation handler associated with this validation request
 void setValidationHandler(String className)
          Method to set the app-specific validation handler associated with this validation request Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee
 void submit()
          Insert the method's description here.
 String validationURL()
          Utility function to create a URL based on the webapp context, and setup values such as the http server/port etc.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRM_VALIDATOR

public static final String PRM_VALIDATOR
Parameter for validator

See Also:
Constant Field Values

PRM_EXPIRES_AFTER

public static final String PRM_EXPIRES_AFTER
PArameter for 'Expires After'

See Also:
Constant Field Values

PRM_VAL_TITLE

public static final String PRM_VAL_TITLE
Parameter for 'Validation Title'

See Also:
Constant Field Values

PRM_VAL_DESC

public static final String PRM_VAL_DESC
Parameter for 'Validation Description'

See Also:
Constant Field Values

PRM_VAL_SERVER

public static final String PRM_VAL_SERVER
Parameter for 'Validation Server'

See Also:
Constant Field Values

PRM_VAL_PORT

public static final String PRM_VAL_PORT
Parameter for 'Validation Port'

See Also:
Constant Field Values

PRM_VAL_CTX

public static final String PRM_VAL_CTX
Parameter for 'Validation webapp context'

See Also:
Constant Field Values

NEW

public static final String NEW
Status for new

See Also:
Constant Field Values

WAITING

public static final String WAITING
Status for waiting

See Also:
Constant Field Values

AVAILABLE

public static final String AVAILABLE
Status for available

See Also:
Constant Field Values

VALIDATED

public static final String VALIDATED
Status for Validated

See Also:
Constant Field Values

EXPIRED

public static final String EXPIRED
Status for Expired

See Also:
Constant Field Values

SESSION_KEY

public static final String SESSION_KEY
Session validation key

See Also:
Constant Field Values

jq

protected JobQueue jq
JobQueue


jqp

protected JobQueueParam jqp
JobQueue parameter data object


dataContext

protected String dataContext
default data context


expiresAfter

protected String expiresAfter
Time it expires after


jobClassName

protected String jobClassName
The Job class name


jobNumber

protected String jobNumber
The Job Number


valContextPath

protected String valContextPath
The validation context path


valDesc

protected String valDesc
The default description


valPort

protected String valPort
The validation port


valServer

protected String valServer
The validation server


valTitle

protected String valTitle
The validation job title


valType

protected String valType
?


validationClassName

protected String validationClassName
The validator class name


vq

protected ValidationQueue vq
The validation queue


paramNum

protected int paramNum
current parameter number

Constructor Detail

ValidationEntry

public ValidationEntry(String newDbName)
                throws AuthValidationException
This constructor is used by classes that submit a validation request into the system. It creates a Job Queue Entry for the validation request. Application specific parameters are added using the addParam(...) method, and the request finally committed using the submit(...) method. Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee

Parameters:
newDbName - newDbName The database context to create the validation Job/Entry in.

ValidationEntry

public ValidationEntry(String dbName,
                       String id)
                throws AuthValidationException
This constructor is used, after a validation request comes in, to resurrect a validation entry from the DB. Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee

Parameters:
dbName - dbName The DB context to retrieve the validation entry from
id - id The validation request id/seq. number
Throws:
AuthValidationException - AuthValidationException

ValidationEntry

public ValidationEntry(String context,
                       List paramsVector,
                       JobQueue jq)
                throws AuthValidationException
This constructor is used by the validation job to create a validation entry from the job parameters. Application classes should have no need to use this class/ Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee

Parameters:
context - context The DB context to use for the validation entry
paramsVector - paramsVector All the params passed in to the job
jq - jq The job queue entry in its entirety
Throws:
AuthValidationException - AuthValidationException
Method Detail

setContextPath

public void setContextPath(String path)
Parameters:
path -

setDesc

public void setDesc(String desc)
Sets the description for the validation job Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee

Parameters:
desc - desc The description

getExpiresAt

public Date getExpiresAt()
                  throws AuthValidationException
Method to retrieve the absolute date/time when the request expires. Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee

Returns:
The expiry date/time
Throws:
AuthValidationException

setJobClassName

public void setJobClassName(String name)
                     throws AuthValidationException
Sets the name of the job class for validation requests. Currently the only job that should be specified is ValidationJob Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee

Parameters:
name - name Class name of validation job
Throws:
AuthValidationException - AuthValidationException if the class isn't an Expresso Job class

getParams

public Hashtable getParams()
                    throws AuthValidationException
Method to return all the application-specific parameters associated with this validation request Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee

Returns:
Hashtable of all the parameters, keyed by parameter name
Throws:
AuthValidationException

setPort

public void setPort(String port)
Parameters:
port -

setServer

public void setServer(String server)
Parameters:
server -

setStatus

public void setStatus(String newStatus)
               throws AuthValidationException
Sets the current status of the validation entry Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee

Parameters:
newStatus - newStatus = "A"=available, "N"=new, "W"=waiting, "V"=validated, "E"=expired
Throws:
AuthValidationException - AuthValidationException

getStatus

public String getStatus()
                 throws AuthValidationException
Returns the current status of the validation request Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee

Returns:
"N","A","V","E" - for "new", "available", "validated", "expired"
Throws:
AuthValidationException - AuthValidationException

setTitle

public void setTitle(String title)
Set's the title of the validation entry job Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee

Parameters:
title - title The title

setValidationHandler

public void setValidationHandler(String className)
                          throws AuthValidationException
Method to set the app-specific validation handler associated with this validation request Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee

Parameters:
className - className Class name of a class that implements ValidationHandler interface
Throws:
AuthValidationException - AuthValidationException if the handler is not of the correct class, or if the instantiation fails

setValidationHandler

public void setValidationHandler(Class clazz)
                          throws AuthValidationException
Method to set the app-specific validation handler associated with this validation request

Parameters:
clazz - Class that implements ValidationHandler interface
Throws:
AuthValidationException - AuthValidationException if the handler is not of the correct class, or if the instantiation fails

addParam

public void addParam(String name,
                     String value)
              throws AuthValidationException
Adds an application specific parameter into the validation entry Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee

Parameters:
name - name Name of the parameter
value - value Value of the parameter
Throws:
AuthValidationException

codeMatches

public boolean codeMatches(String code)
                    throws AuthValidationException
Function to match the code in the DB versus the code in the request. Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee

Parameters:
code - code Code in the request URL
Returns:
true if code matches, false otherwise
Throws:
AuthValidationException - AuthValidationException

delete

public void delete()
            throws AuthValidationException
Deletes the validation entry and all the connected parameters

Throws:
AuthValidationException - if no record is loaded OR there's an error deleting the records.

expiresAfter

public void expiresAfter(int hr,
                         int min,
                         int sec)
Method to set the time delta from current time when the request will expire if unused Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee

Parameters:
hr - hr Delta hours
min - min Delta minutes
sec - sec Delta seconds

instantiateHandler

public ValidationHandler instantiateHandler()
                                     throws AuthValidationException
Utility function to instantiate the app-specific validation handler Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee

Returns:
Object of class ValidationHandler
Throws:
AuthValidationException - AuthValidationException

notifyByEmail

public static void notifyByEmail(String dbName,
                                 String from,
                                 Vector addresses,
                                 String subject,
                                 String content)
                          throws AuthValidationException
Insert the method's description here. Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee

Parameters:
dbName - The data context to use
from - the "From" email field.
addresses - the email addresses to notify
subject - the subject of the email
content - The body of the email message
Throws:
AuthValidationException

submit

public void submit()
            throws AuthValidationException
Insert the method's description here. Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee

Throws:
AuthValidationException - upon error

validationURL

public String validationURL()
                     throws AuthValidationException
Utility function to create a URL based on the webapp context, and setup values such as the http server/port etc. It tags on the db context, the validation entry id and the validation code as request parameters. Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee

Returns:
The URL for use by the validator to approve the validation request
Throws:
AuthValidationException - upon error

createValidationCode

protected static String createValidationCode()
Create a cryptographically sound validation code for use in the validation operation [Currently generates a 256-bit random number] Creation date: (9/23/2001 9:41:06 PM) Author: Shash Chatterjee, strengthened by Mike Rimov

Returns:
The validation code

Expresso 5-6

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