From a0f3015ac6490ab1a1618881f83a57a4975103c9 Mon Sep 17 00:00:00 2001 From: Luke Taylor Date: Thu, 19 Mar 2009 02:01:24 +0000 Subject: [PATCH] SEC-1086: AccessDecisionManager implementations now log debug messages giving the results returned by each voter polled. --- .../security/vote/AbstractAccessDecisionManager.java | 3 +++ .../org/springframework/security/vote/AffirmativeBased.java | 4 ++++ .../org/springframework/security/vote/ConsensusBased.java | 4 ++++ .../org/springframework/security/vote/UnanimousBased.java | 4 ++++ 4 files changed, 15 insertions(+) diff --git a/core/src/main/java/org/springframework/security/vote/AbstractAccessDecisionManager.java b/core/src/main/java/org/springframework/security/vote/AbstractAccessDecisionManager.java index eb5758903e..e9643c5b06 100644 --- a/core/src/main/java/org/springframework/security/vote/AbstractAccessDecisionManager.java +++ b/core/src/main/java/org/springframework/security/vote/AbstractAccessDecisionManager.java @@ -18,6 +18,8 @@ package org.springframework.security.vote; import java.util.Iterator; import java.util.List; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.springframework.security.AccessDecisionManager; import org.springframework.security.AccessDeniedException; import org.springframework.security.SpringSecurityMessageSource; @@ -39,6 +41,7 @@ import org.springframework.util.Assert; public abstract class AbstractAccessDecisionManager implements AccessDecisionManager, InitializingBean, MessageSourceAware { //~ Instance fields ================================================================================================ + protected final Log logger = LogFactory.getLog(getClass()); private List decisionVoters; diff --git a/core/src/main/java/org/springframework/security/vote/AffirmativeBased.java b/core/src/main/java/org/springframework/security/vote/AffirmativeBased.java index e6773ebd5c..4b5d8f0941 100644 --- a/core/src/main/java/org/springframework/security/vote/AffirmativeBased.java +++ b/core/src/main/java/org/springframework/security/vote/AffirmativeBased.java @@ -48,6 +48,10 @@ public class AffirmativeBased extends AbstractAccessDecisionManager { for (AccessDecisionVoter voter : getDecisionVoters()) { int result = voter.vote(authentication, object, configAttributes); + if (logger.isDebugEnabled()) { + logger.debug("Voter: " + voter + ", returned: " + result); + } + switch (result) { case AccessDecisionVoter.ACCESS_GRANTED: return; diff --git a/core/src/main/java/org/springframework/security/vote/ConsensusBased.java b/core/src/main/java/org/springframework/security/vote/ConsensusBased.java index eca091b066..cf16e1c6a9 100644 --- a/core/src/main/java/org/springframework/security/vote/ConsensusBased.java +++ b/core/src/main/java/org/springframework/security/vote/ConsensusBased.java @@ -60,6 +60,10 @@ public class ConsensusBased extends AbstractAccessDecisionManager { for (AccessDecisionVoter voter : getDecisionVoters()) { int result = voter.vote(authentication, object, configAttributes); + if (logger.isDebugEnabled()) { + logger.debug("Voter: " + voter + ", returned: " + result); + } + switch (result) { case AccessDecisionVoter.ACCESS_GRANTED: grant++; diff --git a/core/src/main/java/org/springframework/security/vote/UnanimousBased.java b/core/src/main/java/org/springframework/security/vote/UnanimousBased.java index fa7fe7375b..0aa349f20c 100644 --- a/core/src/main/java/org/springframework/security/vote/UnanimousBased.java +++ b/core/src/main/java/org/springframework/security/vote/UnanimousBased.java @@ -62,6 +62,10 @@ public class UnanimousBased extends AbstractAccessDecisionManager { for(AccessDecisionVoter voter : getDecisionVoters()) { int result = voter.vote(authentication, object, singleAttributeList); + if (logger.isDebugEnabled()) { + logger.debug("Voter: " + voter + ", returned: " + result); + } + switch (result) { case AccessDecisionVoter.ACCESS_GRANTED: grant++;