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的更多相关文章

  1. CAS Client集群环境的Session问题及解决方案

    [原创申明:文章为原创,欢迎非盈利性转载,但转载必须注明来源] 之前写过一篇文章,介绍单点登录的基本原理.这篇文章重点介绍开源单点登录系统CAS的登录和注销的实现方法.并结合实际工作中碰到的问题,探讨 ...

  2. 单点登录系统CAS筹建及取得更多用户信息的实现

    国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...

  3. cas改造随笔

    原http://www.cnblogs.com/hellowood/archive/2010/08/05/1793364.html 键字: sso域名:cas.server.com 登陆地址(spri ...

  4. Configuring the JA-SIG CAS Client --官方

    1. for Java using Spring Configuration of the CAS Client for Java via Spring IoC will depend heavily ...

  5. CAS Client集群环境的Session问题及解决方案介绍,下篇介绍作者本人项目中的解决方案代码

    CAS Client集群环境的Session问题及解决方案  程序猿讲故事  2016-05-20  原文 [原创申明:文章为原创,欢迎非盈利性转载,但转载必须注明来源] 之前写过一篇文章,介绍单点登 ...

  6. 单点登录(一)-----理论-----单点登录SSO的介绍和CAS+选型

    什么是单点登录(SSO) 单点登录主要用于多系统集成,即在多个系统中,用户只需要到一个中央服务器登录一次即可访问这些系统中的任何一个,无须多次登录. 单点登录(Single Sign On),简称为 ...

  7. CAS单点登录(一):单点登录与CAS理论介绍

    一.什么是单点登录(SSO) 单点登录主要用于多系统集成,即在多个系统中,用户只需要到一个中央服务器登录一次即可访问这些系统中的任何一个,无须多次登录. 单点登录(Single Sign On),简称 ...

  8. cas sso单点登录 登录过程和登出过程原理说明

    CAS大体原理我就不说了,网上一大把,不过具体交互流程没说清楚,所以有这篇文章,如果有错误,请多多指教 登录过程 用户第一次访问一个CAS 服务的客户web 应用时(访问URL :http://192 ...

  9. CAS单点登录系列之极速入门于实战教程(4.2.7)

    @ 目录 一. SSO简介 1.1 单点登录定义 1.2 单点登录角色 1.3 单点登录分类 二. CAS简介 2.1 CAS简单定义 2.2 CAS体系结构 2.3 CAS原理 三.CAS服务端搭建 ...

随机推荐

  1. 20145329 《网络对抗技术》Web安全基础实践

    实践的目标 理解常用网络攻击技术的基本原理.Webgoat实践下相关实验:SQL注入攻击.XSS攻击.CSRF攻击. 实验后回答问题 (1)SQL注入攻击原理,如何防御 攻击原理 SQL注入即是指we ...

  2. Python3基础 set 删除list中的重复项

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  3. ubuntu16.04下编译ceres-solver

    一.编译环境 ubuntu16.04 二.准备工作之安装必要的库 2.1安装cmake sudo apt-get install cmake 2.2 安装google-glog + gflags su ...

  4. java中常量接口及实现常量接口的利与弊

    在所做的项目中,将程序中很多要用的常量放置在ServiceConstants的接口中,称其为常量接口,只要实现该接口,就可以 在项目中直接使用常量接口中的常量,通过上网搜索之后,将很好的两篇博客链接储 ...

  5. vue router菜单 存在点哪个但还是会显示active

    <router-link to="/" exact>Home</router-link> <router-link to="/add&quo ...

  6. go 并发 demo

    两个进程执行两个goroutine // This sample program demonstrates how to create goroutines and // how the schedu ...

  7. Qt_OpenGL_教程

    1. 中文版: Qt OpenGL教程 http://blog.csdn.net/myths_0/article/details/24431597 http://qiliang.net/old/neh ...

  8. jsjl_for_ubuntu12.04

    1. VC++代码: #include <stdio.h> #include <windows.h> #include <wchar.h> void MoveMou ...

  9. js 中面向对象的多态

    什么是多态: 实际上是不同对象作用与同一操作产生不同的效果.多态的思想实际上是把“想做什么”和“谁去做“分开,多态的好处是什么呢?为什么要多态?我们来看看 Martin Fowler 在<重构: ...

  10. 移动端视频h5表现问题汇总

    1. 同屏播放视频 <video src="" x-webkit-airplay="true" webkit-playsinline="true ...