1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.astrogrid.community.common.policy.data ;
19
20 public class PolicyPermission
21 {
22 /***
23 * Status code for permission granted.
24 *
25 */
26 public static final int STATUS_PERMISSION_GRANTED = 0xFF ;
27
28 /***
29 * Status code for no permission.
30 *
31 */
32 public static final int STATUS_PERMISSION_UNKNOWN = 0x00 ;
33
34 /***
35 * Status code for permission revoked.
36 *
37 */
38 public static final int STATUS_PERMISSION_REVOKED = 0x01 ;
39
40 /***
41 * Status code for credentials invalid.
42 *
43 */
44 public static final int STATUS_CREDENTIALS_INVALID = 0x02 ;
45
46 /***
47 * The XML status code for permission granted.
48 *
49 */
50 public static final String XML_PERMISSION_GRANTED = "GRANT" ;
51
52 /***
53 * The XML status code no permission.
54 *
55 */
56 public static final String XML_PERMISSION_UNKNOWN = "UNKNOWN" ;
57
58 /***
59 * The XML status code for permission revoked.
60 *
61 */
62 public static final String XML_PERMISSION_REVOKED = "REVOKED" ;
63
64 /***
65 * The XML status code for credentials invalid.
66 *
67 */
68 public static final String XML_CREDENTIALS_INVALID = "INVALID" ;
69
70 /***
71 * The reason text for permission unknown.
72 *
73 */
74 public static final String REASON_PERMISSION_UNKNOWN = "Permissions unknown" ;
75
76 /***
77 * The reason text for no permission set.
78 *
79 */
80 public static final String REASON_NO_PERMISSION = "No permissions set" ;
81
82 /***
83 * The reason text for invalid credentials.
84 *
85 */
86 public static final String REASON_CREDENTIALS_INVALID = "Credentials invalid" ;
87
88
89 /***
90 * Public constructor.
91 *
92 */
93 public PolicyPermission()
94 {
95 }
96
97 /***
98 * Public constructor.
99 *
100 */
101 public PolicyPermission(String resource, String group, String action)
102 {
103 this.group = group ;
104 this.action = action ;
105 this.resource = resource ;
106 this.status = STATUS_PERMISSION_UNKNOWN ;
107 this.reason = REASON_PERMISSION_UNKNOWN ;
108 }
109
110 /***
111 * Our Group ident.
112 *
113 */
114 private String group ;
115
116 /***
117 * Access to our Group ident.
118 *
119 */
120 public String getGroup()
121 {
122 return this.group ;
123 }
124
125 /***
126 * Access to our Group ident.
127 *
128 */
129 public void setGroup(String value)
130 {
131 this.group = value ;
132 }
133
134 /***
135 * Our Resource ident.
136 *
137 */
138 private String resource ;
139
140 /***
141 * Access to our Resource ident.
142 *
143 */
144 public String getResource()
145 {
146 return this.resource ;
147 }
148
149 /***
150 * Access to our Resource ident.
151 *
152 */
153 public void setResource(String value)
154 {
155 this.resource = value ;
156 }
157
158 /***
159 * The allowed action.
160 *
161 */
162 private String action ;
163
164 /***
165 * Access to the action.
166 *
167 */
168 public String getAction()
169 {
170 return this.action ;
171 }
172
173 /***
174 * Access to the action.
175 *
176 */
177 public void setAction(String value)
178 {
179 this.action = value ;
180 }
181
182 /***
183 * The permission status.
184 *
185 */
186 private int status ;
187
188 /***
189 * Access to the status code.
190 *
191 */
192 public int getStatus()
193 {
194 return this.status ;
195 }
196
197 /***
198 * Set the status code to a specific value.
199 *
200 */
201 public void setStatus(int value)
202 {
203 this.status = value ;
204 }
205
206 /***
207 * Set the status using a String from an XML attribute.
208 *
209 */
210 public void setStatus(String value)
211 {
212
213
214 setStatus(STATUS_PERMISSION_UNKNOWN) ;
215
216
217 if (XML_PERMISSION_GRANTED.equals(value))
218 {
219 setStatus(STATUS_PERMISSION_GRANTED) ;
220 }
221 if (XML_PERMISSION_UNKNOWN.equals(value))
222 {
223 setStatus(STATUS_PERMISSION_UNKNOWN) ;
224 }
225 if (XML_PERMISSION_REVOKED.equals(value))
226 {
227 setStatus(STATUS_PERMISSION_REVOKED) ;
228 }
229 if (XML_CREDENTIALS_INVALID.equals(value))
230 {
231 setStatus(STATUS_CREDENTIALS_INVALID) ;
232 }
233 }
234
235 /***
236 * Check if the status is granteed.
237 *
238 */
239 public boolean isValid()
240 {
241 return (STATUS_PERMISSION_GRANTED == this.status) ;
242 }
243
244 /***
245 * The status reason, explains status.
246 *
247 */
248 private String reason ;
249
250 /***
251 * Access to the reason.
252 *
253 */
254 public String getReason()
255 {
256 return this.reason ;
257 }
258
259 /***
260 * Access to the reason.
261 *
262 */
263 public void setReason(String value)
264 {
265 this.reason = value ;
266 }
267 }