wt.sysadm
Class SysAdminRequest

java.lang.Object
  extended bywt.sysadm.SysAdminRequest
All Implemented Interfaces:
CGIConstants

public class SysAdminRequest
extends Object
implements CGIConstants

This class is a carrier of request information to SysAdmin program. Instances contain information about the request (I.e. CGI environment values) and an input stream reference.


Field Summary
private static int BUFSIZ
           
private  Properties cgiData
           
private  EncodingConverter encoder
           
private  Properties formData
           
private  InputStream inputStream
           
private static boolean REQUEST_URI_DECODE
          Some webservers are appearing to decoding the RequestURI prior to passing it to the servlet engine.
static boolean VERBOSE
           
private static String versionID
           
 
Fields inherited from interface wt.sysadm.CGIConstants
CGI_ACCEPT, CGI_ACCEPT_CHARSET, CGI_ACCEPT_LANGUAGE, CGI_AUTH_TYPE, CGI_AUTHORIZATION, CGI_CONNECTION, CGI_CONTENT_LENGTH, CGI_CONTENT_TYPE, CGI_DELETE_METHOD, CGI_GATEWAY_INTERFACE, CGI_GET_METHOD, CGI_HEAD_METHOD, CGI_HOST, CGI_MULTIPART_BOUNDARY, CGI_PATH_INFO, CGI_PATH_TRANSLATED, CGI_POST_METHOD, CGI_PRAGMA, CGI_PROPERTY_PREFIX, CGI_PROTOCOL, CGI_PUT_METHOD, CGI_QUERY_STRING, CGI_REFERER, CGI_REMOTE_ADDR, CGI_REMOTE_HOST, CGI_REMOTE_IDENT, CGI_REMOTE_USER, CGI_REQUEST_METHOD, CGI_SCHEME, CGI_SCRIPT_NAME, CGI_SERVER_NAME, CGI_SERVER_PORT, CGI_SERVER_PROTOCOL, CGI_SERVER_SOFTWARE, CGI_TRACE_METHOD, CGI_UA_COLOR, CGI_UA_CPU, CGI_UA_OS, CGI_UA_PIXELS, CGI_URI, CGI_URL, CGI_USER_AGENT
 
Constructor Summary
SysAdminRequest(Properties cgi_data, InputStream input_stream)
          Public Constructor.
 
Method Summary
private  void fixCgiData()
           
 String getBaseURL()
          Determine the Base URL of this script.
 Properties getFormData()
          Retrieves the FORM data from the incoming input stream as x-www-form-urlencoded data.
 String getFullURL()
          Determine the Full URL of this script.
 InputStream getInputStream()
          Gets the input stream associated with this SysAdmin object.
 String getMultiPartBoundary(String ContentType)
          Utility routine to parse out the multipart object-body boundary
 String getProperty(String key)
          Public getter method for access to CGI data.
 String getProperty(String key, String default_value)
          Public getter method for access to CGI data.
 Enumeration getPropertyKeys()
          Public getter method for access to CGI data keys.
 boolean isGetRequest()
          Determine if the REQUEST_METHOD used to send the data from the browser was the GET method.
 boolean isPostRequest()
          Determine if the REQUEST_METHOD used to send the data from the browser was the POST method.
 boolean isUrlencodedContent()
          Determine if the CONTENT_TYPE used to send the data from the browser was urlencoded form data.
 void listProperties(PrintWriter out)
          Public lister method for debug access to CGI data.
static void main(String[] args)
          The main routine is included here as a test driver.
 PrintWriter newPrintWriter(OutputStream output_stream)
          Utility routine to construct a buffered PrintWriter from an OutputStream.
 void printFormDataHTML(PrintWriter out)
          Print all of the form data using HTML.
 void printHTMLBottom(PrintWriter out)
          Generate some vanilla HTML that you usually want to include at the bottom of any HTML page you generate.
 void printHTMLHeader(PrintWriter out)
          Print a standard HTTP HTML header.
 void printHTMLTop(PrintWriter out, String title)
          Generate some vanilla HTML that you usually want to include at the top of any HTML page you generate.
 void printHTMLTop(PrintWriter out, String title, String doc_base, String[] body_tags)
          Generate some vanilla HTML that you usually want to include at the top of any HTML page you generate.
 void printPropertiesHTML(PrintWriter out)
          Print all of the CGI properties and the associated values using HTML.
private  String readQueryString(InputStream input_stream)
          Reads the query string from the incoming input stream.
 Properties splitQueryString(String query_string)
          Splits the URLs query string into name value pairs based on the ampersand and equal character tokens.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionID

private static final String versionID
See Also:
Constant Field Values

BUFSIZ

private static final int BUFSIZ
See Also:
Constant Field Values

VERBOSE

public static boolean VERBOSE

cgiData

private Properties cgiData

formData

private Properties formData

inputStream

private InputStream inputStream

encoder

private EncodingConverter encoder

REQUEST_URI_DECODE

