Spring security 在Spring安全防护应用程序上实现CAS单点登录

Spring security 在Spring安全防护应用程序上实现CAS单点登录,spring-security,Spring Security,我正在尝试在我的应用程序中实现CAS单点登录。应用程序由Spring security保护。我已将所有必需的JAR放入应用程序的lib文件夹中,但我遇到了这些错误 >SEVERE: Exception starting filter CAS Gateway Filter java.lang.IllegalArgumentException: serverName or service must be set. at org.jasig.cas.client.util.CommonUtils

我正在尝试在我的应用程序中实现CAS单点登录。应用程序由Spring security保护。我已将所有必需的JAR放入应用程序的lib文件夹中,但我遇到了这些错误

>SEVERE: Exception starting filter CAS Gateway Filter
java.lang.IllegalArgumentException: serverName or service must be set.
at org.jasig.cas.client.util.CommonUtils.assertTrue(CommonUtils.java:116)...

>SEVERE: Exception starting filter CAS Validation Filter
java.lang.IllegalArgumentException: casServerUrlPrefix cannot be null.
at org.jasig.cas.client.util.CommonUtils.assertNotNull(CommonUtils.java:89)...



>SEVERE: Exception starting filter CAS Renew Filter
java.lang.IllegalArgumentException: serverName or service must be set.
at org.jasig.cas.client.util.CommonUtils.assertTrue(CommonUtils.java:116)...


>SEVERE: Exception starting filter CAS Authentication Filter
java.lang.IllegalArgumentException: serverName or service must be set.
at org.jasig.cas.client.util.CommonUtils.assertTrue(CommonUtils.java:116)...
任何人都可以帮忙。我试图浏览一些论坛寻找答案,但我不明白我在这里做错了什么

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<display-name>sboffice</display-name>
<!-- Added Spring MVC Dispatcher Servlet -->
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        /WEB-INF/spring-security.xml
    </param-value>
</context-param>
<filter>
    <filter-name>CAS Authentication Filter</filter-name>
    <filter-class>org.jasig.cas.client.authentication.AuthenticationFilter</filter-class>
    <init-param>
        <param-name>casServerLoginUrl</param-name>
        <param-value>https://arunodaya.localhost:8443/cas/login</param-value>
    </init-param>
    <init-param>
        <param-name>service</param-name>
        <param-value>http://arunodaya.localhost:8080/sboffice/</param-value>
        </init-param>
    <init-param>
        <param-name>serverName</param-name>
        <param-value>http://localhost:8080/</param-value>
    </init-param>
</filter>
<filter>
<filter-name>CAS Validation Filter</filter-name>
<filter-class>org.jasig.cas.client.validation.Cas10TicketValidationFilter</filter-class>
<init-param>
<param-name>casServerUrlPrefix</param-name>
<param-value>https://localhost:8443/cas</param-value>
</init-param>
<init-param>
<param-name>service</param-name>
<param-value>http://arunodaya.localhost:8080/sboffice/</param-value>
</init-param>
<init-param>
<param-name>serverName</param-name>
<param-value>http://localhost:8080/</param-value>
</init-param>
</filter>
<filter>
    <filter-name>CAS HttpServletRequest Wrapper Filter</filter-name>
    <filter-class>org.jasig.cas.client.util.HttpServletRequestWrapperFilter</filter-class>
</filter>
  <filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<!--
  - Loads the root application context of this web app at startup.
-->
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter-mapping>
    <filter-name>CAS Authentication Filter</filter-name>
    <url-pattern>/login</url-pattern>
</filter-mapping> 
<filter-mapping>
    <filter-name>CAS Validation Filter</filter-name>
    <url-pattern>/login</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>CAS HttpServletRequest Wrapper Filter</filter-name>
    <url-pattern>/login</url-pattern>
</filter-mapping>
<filter-mapping>
  <filter-name>springSecurityFilterChain</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
    <servlet-name>springweb</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

