Spring Security 3.2配置文件中的错误

时间:2015-06-02 08:28:48

标签: xml spring spring-security

我正在使用spring security 3.2。我的项目工作正常。但我的安全配置文件显示两个错误

1)在<security:http auto-config="true" use-expressions="true">

  

此行找到多个注释:      - schema_reference.4:无法读取架构文档&#39; http://www.springframework.org/schema/security/spring-security-3.2.xsd&#39;,   因为1)找不到文件; 2)文件不能   被阅读; 3)文档的根元素不是。      - cvc-complex-type.2.4.c:匹配的通配符是严格的,但是没有找到元素&#39; security的声明:http&#39;。

2)<security:authentication-manager>

  

cvc-complex-type.2.4.c:匹配的通配符是严格的,但是没有为元素&#39; security:authentication-manager&#39;找到声明。

<?xml version="1.0" encoding="UTF-8"?>
<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" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-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.2.xsd">

<security:http auto-config="true" use-expressions="true">

    <security:expression-handler ref="expressionHandler" />

    <security:intercept-url pattern="/admin/*"
        access="hasIpAddress('127.0.0.1') 
        and (isAnonymous() ? false : principal.lastname== 'Scarioni') and over18" />

    <security:intercept-url pattern="/movies/**/*"
        access="hasRole('ROLE_USER')" />

    <security:intercept-url pattern="/movies/*"
        access="hasAnyRole('ROLE_USER','ROLE_VIP')" />

    <security:intercept-url pattern="/j_spring_security_switch_user"
        access="hasRole('ROLE_ADMIN')" />

    <security:intercept-url pattern="/j_spring_security_exit_user"
        access="hasRole('ROLE_ADMIN')" />

    <security:intercept-url pattern="/custom_login"
        requires-channel="https" />

    <security:intercept-url pattern="/j_spring_security_check"
        requires-channel="https" />

    <security:remember-me key="terror-key" />

    <security:logout delete-cookies="JSESSIONID"
        success-handler-ref="logoutRedirectToAny" />

    <security:custom-filter ref="switchUser"
        before="FILTER_SECURITY_INTERCEPTOR" />

    <security:form-login login-page="/custom_login"
        authentication-failure-handler-ref="serverErrorHandler"
        username-parameter="user_param" password-parameter="pass_param" />

    <security:session-management>
        <security:concurrency-control
            max-sessions="1" />
    </security:session-management>

</security:http>

<security:authentication-manager>
    <security:authentication-provider
        user-service-ref="inMemoryUserServiceWithCustomUser" />
</security:authentication-manager>

<bean id="switchUser"
    class="org.springframework.security.web.authentication.switchuser.SwitchUserFilter">
    <property name="userDetailsService" ref="inMemoryUserServiceWithCustomUser" />
    <property name="targetUrl" value="/" />

</bean>

<bean id="expressionHandler"
    class="com.apress.pss.terrormovies.security.CustomWebSecurityExpressionHandler" />

<bean id="inMemoryUserServiceWithCustomUser"
    class="com.apress.pss.terrormovies.spring.CustomInMemoryUserDetailsManager">

    <constructor-arg>

        <list>

            <bean class="com.apress.pss.terrormovies.model.User">

                <constructor-arg value="admin" />
                <constructor-arg value="admin" />

                <constructor-arg>

                    <list>

                        <bean
                            class="org.springframework.security.core.authority.SimpleGrantedAuthority">
                            <constructor-arg value="ROLE_ADMIN" />
                        </bean>

                    </list>

                </constructor-arg>

                <constructor-arg value="Scarioni" />
                <constructor-arg value="19" />

            </bean>

            <bean class="com.apress.pss.terrormovies.model.User">

                <constructor-arg value="paco" />
                <constructor-arg value="tous" />

                <constructor-arg>

                    <list>

                        <bean
                            class="org.springframework.security.core.authority.SimpleGrantedAuthority">
                            <constructor-arg value="ROLE_USER" />
                        </bean>

                    </list>

                </constructor-arg>

                <constructor-arg value="Miranda" />
                <constructor-arg value="20" />

            </bean>

            <bean class="com.apress.pss.terrormovies.model.User">

                <constructor-arg value="lucas" />
                <constructor-arg value="fernandez" />

                <constructor-arg>

                    <list>

                        <bean
                            class="org.springframework.security.core.authority.SimpleGrantedAuthority">
                            <constructor-arg value="ROLE_VIP" />
                        </bean>
                        <bean
                            class="org.springframework.security.core.authority.SimpleGrantedAuthority">
                            <constructor-arg value="ROLE_USER" />
                        </bean>

                    </list>

                </constructor-arg>

                <constructor-arg value="Silva" />
                <constructor-arg value="20" />

            </bean>

        </list>

    </constructor-arg>

</bean>

<bean id="logoutRedirectToAny"
    class="org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler">
    <property name="targetUrlParameter" value="redirectTo" />
</bean>

<bean id="serverErrorHandler"
    class="com.apress.pss.terrormovies.security.ServerErrorFailureHandler" />
</beans>

请帮帮我。

0 个答案:

没有答案