com.infoengine.object.factory
Class Request

java.lang.Object
  extended by com.infoengine.object.factory.Request
All Implemented Interfaces:
java.io.Serializable

public class Request
extends java.lang.Object
implements java.io.Serializable

Wrapper for com.infoengine.object.IeRequest object. This class also supports signing and validation. This is useful to allow Info*Engines which are resident on seperate machines to share information and verify that a request comes from a 'trusted' source. Implementation uses java.security.MessageDigest and a 'secret' string in conjunction with the requested uri to create a unique fingerprint to be sent along with/retreived from a request for validation. Cooperating Info*Engines must be configured with exactly the same 'secret' string and MessageDigest algorithm. The string and algorithm are configured by setting of properties in the ie.properties file. 'secret.text' holds the secret string used in computing the fingerprint. Optionally 'secret.algorithm' sets the algorithm to be used in computing the fingerprint. Valid algorithms include: SHA or SHA-1 - defined in NIST's FIPS 180-1. output: 160-bit digest. MD2 - defined in RFC 1319. output: 128-bit (16 byte) digest. MD5 - defined in RFC 1321. output: 128-bit (16 byte) digest. (specified in Java Cryptography Architecture API Specification & Reference, Appendix A and Appendix B) if 'secret.algorithm' is not specified SHA-1 is used. if 'secret.text' is not specified requests are not validated, alternately if 'secret.text' has a value then the receiving Info*Engine requires that any sender MUST sign the request.

See Also:
Serialized Form

Constructor Summary
Request(IeRequest req)
          Constructs a Request wrapper around an IeRequest object.
Request(java.lang.String name)
          Constructs an empty named Request.
 
Method Summary
 void addContext(java.lang.String type, java.lang.String name, java.lang.String value)
          Add a name/value pair to a named context area of this request.
 void addOutput(byte[] data)
          Adds a byte array to the output of this request.
 void addOutput(java.lang.String data)
          Adds a string to the output of this request.
 void clearOutput()
          Removes all output text from this request.
 void clearSource()
          Removes all input text from this request.
 Group getContextGroup(java.lang.String name)
          Get a named context group.
 java.lang.String getName()
          Returns the name of this request.
 java.util.Enumeration getOutput()
          Returns a list of strings output by this request.
 java.lang.String getPassword()
          Returns the password of this request.
 IeRequest getRequest()
          Returns the standard request used to pass this request to a service.
 java.lang.String getSecret()
          get the value of secret
 java.lang.String getSignatureAlgorithm()
          get the algorithm
 java.lang.String getSource()
          Returns the source string for this request.
 java.lang.String getSuperSecret()
          get the value of superSecret
 Task getTask()
          Returns the task that this request encapsulates.
 java.lang.String getType()
          Returns the type of this request.
 java.lang.String getUserName()
          Returns the user name of this request.
 void printTree()
           
 void setContext(Group grp)
          Sets a context group.
 void setName(java.lang.String name)
          Sets the name of this request.
 void setPassword(java.lang.String pwd)
          Sets the password of this request.
 void setSecret(java.lang.String secret)
          set the value of secret
 void setSignatureAlgorithm(java.lang.String signatureAlgorithm)
          set the algorithm
 void setSource(java.io.File temp)
          Adds a file to the input source of this request.
 void setSource(java.lang.String data)
          Adds a string to the input source of this request.
 void setSuperSecret(java.lang.String secret)
          set the value of superSecret
 void setType(java.lang.String type)
          Sets this request's type.
 void setUserName(java.lang.String name)
          Sets the user name of this request.
 void sign()
          sign request if Info*Engine is configured to do so.
 void sign(java.lang.String property_prefix)
          sign request if Info*Engine is configured to do so.
 boolean validate()
           
 void validateSignature()
          validate request if Info*Engine is configured to do so.
 void validateSignature(java.lang.String property_prefix)
          validate request if Info*Engine is configured to do so.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Request

public Request(java.lang.String name)
Constructs an empty named Request.


Request

public Request(IeRequest req)
Constructs a Request wrapper around an IeRequest object.

Parameters:
req - the IeRequest object to be wrapped
Method Detail

getRequest

public IeRequest getRequest()
Returns the standard request used to pass this request to a service.

Returns:
This request's internal structure.

getTask

public Task getTask()
Returns the task that this request encapsulates.

Returns:
This request's task.

getName

public java.lang.String getName()
Returns the name of this request.

