From 07e203725111fef04b518e8e5f3452097e1d5edb Mon Sep 17 00:00:00 2001 From: Ben Alex Date: Fri, 3 Dec 2004 06:43:17 +0000 Subject: [PATCH] Find target domain object argument in a manner that works if nulls are presented for the domain object argument. --- .../vote/BasicAclEntryVoter.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/core/src/main/java/org/acegisecurity/vote/BasicAclEntryVoter.java b/core/src/main/java/org/acegisecurity/vote/BasicAclEntryVoter.java index d41f8ddd0e..bf649dcc68 100644 --- a/core/src/main/java/org/acegisecurity/vote/BasicAclEntryVoter.java +++ b/core/src/main/java/org/acegisecurity/vote/BasicAclEntryVoter.java @@ -330,22 +330,20 @@ public class BasicAclEntryVoter implements AccessDecisionVoter, } private Object getDomainObjectInstance(Object secureObject) { - if (secureObject instanceof MethodInvocation) { - MethodInvocation invocation = (MethodInvocation) secureObject; + MethodInvocation invocation = (MethodInvocation) secureObject; - for (int i = 0; i < invocation.getArguments().length; i++) { - Class argClass = invocation.getArguments()[i].getClass(); + // Check if this MethodInvocation provides the required argument + Method method = invocation.getMethod(); + Class[] params = method.getParameterTypes(); - if (processDomainObjectClass.isAssignableFrom(argClass)) { - return invocation.getArguments()[i]; - } + for (int i = 0; i < params.length; i++) { + if (processDomainObjectClass.isAssignableFrom(params[i])) { + return invocation.getArguments()[i]; } - - throw new AuthorizationServiceException("MethodInvocation: " - + invocation + " did not provide any argument of type: " - + processDomainObjectClass); } - return null; // should never happen + throw new AuthorizationServiceException("MethodInvocation: " + + invocation + " did not provide any argument of type: " + + processDomainObjectClass); } }