Package org.wso2.carbon.ui.filters.cache
Class AbstractCachePreventionFilter
- java.lang.Object
-
- org.wso2.carbon.ui.filters.cache.AbstractCachePreventionFilter
-
- All Implemented Interfaces:
javax.servlet.Filter
- Direct Known Subclasses:
ContentTypeBasedCachePreventionFilter,URLBasedCachePreventionFilter
public abstract class AbstractCachePreventionFilter extends Object implements javax.servlet.Filter
This filter implements browser/proxy cache prevention. It would prevent sensitive information being cached on web browsers and intermediate network devices that adhere to protocols HTTP 1.0 through HTTP 1.1. In order to accommodate future modifications to protocol specifications and introduction of custom cache prevention headers and values, the filter can also utilize headers and values that are defined in the web.xml file.- Since:
- 4.2.0
-
-
Constructor Summary
Constructors Constructor Description AbstractCachePreventionFilter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidapplyCachePreventionHeaders(javax.servlet.http.HttpServletResponse response)Setting cache prevention headers to responses.protected booleancanApplyCachePreventionHeaders(String stringToBeMatched)Checks for a match with the filtering pattern and the Content Type/ URL.voiddestroy()abstract voiddoFilter(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse, javax.servlet.FilterChain filterChain)voidinit(javax.servlet.FilterConfig filterConfig)protected voidinitHeaders(javax.servlet.FilterConfig filterConfig)This method will check for any headers defined in the web.xml.protected voidinitPatternsAndAction(javax.servlet.FilterConfig filterConfig)Reading the filtering pattern and the action to be performed against the pattern from the web.xml.
-
-
-
Method Detail
-
init
public void init(javax.servlet.FilterConfig filterConfig) throws javax.servlet.ServletException- Specified by:
initin interfacejavax.servlet.Filter- Throws:
javax.servlet.ServletException
-
initHeaders
protected void initHeaders(javax.servlet.FilterConfig filterConfig) throws javax.servlet.ServletExceptionThis method will check for any headers defined in the web.xml. If any headers are found in the web.xml, those headers with the corresponding values will be set to prevent caching. If any headers aren't found in the web.xml, the default headers with values will be set for cache prevention.- Parameters:
filterConfig- Configurations specific to this filter in the web.xml- Throws:
javax.servlet.ServletException
-
initPatternsAndAction
protected void initPatternsAndAction(javax.servlet.FilterConfig filterConfig)
Reading the filtering pattern and the action to be performed against the pattern from the web.xml. The pattern is a regex that could define content types or URLs. Multiple patterns can be defined in each new line.- Parameters:
filterConfig- Configurations specific to this filter in the web.xml
-
canApplyCachePreventionHeaders
protected boolean canApplyCachePreventionHeaders(String stringToBeMatched)
Checks for a match with the filtering pattern and the Content Type/ URL.- Parameters:
stringToBeMatched- Requested URL or the Content Type in the response- Returns:
- true for either to set headers for a match, or skip setting headers to a match
-
applyCachePreventionHeaders
protected void applyCachePreventionHeaders(javax.servlet.http.HttpServletResponse response)
Setting cache prevention headers to responses.- Parameters:
response- HTTP Servlet Response
-
doFilter
public abstract void doFilter(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse, javax.servlet.FilterChain filterChain) throws IOException, javax.servlet.ServletException- Specified by:
doFilterin interfacejavax.servlet.Filter- Throws:
IOExceptionjavax.servlet.ServletException
-
destroy
public void destroy()
- Specified by:
destroyin interfacejavax.servlet.Filter
-
-