cas AuthenticationFilter
AuthenticationFilter
*** 这个类的作用:判断是否已经登录,如果没有登录则根据配置的信息来决定将跳转到什么地方 ***
casServerLoginUrl:定义cas 服务器的登录URL地址 如:http://localhost:8443/cas/login
service/serviceName
service:发送到cas服务器的servic URL地址,例如 https://locahost:8443/yourwebapp/index.html
serviceName:cas客户端的服务器名称,service URL使用这个名称动态组装,
例如:http://localhost:8080(必须包括协议,如果端口是标准端口则可以不写)
renew:指定renew是否为true,有效值为true和false,如果为true,则每次请求都产生新的session。默认是false
gateway: 指定是否使用防火墙,有效值为true或false,默认是false
artifactParameterName: 指定request保存票据的参数名称,默认是ticket
serviceParamterName: 指定request保存service的参数名词,默认是service
public final void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain filterChain) throws IOException, ServletException {
// 转换参数
final HttpServletRequest request = (HttpServletRequest) servletRequest;
final HttpServletResponse response = (HttpServletResponse) servletResponse;
//从session中取得Assertion
final HttpSession session = request.getSession(false);
final Assertion assertion = session != null ? (Assertion) session.getAttribute(CONST_CAS_ASSERTION) : null;
//如果存在,则说明已经登录,本过滤器处理完成,处理下个过滤器
if (assertion != null) {
filterChain.doFilter(request, response);
return;
}
//如果session中没有Assertion对象,组装serviceUrl并试着从参数中取得ticket属性。
final String serviceUrl = constructServiceUrl(request, response);
final String ticket = CommonUtils.safeGetParameter(request,getArtifactParameterName());
final boolean wasGatewayed = this.gatewayStorage.hasGatewayedAlready(request, serviceUrl);
//如果ticket不为空,或者wasGatewayed为true,则本过滤器处理完成,处理下个过滤器
if (CommonUtils.isNotBlank(ticket) || wasGatewayed) {
filterChain.doFilter(request, response);
return;
}
// 定义需要条状的url地址
final String modifiedServiceUrl;
log.debug("no ticket and no assertion found");
//ticket 为空,并且wasGatewayed也为false,则根据初始化参数gateway的值来组装跳转url。
if (this.gateway) {
log.debug("setting gateway attribute in session");
modifiedServiceUrl = this.gatewayStorage.storeGatewayInformation(request, serviceUrl);
} else {
modifiedServiceUrl = serviceUrl;
}
if (log.isDebugEnabled()) {
log.debug("Constructed service url: " + modifiedServiceUrl);
}
//组装跳转url
final String urlToRedirectTo = CommonUtils.constructRedirectUrl(this.casServerLoginUrl, getServiceParameterName(),
modifiedServiceUrl, this.renew, this.gateway, this.aspId);
if (log.isDebugEnabled()) {
log.debug("redirecting to \"" + urlToRedirectTo + "\"");
}
//跳转到urlToRedirectTo指定的url,如果没有配置gateway,则跳转到casServerLoginUrl参数指定的url。
response.sendRedirect(urlToRedirectTo);
}
cas AuthenticationFilter的更多相关文章
- CAS Client集群环境的Session问题及解决方案
[原创申明:文章为原创,欢迎非盈利性转载,但转载必须注明来源] 之前写过一篇文章,介绍单点登录的基本原理.这篇文章重点介绍开源单点登录系统CAS的登录和注销的实现方法.并结合实际工作中碰到的问题,探讨 ...
- 单点登录系统CAS筹建及取得更多用户信息的实现
国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...
- cas改造随笔
原http://www.cnblogs.com/hellowood/archive/2010/08/05/1793364.html 键字: sso域名:cas.server.com 登陆地址(spri ...
- Configuring the JA-SIG CAS Client --官方
1. for Java using Spring Configuration of the CAS Client for Java via Spring IoC will depend heavily ...
- CAS Client集群环境的Session问题及解决方案介绍,下篇介绍作者本人项目中的解决方案代码
CAS Client集群环境的Session问题及解决方案 程序猿讲故事 2016-05-20 原文 [原创申明:文章为原创,欢迎非盈利性转载,但转载必须注明来源] 之前写过一篇文章,介绍单点登 ...
- 单点登录(一)-----理论-----单点登录SSO的介绍和CAS+选型
什么是单点登录(SSO) 单点登录主要用于多系统集成,即在多个系统中,用户只需要到一个中央服务器登录一次即可访问这些系统中的任何一个,无须多次登录. 单点登录(Single Sign On),简称为 ...
- CAS单点登录(一):单点登录与CAS理论介绍
一.什么是单点登录(SSO) 单点登录主要用于多系统集成,即在多个系统中,用户只需要到一个中央服务器登录一次即可访问这些系统中的任何一个,无须多次登录. 单点登录(Single Sign On),简称 ...
- cas sso单点登录 登录过程和登出过程原理说明
CAS大体原理我就不说了,网上一大把,不过具体交互流程没说清楚,所以有这篇文章,如果有错误,请多多指教 登录过程 用户第一次访问一个CAS 服务的客户web 应用时(访问URL :http://192 ...
- CAS单点登录系列之极速入门于实战教程(4.2.7)
@ 目录 一. SSO简介 1.1 单点登录定义 1.2 单点登录角色 1.3 单点登录分类 二. CAS简介 2.1 CAS简单定义 2.2 CAS体系结构 2.3 CAS原理 三.CAS服务端搭建 ...
随机推荐
- 20145335郝昊《网络攻防》Exp9 Web安全基础实践
20145335郝昊<网络攻防>Exp9 Web安全基础实践 实验内容 理解常用网络攻击技术的基本原理. 完成WebGoat实践下相关实验 实验步骤 XSS注入攻击 Phishing wi ...
- Python3.5 MySQL 数据库连接
Python3.5 MySQL 数据库连接 在本文中介绍 Python3 使用PyMySQL连接数据库,并实现简单的增删改查 为什么使用PyMySQL? PyMySQL是在Pyhton3.x版本中用 ...
- Python3基础 response.getcode 得到http的状态 200表示正常
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Inversion of Control Containers and the Dependency Injection pattern
https://martinfowler.com/articles/injection.html One of the entertaining things about the enterprise ...
- ThreadPoolExecutor执行过程分析
ThreadPoolExecutor public ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTi ...
- HDU 2874 Connections between cities(LCA离线算法实现)
http://acm.hdu.edu.cn/showproblem.php?pid=2874 题意: 求两个城市之间的距离. 思路: LCA题,注意原图可能不连通. 如果不了解离线算法的话,可以看我之 ...
- mybatis 关于传long 类型问题
@Datapublic class PrealertPackageStatusDTO { private Integer nowStatus; /** * packageStatusEnum */ p ...
- ros python 订阅robot_pose
#!/usr/bin/env python import rospy import tf import time from tf.transformations import * from std_m ...
- robot_pose的类型
http://docs.ros.org/api/geometry_msgs/html/msg/Pose.html
- list_01
双向链表 不支持随机存取([?] / at(?)) A.头尾 添加/移除 A.1.list::push_back(elemValue); A.2.list::pop_back(); A.3.list: ...