Spring Security Framework

org.springframework.security.wrapper
Class SavedRequestAwareWrapper

java.lang.Object
  extended by javax.servlet.ServletRequestWrapper
      extended by javax.servlet.http.HttpServletRequestWrapper
          extended by org.springframework.security.wrapper.SecurityContextHolderAwareRequestWrapper
              extended by org.springframework.security.wrapper.SavedRequestAwareWrapper
All Implemented Interfaces:
HttpServletRequest, ServletRequest

public class SavedRequestAwareWrapper
extends SecurityContextHolderAwareRequestWrapper

Provides request parameters, headers and cookies from either an original request or a saved request.

Note that not all request parameters in the original request are emulated by this wrapper. Nevertheless, the important data from the original request is emulated and this should prove adequate for most purposes (in particular standard HTTP GET and POST operations).

Added into a request by SecurityContextHolderAwareRequestFilter.

Version:
$Id$
Author:
Andrey Grebnev, Ben Alex
See Also:
SecurityContextHolderAwareRequestFilter

Field Summary
protected static Locale defaultLocale
          The default Locale if none are specified.
protected  SimpleDateFormat[] formats
          The set of SimpleDateFormat formats to use in getDateHeader().
protected static TimeZone GMT_ZONE
           
protected static org.apache.commons.logging.Log logger
           
protected  SavedRequest savedRequest
           
 
Fields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
 
Constructor Summary
SavedRequestAwareWrapper(HttpServletRequest request, PortResolver portResolver, String rolePrefix)
           
 
Method Summary
 Cookie[] getCookies()
           
 long getDateHeader(String name)
           
 String getHeader(String name)
           
 Enumeration getHeaderNames()
           
 Enumeration getHeaders(String name)
           
 int getIntHeader(String name)
           
 Locale getLocale()
           
 Enumeration getLocales()
           
 String getMethod()
           
 String getParameter(String name)
          If the parameter is available from the wrapped request then either There is no saved request (it a normal request) There is a saved request, but the request has been forwarded/included to a URL with parameters, either supplementing or overriding the saved request values. In both cases the value from the wrapped request should be used.
 Map getParameterMap()
           
 Enumeration getParameterNames()
           
 String[] getParameterValues(String name)
           
 
Methods inherited from class org.springframework.security.wrapper.SecurityContextHolderAwareRequestWrapper
getRemoteUser, getUserPrincipal, isUserInRole
 
Methods inherited from class javax.servlet.http.HttpServletRequestWrapper
getAuthType, getContextPath, getPathInfo, getPathTranslated, getQueryString, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid
 
Methods inherited from class javax.servlet.ServletRequestWrapper
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocalName, getLocalPort, 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, getLocalName, getLocalPort, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding
 

Field Detail

logger

protected static final org.apache.commons.logging.Log logger

GMT_ZONE

protected static final TimeZone GMT_ZONE

defaultLocale

protected static Locale defaultLocale
The default Locale if none are specified.


savedRequest

protected SavedRequest savedRequest

formats

protected SimpleDateFormat[] formats
The set of SimpleDateFormat formats to use in getDateHeader(). Notice that because SimpleDateFormat is not thread-safe, we can't declare formats[] as a static variable.

Constructor Detail

SavedRequestAwareWrapper

public SavedRequestAwareWrapper(HttpServletRequest request,
                                PortResolver portResolver,
                                String rolePrefix)
Method Detail

getCookies

public Cookie[] getCookies()
Specified by:
getCookies in interface HttpServletRequest
Overrides:
getCookies in class HttpServletRequestWrapper

getDateHeader

public long getDateHeader(String name)
Specified by:
getDateHeader in interface HttpServletRequest
Overrides:
getDateHeader in class HttpServletRequestWrapper

getHeader

public String getHeader(String name)
Specified by:
getHeader in interface HttpServletRequest
Overrides:
getHeader in class HttpServletRequestWrapper

getHeaderNames

public Enumeration getHeaderNames()
Specified by:
getHeaderNames in interface HttpServletRequest
Overrides:
getHeaderNames in class HttpServletRequestWrapper

getHeaders

public Enumeration getHeaders(String name)
Specified by:
getHeaders in interface HttpServletRequest
Overrides:
getHeaders in class HttpServletRequestWrapper

getIntHeader

public int getIntHeader(String name)
Specified by:
getIntHeader in interface HttpServletRequest
Overrides:
getIntHeader in class HttpServletRequestWrapper

getLocale

public Locale getLocale()
Specified by:
getLocale in interface ServletRequest
Overrides:
getLocale in class ServletRequestWrapper

getLocales

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

getMethod

public String getMethod()
Specified by:
getMethod in interface HttpServletRequest
Overrides:
getMethod in class HttpServletRequestWrapper

getParameter

public String getParameter(String name)
If the parameter is available from the wrapped request then either
  1. There is no saved request (it a normal request)
  2. There is a saved request, but the request has been forwarded/included to a URL with parameters, either supplementing or overriding the saved request values.
In both cases the value from the wrapped request should be used.

If the value from the wrapped request is null, an attempt will be made to retrieve the parameter from the SavedRequest, if available..

Specified by:
getParameter in interface ServletRequest
Overrides:
getParameter in class ServletRequestWrapper

getParameterMap

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

getParameterNames

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

getParameterValues

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

Spring Security Framework

Copyright © 2004-2010 SpringSource, Inc. All Rights Reserved.