01: /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
02: *
03: * Licensed under the Apache License, Version 2.0 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * Unless required by applicable law or agreed to in writing, software
10: * distributed under the License is distributed on an "AS IS" BASIS,
11: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: * See the License for the specific language governing permissions and
13: * limitations under the License.
14: */
15:
16: package org.acegisecurity;
17:
18: import java.util.Iterator;
19:
20: /**
21: * If there is a configuration attribute of "AFTER_INVOCATION_MOCK", modifies the return value to null.
22: *
23: * @author Ben Alex
24: * @version $Id: MockAfterInvocationManager.java 1496 2006-05-23 13:38:33Z benalex $
25: */
26: public class MockAfterInvocationManager implements
27: AfterInvocationManager {
28: //~ Methods ========================================================================================================
29:
30: public Object decide(Authentication authentication, Object object,
31: ConfigAttributeDefinition config, Object returnedObject)
32: throws AccessDeniedException {
33: Iterator iter = config.getConfigAttributes();
34:
35: while (iter.hasNext()) {
36: ConfigAttribute attr = (ConfigAttribute) iter.next();
37:
38: if (this .supports(attr)) {
39: return null;
40: }
41: }
42:
43: // this "after invocation" hasn't got a config attribute asking
44: // for this mock to modify the returned object
45: return returnedObject;
46: }
47:
48: public boolean supports(ConfigAttribute attribute) {
49: if (attribute.getAttribute().equals("AFTER_INVOCATION_MOCK")) {
50: return true;
51: } else {
52: return false;
53: }
54: }
55:
56: public boolean supports(Class clazz) {
57: return true;
58: }
59: }
|