com.cafesoft.cams.agent.http
Class AbstractCamsHttpAgentRequest

java.lang.Object
  extended by com.cafesoft.cams.agent.http.AbstractCamsHttpAgentRequest
All Implemented Interfaces:
CamsHttpAgentRequest

public abstract class AbstractCamsHttpAgentRequest
extends Object
implements CamsHttpAgentRequest

Abstract implementation of CamsHttpAgentRequest.

Since:
1/22/02

Field Summary
protected  boolean debug
          A flag used to indicate whether DEBUG-level messages should be logged.
protected  Logger logger
          Logs data.
protected  javax.servlet.http.HttpServletRequest request
          The HttpServletRequest cast from the more general Request.
 
Constructor Summary
AbstractCamsHttpAgentRequest()
           
AbstractCamsHttpAgentRequest(javax.servlet.http.HttpServletRequest request)
          Create a new AbstractCamsHttpAgentRequest.
 
Method Summary
abstract  void addHeader(String name, String value)
          Adds the specified header and value to this CamsHttpAgentRequest.
 void addSessionId(SessionId sessionId)
          Add a SessionId to the request.
 boolean containsCamsHeaders()
          Determine if the CamsHttpAgentRequest contains CAMS HTTP Headers.
 void destroy()
          Destroy the CamsHttpAgentRequest.
 X509Certificate[] getClientX509CertificateChain()
          Get the client X509 certificate chain.
 javax.servlet.http.Cookie getCookie(String name)
          Get a Cookie with the given name.
 javax.servlet.http.Cookie[] getCookies(com.cafesoft.core.http.HttpCookieFilter filter)
          Returns an array containing all of the Cookie objects the client sent with this request.
 String getHeader(String name)
          Returns the value of the specified request header as a String.
 Enumeration getHeaderNames()
          Returns an enumeration of all the header names this request contains.
 Enumeration getHeaders(String name)
          Returns all the values of the specified request header as an Enumeration of String objects.
 String getMethod()
          Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.
 String getParameter(String name)
          Returns the value mapped to the specified parameter.
 Enumeration getParameterNames()
          Returns all of the Http parameters.
 String getProtocol()
          Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1.
 String getQueryString()
          Returns the query string that is contained in the request URL after the path.
 String getRemoteAddr()
          Returns the Internet Protocol (IP) address of the client that sent the request.
 String getRemoteHost()
          Returns the fully qualified name of the client that sent the request.
 String getRequestURI()
          Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.
 String getRequestURL()
          Reconstructs the URL the client used to make the request.
 String getScheme()
          Returns the name of the scheme used to make this request.
 String getSecurityDomain()
          Get the name of the SecurityDomain handling this request.
 String getServerAddr()
          Returns the IP address of the server where the CamsHttpAgent is running.
 String getServerName()
          Returns the host name of the server that received the request.
 int getServerPort()
          Returns the port number on which this request was received.
 SessionId getSessionId(String securityDomain)
          Get a SecurityDomain specific SessionId.
 SessionId[] getSessionIds()
          Get all of the request's SessionIds.
 String getValueByPropertySpec(PropertySpec ps)
          Get an HTTP request value by PropertySpec.
 void initialize(Config config)
          Initializes this request.
 boolean isAESO()
          Determines if this Http request is for automatic enterprise sign-on (AESO).
 boolean isLogin()
          Determines if this Http request is for logging in.
 boolean isLogout()
          Determines if this Http request is for logging out.
 boolean isSecure()
          Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
 boolean isSSO()
          Determines if this Http request is for cross DNS domain single sign-on.
 void log()
          Logs the data contained in this CamsHttpAgentRequest.
 void recycle()
          Recycle the CamsHttpAgentRequest so it can be reused.
 void removeSessionId(SessionId sessionId)
          Remove a Sessionid from the request.
 void setRequest(javax.servlet.http.HttpServletRequest request)
          Sets the Request object.
 void setSecurityDomain(String securityDomain)
          Get the name of the SecurityDomain handling this request.
 void validateHeaders()
          Validate the request headers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

request

protected javax.servlet.http.HttpServletRequest request
The HttpServletRequest cast from the more general Request. This will be much more practical for most uses in this class.


logger

protected Logger logger
Logs data.


debug

protected boolean debug
A flag used to indicate whether DEBUG-level messages should be logged.

Constructor Detail

AbstractCamsHttpAgentRequest

public AbstractCamsHttpAgentRequest()

AbstractCamsHttpAgentRequest

public AbstractCamsHttpAgentRequest(javax.servlet.http.HttpServletRequest request)
Create a new AbstractCamsHttpAgentRequest.

Parameters:
request - the Http request
Throws:
NullPointerException - thrown if the request is null
Method Detail

addHeader

public abstract void addHeader(String name,
                               String value)
Adds the specified header and value to this CamsHttpAgentRequest.

Specified by:
addHeader in interface CamsHttpAgentRequest
Parameters:
name - the name of the header
value - the value of the header

validateHeaders

public void validateHeaders()
                     throws CamsHttpAgentException
Validate the request headers.

