org.cdlib.xtf.servletBase
Class TextServlet.RequestWrapper

Object
  extended by ServletRequestWrapper
      extended by HttpServletRequestWrapper
          extended by TextServlet.RequestWrapper
All Implemented Interfaces:
HttpServletRequest, ServletRequest
Enclosing class:
TextServlet

private class TextServlet.RequestWrapper
extends HttpServletRequestWrapper

Wraps a servlet request, substituting a different parameter set that allows ';' in addition to '&' as a separator. Also, removes any session ID in the URL. Note: Some deprecated methods are included in HttpServletRequestWrapper. Since there's nothing we can do about that, we simply suppress warnings about that.


Field Summary
private  char equalChar
          Special code to protect equal signs in protectChars()
private  char[] hexChars
           
(package private)  HttpServletRequest inReq
           
(package private)  ArrayList<String> paramNames
           
(package private)  HashMap<String,ArrayList<String>> params
           
private  char semiChar
          Special code to protect semicolons in protectChars()
 
Fields inherited from interface HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
 
Constructor Summary
TextServlet.RequestWrapper(HttpServletRequest inReq)
           
 
Method Summary
private  void addParam(String name, String val)
           
 String getParameter(String name)
           
 Map getParameterMap()
           
 Enumeration getParameterNames()
           
 String[] getParameterValues(String name)
           
private  void init()
           
private  boolean matchHex(char[] src, int sp, int max, int val)
          See if there's a '%XX' hex code at the given position for the value.
private  String protectChars(String paramName, String val)
          Protect '=' and ';' characters that were actually escaped with % codes in the original URL.
private  String unprotectChars(String val)
          Translates protected '=' and ';' characters from protectChars above back into regular characters.
 
Methods inherited from class HttpServletRequestWrapper
getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole
 
Methods inherited from class ServletRequestWrapper
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocale, getLocales, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding, setRequest
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ServletRequest
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocale, getLocales, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding
 

Field Detail

inReq

HttpServletRequest inReq

paramNames

ArrayList<String> paramNames

params

HashMap<String,ArrayList<String>> params

semiChar

private char semiChar
Special code to protect semicolons in protectChars()


equalChar

private char equalChar
Special code to protect equal signs in protectChars()


hexChars

private char[] hexChars
Constructor Detail

TextServlet.RequestWrapper

TextServlet.RequestWrapper(HttpServletRequest inReq)
Method Detail

init

private void init()

protectChars

private String protectChars(String paramName,
                            String val)
Protect '=' and ';' characters that were actually escaped with % codes in the original URL. Escaping indicates that the user wanted to query for these, so we should not use them as parameter separators.

Parameters:
paramName - Name of the parameter we're working on
val - Unescaped value to protect
Returns:
Value with % coded '=' or ';' translated to equalChar or semiChar respectively.

matchHex

private boolean matchHex(char[] src,
                         int sp,
                         int max,
                         int val)
See if there's a '%XX' hex code at the given position for the value.


unprotectChars

private String unprotectChars(String val)
Translates protected '=' and ';' characters from protectChars above back into regular characters.

Parameters:
val - Value possibly containing protected characters.
Returns:
Same value but with unprotected characters.

addParam

private void addParam(String name,
                      String val)

getParameterNames

public Enumeration getParameterNames()
Specified by:
getParameterNames in interface ServletRequest
Overrides:
getParameterNames in class ServletRequestWrapper

getParameter

public String getParameter(String name)
Specified by:
getParameter in interface ServletRequest
Overrides:
getParameter in class ServletRequestWrapper

getParameterValues

public String[] getParameterValues(String name)
Specified by:
getParameterValues in interface ServletRequest
Overrides:
getParameterValues in class ServletRequestWrapper

getParameterMap

public Map getParameterMap()
Specified by:
getParameterMap in interface ServletRequest
Overrides:
getParameterMap in class ServletRequestWrapper