查看我自己的代码后,我注意到我没有使用“ref”属性,而是将此标签放置在我的 bean 定义中,如下所示:
<bean id="ntlmFilter" class="org.springframework.security.ntlm.samples.failover.NtlmProcessingFilter">
<sec:custom-filter position="NTLM_FILTER" />
<property name="authenticationManager" ref="authenticationManager" />
<property name="retryOnAuthFailure" value="false" />
<property name="securityConfiguration" ref="securityConfiguration" />
</bean>
Source: http://github.com/aloiscochard/spring-security-ntlm-samples/blob/master/spring-security-ntlm-samples-failover/src/main/resources/applicationContext-security.xml http://github.com/aloiscochard/spring-security-ntlm-samples/blob/master/spring-security-ntlm-samples-failover/src/main/resources/applicationContext-security.xml
即使是 spring-security 2,版本 3 中的行为也是相同的。
您可以在 org.springframework.security.config.http.SecurityFilters 枚举中找到所有可能的位置:
http://grepcode.com/file/repo1.maven.org/maven2/org.springframework.security/spring-security-config/3.0.2.RELEASE/org/springframework/security/config/http/SecurityFilters.java http://grepcode.com/file/repo1.maven.org/maven2/org.springframework.security/spring-security-config/3.0.2.RELEASE/org/springframework/security/config/http/SecurityFilters.java
您可以使用此枚举中已定义的某些位置来定义自定义过滤器必须设置的顺序。
例如:
- LAST 之前有一个过滤器,LAST 上有一个过滤器(但不能在 LAST 之后!LAST 之后不能有任何内容!)
- 或者 SWITCH_USER_FILTER 之前有一个过滤器,之后有一个过滤器。
不知道您将标签放在哪里?但我喜欢将它们直接放在过滤器 bean 内...更易于维护:-)
希望有帮助!
PS:由于位置基于整数,您也许可以输入数字而不是枚举值(警告我们正确的位置编号,查看 SecurityFilters 枚举内部的逻辑),不确定是否接受...