private static boolean REQUEST_URI_DECODE
Some webservers are appearing to decoding the RequestURI prior to passing it to the servlet engine. This includes the iPlanet family of servers. In order to prevent clobbering of the request URI the property below if set to true will www_url_decode the RequestURI, otherwise no decoding will be performed.

Constructor Detail

SysAdminRequest

public SysAdminRequest(Properties cgi_data,
                       InputStream input_stream)
Public Constructor.

Parameters:
cgi_data - Properties object of http headers
Method Detail

fixCgiData

private void fixCgiData()

getInputStream

public InputStream getInputStream()
Gets the input stream associated with this SysAdmin object.

Returns:
An InputStream.

readQueryString

private String readQueryString(InputStream input_stream)
Reads the query string from the incoming input stream.

Returns:
String the query string.

getFormData

public Properties getFormData()
Retrieves the FORM data from the incoming input stream as x-www-form-urlencoded data. If the input stream is null, it will read FORM data from the header query string.

Returns:
Properties the form data as name value pairs.

splitQueryString

public Properties splitQueryString(String query_string)
Splits the URLs query string into name value pairs based on the ampersand and equal character tokens.

Returns:
Properties the query string info as name value pairs.

isGetRequest

public boolean isGetRequest()
Determine if the REQUEST_METHOD used to send the data from the browser was the GET method.

Returns:
true, if the REQUEST_METHOD was GET. false, otherwise.

isPostRequest

public boolean isPostRequest()
Determine if the REQUEST_METHOD used to send the data from the browser was the POST method.

Returns:
true, if the REQUEST_METHOD was POST. false, otherwise.

isUrlencodedContent

public boolean isUrlencodedContent()
Determine if the CONTENT_TYPE used to send the data from the browser was urlencoded form data.

Returns:
true, if the CONTENT_TYPE was urlencoded form data. false, otherwise.

getBaseURL

public String getBaseURL()
Determine the Base URL of this script. (Does not include the QUERY_STRING (if any) or PATH_INFO (if any).

Returns:
The Base URL of this script as a String.

getFullURL

public String getFullURL()
Determine the Full URL of this script. (Includes the QUERY_STRING (if any) or PATH_INFO (if any).

Returns:
The Full URL of this script as a String.

getProperty

public String getProperty(String key)
Public getter method for access to CGI data.

Returns:
String the value

getPropertyKeys

public Enumeration getPropertyKeys()
Public getter method for access to CGI data keys.

Returns:
Enumeration of the keys

listProperties

public void listProperties(PrintWriter out)
Public lister method for debug access to CGI data. Output is not formated. For formated output (html), see the printPropertiesHTML method below.


getProperty

public String getProperty(String key,
                          String default_value)
Public getter method for access to CGI data. If not set, default value is returned.

Returns:
String the value

printHTMLHeader

public void printHTMLHeader(PrintWriter out)
                     throws IOException
Print a standard HTTP HTML header.

Parameters:
out - PrintWriter to receive output.

Returns:
A String containing the standard HTTP HTML header.
Throws:
IOException

printHTMLTop

public void printHTMLTop(PrintWriter out,
                         String title,
                         String doc_base,
                         String[] body_tags)
                  throws IOException
Generate some vanilla HTML that you usually want to include at the top of any HTML page you generate.

Parameters:
out - PrintWriter to receive output.
Returns:
A String containing the top portion of an HTML file.
Throws:
IOException

printHTMLTop

public void printHTMLTop(PrintWriter out,
                         String title)
                  throws IOException
Generate some vanilla HTML that you usually want to include at the top of any HTML page you generate.

Parameters:
out - PrintWriter to receive output.
Returns:
A String containing the top portion of an HTML file.
Throws:
IOException

printHTMLBottom

public void printHTMLBottom(PrintWriter out)
                     throws IOException
Generate some vanilla HTML that you usually want to include at the bottom of any HTML page you generate.

Parameters:
out - PrintWriter to receive output.

Returns:
A String containing the bottom portion of an HTML file.
Throws:
IOException

printPropertiesHTML

public void printPropertiesHTML(PrintWriter out)
                         throws IOException
Print all of the CGI properties and the associated values using HTML.

Parameters:
out - PrintWriter to receive output.
Throws:
IOException

printFormDataHTML

public void printFormDataHTML(PrintWriter out)
                       throws IOException
Print all of the form data using HTML.

Parameters:
out - PrintWriter to receive output.
Throws:
IOException

newPrintWriter

public PrintWriter newPrintWriter(OutputStream output_stream)
Utility routine to construct a buffered PrintWriter from an OutputStream.

Parameters:
output_stream - OutputStream to be wrapped

Returns:
A buffered PrintWriter consturcted around the given OutPutStream.

getMultiPartBoundary

public String getMultiPartBoundary(String ContentType)
Utility routine to parse out the multipart object-body boundary

Parameters:
ContentType - String containing the content-type and boundary, separated by a semi-colon

Returns:
A String containing the object-body boundary, not to exceed 70 characters per RFC1341

main

public static void main(String[] args)
The main routine is included here as a test driver.