I was following this tutorial:
http://www.mkyong.com/spring-security/spring-security-hello-world-example/
In the spring-security-xml
<http auto-config="true">
<intercept-url pattern="/welcome*" access="ROLE_USER" />
</http>
And in the web.xml, we must define the actual filter
<!-- Spring Security -->
<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>
So I don’t get this, we are mapping the interception to 2 urls in 2 places. To /welcome* and /*. Why we need both of these? Am I missing something here?
DelegatingFilterProxyis not a Spring Security class. It is from Spring Web package.When you use
Spring Security creates (implicitly) bean with name
springSecurityFilterChain(that’s why you have<filter-name>springSecurityFilterChain</filter-name>in yourweb.xml) and all requests (/*) are processed by it (by Spring Security).Then you configure Spring Security and give it more specific URL (
/*welcome).It’s like saying:
/*) should be investigated by Spring Security/welcome*principal should haveROLE_USERrole.If your application requires more advanced security processing you can create that filter chain bean by yourself and configure all filters manually.
Example: