继续得到No bean命名' springSecurityFilterChain'被定义为

时间:2015-03-05 14:17:46

标签: spring-security single-sign-on siteminder

我正在学习并需要使用Spring Security配置siteminder SSO。我关注了一些博客并将我的代码编写为fllowing。 Plz帮助重新解决:"没有名为“springSecurityFilterChain'已定义"错误。这是我的代码:

的web.xml

<context-param> 
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/conf/Security-config.xml</param-value>
</context-param>     

<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping> 

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

安全-config.xml中

<security:http use-expressions="true" auto-config="false" entry-point-ref="http403EntryPoint">
    <security:intercept-url pattern="/**" access="hasRole('ROLE_USER')" />
    <security:custom-filter position="PRE_AUTH_FILTER" ref="siteminderFilter" />
</security:http>

<bean id="siteminderFilter" class="org.springframework.security.web.authentication.preauth.RequestHeaderAuthenticationFilter">
    <property name="principalRequestHeader" value="SM_USER"/>
    <property name="authenticationManager" ref="authenticationManager" />
</bean>

<bean id="preauthAuthProvider" class="org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider">
    <property name="preAuthenticatedUserDetailsService">
        <bean id="userDetailsServiceWrapper"  class="org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper">
            <property name="userDetailsService" ref="customUserDetailsService"/>
        </bean>
    </property>
</bean>

<security:authentication-manager alias="authenticationManager">
    <security:authentication-provider ref="preauthAuthProvider" />
</security:authentication-manager>   

<bean id="customUserDetailsService" class="com.cno.cnofdw.security.CustomUserDetailsService"></bean>
<bean id="http403EntryPoint" class="org.springframework.security.web.authentication.Http403ForbiddenEntryPoint"></bean>

在WEB-INF / conf /下放置Security-config.xml 甚至我尝试在applicationContext.xml中导入。但没用。

有人可以帮我解决这个问题,如果可能的话,请建议任何博客配置带有siteminder signle登录的弹簧吗?

2 个答案:

答案 0 :(得分:0)

路径中缺少“/”。它应该是:

<context-param> 
    <param-name>contextConfigLocation</param-name>
    <param-value>
        /WEB-INF/conf/Security-config.xml
    </param-value>
</context-param>  

答案 1 :(得分:0)

谢谢所有花时间回答我的问题的人。我已经将contextClass放在我的web.xml中,我已经对它进行了评论并得到了解决。

        contextClass                    org.springframework.web.context.support.AnnotationConfigWebApplicationContext