|
Before you try to use the CASValidateFilter, consider whether the basic CASFilter would better suit your needs. CASFilter provides a standard distribution of the most frequently needed CASification behaviors for Java webapps. CASValidateFilter came into existence to provide a standard distribution of a more flexible CAS authentication filter. CASValidate filter does less. Configuring CASValidateFilterJust a few lines of XML need to be added to your web application's deployment descriptor (web.xml): <web-app> ... <filter> <filter-name>CAS Validate Filter</filter-name> <filter-class>edu.yale.its.tp.cas.client.filter.CASValidateFilter</filter-class> <init-param> <param-name>edu.yale.its.tp.cas.client.filter.validateUrl</param-name> <param-value>https://secure.its.yale.edu/cas/serviceValidate</param-value> </init-param> <init-param> <param-name>edu.yale.its.tp.cas.client.filter.serverName</param-name> <param-value>hkg2.cis.yale.edu:8080</param-value> </init-param> <init-param> <param-name>edu.yale.its.tp.cas.client.filter.proxyCallbackUrl</param-name> <param-value>https://hkg2.cis.yale.edu/uPortal/CasProxyServlet</param-value> </init-param> </filter> <filter-mapping> <filter-name>CAS Validate Filter</filter-name> <url-pattern>/Login</url-pattern> </filter-mapping> ... </web-app> In this case, the filter will perform ticket validation on the URL /webapp/Login if a service ticket is present. Unlike CASFilter, CASValidateFilter will just let the request right through without performing any CAS authentcation if a service ticket is not presented on the request. The serverName initialization parameter does not require a port number if you are using the standard HTTP port (80). You can specify other initialization parameters to configure the behavior of the filter: Required CASValidateFilter init-params
Optional CASFilter init-params
Consuming the results of CASValidateFilterOnce the user has logged into your application through the filter, the application may access the user's NetID through the session attribute, edu.yale.its.tp.cas.client.filter.user, or if you import edu.yale.its.tp.cas.client.filter.CASFilter in your JSP or servlet, simply CASFilter.CAS_FILTER_USER. // either of these will work: session.getAttribute(CASFilter.CAS_FILTER_USER); session.getAttribute("edu.yale.its.tp.cas.client.filter.user"); Additionally, the client application may access a CASReceipt JavaBean-style object which exposes the username as well as additional information about the successful authentication, in the session attribute edu.yale.its.tp.cas.client.filter.receipt . // either of these will work: session.getAttribute(CASFilter.CAS_FILTER_RECEIPT); session.getAttribute("edu.yale.its.tp.cas.client.filter.receipt"); Session attributes set by CASValidateFilter
|
