|
JSecurity | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jsecurity.web.servlet.ServletContextSupport
org.jsecurity.web.servlet.OncePerRequestFilter
public abstract class OncePerRequestFilter
Filter base class that guarantees to be just executed once per request,
on any servlet container. It provides a doFilterInternal(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
method with HttpServletRequest and HttpServletResponse arguments.
The getAlreadyFilteredAttributeName() method determines how
to identify that a request is already filtered. The default implementation
is based on the configured name of the concrete filter instance.
NOTE This class was borrowed from the Spring framework, and as such, all copyright notices and author names have remained in tact.
| Field Summary | |
|---|---|
static String |
ALREADY_FILTERED_SUFFIX
Suffix that gets appended to the filter name for the "already filtered" request attribute. |
protected FilterConfig |
filterConfig
|
| Fields inherited from class org.jsecurity.web.servlet.ServletContextSupport |
|---|
HTTP_SESSION_MODE, JSECURITY_SESSION_MODE, SESSION_MODE_CONTEXT_PARAM_NAME |
| Constructor Summary | |
|---|---|
OncePerRequestFilter()
|
|
| Method Summary | |
|---|---|
void |
destroy()
Default no-op implementation that can be overridden by subclasses for custom cleanup behavior. |
void |
doFilter(ServletRequest request,
ServletResponse response,
FilterChain filterChain)
This doFilter implementation stores a request attribute for
"already filtered", proceeding without filtering again if the
attribute is already there. |
protected abstract void |
doFilterInternal(ServletRequest request,
ServletResponse response,
FilterChain filterChain)
Same contract as for doFilter, but guaranteed to be
just invoked once per request. |
protected String |
getAlreadyFilteredAttributeName()
Return name of the request attribute that identifies that a request has already been filtered. |
FilterConfig |
getFilterConfig()
Returns the servlet container specified FilterConfig instance provided at
startup. |
protected String |
getName()
Returns the name of this filter. |
void |
init(FilterConfig filterConfig)
Sets the filter's filterConfig and then immediately calls
onFilterConfigSet() to trigger any processing a subclass might wish to perform. |
protected void |
onFilterConfigSet()
Template method to be overridden by subclasses to perform initialization logic at startup. |
void |
setFilterConfig(FilterConfig filterConfig)
Sets the FilterConfig and the ServletContext as attributes of this class for use by
subclasses. |
void |
setName(String name)
Sets the filter's name. |
protected boolean |
shouldNotFilter(ServletRequest request)
Can be overridden in subclasses for custom filtering control, returning true to avoid filtering of the given request. |
| Methods inherited from class org.jsecurity.web.servlet.ServletContextSupport |
|---|
bind, getAttribute, getContextInitParam, getServletContext, removeAttribute, setAttribute, setServletContext |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String ALREADY_FILTERED_SUFFIX
getAlreadyFilteredAttributeName(),
Constant Field Valuesprotected FilterConfig filterConfig
| Constructor Detail |
|---|
public OncePerRequestFilter()
| Method Detail |
|---|
public FilterConfig getFilterConfig()
FilterConfig instance provided at
startup.
FilterConfig instance provided at startup.public void setFilterConfig(FilterConfig filterConfig)
ServletContext as attributes of this class for use by
subclasses. That is:
this.filterConfig = filterConfig;
setServletContext(filterConfig.getServletContext());
filterConfig - the FilterConfig instance provided by the Servlet container at startup.protected String getName()
setName(String) method, this value defaults to the
filter name as specified by the servlet container at startup:
this.name = getFilterConfig().getName();
null if none availableGenericServlet.getServletName(),
FilterConfig.getFilterName()public void setName(String name)
this.name = getFilterConfig().getName();
setName in interface Nameablename - the name of the filter.
public final void init(FilterConfig filterConfig)
throws ServletException
filterConfig and then immediately calls
onFilterConfigSet() to trigger any processing a subclass might wish to perform.
init in interface FilterfilterConfig - the servlet container supplied FilterConfig instance.
ServletException - if onFilterConfigSet() throws an Exception.
protected void onFilterConfigSet()
throws Exception
ServletContext and FilterConfig will be accessible
(and non-null) at the time this method is invoked via the
getServletContext() and getFilterConfig()
methods respectively.
Exception - if the subclass has an error upon initialization.
public final void doFilter(ServletRequest request,
ServletResponse response,
FilterChain filterChain)
throws ServletException,
IOException
doFilter implementation stores a request attribute for
"already filtered", proceeding without filtering again if the
attribute is already there.
doFilter in interface FilterServletException
IOExceptiongetAlreadyFilteredAttributeName(),
shouldNotFilter(javax.servlet.ServletRequest),
doFilterInternal(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)protected String getAlreadyFilteredAttributeName()
name and appends ".FILTERED".
If the filter is not fully initialized, it falls back to the implementation's class name.
getName(),
ALREADY_FILTERED_SUFFIX
protected boolean shouldNotFilter(ServletRequest request)
throws ServletException
true to avoid filtering of the given request.
The default implementation always returns false.
request - current HTTP request
ServletException - in case of errors
protected abstract void doFilterInternal(ServletRequest request,
ServletResponse response,
FilterChain filterChain)
throws ServletException,
IOException
doFilter, but guaranteed to be
just invoked once per request. Provides HttpServletRequest and
HttpServletResponse arguments instead of the default ServletRequest
and ServletResponse ones.
ServletException
IOExceptionpublic void destroy()
destroy in interface Filter
|
JSecurity | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||