1

SessionManagementFilterデフォルトを自分のものに置き換えたいのですが、これに遭遇しています

17:31:32,901 ERROR [[/accounts]] Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Filter beans '<accountsSessionManageFilter>' and 'Root bean: class [org.springframework.security.web.session.SessionManagementFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null' have the same 'order' value. When using custom filters, please make sure the positions do not conflict with default filters. Alternatively you can disable the default filters by removing the corresponding child elements from <http> and avoiding the use of <http auto-config='true'>. Offending resource: ServletContext resource [/WEB-INF/spring-contexts/security.xml]

問題は<http>、デフォルトのフィルターを同じ位置に設定する要素/属性を使用していることです。ただし、そうではありません(または、意図的でない場合)。

これは私のセキュリティ コンテキストの<http>定義です。

<http use-expressions="true" auto-config="false" entry-point-ref="loginUrlAuthenticationEntryPoint">

    <!-- lots of intercept-url definitions (nothing else) -->

    <custom-filter position="SESSION_MANAGEMENT_FILTER" ref="accountsSessionManageFilter"/>
    <custom-filter position="FORM_LOGIN_FILTER" ref="accountsSsoFilter"/>
</http>

.......

<beans:bean id="accountsSessionManageFilter" class="org.springframework.security.web.session.SessionManagementFilter">
    <beans:property name="sessionAuthenticationStrategy" ref="NullAuthenticatedSessionStrategy"/>
</beans:bean>

.......

<bean id="accountsSsoFilter" class="cayetano.core.base.service.impl.spring.filter.SsoUserPassAuthFilter">
    <property name="authenticationManager" ref="ssoAuthManager" />

    <property name="authenticationFailureHandler" ref="relativeLoginFailureHandler" />
    <property name="authenticationSuccessHandler" ref="noopLoginSuccessHandler" />

    <property name="authenticationService" ref="basicAuthenticatorService" />
    <property name="authorityService" ref="userTypeBasedAuthotiryService" />
</bean>

では、なぜ Spring<http>は、デフォルトのフィルターを使用する要素を使用していると不平を言うのでしょうか?

また、ドキュメントには、デフォルトのフィルターを使用<session-management>する唯一の<http>要素であると記載されていますが、他の要素はありますか?

Spring Security 3.0 を使用しています。

ありがとう、

4

1 に答える 1

3

デフォルトのクラス/インスタンスのcustom SESSION_MANAGEMENT_FILTERを変更できるように を指定しようとしている場合は属性を使用してください:sessionAuthenticationStrategysession-authentication-strategy-ref

<http ...>
    <session-management session-authentication-strategy-ref="NullAuthenticatedSessionStrategy"/>
</http>

NullAuthenticatedSessionStrategyもちろん、これはコンテキストで定義された別の Beanであると想定しています。これは Spring Security のクラスの名前でもあるため、本当に必要なのは次のとおりだと思います。

<http ...>
    <session-management session-authentication-strategy-ref="sessionStrategy"/>
</http>

<bean id="sessionStrategy" class="org.springframework.security.web.authentication.session.NullAuthenticatedSessionStrategy"/>
于 2012-04-24T15:52:14.480 に答える