188 |
} |
} |
189 |
}; |
}; |
190 |
} |
} |
|
} // class Permissions |
|
|
|
|
|
/** |
|
|
* Implements the permission collection for all permissions without one of |
|
|
* their own, and obeys serialization of JDK. |
|
|
* |
|
|
* @author Eric Blake <ebb9@email.byu.edu> |
|
|
*/ |
|
|
class PermissionsHash extends PermissionCollection |
|
|
{ |
|
|
/** |
|
|
* Compatible with JDK 1.1+. |
|
|
*/ |
|
|
private static final long serialVersionUID = -8491988220802933440L; |
|
191 |
|
|
192 |
/** |
/** |
193 |
* Hashtable where we store permissions. |
* Implements the permission collection for all permissions without one of |
194 |
|
* their own, and obeys serialization of JDK. |
195 |
* |
* |
196 |
* @serial the stored permissions, both as key and value |
* @author Eric Blake <ebb9@email.byu.edu> |
197 |
*/ |
*/ |
198 |
private final Hashtable perms = new Hashtable(); |
private static final class PermissionsHash extends PermissionCollection |
|
|
|
|
/** |
|
|
* Add a permission. We don't need to check for read-only, as this |
|
|
* collection is never exposed outside of Permissions, which has already |
|
|
* done that check. |
|
|
* |
|
|
* @param perm the permission to add |
|
|
*/ |
|
|
public void add(Permission perm) |
|
199 |
{ |
{ |
200 |
perms.put(perm, perm); |
/** |
201 |
} |
* Compatible with JDK 1.1+. |
202 |
|
*/ |
203 |
|
private static final long serialVersionUID = -8491988220802933440L; |
204 |
|
|
205 |
/** |
/** |
206 |
* Returns true if perm is in the collection. |
* Hashtable where we store permissions. |
207 |
* |
* |
208 |
* @param perm the permission to check |
* @serial the stored permissions, both as key and value |
209 |
* @return true if it is implied |
*/ |
210 |
*/ |
private final Hashtable perms = new Hashtable(); |
|
public boolean implies(Permission perm) |
|
|
{ |
|
|
return perms.get(perm) != null; |
|
|
} |
|
211 |
|
|
212 |
/** |
/** |
213 |
* Return the elements. |
* Add a permission. We don't need to check for read-only, as this |
214 |
* |
* collection is never exposed outside of Permissions, which has already |
215 |
* @return the elements |
* done that check. |
216 |
*/ |
* |
217 |
public Enumeration elements() |
* @param perm the permission to add |
218 |
{ |
*/ |
219 |
return perms.elements(); |
public void add(Permission perm) |
220 |
} |
{ |
221 |
|
perms.put(perm, perm); |
222 |
|
} |
223 |
|
|
224 |
|
/** |
225 |
|
* Returns true if perm is in the collection. |
226 |
|
* |
227 |
|
* @param perm the permission to check |
228 |
|
* @return true if it is implied |
229 |
|
*/ |
230 |
|
public boolean implies(Permission perm) |
231 |
|
{ |
232 |
|
return perms.get(perm) != null; |
233 |
|
} |
234 |
|
|
235 |
|
/** |
236 |
|
* Return the elements. |
237 |
|
* |
238 |
|
* @return the elements |
239 |
|
*/ |
240 |
|
public Enumeration elements() |
241 |
|
{ |
242 |
|
return perms.elements(); |
243 |
|
} |
244 |
|
} // class PermissionsHash |
245 |
} // class Permissions |
} // class Permissions |