I'm using Spring 5.1 and Spring security 4.2. I'm configured access rules using an XML file. My question is, how do I write an intercept rule (access control to a URL) based on a property in the Spring security context? That is, I have a variable
productList
in the security context that is of type java.util.ArrayList. I would like to restrict access to a URL if this list is empty or null. How do I write this? I have
<http name="defaultSecurity" security-context-repository-ref="myContextRepository"
auto-config="false" use-expressions="true" authentication-manager-ref="authenticationManager"
entry-point-ref="loginUrlAuthenticationEntryPoint">
...
<intercept-url pattern="/myurl" access="length(principal.productList) > 0" />
...
</http>
but of course, teh above
length(principal.productList) > 0
expression is completely wrong. Is there a right way to write it?