CAS Client認證在Tomcat下非Spring系統方式

1. 函式庫加入  cas-client-core-3.1.3.jar 即可
 
2. Web.xml 檔範例:
 
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
 id="WebApp_ID" version="2.5">
 <servlet>
  <servlet-name>hello</servlet-name>
  <servlet-class>com.wps.cas.action.HelloServlet</servlet-class>
 </servlet>
 <servlet-mapping>
  <servlet-name>hello</servlet-name>
  <url-pattern>/protect/hello</url-pattern>
 </servlet-mapping>
 <!–CAS Authentication FILTER –>
 <filter>
  <filter-name>CAS Authentication Filter</filter-name>
  <filter-class>org.jasig.cas.client.authentication.AuthenticationFilter</filter-class>
  <init-param>
   <param-name>casServerLoginUrl</param-name>
   <param-value>https://localhost:8443/cas/login</param-value&gt;
  </init-param>
  <init-param>
   <param-name>serverName</param-name>
   <param-value>http://localhost:8081</param-value&gt;
  </init-param>
 </filter>
 <!– CAS Validation FILTER –>
 <filter>
  <filter-name>CAS Validation Filter</filter-name>
  <filter-class>org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter</filter-class>
  <init-param>
   <param-name>casServerUrlPrefix</param-name>
   <param-value>https://localhost:8443/cas</param-value&gt;
  </init-param>
  <init-param>
   <param-name>serverName</param-name>
   <param-value>http://localhost:8081</param-value&gt;
  </init-param>
  <init-param>
   <param-name>exceptionOnValidationFailure</param-name>
   <param-value>false</param-value>
  </init-param>
  <!– the URL to watch for PGTIOU/PGT responses from the CAS server –>
  <init-param>
   <param-name>allowedProxyChains</param-name>
   <param-value>http://localhost:8081/cas-client2</param-value&gt;
  </init-param>
  <!– validation callback validate url –>
  <init-param>
   <param-name>proxyCallbackUrl</param-name>
   <param-value>http://localhost:8081/cas-client2</param-value&gt;
  </init-param>
  <!– Proxy Receptor url –>
  <init-param>
   <param-name>proxyReceptorUrl</param-name>
   <param-value>/proxy/test.jsp</param-value>
  </init-param>
 </filter>
 <!– cas security username on request.getRemoteUser() –>
 <filter>
  <filter-name>CAS HttpServletRequest Wrapper Filter</filter-name>
  <filter-class>org.jasig.cas.client.util.HttpServletRequestWrapperFilter</filter-class>
 </filter>
 <!– CAS SINGLE SIGN OUT FILTER –>
 <filter>
  <filter-name>CAS Single Sign Out Filter</filter-name>
  <filter-class>org.jasig.cas.client.session.SingleSignOutFilter</filter-class>
 </filter>
 <filter-mapping>
  <filter-name>CAS Single Sign Out Filter</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>
 <filter-mapping>
  <filter-name>CAS Authentication Filter</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>
 <filter-mapping>
  <filter-name>CAS Validation Filter</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>
 <filter-mapping>
  <filter-name>CAS HttpServletRequest Wrapper Filter</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>
 <!– SingleSignOutHttpSessionListener LISTENER –>
 <listener>
  <listener-class>org.jasig.cas.client.session.SingleSignOutHttpSessionListener</listener-class>
 </listener>
 <welcome-file-list>
  <welcome-file>index.html</welcome-file>
  <welcome-file>index.htm</welcome-file>
  <welcome-file>index.jsp</welcome-file>
 </welcome-file-list>
</web-app>
 
廣告

About fenjj

Perfect !!??...
本篇發表於 Uncategorized。將永久鏈結加入書籤。

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

您的留言將使用 WordPress.com 帳號。 登出 / 變更 )

Twitter picture

您的留言將使用 Twitter 帳號。 登出 / 變更 )

Facebook照片

您的留言將使用 Facebook 帳號。 登出 / 變更 )

Google+ photo

您的留言將使用 Google+ 帳號。 登出 / 變更 )

連結到 %s