Returns:
The request's current name.

setName

public void setName(java.lang.String name)
Sets the name of this request.

Parameters:
name - The new name of the request.

getType

public java.lang.String getType()
Returns the type of this request.

Returns:
The request's current type.

setType

public void setType(java.lang.String type)
Sets this request's type.

Parameters:
type - The request's new type.

setPassword

public void setPassword(java.lang.String pwd)
Sets the password of this request.

Parameters:
pwd - The request's new password.

getPassword

public java.lang.String getPassword()
Returns the password of this request.

Returns:
The request's current password.

setUserName

public void setUserName(java.lang.String name)
Sets the user name of this request.

Parameters:
name - The request's new user name.

getUserName

public java.lang.String getUserName()
Returns the user name of this request.

Returns:
The request's current user name.

clearSource

public void clearSource()
Removes all input text from this request.


setSource

public void setSource(java.lang.String data)
Adds a string to the input source of this request.

Parameters:
data - Template source to be processed by this request.

setSource

public void setSource(java.io.File temp)
Adds a file to the input source of this request.

Parameters:
temp - Template file to be processed by this request.

getSource

public java.lang.String getSource()
Returns the source string for this request.

Returns:
The template source to be used in the processing of this request.

clearOutput

public void clearOutput()
Removes all output text from this request.


addOutput

public void addOutput(java.lang.String data)
Adds a string to the output of this request.

Parameters:
data - A stream of text output by this request.

addOutput

public void addOutput(byte[] data)
Adds a byte array to the output of this request.

Parameters:
data - A byte [] output by this request.

getOutput

public java.util.Enumeration getOutput()
Returns a list of strings output by this request.

Returns:
A list of text generated during the processing of this request.

addContext

public void addContext(java.lang.String type,
                       java.lang.String name,
                       java.lang.String value)
Add a name/value pair to a named context area of this request.

Parameters:
type - The named context area (FORMDATA, SERVERDATA, etc.)
name - The context variable name.
value - The context variable value.

setContext

public void setContext(Group grp)
Sets a context group.

Parameters:
grp - The context group (FORM, SERVER, etc.)

getContextGroup

public Group getContextGroup(java.lang.String name)
Get a named context group.

Parameters:
name - The context group name (FORM, SERVER, etc.)
Returns:
The named context group

validate

public boolean validate()

printTree

public void printTree()

setSecret

public void setSecret(java.lang.String secret)
set the value of secret

Parameters:
secret - new secret used when signing/verifying requests

getSecret

public java.lang.String getSecret()
get the value of secret


setSuperSecret

public void setSuperSecret(java.lang.String secret)
set the value of superSecret


getSuperSecret

public java.lang.String getSuperSecret()
get the value of superSecret


setSignatureAlgorithm

public void setSignatureAlgorithm(java.lang.String signatureAlgorithm)
set the algorithm

Parameters:
signatureAlgorithm - new algorithm used when signing/verifying requests

getSignatureAlgorithm

public java.lang.String getSignatureAlgorithm()
get the algorithm


sign

public void sign()
          throws IEException
sign request if Info*Engine is configured to do so.

Throws:
IEException - exceptions thrown by #generateHash are not caught
IEException

sign

public void sign(java.lang.String property_prefix)
          throws IEException
sign request if Info*Engine is configured to do so. look for secret text and algorithm under a specific property

Parameters:
property_prefix - prefix to add while looking for secret text and algorithm example: jdbcAdapter use: jdbcAdapter.secret.text jdbcAdapter.secret.algorithm
Throws:
IEException - exceptions thrown by #sign are not caught
IEException

validateSignature

public void validateSignature()
                       throws IEException
validate request if Info*Engine is configured to do so.

Throws:
IEException - exceptions thrown by #generateHash are not caught. Thrown if Info*Engine is configured to validate requests and sender has not signed the request. Thrown if Info*Engine is configured to validate requests, sender has signed the request but the fingerprint does not match the fingerprint computed locally for the given request.
IEException

validateSignature

public void validateSignature(java.lang.String property_prefix)
                       throws IEException
validate request if Info*Engine is configured to do so. look for secret text and algorithm under a specific property

Parameters:
property_prefix - prefix to add while looking for secret text and algorithm example: jdbcAdapter use: jdbcAdapter.secret.text jdbcAdapter.secret.algorithm
Throws:
IEException - exceptions thrown by #validateSignature are not caught
IEException