zoukankan      html  css  js  c++  java
  • CAS单点登录

    CAS单点登录系列:

    扩展:cas客户端 spring-security 集成cas

    jar:cas-client-core-3.5.1.jar,spring-security-cas-3.1.3.RELEASE.jar

    web.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    
    <beans:beans xmlns="http://www.springframework.org/schema/security"
        xmlns:beans="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans 
                  http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/security
                  http://www.springframework.org/schema/security/spring-security-3.1.xsd"
    > <!-- spring-security整合CAS单点登录系统 --> <!-- 配置不需要进行安全认证的资源 --> <http pattern="/static/**" security="none"/> <http pattern="/res/**" security="none"/> <http pattern="/services/soap/**" security="none"/> <http pattern="/security/**" security="none"/> <!-- entry-point-ref 入口点引用 --> <http use-expressions="false" entry-point-ref="casProcessingFilterEntryPoint"> <intercept-url pattern="/**" access="ROLE_USER"/> <!-- custom-filter为过滤器, position 表示将过滤器放在指定的位置上,before表示放在指定位置之前 ,after表示放在指定的位置之后 --> <custom-filter ref="casAuthenticationFilter" position="CAS_FILTER" /> <custom-filter ref="requestSingleLogoutFilter" before="LOGOUT_FILTER" /> <custom-filter ref="singleLogoutFilter" before="CAS_FILTER" /> </http> <!-- CAS入口点 开始 --> <beans:bean id="casProcessingFilterEntryPoint" class="org.springframework.security.cas.web.CasAuthenticationEntryPoint"> <!-- 单点登录服务器登录URL --> <beans:property name="loginUrl" value="http://127.0.0.1:8080/cas_overlay_war/login" /> <beans:property name="serviceProperties" ref="serviceProperties" /> </beans:bean> <beans:bean id="serviceProperties" class="org.springframework.security.cas.ServiceProperties"> <!-- Cas Server认证成功后的跳转地址,这里要跳转到我们的Spring Security应用, 之后会由CasAuthenticationFilter处理,默认处理地址为/j_spring_cas_security_check --> <beans:property name="service" value="http://127.0.0.1:8888/t/j_spring_cas_security_check" /> </beans:bean> <!-- CAS入口点 结束 --> <!-- 认证过滤器 开始 --> <beans:bean id="casAuthenticationFilter" class="org.springframework.security.cas.web.CasAuthenticationFilter"> <beans:property name="authenticationManager" ref="authenticationManager" /> <!-- 指定处理地址,不指定时默认将会是“/j_spring_cas_security_check” --> <beans:property name="filterProcessesUrl" value="/j_spring_cas_security_check"/> </beans:bean> <!-- 认证管理器 --> <authentication-manager alias="authenticationManager" > <authentication-provider ref="casAuthenticationProvider" /> </authentication-manager> <!-- 认证提供者 --> <beans:bean id="casAuthenticationProvider" class="org.springframework.security.cas.authentication.CasAuthenticationProvider"> <beans:property name="authenticationUserDetailsService"> <beans:bean class="org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper"> <beans:constructor-arg ref="XarchUserService" /> </beans:bean> </beans:property> <beans:property name="serviceProperties" ref="serviceProperties" /> <!-- ticketValidator 为票据验证器 --> <beans:property name="ticketValidator"> <beans:bean class="org.jasig.cas.client.validation.Cas20ServiceTicketValidator"> <beans:constructor-arg index="0" value="http://127.0.0.1:8080/cas_overlay_war" /> <beans:property name="encoding" value="UTF-8" /> </beans:bean> </beans:property> <beans:property name="key" value="an_id_for_this_auth_provider_only" /> </beans:bean> <!-- <beans:bean id="XarchUserService" class="com.ces.xarch.plugins.authsystem.service.XarchUserDetailService" /> --> <!-- 认证过滤器 结束 --> <!-- 单点登出 开始 --> <beans:bean id="singleLogoutFilter" class="org.jasig.cas.client.session.SingleSignOutFilter" /> <beans:bean id="requestSingleLogoutFilter" class="org.springframework.security.web.authentication.logout.LogoutFilter"> <!-- 退出登录后跳转的路径 --> <beans:constructor-arg value="http://127.0.0.1:8080/cas_overlay_war/logout" /> <beans:constructor-arg> <beans:bean class="org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler" /> </beans:constructor-arg> <!-- 该Filter需要处理的地址,默认是Spring Security的默认登出地址“/j_spring_security_logout”--> <beans:property name="filterProcessesUrl" value="/j_spring_cas_security_logout" /> </beans:bean> <!-- 单点登出 结束 --> </beans:beans>
  • 相关阅读:
    剑指Offer——矩形覆盖
    剑指Offer——变态跳台阶
    ASCII table and description .
    字符编解码的故事(ASCII,ANSI,Unicode,Utf-8区别) .
    tchar 输入输出类 和 string 类 函数简单说明 总结各种前缀后缀
    各种 C++编译器的性能对比
    怎样写参数个数可变的宏 Debug宏 Log宏等
    C语言中的可变参数函数 三个点“…”printf( const char* format, ...)
    常用C语言字符串操作函数
    Multi-Byte Character Set &amp; Use Unicode Character Set .
  • 原文地址:https://www.cnblogs.com/BambooLamp/p/12917499.html
Copyright © 2011-2022 走看看