博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
二、配置cas服务器和客户端
阅读量:5462 次
发布时间:2019-06-16

本文共 5330 字,大约阅读时间需要 17 分钟。

1.编译cas

下载 cas-4.1.9.tar.gz
tar -xzf cas-4.1.9.tar.gz
cd cas-4.1.9
mvn clean install -DskipTests

2.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
发现又要登录

转载于:https://www.cnblogs.com/pizhiyun/p/9359033.html

你可能感兴趣的文章
Python:tesserocr 在 windows 下的安装及简单使用
查看>>
周周总结——时时更新(第4学期,第4周)
查看>>
在ubuntu12.04,64位中安装lnmp一键包mysql的问题
查看>>
一级关联数组转化成多层子级数组
查看>>
百度Ueditor编辑器的Html模式自动替换样式的解决方法
查看>>
八:Razor(MVC框架视图引擎)
查看>>
java代码编辑器 pdf文件预览 主流SSM 代码生成器 shrio redis websocket即时通讯
查看>>
final
查看>>
Win8下更改Chrome缓存目录
查看>>
django框架小技巧
查看>>
(八)8-3多线程共享变量
查看>>
Parameter配置文件获取
查看>>
[Operating System] {ud923} P3L1: Scheduling
查看>>
java后端发送http请求使用RestTemplate
查看>>
避免商品超卖的4种方案
查看>>
AtCoder - 1999 Candy Piles
查看>>
Checklist: 2019 05.01 ~ 06.30
查看>>
【最短路】Vijos P1022Victoria的舞会2
查看>>
(原创)大数据时代:基于微软案例数据库数据挖掘知识点总结(Microsoft 线性回归分析算法)...
查看>>
调整Tomcat的并发线程到5000+
查看>>