`

cas整合spring配置

 
阅读更多
<?xml version="1.0"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:security="http://www.springframework.org/schema/security"
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.0.xsd http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.xsd">

<security:http auto-config="false" entry-point-ref="casEntryPoint">
<security:form-login login-page="/login.jsp"/>
<security:intercept-url pattern="/login.jsp*" filters="none"/>
<security:intercept-url pattern="/**"  access="ROLE_USER"></security:intercept-url>
<security:custom-filter position="CAS_FILTER" ref="casFilter"></security:custom-filter>
<security:custom-filter before="LOGOUT_FILTER" ref="requestSingleLogoutFilter"/>
<security:custom-filter before="CAS_FILTER" ref="singleLogoutFilter"/>
</security:http>

<!-- 配置认证管理器 -->
<security:authentication-manager alias="casAuthenticationManager">
<security:authentication-provider ref="casAuthenticationProvider"></security:authentication-provider>
</security:authentication-manager>


<bean id="serviceProperties" class="org.springframework.security.cas.ServiceProperties">
<property name="service" value="http://ufseih8dqtzu33z:8099/soos/j_spring_cas_security_check"></property>
<property name="sendRenew" value="false"></property>
</bean>

<bean id="casEntryPoint" class="org.springframework.security.cas.web.CasAuthenticationEntryPoint">
<property name="loginUrl" value="https://ufseih8dqtzu33z:8443/cas/login"></property>
<property name="serviceProperties" ref="serviceProperties"></property>
</bean>


<bean id="casFilter" class="org.springframework.security.cas.web.CasAuthenticationFilter">
<property name="authenticationManager" ref="casAuthenticationManager"></property>
<property name="authenticationSuccessHandler" ref="authenticationSuccessHandler"></property>
<property name="authenticationFailureHandler" ref="authenticationFailureHandler"></property>
</bean>

<bean id="authenticationSuccessHandler" class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler" />
<bean id="authenticationFailureHandler" class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler">
<property name="defaultFailureUrl" value="/casfailed.jsp"/>
</bean>

<bean id="casAuthenticationProvider" class="org.springframework.security.cas.authentication.CasAuthenticationProvider">
<property name="userDetailsService" ref="userService"/>
<property name="serviceProperties" ref="serviceProperties"></property>
<property name="ticketValidator">
<bean class="org.jasig.cas.client.validation.Cas20ServiceTicketValidator">
<constructor-arg index="0" value="https://ufseih8dqtzu33z:8443/cas" />
</bean>
</property>
<property name="key" value="an_id_for_this_auth_provider_only"></property>
</bean>

<bean id="userService" class="org.springframework.security.core.userdetails.memory.InMemoryDaoImpl">
<property name="userMap"> 
            <value> 
                liuyxit=123,ROLE_SUPERVISOR
                user1=user1,ROLE_USER
                user2=user2,disabled,ROLE_USER  
            </value> 
     </property>
</bean>

<bean id="singleLogoutFilter" class="org.jasig.cas.client.session.SingleSignOutFilter"></bean>

<bean id="requestSingleLogoutFilter" class="org.springframework.security.web.authentication.logout.LogoutFilter">
<constructor-arg value="https://ufseih8dqtzu33z:8443/cas/logout"></constructor-arg>
<constructor-arg>
<bean class="org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler"></bean>
</constructor-arg>
<property name="filterProcessesUrl" value="/j_spring_cas_serurity_logout"/>
</bean>

</beans>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics