国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html
内部邀请码:C8E245J (不写邀请码,没有现金送)
国内私募机构九鼎控股打造,九鼎投资是在全国股份转让系统挂牌的公众公司,股票代码为430719,为中国PE第一股,市值超1000亿元。 

------------------------------------------------------------------------------------------------------------------------------------------------------------------

SpringSecurity本身已经做好了与CAS的集成工作,只需要我们做简单配置就可以了

步骤1 spring-cas.xml配置文件内容如下(完整版)

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans:beans xmlns="http://www.springframework.org/schema/security"
  3. xmlns:context="http://www.springframework.org/schema/context"
  4. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
  5. xmlns:beans="http://www.springframework.org/schema/beans"
  6. xsi:schemaLocation="  http://www.springframework.org/schema/context  http://www.springframework.org/schema/context/spring-context-2.5.xsd
  7. http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  8. http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd"
  9. default-lazy-init="true">
  10. <context:component-scan base-package="com.itec.core" />
  11. <!--SSO -->
  12. <http auto-config="false" entry-point-ref="casEntryPoint" servlet-api-provision="true">
  13. <intercept-url pattern="/login.do" filters="none" />
  14. <intercept-url pattern="/image.do" filters="none" />
  15. <intercept-url pattern="/admin/*.do*" access="ROLE_LOGIN" />
  16. <!-- logout-success-url="/login.html" -->
  17. <!--        <logout logout-url="/login.do" success-handler-ref="casLogoutSuccessHandler"/>   -->
  18. <custom-filter ref="requestSingleLogoutFilter" before="LOGOUT_FILTER" />
  19. <custom-filter position="FORM_LOGIN_FILTER" ref="casFilter"/>
  20. <custom-filter ref="singleLogoutFilter" before="CAS_FILTER" />
  21. </http>
  22. <beans:bean id="casEntryPoint"  class="org.springframework.security.cas.web.CasAuthenticationEntryPoint">
  23. <beans:property name="loginUrl" value="http://172.19.50.21:9083/HASLSSO/login"/>
  24. <beans:property name="serviceProperties" ref="serviceProperties"/>
  25. </beans:bean>
  26. <beans:bean id="serviceProperties"  class="org.springframework.security.cas.ServiceProperties">
  27. <beans:property name="service"  value="http://172.19.4.225:8080/HACMS/j_spring_cas_security_check"/>
  28. <beans:property name="sendRenew" value="false"/>
  29. </beans:bean>
  30. <beans:bean id="casFilter"  class="org.springframework.security.cas.web.CasAuthenticationFilter">
  31. <beans:property name="authenticationManager" ref="authenticationManager"/>
  32. </beans:bean>
  33. <authentication-manager alias="authenticationManager">
  34. <authentication-provider ref="casAuthenticationProvider"/>
  35. </authentication-manager>
  36. <beans:bean id="casAuthenticationUserDetailsService" class="org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper">
  37. <beans:property name="userDetailsService" >
  38. <beans:ref bean="userDetailsManager" />
  39. </beans:property>
  40. </beans:bean>
  41. <beans:bean id="casAuthenticationProvider"
  42. class="org.springframework.security.cas.authentication.CasAuthenticationProvider">
  43. <beans:property name="authenticationUserDetailsService" ref="casAuthenticationUserDetailsService"/>
  44. <beans:property name="serviceProperties" ref="serviceProperties" />
  45. <beans:property name="ticketValidator">
  46. <beans:bean class="org.jasig.cas.client.validation.Cas20ServiceTicketValidator">
  47. <beans:constructor-arg index="0" value="http://172.19.50.21:9083/HASLSSO" />
  48. </beans:bean>
  49. </beans:property>
  50. <beans:property name="key" value="an_id_for_this_auth_provider_only"/>
  51. </beans:bean>
  52. <!-- 注销客户端 -->
  53. <beans:bean id="singleLogoutFilter" class="org.jasig.cas.client.session.SingleSignOutFilter" />
  54. <!-- 注销服务器端 -->
  55. <beans:bean id="requestSingleLogoutFilter"
  56. class="org.springframework.security.web.authentication.logout.LogoutFilter">
  57. <beans:constructor-arg
  58. value="http://172.19.50.21:9083/HASLSSO/logout" />
  59. <beans:constructor-arg>
  60. <beans:bean
  61. class="org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler"/>
  62. </beans:constructor-arg>
  63. <beans:property name="filterProcessesUrl" value="/j_spring_cas_security_logout" />
  64. </beans:bean>
  65. </beans:beans>

