Class ConsensusBased
- java.lang.Object
-
- org.springframework.security.access.vote.AbstractAccessDecisionManager
-
- org.springframework.security.access.vote.ConsensusBased
-
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.InitializingBean
,org.springframework.context.MessageSourceAware
,AccessDecisionManager
public class ConsensusBased extends AbstractAccessDecisionManager
Simple concrete implementation ofAccessDecisionManager
that uses a consensus-based approach."Consensus" here means majority-rule (ignoring abstains) rather than unanimous agreement (ignoring abstains). If you require unanimity, please see
UnanimousBased
.
-
-
Field Summary
-
Fields inherited from class org.springframework.security.access.vote.AbstractAccessDecisionManager
logger, messages
-
-
Constructor Summary
Constructors Constructor Description ConsensusBased(java.util.List<AccessDecisionVoter<?>> decisionVoters)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
decide(Authentication authentication, java.lang.Object object, java.util.Collection<ConfigAttribute> configAttributes)
This concrete implementation simply polls all configuredAccessDecisionVoter
s and upon completion determines the consensus of granted against denied responses.boolean
isAllowIfEqualGrantedDeniedDecisions()
void
setAllowIfEqualGrantedDeniedDecisions(boolean allowIfEqualGrantedDeniedDecisions)
-
Methods inherited from class org.springframework.security.access.vote.AbstractAccessDecisionManager
afterPropertiesSet, checkAllowIfAllAbstainDecisions, getDecisionVoters, isAllowIfAllAbstainDecisions, setAllowIfAllAbstainDecisions, setMessageSource, supports, supports
-
-
-
-
Constructor Detail
-
ConsensusBased
public ConsensusBased(java.util.List<AccessDecisionVoter<?>> decisionVoters)
-
-
Method Detail
-
decide
public void decide(Authentication authentication, java.lang.Object object, java.util.Collection<ConfigAttribute> configAttributes) throws AccessDeniedException
This concrete implementation simply polls all configuredAccessDecisionVoter
s and upon completion determines the consensus of granted against denied responses.If there were an equal number of grant and deny votes, the decision will be based on the
isAllowIfEqualGrantedDeniedDecisions()
property (defaults to true).If every
AccessDecisionVoter
abstained from voting, the decision will be based on theAbstractAccessDecisionManager.isAllowIfAllAbstainDecisions()
property (defaults to false).- Parameters:
authentication
- the caller invoking the methodobject
- the secured objectconfigAttributes
- the configuration attributes associated with the method being invoked- Throws:
AccessDeniedException
- if access is denied
-
isAllowIfEqualGrantedDeniedDecisions
public boolean isAllowIfEqualGrantedDeniedDecisions()
-
setAllowIfEqualGrantedDeniedDecisions
public void setAllowIfEqualGrantedDeniedDecisions(boolean allowIfEqualGrantedDeniedDecisions)
-
-