Исключение с (пользовательским) заказом RestAuthenticationProcessingFilter



Я пытаюсь добавить проверку подлинности остальное маркер для моего приложения.
Я создал простой фильтр, не делая ничего другого, чтобы напечатать сообщение:



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 server, я получаю следующее сообщение:



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)


Почему ?



Спасибо

648   1  

1 ответ:

AddFilter:

Добавляет фильтр, который должен быть экземпляром или расширением одного из фильтров обеспечивается в рамках системы безопасности. Метод гарантирует, что заказ фильтров осуществляется автоматически. Заказ из фильтров есть:...

Ваш фильтр не является экземпляром или расширением фильтра в рамках системы безопасности.

Что вы можете сделать, однако, это использовать addFilterBefore или addFilterAfter.

Например:

addFilterBefore(new RestAuthenticationProcessingFilter(), BasicAuthenticationFilter.class)

Ты можно найти порядок цепочки фильтров безопасности в документах:

Http://docs.spring.io/spring-security/site/docs/3.2.0.RELEASE/apidocs/org/springframework/security/config/annotation/web/HttpSecurityBuilder.html#addFilter%28javax.servlet.Filter%29

Comments

    Ничего не найдено.