I’m using Spring Security 3.0.7
How can I get with java code the “access” attributes of the “patterns” that I have defined in the <intercept-url> elements of my security configuration file?
I need to get them in my custom session management filter, so that if the requested URL has an ANONYMOUS access required, I skip the filter and don’t check the session timeout.
Now I’m doing it “manually”, by comparing the requested URL with those patterns I know they have an ANONYMOUS access required. It works, but it’s not a good solution because if I change the xml config file, I have to change the java code.
Thank you in advance.
I’ve found the solution. If someone’s interested I explain it here.
I added the following Java code to the doFilter method in my session management filter, for checking if the user (anonymous user in this case) is allowed to access the requested page:
The webPrivilegeEvaluator is a property of the session management filter that I inject in the xml config file:
And the bean that this property references is:
Finally, the filterSecurityInterceptor has the intercept-url elements with the patterns and access required for them (you don’t put these intercept-url in the http element of the NameSpace, just put them here):
This filter has to be declared as the last one of the filter chain, this way:
NOTE: I’ve intentionally omitted the declarations of other beans in order to not make this answer too large.