步骤2 之前的UserDetailsManager不需要改任何代码

  1. @Service
  2. public class UserDetailsManager implements UserDetailsService {

步骤3 web.xml需要修改一点东西,不加载Security的配置文件就行了

  1. <context-param>
  2. <param-name>contextConfigLocation</param-name>
  3. <!-- 使用工程本身验证 -->
  4. <param-value>/WEB-INF/spring-config.xml,/WEB-INF/spring-freemarker.xml,/WEB-INF/spring-jpa.xml,/WEB-INF/spring-security.xml</param-value>
  5. <!-- 使用 SSO 验证 -->
  6. <!--        <param-value>/WEB-INF/spring-config.xml,/WEB-INF/spring-freemarker.xml,/WEB-INF/spring-jpa.xml,/WEB-INF/spring-cas.xml</param-value> -->
  7. </context-param>

大功告成~!

SpringSecurity3整合CAS实现单点登录的更多相关文章

  1. CAS5.3服务器搭建及SpringBoot整合CAS实现单点登录

    1.1 什么是单点登录 单点登录(Single Sign On),简称为 SSO,是目前比较流行的企业业务整合的解决方案之一.SSO的定义是在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的 ...

  2. pac4j探索(一)之buji-pac4j shiro整合Cas实现单点登录

    https://blog.csdn.net/hxm_code/article/details/79181218 https://blog.csdn.net/hxm_code/article/detai ...

  3. Spring Security 集成CAS实现单点登录

    参考:http://elim.iteye.com/blog/2270446 众所周知,Cas是对单点登录的一种实现.本文假设读者已经了解了Cas的原理及其使用,这些内容在本文将不会讨论.Cas有Ser ...

  4. 如何利用tomcat和cas实现单点登录(1):配置tomcat的ssl和部署cas

    如何利用tomcat和cas实现单点登录,借鉴了网上的很多教程,主要分为以下几个步骤: 一:下载好cas,tomcat之后,首先配置tomcat: 用鼠标右键点击"计算机"→选择& ...

  5. CAS实现单点登录流程

    CAS实现单点登录 环境 客户端: www.app1.com CAS服务器: www.cas-server.com 1.浏览器:发起请求 www.app1.com 2. 客户端:Authenticat ...

  6. CAS实现单点登录SSO执行原理及部署

    一.不落俗套的开始 1.背景介绍 单点登录:Single Sign On,简称SSO,SSO使得在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的应用系统. CAS框架:CAS(Centra ...

  7. [精华][推荐]CAS SSO 单点登录框架学习 环境搭建

    1.了解单点登录  SSO 主要特点是: SSO 应用之间使用 Web 协议(如 HTTPS) ,并且只有一个登录入口. SSO 的体系中有下面三种角色: 1) User(多个) 2) Web 应用( ...

  8. CAS SSO单点登录框架学习

    1.了解单点登录  SSO 主要特点是: SSO 应用之间使用 Web 协议(如 HTTPS) ,并且只有一个登录入口. SSO 的体系中有下面三种角色: 1) User(多个) 2) Web 应用( ...

  9. [精华][推荐]CAS SSO单点登录服务端客户端实例

    1.修改server.xml文件,如下: 注意: 这里使用的是https的认证方式,需要将这个配置放开,并做如下修改: <Connector port="8443" prot ...

随机推荐

  1. AtCoder Non-decreasing(数学思维)

    题目链接:https://abc081.contest.atcoder.jp/tasks/arc086_b 题目大意:有n个数,最多可以执行2*n次操作,每次可以选择将ai加到aj上,最终使得该序列满 ...

  2. MySQL-高并发优化

    一.数据库结构的设计 1.数据行的长度不要超过8020字节,如果超过这个长度的话在物理页中这条数据会占用两行从而造成存储碎片,降低查询效率. 2.能够用数字类型的字段尽量选择数字类型而不用字符串类型的 ...

  3. go-互斥锁及原子函数

    用于解决并发函数的竞争状态问题... package main import ( "fmt" "runtime" "sync" " ...

  4. Hadoop案例(九)流量汇总案例

    流量汇总程序案例 1.自定义输出 统计手机号耗费的总上行流量.下行流量.总流量(序列化) 1)需求: 统计每一个手机号耗费的总上行流量.下行流量.总流量 2)数据准备 phone_date.txt - ...

  5. Roman to Integer & Integer to Roman

    题目: Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from ...

  6. PAT L2-018. 多项式A除以B

    暴力,模拟. 比赛搞了一个小时搞到了$1$分.赛场上不够冷静......之前没接触过多项式除法,但赛场上想到了除法的规则,莫名其妙写的时候不知道哪里崩了.对于这样的题目,应该先测一测数据的指数是不是很 ...

  7. pycharm的安装教程及大坑

    在根据网上的教程创建新工程后,发现不能调用第三方库,网上大多给的是print('hello world'),己适python解释器用的pycharm默认的也不能发现错误.后来浏览了一篇文章才恍然大悟, ...

  8. hdu 1874 畅通工程续(迪杰斯特拉优先队列,floyd,spfa)

    畅通工程续 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Subm ...

  9. 「NOIP2018」保卫王国

    「NOIP2018保卫王国」 题目描述 有一棵 \(n\) 个点, 点有点权 \(a_i\),\(m\) 组询问, 每次求钦点两个节点必须选或者必须不选后的树上最小点覆盖. \(1 \leq n, m ...

  10. 【递推】hdu5927 Auxiliary Set

    题意:给你一棵树.q次询问,每次给你一些非关键点,其他的点都是关键点,让你输出树中既不是关键点,也不是关键点的lca的点的数量. 对每次询问的非关键点按照深度从深到浅排序,依次处理,最开始每个点受到的 ...