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 org.acegisecurity.acl.AclEntry;
19: import org.acegisecurity.acl.AclManager;
20:
21: /**
22: * Returns the indicated collection of <code>AclEntry</code>s when the given <code>Authentication</code> principal
23: * is presented for the indicated domain <code>Object</code> instance.
24: *
25: * @author Ben Alex
26: * @version $Id: MockAclManager.java 1496 2006-05-23 13:38:33Z benalex $
27: */
28: public class MockAclManager implements AclManager {
29: //~ Instance fields ================================================================================================
30:
31: private Object object;
32: private Object principal;
33: private AclEntry[] acls;
34:
35: //~ Constructors ===================================================================================================
36:
37: public MockAclManager(Object domainObject, Object principal,
38: AclEntry[] acls) {
39: this .object = domainObject;
40: this .principal = principal;
41: this .acls = acls;
42: }
43:
44: private MockAclManager() {
45: }
46:
47: //~ Methods ========================================================================================================
48:
49: public AclEntry[] getAcls(Object domainInstance,
50: Authentication authentication) {
51: if (domainInstance.equals(object)
52: && authentication.getPrincipal().equals(principal)) {
53: return acls;
54: } else {
55: return null;
56: }
57: }
58:
59: public AclEntry[] getAcls(Object domainInstance) {
60: if (domainInstance.equals(object)) {
61: return acls;
62: } else {
63: return null;
64: }
65: }
66: }
|