java - "The matching wildcard is strict, but no declaration can be found for element ' http '"错误

标签 java spring spring-security ntlm spring-3

我正在尝试配置 NTLM 身份验证,但收到错误:

cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'http'.

我阅读了很多类似错误的主题,但我找不到解决问题的方法。

导致错误的我的security.xml文件是:

<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.xsd
                            http://www.springframework.org/schema/security
                            http://www.springframework.org/schema/security/spring-security.xsd" >
    
    <http access-denied-page="forms/error403.jsp" entry-point-ref="ntlmEntryPoint" servlet-api-provision="false"> 
        <intercept-url pattern="forms/error403.jsp" filters="none"/>
        <intercept-url pattern="forms/**" access="ROLE_GUEST,ROLE_OPERATOR,ROLE_ADMIN" />
                <custom-filter position="PRE_AUTH_FILTER"/>
    </http>
    
    <authentication-manager alias="mainAuthenticationManager"/>  
    <authentication-provider user-service-ref='userDetailsService' />

    <beans:bean id="userDetailsService"
        class="service.UserInfoService">
        <beans:property name="dataSource" ref="dataSource" />
        <beans:property name="usersByUsernameQuery" value="select distinct name, ' ' as password, 1 as enabled from TMP_SPRING_USERS where name=?" />
        <beans:property name="authoritiesByUsernameQuery" value="select name, role from TMP_SPRING_USERS where name=?" />
    </beans:bean>
      
    <beans:bean id="ntlmEntryPoint"
        class="org.springframework.security.ui.ntlm.NtlmProcessingFilterEntryPoint">
        <beans:property name="authenticationFailureUrl" value="forms/error403.html" />
    </beans:bean>
        
    <beans:bean id="exceptionTranslationFilter"
        class="org.springframework.security.ui.ExceptionTranslationFilter">
        <beans:property name="authenticationEntryPoint" ref="ntlmEntryPoint" />
    </beans:bean>
    
    <beans:bean id="ntlmFilter"
        class="org.springframework.security.ui.ntlm.NtlmProcessingFilter">
        <custom-filter position="NTLM_FILTER" />
        <beans:property name="authenticationManager" ref="mainAuthenticationManager" />
        <beans:property name="retryOnAuthFailure" value="true" />
        <beans:property name="stripDomain" value="true"/>
        <beans:property name="domainController" value="company.com" />
        <beans:property name="jcifsProperties">
            <beans:props>
                <beans:prop key="jcifs.smb.lmCompatibility">0</beans:prop> 
                <beans:prop key="jcifs.smb.client.useExtendedSecurity">false</beans:prop> 
                <beans:prop key="jcifs.smb.client.domain">COMPANY</beans:prop>
                <beans:prop key="jcifs.smb.client.username">somenycuser</beans:prop>
                <beans:prop key="jcifs.smb.client.password">AReallyLoooongRandomPassword</beans:prop>
            </beans:props> 
        </beans:property> 
    </beans:bean>
    
  
</beans:beans>

因为从版本 3.X Spring Security 开始不再包含 NTLM 扩展,我从 http://aloiscochard.blogspot.com/2010/03/spring-security-ntlm-3.html 开始使用它。文章。

请帮帮我。

最佳答案

问题解决了,忘记添加spring-security-config.jar了。我也更改了一些设置。正确的security.xml是::

<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.0.xsd
                            http://www.springframework.org/schema/security
                            http://www.springframework.org/schema/security/spring-security-3.0.4.xsd" >

    <http access-denied-page="forms/error403.jsp" entry-point-ref="ntlmEntryPoint" servlet-api-provision="false"> 
                <intercept-url pattern="/**" access="ROLE_GUEST,ROLE_OPERATOR,ROLE_ADMIN" />
                <custom-filter position="PRE_AUTH_FILTER" ref="ntlmFilter"/>
        </http>

    <authentication-manager alias="mainAuthenticationManager">  
            <authentication-provider user-service-ref="userDetailsService" />
        </authentication-manager>

    <beans:bean id="userDetailsService"
        class="service.UserInfoService">
        <beans:property name="dataSource" ref="dataSource" />
        <beans:property name="usersByUsernameQuery" value="select distinct name, ' ' as password, 1 as enabled from TMP_SPRING_USERS where name=?" />
        <beans:property name="authoritiesByUsernameQuery" value="select name, role from TMP_SPRING_USERS where name=?" />
    </beans:bean>

    <beans:bean id="ntlmEntryPoint"
        class="org.springframework.security.ui.ntlm.NtlmAuthenticationFilterEntryPoint">
        <beans:property name="authenticationFailureUrl" value="forms/error403.html" />
    </beans:bean>



    <beans:bean id="ntlmFilter"
        class="org.springframework.security.ui.ntlm.NtlmAuthenticationFilter">
                <beans:property name="authenticationManager" ref="mainAuthenticationManager" />
        <beans:property name="retryOnAuthFailure" value="true" />
        <beans:property name="stripDomain" value="true"/>
        <beans:property name="domainController" value="company.com" />
        <beans:property name="jcifsProperties">
            <beans:props>
                <beans:prop key="jcifs.smb.lmCompatibility">0</beans:prop> 
                <beans:prop key="jcifs.smb.client.useExtendedSecurity">false</beans:prop> 
                <beans:prop key="jcifs.smb.client.domain">COMPANY</beans:prop>
                <beans:prop key="jcifs.smb.client.username">somenycuser</beans:prop>
                <beans:prop key="jcifs.smb.client.password">AReallyLoooongRandomPassword</beans:prop>
            </beans:props> 
        </beans:property> 
    </beans:bean>


</beans:beans>

关于java - "The matching wildcard is strict, but no declaration can be found for element ' http '"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10561579/

相关文章:

java - 使用 Unitils 针对 Postgres 数据库运行单元测试时出现 NullPointerException

java - 查看 Springs 下拉列表的排序顺序

java - QueryDSL NumberPath<BigDecimal> 大于从 MongoDB 集合提供不准确的结果

spring - 身份验证在 Spring Boot 1.5.2 和 Oauth2 中不起作用

java - 如何在安全 xml 中配置 BCryptPasswordEncoder

java - 使用 Java bean 作为 Grails 域类

java - 另一个带有 JSF 2.0 和 Primefaces 的 "cannot find component"

java - 有没有办法找出传递给 jar 的参数是否被引用?

java - 如何根据这种特殊的 equals 逻辑重写 hashcode 方法

java - security.oauth2.resource.jwt.key-value 的编码