Issue Details (XML | Word | Printable)

Key: SEC-908
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Ben Alex
Reporter: Jim Wunderlich
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Spring Security

BasePermission.buildFromName(name) does not find static permission in class

Created: 06/Jul/08 10:40 PM   Updated: 30/Sep/08 08:09 AM
Component/s: ACLs
Affects Version/s: 2.0.3
Fix Version/s: 2.0.4

Time Tracking:
Not Specified

Environment: spring 2.0.8, tomcat 5.5.20, java 1.6.0_05


 Description  « Hide
I am converting from Acegi 1.0.3.

This code:

     BasePermission.buildFromName(name)

With name having the value "WRITE" (a permission within BasePermission) throws this assertion error:

java.lang.IllegalArgumentException: Unknown permission 'WRITE'
        at org.springframework.util.Assert.isTrue(Assert.java:65)
        at org.springframework.security.acls.domain.DefaultPermissionFactory.bui
ldFromName(DefaultPermissionFactory.java:108)
        at org.springframework.security.acls.domain.AbstractRegisteredPermission
.buildFromName(AbstractRegisteredPermission.java:33)

After a little debugging, the registeredPermissionsByName Map is in fact empty.

I could be wrong, but I believe the problem is that java will call the method in the superclass of BasePermission and not execute the static initializer. I could get around this problem by hacking an inner class to use the BasePermission constructor before using this method (which forces the static initializer to execute).


 All   Comments   Work Log   Change History   FishEye   Builds      Sort Order: Ascending order - Click to sort in descending order
Jim Wunderlich added a comment - 07/Jul/08 09:23 AM
Of course, an easier hack to get around the problem was to just add this statement before the buildFromName():

             Object o = BasePermission.WRITE;

That also forces the static initializer to execute.

Ben Alex added a comment - 04/Sep/08 11:36 PM
Add a PermissionTests.basePermissionTest() and reproduced the error.

Removed the AbstractRegisteredPermission superclass, relocating its methods to BasePermission. This avoid superclass static initialization failures.

Tests all pass. Checked in as revision 3269.