java – (自定义)RestAuthenticationProcessingFilter Ordering的异常
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了java – (自定义)RestAuthenticationProcessingFilter Ordering的异常,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2720字,纯文字阅读大概需要4分钟。
内容图文
![java – (自定义)RestAuthenticationProcessingFilter Ordering的异常](/upload/InfoBanner/zyjiaocheng/759/ba81c6339f7b43909353055ddacdc559.jpg)
我尝试通过令牌将Rest身份验证添加到我的应用程序.
我创建了一个简单的过滤器,其他任何东西都不打印消
public class RestAuthenticationProcessingFilter extends GenericFilterBean {
@Override
public void doFilter(ServletRequest arg0, ServletResponse arg1,
FilterChain arg2) throws IOException, ServletException {
System.out.println(arg0);
// EDIT 25/02/2014
arg2.doFilter(arg0,arg1);
}
}
我正在使用Spring 4.0和Spring Security 3.2与JavaConfig.
我在我的适配器中添加了这个:
@Override
protected void configure(HttpSecurity http) throws Exception {
/*
* @RemarqueDev Différence entre permitAll et anonymous : permitAll
* contient anonymous. Anonymous uniquement pour non connecté
*/
http.addFilter(new RestAuthenticationProcessingFilter());
http.csrf().disable().headers().disable();
http.exceptionHandling().authenticationEntryPoint(new RestAuthenticationEntryPoint());
当我运行jetty服务器时,我收到此消息:
Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain' defined in class org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public javax.servlet.Filter org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration.springSecurityFilterChain() throws java.lang.Exception] threw exception; nested exception is java.lang.IllegalArgumentException: The Filter class my.package.config.RestAuthenticationProcessingFilter does not have a registered order and cannot be added without a specified order. Consider using addFilterBefore or addFilterAfter instead.:
java.lang.IllegalArgumentException: The Filter class com.jle.athleges.config.RestAuthenticationProcessingFilter does not have a registered order and cannot be added without a specified order. Consider using addFilterBefore or addFilterAfter instead.
at org.springframework.security.config.annotation.web.builders.HttpSecurity.addFilter(HttpSecurity.java:1122)
为什么?
谢谢
解决方法:
AddFilter:
Adds a Filter that must be an instance of or extend one of the Filters
provided within the Security framework. The method ensures that the
ordering of the Filters is automatically taken care of. The ordering
of the Filters is:…
您的过滤器不是安全框架内的过滤器的实例或扩展.
但是你可以使用addFilterBefore或addFilterAfter.
例如:
addFilterBefore(new RestAuthenticationProcessingFilter(), BasicAuthenticationFilter.class)
您可以在文档中找到安全过滤器链的顺序:
内容总结
以上是互联网集市为您收集整理的java – (自定义)RestAuthenticationProcessingFilter Ordering的异常全部内容,希望文章能够帮你解决java – (自定义)RestAuthenticationProcessingFilter Ordering的异常所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。