Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jetty addFilter with Spring Security and no web.xml

Normally I would have added org.springframework.web.filter.DelegatingFilterProxy with a snippet like this to web.xml:

<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> 

But with Servlet 3.0 Container and Jetty, I've removed web.xml. I'm trying to add DelegatingFilterProxy to Jetty's launch with:

context.addFilter(DelegatingFilterProxy.class, "/*", EnumSet.allOf(DispatcherType.class));

but I get error:

No bean named 'org.springframework.web.filter.DelegatingFilterProxy-100555887' is defined

How am I supposed to create and add this filter?

like image 722
vertti Avatar asked Sep 27 '13 14:09

vertti


1 Answers

context.addFilter(new FilterHolder(new DelegatingFilterProxy("springSecurityFilterChain")), "/*", EnumSet.allOf(DispatcherType.class));

seems to be the correct syntax.

like image 138
vertti Avatar answered Nov 18 '22 17:11

vertti