public abstract class

SaveContextOnUpdateOrErrorResponseWrapper

extends HttpServletResponseWrapper
java.lang.Object
   ↳ javax.servlet.ServletResponseWrapper
     ↳ javax.servlet.http.HttpServletResponseWrapper
       ↳ org.springframework.security.web.context.SaveContextOnUpdateOrErrorResponseWrapper

Class Overview

Base class for response wrappers which encapsulate the logic for storing a security context and which store the with the SecurityContext when a sendError() or sendRedirect happens. See issue SEC-398.

Sub-classes should implement the saveContext(SecurityContext) method.

Support is also provided for disabling URL rewriting

Summary

[Expand]
Inherited Constants
From interface javax.servlet.http.HttpServletResponse
Public Constructors
SaveContextOnUpdateOrErrorResponseWrapper(HttpServletResponse response, boolean disableUrlRewriting)
Public Methods
final String encodeRedirectURL(String url)
final String encodeRedirectUrl(String url)
final String encodeURL(String url)
final String encodeUrl(String url)
final boolean isContextSaved()
Tells if the response wrapper has called saveContext() because of an error or redirect.
final void sendError(int sc)
Makes sure the session is updated before calling the superclass sendError()
final void sendError(int sc, String msg)
Makes sure the session is updated before calling the superclass sendError()
final void sendRedirect(String location)
Makes sure the context is stored before calling the superclass sendRedirect()
Protected Methods
abstract void saveContext(SecurityContext context)
Implements the logic for storing the security context.
[Expand]
Inherited Methods
From class javax.servlet.http.HttpServletResponseWrapper
From class javax.servlet.ServletResponseWrapper
From class java.lang.Object
From interface javax.servlet.ServletResponse
From interface javax.servlet.http.HttpServletResponse

Public Constructors

public SaveContextOnUpdateOrErrorResponseWrapper (HttpServletResponse response, boolean disableUrlRewriting)

Parameters
response the response to be wrapped
disableUrlRewriting turns the URL encoding methods into null operations, preventing the use of URL rewriting to add the session identifier as a URL parameter.

Public Methods

public final String encodeRedirectURL (String url)

public final String encodeRedirectUrl (String url)

public final String encodeURL (String url)

public final String encodeUrl (String url)

public final boolean isContextSaved ()

Tells if the response wrapper has called saveContext() because of an error or redirect.

public final void sendError (int sc)

Makes sure the session is updated before calling the superclass sendError()

Throws
IOException

public final void sendError (int sc, String msg)

Makes sure the session is updated before calling the superclass sendError()

Throws
IOException

public final void sendRedirect (String location)

Makes sure the context is stored before calling the superclass sendRedirect()

Throws
IOException

Protected Methods

protected abstract void saveContext (SecurityContext context)

Implements the logic for storing the security context.

Parameters
context the SecurityContext instance to store