1.编译cas
下载 cas-4.1.9.tar.gztar -xzf cas-4.1.9.tar.gzcd cas-4.1.9mvn clean install -DskipTests2.cd cas-server-webapp/target/cas.war ../server-tomcat-8.0.12/webapps/
启动tomcat
通过浏览器访问https://server.hacker.org:8443/cas
用户名和密码在cas\WEB-INF\deployerConfigContext.xml文件中定义
<entry key="casuser" value="Mellon"/>3.客户端tomcat 配置
两个tomcat-8.0.12\webapps\examples\WEB-INF\lib下添加cas-client-core-3.2.0.jar、commons-logging-1.1.3.jar、slf4j-api-1.7.12.jar三个jar包修改login-tomcat-8.0.12\webapps\examples\WEB-INF\web.xml
添加<filter>
<filter-name>CAS Single Sign Out Filter</filter-name> <filter-class>org.jasig.cas.client.session.SingleSignOutFilter</filter-class> <init-param> <param-name>casServerUrlPrefix</param-name> <param-value>https://server.hacker.org:8443/cas</param-value> </init-param> </filter><listener>
<listener-class>org.jasig.cas.client.session.SingleSignOutHttpSessionListener</listener-class> </listener><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://server.hacker.org:8443/cas/login</param-value> </init-param> <init-param> <param-name>serverName</param-name> <param-value>https://login.hacker.org:18443</param-value> </init-param> </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://server.hacker.org:8443/cas</param-value> </init-param> <init-param> <param-name>serverName</param-name> <param-value>https://login.hacker.org:18443</param-value> </init-param> <init-param> <param-name>redirectAfterValidation</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>useSession</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>authn_method</param-name> <param-value>mfa-duo</param-value> </init-param> </filter><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 Single Sign Out 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 Authentication 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> blog-tomcat-8.0.12的修改如下: <filter> <filter-name>CAS Single Sign Out Filter</filter-name> <filter-class>org.jasig.cas.client.session.SingleSignOutFilter</filter-class> <init-param> <param-name>casServerUrlPrefix</param-name> <param-value>https://server.hacker.org:8443/cas</param-value> </init-param> </filter><listener>
<listener-class>org.jasig.cas.client.session.SingleSignOutHttpSessionListener</listener-class> </listener><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://server.hacker.org:8443/cas/login</param-value> </init-param> <init-param> <param-name>serverName</param-name> <param-value>https://blog.hacker.org:28443</param-value> </init-param> </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://server.hacker.org:8443/cas</param-value> </init-param> <init-param> <param-name>serverName</param-name> <param-value>https://blog.hacker.org:28443</param-value> </init-param> <init-param> <param-name>redirectAfterValidation</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>useSession</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>authn_method</param-name> <param-value>mfa-duo</param-value> </init-param> </filter><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 Single Sign Out 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 Authentication 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>启动login和blog tomcat
4.访问,见证奇迹的时候到了
访问https://login.hacker.org:18443/examples/servlets/servlet/HelloWorldExample输入用户名和密码再访问https://blog.hacker.org:28443/examples/servlets/servlet/HelloWorldExample发现不用输入用户名和密码就可以登录退出登录https://server.hacker.org:8443/cas/logout再次访问https://login.hacker.org:18443/examples/servlets/servlet/HelloWorldExample发现又要登录