国内私募机构九鼎控股打造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. **CodeIgniter系列 添加filter和helper

    filter: 使用CI的hooks来实现filter. 1.在system/application/config/config.php中,把enable_hooks的值改为TRUE $config[ ...

  2. 关于为什么某些C/C++环境下浮点数可以“正常”比较的问题

    有师妹问浮点数比较的问题,然后有人展示了可以“正常”比较的例子,google了一堆东西如下,有空仔细读一读,整理整理 http://bytes.com/topic/c/answers/629184-p ...

  3. iis应用池内存溢出卡死优化

    1.修改回收阀值memoryLimit 在ASP.NET Web服务器上,ASP.NET所能够用到的内存,通常不会等同于所有的内存数量.在machine.config(C:/WINDOWS/Micro ...

  4. merc_timer_handle_t函数的使用

    merc_timer_handle_t,是定义一个时间类型,这个时间类型可以用来接收2个函数之间的wasted time 但是在项目中出现这个情况: 因为在脚本中添加了该函数:

  5. bzoj 1854 并查集 + 贪心

    思路:这个题的并查集用的好NB啊, 我们把伤害看成图上的点,武器作为边,对于一个联通块来说, 如果是一棵大小为k的树,那么这个联通块里面有k - 1个伤害能被取到,如果图上有环那么k个值都能 取到,对 ...

  6. CodeForces 772A Voltage Keepsake

    二分答案,验证. 二分到一个答案,比他小的时间都需要补充到这个时间,计算所需的量,然后和能提供的量进行比较. #include <cstdio> #include <cmath> ...

  7. zookpeer应用和zkclient实践

    分布式 zkclient 排它锁 在需要获取排它锁时,通过调用create()接口,创建临时子节点.zk会保证在所有客户端中,只有一个会创建成功,从而获取锁. 其他客户端注册该节点的变更watch监听 ...

  8. maven-surefire-plugin插件

    https://sq.163yun.com/blog/article/173632756223238144 目前很多项目组的测试代码工程都是采用MAVEN+TESTNG的方式构造的. 因此测试代码pr ...

  9. mysql 之 用python操作数据库

  10. 【BZOJ 4380】4380: [POI2015]Myjnie (区间DP)

    4380: [POI2015]Myjnie Description 有n家洗车店从左往右排成一排,每家店都有一个正整数价格p[i].有m个人要来消费,第i个人会驶过第a[i]个开始一直到第b[i]个洗 ...