Class AclEntryVoter
- java.lang.Object
-
- org.springframework.security.access.vote.AbstractAclVoter
-
- org.springframework.security.acls.AclEntryVoter
-
- All Implemented Interfaces:
AccessDecisionVoter<org.aopalliance.intercept.MethodInvocation>
public class AclEntryVoter extends AbstractAclVoter
Given a domain object instance passed as a method argument, ensures the principal has appropriate permission as indicated by the
AclService.The AclService is used to retrieve the access control list (ACL) permissions associated with a domain object instance for the current Authentication object.
The voter will vote if any
ConfigAttribute.getAttribute()matches theprocessConfigAttribute. The provider will then locate the first method argument of typeAbstractAclVoter.processDomainObjectClass. Assuming that method argument is non-null, the provider will then lookup the ACLs from theAclManagerand ensure the principal isAcl.isGranted(List, List, boolean)when presenting therequirePermissionarray to that method.If the method argument is null, the voter will abstain from voting. If the method argument could not be found, an
AuthorizationServiceExceptionwill be thrown.In practical terms users will typically setup a number of AclEntryVoters. Each will have a different
processDomainObjectClass,processConfigAttributeandrequirePermissioncombination. For example, a small application might employ the following instances of AclEntryVoter:- Process domain object class
BankAccount, configuration attributeVOTE_ACL_BANK_ACCONT_READ, require permissionBasePermission.READ - Process domain object class
BankAccount, configuration attributeVOTE_ACL_BANK_ACCOUNT_WRITE, require permission listBasePermission.WRITEandBasePermission.CREATE(allowing the principal to have either of these two permissions) - Process domain object class
Customer, configuration attributeVOTE_ACL_CUSTOMER_READ, require permissionBasePermission.READ - Process domain object class
Customer, configuration attributeVOTE_ACL_CUSTOMER_WRITE, require permission listBasePermission.WRITEandBasePermission.CREATE
AbstractAclVoter.processDomainObjectClassif bothBankAccountandCustomerhad common parents.If the principal does not have sufficient permissions, the voter will vote to deny access.
All comparisons and prefixes are case sensitive.
-
-
Field Summary
-
Fields inherited from interface org.springframework.security.access.AccessDecisionVoter
ACCESS_ABSTAIN, ACCESS_DENIED, ACCESS_GRANTED
-
-
Constructor Summary
Constructors Constructor Description AclEntryVoter(AclService aclService, java.lang.String processConfigAttribute, Permission[] requirePermission)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringgetInternalMethod()Optionally specifies a method of the domain object that will be used to obtain a contained domain object.protected java.lang.StringgetProcessConfigAttribute()voidsetInternalMethod(java.lang.String internalMethod)voidsetObjectIdentityRetrievalStrategy(ObjectIdentityRetrievalStrategy objectIdentityRetrievalStrategy)voidsetSidRetrievalStrategy(SidRetrievalStrategy sidRetrievalStrategy)booleansupports(ConfigAttribute attribute)Indicates whether thisAccessDecisionVoteris able to vote on the passedConfigAttribute.intvote(Authentication authentication, org.aopalliance.intercept.MethodInvocation object, java.util.Collection<ConfigAttribute> attributes)Indicates whether or not access is granted.-
Methods inherited from class org.springframework.security.access.vote.AbstractAclVoter
getDomainObjectInstance, getProcessDomainObjectClass, setProcessDomainObjectClass, supports
-
-
-
-
Constructor Detail
-
AclEntryVoter
public AclEntryVoter(AclService aclService, java.lang.String processConfigAttribute, Permission[] requirePermission)
-
-
Method Detail
-
getInternalMethod
protected java.lang.String getInternalMethod()
Optionally specifies a method of the domain object that will be used to obtain a contained domain object. That contained domain object will be used for the ACL evaluation. This is useful if a domain object contains a parent that an ACL evaluation should be targeted for, instead of the child domain object (which perhaps is being created and as such does not yet have any ACL permissions)- Returns:
nullto use the domain object, or the name of a method (that requires no arguments) that should be invoked to obtain anObjectwhich will be the domain object used for ACL evaluation
-
setInternalMethod
public void setInternalMethod(java.lang.String internalMethod)
-
getProcessConfigAttribute
protected java.lang.String getProcessConfigAttribute()
-
setObjectIdentityRetrievalStrategy
public void setObjectIdentityRetrievalStrategy(ObjectIdentityRetrievalStrategy objectIdentityRetrievalStrategy)
-
setSidRetrievalStrategy
public void setSidRetrievalStrategy(SidRetrievalStrategy sidRetrievalStrategy)
-
supports
public boolean supports(ConfigAttribute attribute)
Description copied from interface:AccessDecisionVoterIndicates whether thisAccessDecisionVoteris able to vote on the passedConfigAttribute.This allows the
AbstractSecurityInterceptorto check every configuration attribute can be consumed by the configuredAccessDecisionManagerand/orRunAsManagerand/orAfterInvocationManager.- Parameters:
attribute- a configuration attribute that has been configured against theAbstractSecurityInterceptor- Returns:
- true if this
AccessDecisionVotercan support the passed configuration attribute
-
vote
public int vote(Authentication authentication, org.aopalliance.intercept.MethodInvocation object, java.util.Collection<ConfigAttribute> attributes)
Description copied from interface:AccessDecisionVoterIndicates whether or not access is granted.The decision must be affirmative (
ACCESS_GRANTED), negative (ACCESS_DENIED) or theAccessDecisionVotercan abstain (ACCESS_ABSTAIN) from voting. Under no circumstances should implementing classes return any other value. If a weighting of results is desired, this should be handled in a customAccessDecisionManagerinstead.Unless an
AccessDecisionVoteris specifically intended to vote on an access control decision due to a passed method invocation or configuration attribute parameter, it must returnACCESS_ABSTAIN. This prevents the coordinatingAccessDecisionManagerfrom counting votes from thoseAccessDecisionVoters without a legitimate interest in the access control decision.Whilst the secured object (such as a
MethodInvocation) is passed as a parameter to maximise flexibility in making access control decisions, implementing classes should not modify it or cause the represented invocation to take place (for example, by callingMethodInvocation.proceed()).- Parameters:
authentication- the caller making the invocationobject- the secured object being invokedattributes- the configuration attributes associated with the secured object- Returns:
- either
AccessDecisionVoter.ACCESS_GRANTED,AccessDecisionVoter.ACCESS_ABSTAINorAccessDecisionVoter.ACCESS_DENIED
-
-