public class UriFilter extends Object implements javax.servlet.Filter
There are 3 possible filter configurations and these filtering criteria are applied in the following order,
| Criterion | context-param | Required | Description |
|---|---|---|---|
| URI exclusion | uriExclusionFilterPattern | No | URIs that should not be subject to CAS authentication |
| URI inclusion | uriFilterPattern | No | URIs that are to be subject to CAS authentication |
| Only if logged in | authenticateOnlyIfLoggedInFilterPattern | No | URIs that should be subject to CAS authentication only if logged in (indicated by the presence of the ALA-Auth cookie) |
The list of URI patterns is specified as a comma delimited list of regular expressions in a <context-param>.
So if a request's path matches one of the URI patterns then the filter specified by the filterClass <init-param> is invoked.
The contextPath from the ServletContext is prefixed to each URI pattern defined for each filter.
An example of usage is shown in the following web.xml fragment,
...
<context-param>
<param-name>uriFilterPattern</param-name>
<param-value>/occurrences/\d+</param-value>
</context-param>
<!-- CAS Authentication Service filters -->
<filter>
<filter-name>CAS Authentication Filter</filter-name>
<filter-class>au.org.ala.cas.client.UriFilter</filter-class>
<init-param>
<param-name>filterClass</param-name>
<param-value>org.jasig.cas.client.authentication.AuthenticationFilter</param-value>
</init-param>
<init-param>
<param-name>casServerLoginUrl</param-name>
<param-value>https://auth.ala.org.au/cas/login</param-value>
</init-param>
<init-param>
<param-name>gateway</param-name>
<param-value>true</param-value>
</init-param>
</filter>
...
| Modifier and Type | Field and Description |
|---|---|
static String |
AUTHENTICATE_ONLY_IF_LOGGED_IN_FILTER_PATTERN |
static String |
URI_EXCLUSION_FILTER_PATTERN |
static String |
URI_FILTER_PATTERN |
| Constructor and Description |
|---|
UriFilter() |
public static final String URI_FILTER_PATTERN
public static final String URI_EXCLUSION_FILTER_PATTERN
public static final String AUTHENTICATE_ONLY_IF_LOGGED_IN_FILTER_PATTERN
public void init(javax.servlet.FilterConfig filterConfig)
throws javax.servlet.ServletException
init in interface javax.servlet.Filterjavax.servlet.ServletExceptionpublic void doFilter(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
javax.servlet.FilterChain chain)
throws IOException,
javax.servlet.ServletException
doFilter in interface javax.servlet.FilterIOExceptionjavax.servlet.ServletExceptionpublic void destroy()
destroy in interface javax.servlet.FilterCopyright © 2017. All rights reserved.