Hello there.
I have been struggling for some time to get to grips with the ACL side of Spring Security 2.
I am currently trying to understand the mask value on AclEntry.
Firstly, I have an object read voter configured like this:
Code:<bean id="aclObjectReadVoter" class="org.springframework.security.vote.AclEntryVoter"> <constructor-arg ref="aclService" /> <constructor-arg value="ACL_OBJECT_READ" /> <constructor-arg> <list> <ref local="administrationPermission" /> <ref local="readPermission" /> </list> </constructor-arg> <property name="processDomainObjectClass" value="org.sample.MySecureClass" /> </bean>
I understand from reading here that a mask value of '3' represents read and write access
So I would have thought that a user whose ACL entry for a particular object was 3 would get a positive result when this voter votes. Unfortunately I cannot see this happening.
So I have been digging into the source code and have come across this in AclImpl.isGranted
From my reading of this I understand that it is doing a direct comparrison (specifically an ==) on the mask of the accessControlEntry's permission, and that of the various permissions that the voter tests (in my case READ (1) and Administration (16) ). This would suggest that the mask does not actually get applied in terms of a bitwise comparrision. Am I missing something, or does this mean that a mask value of 3 will not allow READ?Code:for (int i = 0; i < permission.length; i++) { for (int x = 0; x < sids.length; x++) { // Attempt to find exact match for this permission mask and SID Iterator acesIterator = aces.iterator(); boolean scanNextSid = true; while (acesIterator.hasNext()) { AccessControlEntry ace = (AccessControlEntry) acesIterator.next(); if ((ace.getPermission().getMask() == permission[i].getMask()) && ace.getSid().equals(sids[x])) { // Found a matching ACE, so its authorization decision will prevail if (ace.isGranting()) { // Success if (!administrativeMode) { auditLogger.logIfNeeded(true, ace); } return true; } else { // Failure for this permission, so stop search // We will see if they have a different permission // (this permission is 100% rejected for this SID) if (firstRejection == null) { // Store first rejection for auditing reasons firstRejection = ace; } scanNextSid = false; // helps break the loop break; // exit "aceIterator" while loop } } } if (!scanNextSid) { break; // exit SID for loop (now try next permission) } } }



