AuthenticationFilter

*** 这个类的作用:判断是否已经登录,如果没有登录则根据配置的信息来决定将跳转到什么地方 ***

  1. casServerLoginUrl:定义cas 服务器的登录URL地址 如:http://localhost:8443/cas/login
  2. service/serviceName
  3. service:发送到cas服务器的servic URL地址,例如 https://locahost:8443/yourwebapp/index.html
  4. serviceNamecas客户端的服务器名称,service URL使用这个名称动态组装,
  5. 例如:http://localhost:8080(必须包括协议,如果端口是标准端口则可以不写)
  1. renew:指定renew是否为true,有效值为truefalse,如果为true,则每次请求都产生新的session。默认是false
  2. gateway: 指定是否使用防火墙,有效值为truefalse,默认是false
  3. artifactParameterName 指定request保存票据的参数名称,默认是ticket
  4. serviceParamterName: 指定request保存service的参数名词,默认是service
  1. public final void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain filterChain) throws IOException, ServletException {
  2. // 转换参数
  3. final HttpServletRequest request = (HttpServletRequest) servletRequest;
  4. final HttpServletResponse response = (HttpServletResponse) servletResponse;
  5. //从session中取得Assertion
  6. final HttpSession session = request.getSession(false);
  7. final Assertion assertion = session != null ? (Assertion) session.getAttribute(CONST_CAS_ASSERTION) : null;
  8. //如果存在,则说明已经登录,本过滤器处理完成,处理下个过滤器
  9. if (assertion != null) {
  10. filterChain.doFilter(request, response);
  11. return;
  12. }
  13. //如果session中没有Assertion对象,组装serviceUrl并试着从参数中取得ticket属性。
  14. final String serviceUrl = constructServiceUrl(request, response);
  15. final String ticket = CommonUtils.safeGetParameter(request,getArtifactParameterName());
  16. final boolean wasGatewayed = this.gatewayStorage.hasGatewayedAlready(request, serviceUrl);
  17. //如果ticket不为空,或者wasGatewayed为true,则本过滤器处理完成,处理下个过滤器
  18. if (CommonUtils.isNotBlank(ticket) || wasGatewayed) {
  19. filterChain.doFilter(request, response);
  20. return;
  21. }
  22. // 定义需要条状的url地址
  23. final String modifiedServiceUrl;
  24. log.debug("no ticket and no assertion found");
  25. //ticket 为空,并且wasGatewayed也为false,则根据初始化参数gateway的值来组装跳转url。
  26. if (this.gateway) {
  27. log.debug("setting gateway attribute in session");
  28. modifiedServiceUrl = this.gatewayStorage.storeGatewayInformation(request, serviceUrl);
  29. } else {
  30. modifiedServiceUrl = serviceUrl;
  31. }
  32. if (log.isDebugEnabled()) {
  33. log.debug("Constructed service url: " + modifiedServiceUrl);
  34. }
  35. //组装跳转url
  36. final String urlToRedirectTo = CommonUtils.constructRedirectUrl(this.casServerLoginUrl, getServiceParameterName(),
  37. modifiedServiceUrl, this.renew, this.gateway, this.aspId);
  38. if (log.isDebugEnabled()) {
  39. log.debug("redirecting to \"" + urlToRedirectTo + "\"");
  40. }
  41. //跳转到urlToRedirectTo指定的url,如果没有配置gateway,则跳转到casServerLoginUrl参数指定的url。
  42. response.sendRedirect(urlToRedirectTo);
  43. }

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. 20145335郝昊《网络攻防》Exp9 Web安全基础实践

    20145335郝昊<网络攻防>Exp9 Web安全基础实践 实验内容 理解常用网络攻击技术的基本原理. 完成WebGoat实践下相关实验 实验步骤 XSS注入攻击 Phishing wi ...

  2. Python3.5 MySQL 数据库连接

    Python3.5  MySQL 数据库连接 在本文中介绍 Python3 使用PyMySQL连接数据库,并实现简单的增删改查 为什么使用PyMySQL? PyMySQL是在Pyhton3.x版本中用 ...

  3. Python3基础 response.getcode 得到http的状态 200表示正常

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

  4. Inversion of Control Containers and the Dependency Injection pattern

    https://martinfowler.com/articles/injection.html One of the entertaining things about the enterprise ...

  5. ThreadPoolExecutor执行过程分析

    ThreadPoolExecutor public ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTi ...

  6. HDU 2874 Connections between cities(LCA离线算法实现)

    http://acm.hdu.edu.cn/showproblem.php?pid=2874 题意: 求两个城市之间的距离. 思路: LCA题,注意原图可能不连通. 如果不了解离线算法的话,可以看我之 ...

  7. mybatis 关于传long 类型问题

    @Datapublic class PrealertPackageStatusDTO { private Integer nowStatus; /** * packageStatusEnum */ p ...

  8. ros python 订阅robot_pose

    #!/usr/bin/env python import rospy import tf import time from tf.transformations import * from std_m ...

  9. robot_pose的类型

    http://docs.ros.org/api/geometry_msgs/html/msg/Pose.html

  10. list_01

    双向链表 不支持随机存取([?] / at(?)) A.头尾 添加/移除 A.1.list::push_back(elemValue); A.2.list::pop_back(); A.3.list: ...