I'm using Spring Security to secure a webapp. The URLs are secured like this:
<security:http entry-point-ref="authenticationEntryPoint">
<security:intercept-url pattern="/" access="ROLE_ANONYMOUS" />
<security:intercept-url pattern="/assets/**/*" access="ROLE_ANONYMOUS" />
...
<security:intercept-url pattern="/**" access="ROLE_USER" />
<security:anonymous granted-authority="ROLE_ANONYMOUS" />
</security:http>
I have a filter that needs to redirect the user to a special page under certain circumstances. However, that page requires images and CSS files in the assets directory which will unfortunately also be redirected to that special page. I don't want the filter to manually check against each URL pattern because my actual URL configuration is much longer, and I also want to allow other pages.
Is there a way to determine from the filter for a given page what roles are required? I could then choose not to redirect if ROLE_ANONYMOUS is not required.