org.sitemesh.webapp.contentfilter
Class HttpServletRequestFilterable

java.lang.Object
  extended by javax.servlet.ServletRequestWrapper
      extended by javax.servlet.http.HttpServletRequestWrapper
          extended by org.sitemesh.webapp.contentfilter.HttpServletRequestFilterable
All Implemented Interfaces:
javax.servlet.http.HttpServletRequest, javax.servlet.ServletRequest

public class HttpServletRequestFilterable
extends javax.servlet.http.HttpServletRequestWrapper

This special HttpServletRequestWrapper is used to allow filtering of the HTTP headers by adding them to an exclusion list. The initial need for this wrapper came up when the decorator is modified and the client/browser sends over the If-Modified-Since header to the server. The result is the servlet container sends back a 304 and changes to the decorator are never rendered until the requested resource is modified. TODO: Implement any method that may be used to obtain the headers which are filtered. i.e., HttpServletRequest#getHeaderNames()

Author:
Richard L. Burton III

Field Summary
protected  Set<String> exclusionsHeaders
          The HTTP Headers that will be removed when filtering is enabled.
 
Fields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
 
Constructor Summary
HttpServletRequestFilterable(javax.servlet.http.HttpServletRequest httpServletRequest)
           
 
Method Summary
 void addExclusion(String header)
          This method will add the header name to the list of headers to be filtered.
 long getDateHeader(String header)
           
 String getHeader(String header)
          This customized version of HttpServletRequest#getHeader(String) returns null for any HTTP header that is being filtered out.
protected  boolean isExcluded(String header)
          This method checks to see if the header name is within the exclusion list.
protected  String normalize(String header)
           
 
Methods inherited from class javax.servlet.http.HttpServletRequestWrapper
getAuthType, getContextPath, getCookies, getHeaderNames, getHeaders, getIntHeader, getMethod, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole
 
Methods inherited from class javax.servlet.ServletRequestWrapper
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding, setRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.ServletRequest
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding
 

Field Detail

exclusionsHeaders

protected Set<String> exclusionsHeaders
The HTTP Headers that will be removed when filtering is enabled.

Constructor Detail

HttpServletRequestFilterable

public HttpServletRequestFilterable(javax.servlet.http.HttpServletRequest httpServletRequest)
See Also:
HttpServletRequestWrapper.HttpServletRequestWrapper(HttpServletRequest)
Method Detail

getHeader

public String getHeader(String header)
This customized version of HttpServletRequest#getHeader(String) returns null for any HTTP header that is being filtered out.

Specified by:
getHeader in interface javax.servlet.http.HttpServletRequest
Overrides:
getHeader in class javax.servlet.http.HttpServletRequestWrapper
Parameters:
header - The HTTP header name.
Returns:
The value for the header name in question.

getDateHeader

public long getDateHeader(String header)
Specified by:
getDateHeader in interface javax.servlet.http.HttpServletRequest
Overrides:
getDateHeader in class javax.servlet.http.HttpServletRequestWrapper

isExcluded

protected boolean isExcluded(String header)
This method checks to see if the header name is within the exclusion list.

Parameters:
header - The header name to check if it's excluded.
Returns:
True if the header name is being filtered, false otherwise.

normalize

protected String normalize(String header)

addExclusion

public void addExclusion(String header)
This method will add the header name to the list of headers to be filtered.

Parameters:
header - The header name to be excluded.


Copyright © 2011. All Rights Reserved.