0

我正在尝试在我的应用程序中实现 CAS 单点登录。该应用程序由 Sp​​ring 安全性保护。我已将所有必需的 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>

弹簧安全.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 更多的是通常的代码......

提前谢谢沙希。

4

0 回答 0