Given a domain object instance passed as a method argument, ensures the principal has appropriate permission
as defined by the
AclManager .
The AclManager is used to retrieve the access control list (ACL) permissions associated with a
domain object instance for the current Authentication object. This class is designed to process
AclEntry s that are subclasses of
org.acegisecurity.acl.basic.BasicAclEntry only. Generally these are
obtained by using the
org.acegisecurity.acl.basic.BasicAclProvider .
The voter will vote if any
ConfigAttribute.getAttribute matches the
BasicAclEntryVoter.processConfigAttribute . The provider will then locate the first method argument of type
BasicAclEntryVoter.processDomainObjectClass . Assuming that method argument is non-null, the provider will then lookup the ACLs from
the AclManager and ensure the principal is
org.acegisecurity.acl.basic.BasicAclEntry.isPermitted(int) for at least one of the
BasicAclEntryVoter.requirePermission s.
If the method argument is null , the voter will abstain from voting. If the method argument
could not be found, an
org.acegisecurity.AuthorizationServiceException will be thrown.
In practical terms users will typically setup a number of BasicAclEntryVoter s. Each will have a
different
BasicAclEntryVoter.processDomainObjectClass ,
BasicAclEntryVoter.processConfigAttribute and
BasicAclEntryVoter.requirePermission combination. For example, a small application might employ the following instances of
BasicAclEntryVoter :
- Process domain object class
BankAccount , configuration attribute
VOTE_ACL_BANK_ACCONT_READ , require permission SimpleAclEntry.READ
- Process domain object class
BankAccount , configuration attribute
VOTE_ACL_BANK_ACCOUNT_WRITE , require permission list SimpleAclEntry.WRITE and
SimpleAclEntry.CREATE (allowing the principal to have either of these two permissions
- Process domain object class
Customer , configuration attribute
VOTE_ACL_CUSTOMER_READ , require permission SimpleAclEntry.READ
- Process domain object class
Customer , configuration attribute
VOTE_ACL_CUSTOMER_WRITE , require permission list SimpleAclEntry.WRITE and
SimpleAclEntry.CREATE
Alternatively, you could have used a common superclass or interface for the
BasicAclEntryVoter.processDomainObjectClass if both BankAccount and Customer had common parents.
If the principal does not have sufficient permissions, the voter will vote to deny access.
The AclManager is allowed to return any implementations of AclEntry it wishes.
However, this provider will only be able to validate against AbstractBasicAclEntry s, and thus a vote
to deny access will be made if no AclEntry is of type AbstractBasicAclEntry .
All comparisons and prefixes are case sensitive.
author: Ben Alex version: $Id: BasicAclEntryVoter.java 1766 2006-11-26 04:47:43Z benalex $ |