|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| package org.acegisecurity.acl.basic; |
|
17 |
| |
|
18 |
| import org.apache.commons.logging.Log; |
|
19 |
| import org.apache.commons.logging.LogFactory; |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| public class SimpleAclEntry extends AbstractBasicAclEntry { |
|
29 |
| |
|
30 |
| |
|
31 |
| private static final Log logger = LogFactory.getLog(SimpleAclEntry.class); |
|
32 |
| |
|
33 |
| |
|
34 |
| public static final int NOTHING = 0; |
|
35 |
| public static final int ADMINISTRATION = (int) Math.pow(2, 0); |
|
36 |
| public static final int READ = (int) Math.pow(2, 1); |
|
37 |
| public static final int WRITE = (int) Math.pow(2, 2); |
|
38 |
| public static final int CREATE = (int) Math.pow(2, 3); |
|
39 |
| public static final int DELETE = (int) Math.pow(2, 4); |
|
40 |
| |
|
41 |
| |
|
42 |
| public static final int READ_WRITE_CREATE_DELETE = READ | WRITE | CREATE |
|
43 |
| | DELETE; |
|
44 |
| public static final int READ_WRITE_CREATE = READ | WRITE | CREATE; |
|
45 |
| public static final int READ_WRITE = READ | WRITE; |
|
46 |
| public static final int READ_WRITE_DELETE = READ | WRITE | DELETE; |
|
47 |
| |
|
48 |
| |
|
49 |
| private static final int[] validPermissions = {NOTHING, ADMINISTRATION, READ, WRITE, CREATE, DELETE, READ_WRITE_CREATE_DELETE, READ_WRITE_CREATE, READ_WRITE, READ_WRITE_DELETE}; |
|
50 |
| |
|
51 |
| |
|
52 |
| |
|
53 |
| |
|
54 |
| |
|
55 |
| |
|
56 |
| |
|
57 |
| |
|
58 |
| |
|
59 |
| |
|
60 |
| |
|
61 |
30
| public SimpleAclEntry() {
|
|
62 |
30
| super();
|
|
63 |
| } |
|
64 |
| |
|
65 |
133
| public SimpleAclEntry(Object recipient,
|
|
66 |
| AclObjectIdentity aclObjectIdentity, |
|
67 |
| AclObjectIdentity aclObjectParentIdentity, int mask) { |
|
68 |
133
| super(recipient, aclObjectIdentity, aclObjectParentIdentity, mask);
|
|
69 |
| } |
|
70 |
| |
|
71 |
| |
|
72 |
| |
|
73 |
163
| public int[] getValidPermissions() {
|
|
74 |
163
| return validPermissions;
|
|
75 |
| } |
|
76 |
| |
|
77 |
6
| public String printPermissionsBlock(int i) {
|
|
78 |
6
| StringBuffer sb = new StringBuffer();
|
|
79 |
| |
|
80 |
6
| if (isPermitted(i, ADMINISTRATION)) {
|
|
81 |
1
| sb.append('A');
|
|
82 |
| } else { |
|
83 |
5
| sb.append('-');
|
|
84 |
| } |
|
85 |
| |
|
86 |
6
| if (isPermitted(i, READ)) {
|
|
87 |
2
| sb.append('R');
|
|
88 |
| } else { |
|
89 |
4
| sb.append('-');
|
|
90 |
| } |
|
91 |
| |
|
92 |
6
| if (isPermitted(i, WRITE)) {
|
|
93 |
2
| sb.append('W');
|
|
94 |
| } else { |
|
95 |
4
| sb.append('-');
|
|
96 |
| } |
|
97 |
| |
|
98 |
6
| if (isPermitted(i, CREATE)) {
|
|
99 |
2
| sb.append('C');
|
|
100 |
| } else { |
|
101 |
4
| sb.append('-');
|
|
102 |
| } |
|
103 |
| |
|
104 |
6
| if (isPermitted(i, DELETE)) {
|
|
105 |
1
| sb.append('D');
|
|
106 |
| } else { |
|
107 |
5
| sb.append('-');
|
|
108 |
| } |
|
109 |
| |
|
110 |
6
| return sb.toString();
|
|
111 |
| } |
|
112 |
| } |