參考網址:web
https://blog.csdn.net/zhurhyme/article/details/29349543服務器
https://blog.csdn.net/shzy1988/article/details/50662462session
cas 分爲服務端,與客戶端。那麼客戶端如何與服務端進行交互呢,或者說服務端發送的response報文客戶端如何接收呢?這就要用到配置。cas client經過filter攔截與cas服務器進行交互。它的主要配置主要有如下幾個filter:app
1.AuthenticationFilterurl
做用,判斷用戶是否登陸,若是登陸則進入第二步,不然重定向到cas服務器spa
2.TicketValidationFilter .net
對於client接收到的ticket進行驗證code
3.HttpServletRequestWrapperFilterserver
4.AssertionThreadLocalFilter
blog
<!-- CAS 單點登陸(SSO) 過濾器配置 (start) --> <!-- 該過濾器用於實現單點登出功能。--> <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> <!-- CAS: 用於單點退出 --> <listener> <listener-class>org.jasig.cas.client.session.SingleSignOutHttpSessionListener</listener-class> </listener> <!-- 該過濾器負責用戶的認證工做,必須啓用它 --> <filter> <filter-name>CASFilter</filter-name> <filter-class>org.jasig.cas.client.authentication.AuthenticationFilter</filter-class> <init-param> <param-name>casServerLoginUrl</param-name> <!-- 下面的URL是Cas服務器的登陸地址 --> <param-value>http://CAS服務端所在服務器IP:8080/cas/login</param-value> </init-param> <init-param> <param-name>serverName</param-name> <!-- 下面的URL是具體某一個應用的訪問地址 --> <param-value>http://具體web應用程序所在服務器IP:8080</param-value> </init-param> </filter> <filter-mapping> <filter-name>CASFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- 該過濾器負責對Ticket的校驗工做,必須啓用它 --> <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> <!-- 下面的URL是Cas服務器的認證地址 --> <param-value>http://CAS服務端所在服務器IP:8080/cas</param-value> </init-param> <init-param> <param-name>serverName</param-name> <!-- 下面的URL是具體某一個應用的訪問地址 --> <param-value>http://具體web應用程序所在服務器IP:8080</param-value> </init-param> <init-param> <param-name>renew</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>gateway</param-name> <param-value>false</param-value> </init-param> </filter> <filter-mapping> <filter-name>CAS Validation Filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- 該過濾器負責實現HttpServletRequest請求的包裹, 好比容許開發者經過HttpServletRequest的getRemoteUser()方法得到SSO登陸用戶的登陸名,可選配置。 --> <filter> <filter-name>CAS HttpServletRequest Wrapper Filter</filter-name> <filter-class>org.jasig.cas.client.util.HttpServletRequestWrapperFilter</filter-class> </filter> <filter-mapping> <filter-name>CAS HttpServletRequest Wrapper Filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- 該過濾器使得開發者能夠經過org.jasig.cas.client.util.AssertionHolder來獲取用戶的登陸名。 好比AssertionHolder.getAssertion().getPrincipal().getName()。 --> <filter> <filter-name>CAS Assertion Thread Local Filter</filter-name> <filter-class>org.jasig.cas.client.util.AssertionThreadLocalFilter</filter-class> </filter> <filter-mapping> <filter-name>CAS Assertion Thread Local Filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- 自動根據單點登陸的結果設置本系統的用戶信息(具體某一個應用實現) --> <filter> <filter-name>CasForInvokeContextFilter</filter-name> <filter-class>com.cm.demo.filter.CasForInvokeContextFilter</filter-class> <init-param> <param-name>appId</param-name> <param-value>a5ea611bbff7474a81753697a1714fb0</param-value> </init-param> </filter> <filter-mapping> <filter-name>CasForInvokeContextFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- CAS 單點登陸(SSO) 過濾器配置 (end) -->