소스 검색

Modified to support changes to interface.

Ben Alex 21 년 전
부모
커밋
8c69eb6abb
1개의 변경된 파일16개의 추가작업 그리고 1개의 파일을 삭제
  1. 16 1
      samples/contacts/src/main/java/sample/contact/ContactSecurityVoter.java

+ 16 - 1
samples/contacts/src/main/java/sample/contact/ContactSecurityVoter.java

@@ -55,8 +55,23 @@ public class ContactSecurityVoter implements AccessDecisionVoter {
         }
     }
 
-    public int vote(Authentication authentication, MethodInvocation invocation,
+    public boolean supports(Class clazz) {
+        if (MethodInvocation.class.isAssignableFrom(clazz)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public int vote(Authentication authentication, Object object,
         ConfigAttributeDefinition config) {
+        if ((object == null) || !this.supports(object.getClass())) {
+            throw new IllegalArgumentException(
+                "Does not support the presented Object type");
+        }
+
+        MethodInvocation invocation = (MethodInvocation) object;
+
         int result = ACCESS_ABSTAIN;
         Iterator iter = config.getConfigAttributes();