Specified by:
validateHeaders in interface CamsHttpAgentRequest
Throws:
CamsHttpAgentException - if any header name starts with the prefix CAMS. The message of the exception is the name of the request header that was invalid.

containsCamsHeaders

public boolean containsCamsHeaders()
Determine if the CamsHttpAgentRequest contains CAMS HTTP Headers. This method has been added to support proxied Cams headers.

Specified by:
containsCamsHeaders in interface CamsHttpAgentRequest
Returns:
true if the CamsHttpAgentRequest contains CAMS HTTP Headers, false otherwise.

setRequest

public void setRequest(javax.servlet.http.HttpServletRequest request)
Sets the Request object.

Parameters:
request - contains the Http request data

initialize

public void initialize(Config config)
Initializes this request.

Parameters:
config - contains configuration data

getParameter

public String getParameter(String name)
Returns the value mapped to the specified parameter.

Specified by:
getParameter in interface CamsHttpAgentRequest
Parameters:
name - the name of the parameter
Returns:
the value mapped to the specified parameter

getParameterNames

public Enumeration getParameterNames()
Returns all of the Http parameters.

Specified by:
getParameterNames in interface CamsHttpAgentRequest
Returns:
all of the Http parameter names

getRemoteAddr

public String getRemoteAddr()
Returns the Internet Protocol (IP) address of the client that sent the request.

Specified by:
getRemoteAddr in interface CamsHttpAgentRequest
Returns:
a String containing the IP address of the client that sent the request

getRemoteHost

public String getRemoteHost()
Returns the fully qualified name of the client that sent the request. If the hostname cannot be resolved, this method returns the dotted-string form of the IP address.

Specified by:
getRemoteHost in interface CamsHttpAgentRequest
Returns:
a String containing the fully qualified name of the client

getProtocol

public String getProtocol()
Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1. For HTTP servlets, the value returned is the same as the value of the CGI variable SERVER_PROTOCOL.

Specified by:
getProtocol in interface CamsHttpAgentRequest
Returns:
a String containing the protocol name and version number

getScheme

public String getScheme()
Returns the name of the scheme used to make this request.

Specified by:
getScheme in interface CamsHttpAgentRequest
Returns:
the scheme. For example, http or https.

getServerName

public String getServerName()
Returns the host name of the server that received the request.

Specified by:
getServerName in interface CamsHttpAgentRequest

getServerAddr

public String getServerAddr()
Returns the IP address of the server where the CamsHttpAgent is running.

Specified by:
getServerAddr in interface CamsHttpAgentRequest
Returns:
the server's IP address as a String

getServerPort

public int getServerPort()
Returns the port number on which this request was received.

Specified by:
getServerPort in interface CamsHttpAgentRequest

isSecure

public boolean isSecure()
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.

Specified by:
isSecure in interface CamsHttpAgentRequest

getMethod

public String getMethod()
Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT. Same as the value of the CGI variable REQUEST_METHOD.

Specified by:
getMethod in interface CamsHttpAgentRequest
Returns:
a String specifying the name of the method with which this request was made

getQueryString

public String getQueryString()
Returns the query string that is contained in the request URL after the path. This method returns if the URL does not have a query string. Same as the value of the CGI variable QUERY_STRING.

Specified by:
getQueryString in interface CamsHttpAgentRequest
Returns:
a String containing the query string or null if the URL contains no query string. The value is not decoded by the container.

getRequestURI

public String getRequestURI()
Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request. The web container does not decode this String. For example: First line of HTTP request Returned Value POST /some/path.html HTTP/1.1 returns: /some/path.html GET http://foo.bar/a.html HTTP/1.0 returns: /a.html HEAD /xyz?a=b HTTP/1.1 returns: /xyz

Specified by:
getRequestURI in interface CamsHttpAgentRequest
Returns:
a String containing the part of the URL from the protocol name up to the query string

getRequestURL

public String getRequestURL()
Reconstructs the URL the client used to make the request. The returned URL contains a protocol, server name, port number, and server path, but it does not include query string parameters.

Specified by:
getRequestURL in interface CamsHttpAgentRequest
Returns:
a String containing the reconstructed URL

getCookie

public javax.servlet.http.Cookie getCookie(String name)
Get a Cookie with the given name. If no cookie with that name exists then return null.

Specified by:
getCookie in interface CamsHttpAgentRequest
Parameters:
name - the name of the Cookie to get.
Returns:
the Cookie with the given name, or null if Cookie does not exist.
Since:
1.11

getCookies

public javax.servlet.http.Cookie[] getCookies(com.cafesoft.core.http.HttpCookieFilter filter)
Returns an array containing all of the Cookie objects the client sent with this request. This method returns null if no cookies were sent.

Specified by:
getCookies in interface CamsHttpAgentRequest
Returns:
an array of all the Cookies included with this request, or null if the request has no cookies.

getHeader

public String getHeader(String name)
Returns the value of the specified request header as a String. If the request did not include a header of the specified name, this method returns null. The header name is case insensitive. You can use this method with any request header.

Specified by:
getHeader in interface CamsHttpAgentRequest
Parameters:
name - a String specifying the header name
Returns:
a String containing the value of the requested header, or null if the request does not have a header of that name

getHeaders

public Enumeration getHeaders(String name)
Returns all the values of the specified request header as an Enumeration of String objects.

Some headers, such as Accept-Language can be sent by clients as several headers each with a different value rather than sending the header as a comma separated list.

If the request did not include any headers of the specified name, this method returns an empty Enumeration. The header name is case insensitive. You can use this method with any request header.

Specified by:
getHeaders in interface CamsHttpAgentRequest
Parameters:
name - a String specifying the header name
Returns:
an Enumeration containing the values of the requested header. If the request does not have any headers of that name return an empty enumeration. If the container does not allow access to header information, return null

getHeaderNames

public Enumeration getHeaderNames()
Returns an enumeration of all the header names this request contains. If the request has no headers, this method returns an empty enumeration. Some servlet containers do not allow do not allow servlets to access headers using this method, in which case this method returns null

Specified by:
getHeaderNames in interface CamsHttpAgentRequest
Returns:
an enumeration of all the header names sent with this request; if the request has no headers, an empty enumeration; if the servlet container does not allow servlets to use this method, null

getClientX509CertificateChain

public X509Certificate[] getClientX509CertificateChain()
Get the client X509 certificate chain.

Specified by:
getClientX509CertificateChain in interface CamsHttpAgentRequest
Returns:
an array of X509Certificate objects or null if no client certificate chain is available.

getSecurityDomain

public String getSecurityDomain()
Get the name of the SecurityDomain handling this request.

Specified by:
getSecurityDomain in interface CamsHttpAgentRequest
Returns:
the name of the SecurityDomain handling this request, or null if the SecurityDomain name has not yet been determined.
Since:
1.14

setSecurityDomain

public void setSecurityDomain(String securityDomain)
Get the name of the SecurityDomain handling this request.

Specified by:
setSecurityDomain in interface CamsHttpAgentRequest
Parameters:
securityDomain - the name of the SecurityDomain handling this request.
Since:
1.14

addSessionId

public void addSessionId(SessionId sessionId)
Add a SessionId to the request.

Specified by:
addSessionId in interface CamsHttpAgentRequest
Parameters:
sessionId - the SessionId to add to the request.
Since:
1.14

removeSessionId

public void removeSessionId(SessionId sessionId)
Remove a Sessionid from the request.

Specified by:
removeSessionId in interface CamsHttpAgentRequest
Parameters:
sessionId - the SessionId to remove from the request.
Since:
1.14

getSessionIds

public SessionId[] getSessionIds()
Get all of the request's SessionIds.

Specified by:
getSessionIds in interface CamsHttpAgentRequest
Returns:
a non-null array of SessionIds.
Since:
1.14

getSessionId

public SessionId getSessionId(String securityDomain)
Get a SecurityDomain specific SessionId.

Specified by:
getSessionId in interface CamsHttpAgentRequest
Parameters:
securityDomain - the name of the SecurityDomain from which the SessionId is being requested from.
Since:
1.14

getValueByPropertySpec

public String getValueByPropertySpec(PropertySpec ps)
                              throws CamsHttpAgentException
Get an HTTP request value by PropertySpec.

Specified by:
getValueByPropertySpec in interface CamsHttpAgentRequest
Parameters:
ps - the PropertySpec.
Returns:
the PropertySpec value or null if the PropertySpec specifies an unknown value.
Throws:
CamsHttpAgentException - if an error occurs resolving the PropertySpec to a value.

isLogin

public boolean isLogin()
Determines if this Http request is for logging in.

Specified by:
isLogin in interface CamsHttpAgentRequest
Returns:
true if this Http request is for logging in, false otherwise

isLogout

public boolean isLogout()
Determines if this Http request is for logging out.

Specified by:
isLogout in interface CamsHttpAgentRequest
Returns:
true if this Http request is for logging out, false otherwise

isSSO

public boolean isSSO()
Determines if this Http request is for cross DNS domain single sign-on.

Specified by:
isSSO in interface CamsHttpAgentRequest
Returns:
true if this Http request is for cross DNS domain single sign-on, false otherwise

isAESO

public boolean isAESO()
Determines if this Http request is for automatic enterprise sign-on (AESO).

Specified by:
isAESO in interface CamsHttpAgentRequest
Returns:
true if this HTTP request is for automatic enterprise sign-on, false otherwise

recycle

public void recycle()
Recycle the CamsHttpAgentRequest so it can be reused.

Specified by:
recycle in interface CamsHttpAgentRequest

destroy

public void destroy()
Destroy the CamsHttpAgentRequest.

This method will destroy the CamsHttpAgentRequest object. This method should be used when the CamsHttpAgentRequest will no longer be used. This method should destroy everything including underlying collections.

Specified by:
destroy in interface CamsHttpAgentRequest

log

public void log()
Logs the data contained in this CamsHttpAgentRequest.

Specified by:
log in interface CamsHttpAgentRequest


Generated on 10:38:35 AM April 14, 2011, © 1996-2010 Cafésoft LLC. All rights reserved.