国内私募机构九鼎控股打造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. Linux软件管理器(如何使用软件管理器来管理软件)

    我们的Linux系统大部分都是某个Linux厂商的系统,所以这些厂商可以编译好一些软件来提供用户下载,用户下载完了之后就可以直接安装,从而省去了编译源码及其过程中的各种问题.这时我们就可以使用相应的软 ...

  2. golang类型转换小总结

    1. int <--> string 1.1. int --> string str := strconv.Itoa(intVal) 当然,整数转换成字符串还有其他方法,比如 fmt ...

  3. JavaScript中的数据类型总结

    Javascript是一种弱类型语言,没有明确的类型分类:网上分类的方式比较多,个人感觉不比去特别的追究细分是什么什么类型,若是能够明确的分出类型的话,javascript就不是弱类型语言,又由于大家 ...

  4. web2.0 HW3 相关阅读材料

    W3C官网的材料简直看花眼……除了挂出的文档,www-style@w3.org的一堆邮件也藏着很多宝,但是看下来又眼花了……(好在宝们基本都被W3C吸收了=.=) 主要来自W3C的官网w3.org的一 ...

  5. NIO-3网络通信

    import java.io.IOException; import java.net.InetSocketAddress; import java.nio.ByteBuffer; import ja ...

  6. Dockerfile 备份

    dotnet core app FROM microsoft/dotnet:1.1.0-runtime WORKDIR /mvcApp COPY ./out . ENTRYPOINT ["d ...

  7. Js~对数组的操作

    在工作中可能用的不多,但一些特殊的场合还是会用到,所以在这里,把JS的数组操作总结一下,分享给大家! Array 对象 Array 对象用于在单个的变量中存储多个值. 创建 Array 对象的语法: ...

  8. SaltStack的salt-ssh使用及LAMP状态设计部署(五)

    一.salt-ssh的使用 官方文档:https://docs.saltstack.com/en/2016.11/topics/ssh/index.html (1)安装salt-ssh [root@l ...

  9. linux网络管理----Linux网络配置

    1.1 linux配置IP地址 1️⃣ ifconfig命令临时配置IP地址 能不能自动获取IP地址和DNS地址,要看有没有DHCP服务器 win10上,输入ipconfig /all 会看到是否有D ...

  10. 洛谷P1552 [APIO2012] 派遣 [左偏树,树形DP]

    题目传送门 忍者 Description 在一个忍者的帮派里,一些忍者们被选中派遣给顾客,然后依据自己的工作获取报偿.在这个帮派里,有一名忍者被称之为 Master.除了 Master以外,每名忍者都 ...