国内私募机构九鼎控股打造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. C#子线程中更新ui

    本文实例总结了C#子线程更新UI控件的方法,对于桌面应用程序设计的UI界面控制来说非常有实用价值.分享给大家供大家参考之用.具体分析如下: 一般在winform C/S程序中经常会在子线程中更新控件的 ...

  2. [Linux: vim]vim自动生成html代码

    如果直接将vim编辑的文字复制粘贴到一些blog的编辑器中,这些代码将会是死板的白纸黑字.如果能加入关键字高亮功能就好了,这样代码阅读起来会很方便.一些blog的编辑器提供了这项功能,一些没有,一些支 ...

  3. csu 1749: Soldiers ' Training(贪心)

    1749: Soldiers ' Training Time Limit: 1 Sec  Memory Limit: 512 MBSubmit: 37  Solved: 18[Submit][Stat ...

  4. IEEEXtreme 10.0 - Inti Sets

    这是 meelo 原创的 IEEEXtreme极限编程大赛题解 Xtreme 10.0 - Inti Sets 题目来源 第10届IEEE极限编程大赛 https://www.hackerrank.c ...

  5. int类中的方法(二)

        25.__pos__(self,*args,**kwargs) def __pos__(self, *args, **kwargs): # real signature unknown &qu ...

  6. 使用360对app安全进行加固

    在写了第一个app之后,打算上架到各个渠道看看,无意间看到了360的app加固工具 http://jiagu.360.cn/ 自己体验了一把,加固过程很傻瓜化, 加固好了之后,还要对app进行二次签名 ...

  7. JavaScript 中的原型(总则)

    1. 一切函数都是对象 2. 一切对象都是由函数创建的,所有函数都是由Function创建的,每个函数都是一个Function对象. 3. 对象.__proto__ === 函数.prototype ...

  8. 四 Python基础

    Python是一种计算机编程语言.计算机编程语言和我们日常使用的自然语言有所不同,最大的区别就是,自然语言在不同的语境下有不同的理解,而计算机要根据编程语言执行任务,就必须保证编程语言写出的程序决不能 ...

  9. POJ 2019 Cornfields [二维RMQ]

    题目传送门 Cornfields Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 7963   Accepted: 3822 ...

  10. linux——(6)vim与vi

    概念:vi与vim的区别 vi是一款老式的文字处理软件,不过现在依然广泛使用,所有的UnixLike系统都会内置vi文本编辑器. vim可以看出vi的升级版,不过vi更像是一个程序开发工具,功能也比v ...