1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.acegisecurity;
17
18 import org.acegisecurity.acl.AclEntry;
19 import org.acegisecurity.acl.AclManager;
20
21
22 /***
23 * Returns the indicated collection of <code>AclEntry</code>s when the given
24 * <code>Authentication</code> principal is presented for the indicated domain
25 * <code>Object</code> instance.
26 *
27 * @author Ben Alex
28 * @version $Id: MockAclManager.java,v 1.2 2005/11/17 00:55:47 benalex Exp $
29 */
30 public class MockAclManager implements AclManager {
31
32
33 private Object object;
34 private Object principal;
35 private AclEntry[] acls;
36
37
38
39 public MockAclManager(Object domainObject, Object principal, AclEntry[] acls) {
40 this.object = domainObject;
41 this.principal = principal;
42 this.acls = acls;
43 }
44
45 private MockAclManager() {}
46
47
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 }