@PreAuthorize, ACLs, spEL, and missing debug info
I am trying to use spring-security 3.0.5 acl features and have it working for post-filtering collections and arrays.
But I am unable to get it working when selecting a single object because of missing debug symbol information.
I've read the Peter Mularien book -- Chapter 7, about setting up and using ACLs -- and I know I need to compile the necessary debug info into the classes but can't seem to find out how to get eclipse to do it.
Here is the annotation on the interface method signature:
@PreAuthorize("hasAnyRole('ROLE_SUPER_USER','ROLE_ SYSTEM_ADMIN') and hasPermission(#id, 'com.xyz.db.domain.impl.XyzConfigImpl', 'read')")
public XyzConfig get(Long id);
Here is the warning:
[110224-19:22:25.155 WARN ] o.s.s.a.e.m.MethodSecurityEvaluationContext - Unable to resolve method parameter names for method: public final com.xyz.db.domain.XyzConfig $Proxy77.get(java.lang.Long). Debug symbol information is required if you are using parameter names in expressions.
Here is the exception:
Exception in thread "main" java.lang.IllegalArgumentException: identifier required
at org.springframework.util.Assert.notNull(Assert.jav a:112)
at org.springframework.security.acls.domain.ObjectIde ntityImpl.<init>(ObjectIdentityImpl.java:43)
at org.springframework.security.acls.domain.ObjectIde ntityRetrievalStrategyImpl.createObjectIdentity(Ob jectIdentityRetrievalStrategyImpl.java:38)
at org.springframework.security.acls.AclPermissionEva luator.hasPermission(AclPermissionEvaluator.java:6 3)
at org.springframework.security.access.expression.met hod.MethodSecurityExpressionRoot.hasPermission(Met hodSecurityExpressionRoot.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.expression.spel.support.Reflec tiveMethodExecutor.execute(ReflectiveMethodExecuto r.java:69)
I am using eclipse 3.6.1 to compile and run this spring/hibernate based java application (not ant,, with a javac -g compiler option).
Is using parameter names in expressions not possible when compiling with eclipse, instead of and ant build file (using the javac.debug=on option)?
Could the problem be related to trying to find a param name in a proxy?
Please help! I'm am really keen to use this feature.
Thanks,
Stan
Fixed -- moved annotations from interface to class
Thanks... I had already set those compiler settings, but that did not fix the problem.
What did fix it was moving the annotation...
@PreAuthorize("hasAnyRole('ROLE_SUPER_USER','ROLE_ SYSTEM_ADMIN') and hasPermission(#id, 'com.xyz.db.domain.impl.XyzConfigImpl', 'read')")
public XyzConfig get(Long id);
...from the interface to the class. I would prefer to put the method security annotation on the interfaces, but no big deal. I can move them back when this problem is fixed in a future release.
Note: it is only the presence of the expression's method parameter which prevents me from annotating the interface.
I am using AspectJ proxying.
The CGLIB jar is not on the classpath.
My parent spring config file contains:
<aop:aspectj-autoproxy proxy-target-class="false"/>
( proxy-target-class="false" is the default... I was experimenting with proxy-target-class="true" )