办公室
上下文配置位置
/WEB-INF/spring-security.xml
CAS认证过滤器
org.jasig.cas.client.authentication.AuthenticationFilter
卡塞尔洛基努尔酒店
https://arunodaya.localhost:8443/cas/login
服务
http://arunodaya.localhost:8080/sboffice/
服务器名
http://localhost:8080/
CAS验证过滤器
org.jasig.cas.client.validation.Cas10TicketValidationFilter
casServerUrlPrefix
https://localhost:8443/cas
服务
http://arunodaya.localhost:8080/sboffice/
服务器名
http://localhost:8080/
CAS HttpServletRequest包装筛选器
org.jasig.cas.client.util.HttpServletRequestWrapperFilter
springSecurityFilterChain
org.springframework.web.filter.DelegatingFilterProxy
org.springframework.web.context.ContextLoaderListener
CAS认证过滤器
/登录
CAS验证过滤器
/登录
CAS HttpServletRequest包装筛选器
/登录
springSecurityFilterChain
/*
春网
org.springframework.web.servlet.DispatcherServlet
1.
index.jsp

spring-security.xml

<?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:sec="http://www.springframework.org/schema/security"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="
    http://www.springframework.org/schema/aop          http://www.springframework.org/schema/aop/spring-aop.xsd
    http://www.springframework.org/schema/context    http://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/jee    http://www.springframework.org/schema/jee/spring-jee.xsd
    http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
    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.0.xsd
    ">
<sec:http entry-point-ref="casProcessingFilterEntryPoint" >
<sec:intercept-url pattern="/resources/jsp" access="ROLE_SUPERVISOR" requires-      channel="https"/>
    <sec:logout logout-success-url="https://localhost:8443/cas/logout"/>
    <sec:custom-filter ref="requestSingleLogoutFilter" before="LOGOUT_FILTER"/>
    <sec:custom-filter ref="singleLogoutFilter" before="CAS_FILTER"/>
    <sec:custom-filter ref="casAuthenticationFilter" after="CAS_FILTER"/>
    </sec:http>

    <sec:authentication-manager alias="authenticationManager">
    <sec:authentication-provider ref="casAuthenticationProvider"/>
    </sec:authentication-manager>
<bean id="casAuthenticationFilter"      class="org.springframework.security.cas.web.CasAuthenticationFilter">
    <property name="authenticationManager" ref="authenticationManager"/>
    <property name="authenticationFailureHandler">
        <bean      class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler        ">
    <property name="defaultFailureUrl" value="/resources/jsp/index.jsp"/>
    </bean>
    </property>
    <property name="authenticationSuccessHandler">
    <bean       class="org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler        ">
            <property name="defaultTargetUrl" value="/"/>
        </bean>
    </property>
    <property name="proxyGrantingTicketStorage" ref="proxyGrantingTicketStorage" />
    <property name="proxyReceptorUrl" value="/resources/jsp/receptor" />
    </bean>

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

    <bean id="casAuthenticationProvider" class="org.springframework.security.cas.authentication.CasAuthenticationProvider">
    <property name="userDetailsService" ref="userService"/>
    <property name="serviceProperties" ref="serviceProperties" />
    <property name="ticketValidator">
        <bean class="org.jasig.cas.client.validation.Cas20ServiceTicketValidator">
            <constructor-arg index="0" value="https://localhost:8443/cas" />
            <property name="proxyGrantingTicketStorage" ref="proxyGrantingTicketStorage"      />
<property name="proxyCallbackUrl"        value="https://arunodaya.localhost:8443/sboffice/resources/jsp/receptor" />

     </bean>
</property>
    <property name="key" value="an_id_for_this_auth_provider_only"/>
    </bean>

    <bean id="proxyGrantingTicketStorage"      class="org.jasig.cas.client.proxy.ProxyGrantingTicketStorageImpl" />
    <bean id="serviceProperties"    class="org.springframework.security.cas.ServiceProperties">
    <property name="service"    value="https://arunodaya.localhost:8443/sboffice/j_spring_cas_security_check"/>
    <property name="sendRenew" value="false"/>
    </bean>

    <!-- This filter handles a Single Logout Request from the CAS Server -->
    <bean id="singleLogoutFilter"   class="org.jasig.cas.client.session.SingleSignOutFilter"/>
    <!-- This filter redirects to the CAS Server to signal Single Logout should be      performed       -->
    <bean id="requestSingleLogoutFilter"
    class="org.springframework.security.web.authentication.logout.LogoutFilter">       <constructor-arg value="https://localhost:8443/cas/logout"/>
    <constructor-arg>
    <bean class=
        "org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler"/>
    </constructor-arg>
    <property name="filterProcessesUrl" value="/j_spring_cas_security_logout"/>
    </bean>
<sec:user-service id="userService">
    <sec:user name="jeyakumaran" password="rod" authorities="ROLE_SUPERVISOR,ROLE_USER"   />
    <sec:user name="dianne" password="dianne" authorities="ROLE_USER" />
    <sec:user name="scott" password="scott" authorities="ROLE_USER" />
</sec:user-service>
    </beans>

springweb-servlet.xml更像是常用的代码


提前感谢shashi。

您可以发布您的xml文件吗?如果您正在尝试使用CAS,那么您的应用程序中的某个地方会调用它,我要求您这样做,但是的,在此之前,CAS应该启动。我正在使用CAS,我将检查并更新issuepaste ur spring应用程序上下文文件以及web.xml