|
|||||||||
| Home >> All >> org >> enhydra >> servlet >> connectionMethods >> [ EnhydraDirector overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.enhydra.servlet.connectionMethods.EnhydraDirector
Class EnhydraDirectorConnection

java.lang.Objectorg.enhydra.servlet.connectionMethods.EnhydraDirector.EnhydraDirectorProtocol
org.enhydra.servlet.connectionMethods.EnhydraDirector.EnhydraDirectorConnection
- All Implemented Interfaces:
- java.util.Enumeration, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.tomcat.core.RequestAdapter, org.apache.tomcat.core.ResponseAdapter, javax.servlet.ServletRequest, javax.servlet.ServletResponse
- public class EnhydraDirectorConnection
- extends EnhydraDirectorProtocol
- implements javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.util.Enumeration, org.apache.tomcat.core.RequestAdapter, org.apache.tomcat.core.ResponseAdapter
- extends EnhydraDirectorProtocol
| Field Summary | |
private java.util.Hashtable |
attributes
Request attributes |
private byte[] |
authData
Authentication key. |
private java.util.Hashtable |
cgiVars
Table of incoming request headers. |
private boolean |
committed
Boolean to indicate whether data bytes have been sent over the wire, and thus that headers and status can no longer be set. |
private java.lang.String |
cookieMangle
Cookie string to stick in request headers. |
private static byte[] |
CRLF
|
private static java.text.DateFormat |
dateFormatter
Parser for dates. |
private static java.text.DateFormat |
dateParser
Parser for dates. |
private static boolean |
debug
Debug flag. |
private static java.util.Hashtable |
emptyHashTable
|
static java.lang.String |
FORM_POST_MIME_TYPE
Standard Mime type for POST-ed forms. |
private boolean |
haveQueryParameters
Whether we have query parameters yet. |
private EnhydraDirectorInputStream |
inStream
Internal ServletInputStream |
private java.lang.String |
ipPortToken
The IP address and Port that the connection is listening on |
private java.util.Locale |
locale
Our locale. |
private EnhydraDirectorOutputStream |
outStream
Internal ServletOutputStream |
private java.util.Hashtable |
postParams
|
private java.util.Hashtable |
privateHeaders
Table of incoming request headers. |
private java.util.Hashtable |
queryParameters
Query String parameters. |
private java.lang.String |
queryString
|
private java.io.BufferedReader |
reader
If getReader() has been called, this keeps a reference
to the created BufferedReader. |
private java.util.Vector |
requestCookies
Cookies received from the client. |
private java.util.Hashtable |
requestHeaders
Table of incoming request headers. |
private java.util.Vector |
responseCookies
Current table of outgoing cookies. |
private java.util.Hashtable |
responseHeaders
Current table of response headers. |
private javax.servlet.ServletContext |
servletContext
Servlet Context passed to us by the handler. |
private java.lang.String |
servletPath
Servlet Path passed to us by the handler. |
private boolean |
sessionAffinity
The session affinity flag |
private int |
statusCode
Status code if no error. |
private java.lang.String |
statusMsg
Status code if no error. |
private boolean |
usingInputStream
Whether getInputStream() has been called on this instance. |
private boolean |
usingOutputStream
Whether getOutputStream() has been called on this instance. |
private java.io.PrintWriter |
writer
Writer reference if the servlet requested a Writer. |
| Fields inherited from interface javax.servlet.http.HttpServletRequest |
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH |
| Constructor Summary | |
EnhydraDirectorConnection(com.lutris.logging.LogChannel chan)
|
|
| Method Summary | |
void |
activate()
Override the activate() method to allow per-connection variables to be reset for each new connection. |
void |
addCookie(javax.servlet.http.Cookie cookie)
Add a cookie to the list of cookies to send to the browser. |
void |
addDateHeader(java.lang.String name,
long date)
Adds a response header with the given name and date value. |
void |
addHeader(java.lang.String name,
java.lang.String value)
Adds a response header with the given name and integer value. |
void |
addIntHeader(java.lang.String name,
int value)
Adds a response header with the given name and integer value. |
void |
addMimeHeaders(org.apache.tomcat.util.MimeHeaders headers)
|
protected boolean |
authRequired()
Implementation class must provide this method. |
void |
closeOutput()
Method to close output stream. |
(package private) void |
commit()
Called by EnhydraDirectorOutputStream to indicate that
actual data bytes have been written. |
boolean |
containsHeader(java.lang.String name)
Returns true if the current response contains the
named header. |
int |
doRead()
|
int |
doRead(byte[] b,
int off,
int len)
Fill in the buffer. |
void |
doWrite(byte[] buffer,
int pos,
int count)
Write a chunk of bytes. |
java.lang.String |
encodeRedirectUrl(java.lang.String url)
Encodes the specified URL for use in the sendRedirect method. |
java.lang.String |
encodeRedirectURL(java.lang.String url)
Encodes the specified URL for use in the sendRedirect method or, if encoding is not needed,
returns the URL unchanged. |
java.lang.String |
encodeUrl(java.lang.String url)
Encodes the specified URL by including the session ID in it, or if encoding is not needed, returns the URL unchanged. |
java.lang.String |
encodeURL(java.lang.String url)
Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged. |
void |
endHeaders()
Signal that we're done with the headers, and body will follow. |
void |
endResponse()
Signal that we're done with a particular request, the server can go on and read more requests or close the socket |
void |
flushBuffer()
Forces any content in the buffer to be written to the client. |
java.lang.Object |
getAttribute(java.lang.String name)
Returns the value of an attribute of the request. |
java.util.Enumeration |
getAttributeNames()
NEW |
protected byte[] |
getAuthData()
Abstract method to get authentication secret data. |
java.lang.String |
getAuthType()
Gets the authentication scheme of this request. |
int |
getBufferSize()
Returns the actual buffer size used for the response. |
java.lang.String |
getCharacterEncoding()
Returns the charset used for the body. |
int |
getContentLength()
Get the size of the request data. |
java.lang.String |
getContentType()
Get the content type of the request. |
java.lang.String |
getContextPath()
Returns the portion of the request URI that indicates the context of the request. |
java.lang.String[] |
getCookieHeaders()
Return the cookies |
javax.servlet.http.Cookie[] |
getCookies()
Gets the array of cookies found in this request. |
long |
getDateHeader(java.lang.String name)
Gets the value of the requested date header field of this request. |
private java.lang.String |
getErrorPage(int sc,
java.lang.String msg)
Generate an HTML error page for sendError. |
protected EnhydraDirectorFunction |
getFunction(int type)
Internal dispatch table for server side function handlers. |
java.lang.String |
getHeader(java.lang.String name)
Gets the value of the requested header field of this request. |
java.util.Enumeration |
getHeaderNames()
Gets the header names for this request. |
java.util.Enumeration |
getHeaders(java.lang.String name)
Returns all the values of the specified requst header as an Enumeration of String objects. |
javax.servlet.ServletInputStream |
getInputStream()
Get an input stream for reading binary data in the request body. |
int |
getIntHeader(java.lang.String name)
Gets the value of the specified integer header field of this request. |
java.lang.String |
getIPPortToken()
|
java.util.Locale |
getLocale()
Gets the locale of the response. |
java.util.Enumeration |
getLocales()
NEW |
java.lang.String |
getMethod()
Gets the HTTP method (for example, GET, POST, PUT) with which this request was made. |
org.apache.tomcat.util.MimeHeaders |
getMimeHeaders()
|
javax.servlet.ServletOutputStream |
getOutputStream()
Returns the byte output stream object for this response. |
java.lang.String |
getParameter(java.lang.String name)
Get a string containing the lone value of the specified parameter. |
java.util.Enumeration |
getParameterNames()
Get the parameter names for this request. |
java.lang.String[] |
getParameterValues(java.lang.String name)
Get the values of the specified parameter for the request. |
java.lang.String |
getPathInfo()
Gets any optional extra path information following the servlet path of this request's URI, but immediately preceding its query string. |
java.lang.String |
getPathTranslated()
Gets any optional extra path information following the servlet path of this request's URI, but immediately preceding its query string, and translates it to a real path. |
java.lang.String |
getProtocol()
Get the protocol and version of the request. |
java.lang.String |
getQueryString()
Gets any query string that is part of the HTTP request URI. |
java.io.BufferedReader |
getReader()
Returns a buffered reader for reading text in the request body. |
java.lang.String |
getRealPath(java.lang.String path)
Applies alias rules to the specified virtual path and returns the corresponding real path, or null if the translation can not be performed for any reason. |
private java.lang.String |
getRedirectPage(java.lang.String url)
Generate an HTML page for sendRedirect. |
java.lang.String |
getRemoteAddr()
Get the IP address of the agent that sent the request. |
java.lang.String |
getRemoteHost()
Get the fully qualified host name of the agent that sent the request. |
java.lang.String |
getRemoteUser()
Gets the name of the user making this request. |
javax.servlet.RequestDispatcher |
getRequestDispatcher(java.lang.String name)
Returns a javax.servlet.RequestDispatcher object that acts as a wrapper for the resource located at the given path. |
java.lang.String |
getRequestedSessionId()
Gets the session id specified with this request. |
java.lang.String |
getRequestURI()
Get the part of this request's URI that is to the left of any query string. |
java.lang.String |
getScheme()
Get the scheme of the URL used in this request, for example "http", "https", or "ftp". |
java.lang.String |
getServerName()
Get the host name of the server that received the request. |
int |
getServerPort()
Get the port number on which this request was received. |
java.lang.String |
getServletName()
|
javax.servlet.ServletOutputStream |
getServletOutputStream()
Either implement ServletOutputStream or return BufferedServletOutputStream(this) and implement doWrite(); |
java.lang.String |
getServletPath()
Gets the part of this request's URI that refers to the servlet being invoked. |
java.lang.String |
getServletPrefix()
|
javax.servlet.http.HttpSession |
getSession()
Gets the current valid session associated with this request, if create is false or, if necessary, creates a new session for the request, if create is true. |
javax.servlet.http.HttpSession |
getSession(boolean create)
Gets the current valid session associated with this request, if create is false or, if necessary, creates a new session for the request, if create is true. |
boolean |
getSessionAffinity()
|
java.security.Principal |
getUserPrincipal()
NEW |
java.io.PrintWriter |
getWriter()
Gets a character stream printing writer for the response. |
boolean |
hasMoreElements()
Stub hasMoreElements implementation so this instance
can be passed as an empty enumeration. |
boolean |
isCommitted()
Returns a boolean indicating whether the response has been committed. |
boolean |
isRequestedSessionIdFromCookie()
Checks whether the session id specified by this request came in as a cookie. |
boolean |
isRequestedSessionIdFromUrl()
Checks whether the session id specified by this request came in as part of the URL. |
boolean |
isRequestedSessionIdFromURL()
Checks whether the session id specified by this request came in as part of the URL. |
boolean |
isRequestedSessionIdValid()
Checks whether this request is associated with a session that is valid in the current session context. |
boolean |
isSecure()
NEW |
boolean |
isUserInRole(java.lang.String role)
NEW |
java.lang.Object |
nextElement()
Stub nextElement implementation so this instance
can be passed as an empty enumeration. |
private void |
parseQueryParameters()
Parse query string or POST form parameters. |
protected void |
processCgiHeader(byte[] nameBytes,
byte[] valueBytes)
Abstract method to get authentication secret data. |
protected void |
processCookie(byte[] nameBytes,
byte[] valueBytes)
Abstract method to get authentication secret data. |
protected void |
processHttpHeader(byte[] nameBytes,
byte[] valueBytes)
Abstract method to get authentication secret data. |
void |
recycle()
|
void |
removeAttribute(java.lang.String name)
NEW |
void |
reset()
Clears any data that exists in the buffer as well as the status code and headers. |
void |
sendError(int sc)
Sends an error response to the client using the specified status code and a default message. |
void |
sendError(int sc,
java.lang.String msg)
Sends an error response to the client using the specified status code and descriptive message. |
void |
sendRedirect(java.lang.String location)
Sends a temporary redirect response to the client using the specified redirect location URL. |
void |
setAttribute(java.lang.String name)
NEW |
void |
setAttribute(java.lang.String name,
java.lang.Object value)
Stores an attribute in this request. |
void |
setAuthData(java.lang.String authData)
Sets authentication data. |
void |
setBufferSize(int size)
Sets the preferred buffer size for the body of the response. |
void |
setContentLength(int len)
Sets the value of the outgoing Content-Length header. |
void |
setContentType(java.lang.String type)
Sets the MIME content type of the outgoing response. |
private static void |
setDateFormatter()
|
void |
setDateHeader(java.lang.String name,
long date)
Sets a response header with the given name and date value. |
void |
setHeader(java.lang.String name,
java.lang.String value)
Sets a response header with the given name and integer value. |
void |
setIntHeader(java.lang.String name,
int value)
Sets a response header with the given name and integer value. |
void |
setIPPortToken(java.lang.String ipPortToken)
These values are used by the session manager to determine what IP and Port number to include with the user's session cookie. |
void |
setLocale(java.util.Locale loc)
Sets the locale of the response. |
void |
setQueryString(java.lang.String queryString)
Sets the query string that is part of the HTTP request URI. |
void |
setServletInfo(java.lang.String reqServletPath,
javax.servlet.ServletContext context)
Sets information that can not be obtained from the request. |
void |
setSessionAffinity(boolean sessionAffinity)
This flag is used by the session manager to determine if the IP and Port string should be included in the session cookie. |
void |
setStatus(int sc)
Sets the status code for this response. |
void |
setStatus(int sc,
java.lang.String sm)
Sets the status code for this response. |
protected void |
stuffInternalHeader(java.lang.String name,
java.lang.String value)
Private helper method to stuff a header into the request headers list. |
| Methods inherited from class org.enhydra.servlet.connectionMethods.EnhydraDirector.EnhydraDirectorProtocol |
authenticate, authenticate, callback, closeConnection, closeInput, connect, deactivate, discardEntity, finishHeaders, getStateName, getStateName, inputAvailable, isAuthenticated, isConnected, isOpen, read, read, read, readExactly, readExactly, sendCookie, sendHeader, skip, toString, write, write, write |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface javax.servlet.http.HttpServletRequest |
getRequestURL |
| Methods inherited from interface javax.servlet.ServletRequest |
getLocalAddr, getLocalName, getLocalPort, getParameterMap, getRemotePort, setCharacterEncoding |
| Methods inherited from interface javax.servlet.ServletResponse |
resetBuffer, setCharacterEncoding |
| Field Detail |
FORM_POST_MIME_TYPE
public static final java.lang.String FORM_POST_MIME_TYPE
- Standard Mime type for POST-ed forms.
- See Also:
- Constant Field Values
dateParser
private static final java.text.DateFormat dateParser
- Parser for dates.
dateFormatter
private static java.text.DateFormat dateFormatter
- Parser for dates.
authData
private byte[] authData
- Authentication key.
requestHeaders
private java.util.Hashtable requestHeaders
- Table of incoming request headers.
cgiVars
private java.util.Hashtable cgiVars
- Table of incoming request headers.
privateHeaders
private java.util.Hashtable privateHeaders
- Table of incoming request headers.
requestCookies
private java.util.Vector requestCookies
- Cookies received from the client.
queryParameters
private java.util.Hashtable queryParameters
- Query String parameters.
haveQueryParameters
private boolean haveQueryParameters
- Whether we have query parameters yet.
usingInputStream
private boolean usingInputStream
- Whether
getInputStream() has been called on this instance.
inStream
private EnhydraDirectorInputStream inStream
- Internal
ServletInputStream
reader
private java.io.BufferedReader reader
- If
getReader()has been called, this keeps a reference to the createdBufferedReader.
usingOutputStream
private boolean usingOutputStream
- Whether
getOutputStream() has been called on this instance.
outStream
private EnhydraDirectorOutputStream outStream
- Internal
ServletOutputStream
writer
private java.io.PrintWriter writer
- Writer reference if the servlet requested a Writer.
servletContext
private javax.servlet.ServletContext servletContext
- Servlet Context passed to us by the handler.
servletPath
private java.lang.String servletPath
- Servlet Path passed to us by the handler.
locale
private java.util.Locale locale
- Our locale.
cookieMangle
private java.lang.String cookieMangle
- Cookie string to stick in request headers. XXX HACK
This is lame. When/if we do persistent appserver connections, this will need to be set to null.
committed
private boolean committed
- Boolean to indicate whether data bytes have been sent over
the wire, and thus that headers and status can no longer
be set.
responseHeaders
private java.util.Hashtable responseHeaders
- Current table of response headers.
responseCookies
private java.util.Vector responseCookies
- Current table of outgoing cookies. This is a
VectorofCookieobjects.
statusCode
private int statusCode
- Status code if no error.
statusMsg
private java.lang.String statusMsg
- Status code if no error.
debug
private static final boolean debug
- Debug flag.
- See Also:
- Constant Field Values
ipPortToken
private java.lang.String ipPortToken
- The IP address and Port that the connection is listening on
sessionAffinity
private boolean sessionAffinity
- The session affinity flag
attributes
private java.util.Hashtable attributes
- Request attributes
postParams
private java.util.Hashtable postParams
emptyHashTable
private static final java.util.Hashtable emptyHashTable
queryString
private java.lang.String queryString
CRLF
private static final byte[] CRLF
| Constructor Detail |
EnhydraDirectorConnection
public EnhydraDirectorConnection(com.lutris.logging.LogChannel chan) throws java.io.IOException
| Method Detail |
setServletInfo
public void setServletInfo(java.lang.String reqServletPath, javax.servlet.ServletContext context)
- Sets information that can not be obtained from the request.
This should be called after next() and before servlet.service() is
called.
parseQueryParameters
private void parseQueryParameters()
throws java.io.IOException
- Parse query string or POST form parameters.
If query parameters exist, obtain them from the QUERY_STRING or POST data and put them in the
queryParametershash table. This method does not handle multipart file upload.
setDateFormatter
private static void setDateFormatter()
commit
void commit()
throws java.io.IOException
- Called by
EnhydraDirectorOutputStreamto indicate that actual data bytes have been written.Once this method has been called, no more changes can be made to the response status or headers.
setIPPortToken
public void setIPPortToken(java.lang.String ipPortToken)
- These values are used by the session manager to determine what
IP and Port number to include with the user's session cookie.
This value default to null and is set by the EnhydraDirectorHandler.java
getIPPortToken
public java.lang.String getIPPortToken()
setSessionAffinity
public void setSessionAffinity(boolean sessionAffinity)
- This flag is used by the session manager to determine if the IP and
Port string should be included in the session cookie. This value
defaults to true and is set by EnhydraDirectorHandler.java
getSessionAffinity
public boolean getSessionAffinity()
activate
public void activate()
throws java.io.IOException
- Override the activate() method to allow per-connection variables
to be reset for each new connection.
- Overrides:
activatein classEnhydraDirectorProtocol
getFunction
protected EnhydraDirectorFunction getFunction(int type)
- Internal dispatch table for server side function handlers.
Supported functions are permanently registered at compile time
by placing them in this method's switch block.
- Specified by:
getFunctionin classEnhydraDirectorProtocol
authRequired
protected boolean authRequired()
- Implementation class must provide this method. It should check
the configuration data to determine if authentication is required
for connections.
- Specified by:
authRequiredin classEnhydraDirectorProtocol
getAuthData
protected byte[] getAuthData()
- Abstract method to get authentication secret data.
This method must be provided by the implementation class. It checks the configuration and finds the secret authentication data used to verify authentication responses from clients.
- Specified by:
getAuthDatain classEnhydraDirectorProtocol
setAuthData
public void setAuthData(java.lang.String authData)
- Sets authentication data.
This method allows the connection method handler to pass the configured authentication string to this instance for use in establishing connections.
processCgiHeader
protected void processCgiHeader(byte[] nameBytes,
byte[] valueBytes)
- Abstract method to get authentication secret data.
- Specified by:
processCgiHeaderin classEnhydraDirectorProtocol
stuffInternalHeader
protected void stuffInternalHeader(java.lang.String name, java.lang.String value)
- Private helper method to stuff a header into the request headers list.
If this is used to stuff 'pseudo' headers for internal code, then the headers should have illegal names that can't conflict with valid HTTP headers.
processHttpHeader
protected void processHttpHeader(byte[] nameBytes,
byte[] valueBytes)
- Abstract method to get authentication secret data.
- Specified by:
processHttpHeaderin classEnhydraDirectorProtocol
processCookie
protected void processCookie(byte[] nameBytes,
byte[] valueBytes)
- Abstract method to get authentication secret data.
- Specified by:
processCookiein classEnhydraDirectorProtocol
hasMoreElements
public boolean hasMoreElements()
- Stub
hasMoreElementsimplementation so this instance can be passed as an empty enumeration.This is necessary because
Enumerationcannot be instantiated by itself, and some methods in this class must return an empty enumeration if certain headers or parameters are not found.- Specified by:
hasMoreElementsin interfacejava.util.Enumeration
nextElement
public java.lang.Object nextElement() throws java.util.NoSuchElementException
- Stub
nextElementimplementation so this instance can be passed as an empty enumeration.This is necessary because
Enumerationcannot be instantiated by itself, and some methods in this class must return an empty enumeration if certain headers or parameters are not found.- Specified by:
nextElementin interfacejava.util.Enumeration
getAuthType
public java.lang.String getAuthType()
- Gets the authentication scheme of this request.
- Specified by:
getAuthTypein interfacejavax.servlet.http.HttpServletRequest
getContextPath
public java.lang.String getContextPath()
- Returns the portion of the request URI that indicates the context
of the request.
The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character. For servlets in the default (root) context, this method returns "".
- Specified by:
getContextPathin interfacejavax.servlet.http.HttpServletRequest
getCookies
public javax.servlet.http.Cookie[] getCookies()
- Gets the array of cookies found in this request.
- Specified by:
getCookiesin interfacejavax.servlet.http.HttpServletRequest
getDateHeader
public long getDateHeader(java.lang.String name)
- Gets the value of the requested date header field of this request.
- Specified by:
getDateHeaderin interfacejavax.servlet.http.HttpServletRequest
getHeader
public java.lang.String getHeader(java.lang.String name)
- Gets the value of the requested header field of this request.
- Specified by:
getHeaderin interfacejavax.servlet.http.HttpServletRequest
getHeaderNames
public java.util.Enumeration getHeaderNames()
- Gets the header names for this request.
- Specified by:
getHeaderNamesin interfacejavax.servlet.http.HttpServletRequest
getHeaders
public java.util.Enumeration getHeaders(java.lang.String name)
- Returns all the values of the specified requst header as an
EnumerationofStringobjects.Some headers, such as
Accept-Languagecan 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:
getHeadersin interfacejavax.servlet.http.HttpServletRequest
getIntHeader
public int getIntHeader(java.lang.String name) throws java.lang.NumberFormatException
- Gets the value of the specified integer header field of this
request.
- Specified by:
getIntHeaderin interfacejavax.servlet.http.HttpServletRequest
getMethod
public java.lang.String getMethod()
JAVADOC