Most Permission objects also include an "actions" list that
tells the actions that are permitted for the object. For example,
for a java.io.FilePermission object, the permission name is
the pathname of a file (or directory), and the actions list
(such as "read, write") specifies which actions are granted for the
specified file (or for files in the specified directory).
The actions list is optional for Permission objects, such as
java.lang.RuntimePermission,
that don't need such a list; you either have the named permission (such
as "system.exit") or you don't.
An important method that must be implemented by each subclass is
the implies method to compare Permissions. Basically,
"permission p1 implies permission p2" means that
if one is granted permission p1, one is naturally granted permission p2.
Thus, this is not an equality test, but rather more of a
subset test.
Permission objects are similar to String objects
in that they are immutable once they have been created. Subclasses should not
provide methods that can change the state of a permission
once it has been created.
Permissions, PermissionCollection
| Modifier and Type | Field and Description |
|---|---|
| private final String | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| public | Permission(String
name of the name)Permission object being created.Constructs a permission with the specified name. |
| Modifier and Type | Method and Description |
|---|---|
| public void | checkGuard(Object
the object being guarded (currently ignored). object)Implements java. Implements the guard interface for a permission. |
| public abstract boolean | Returns: true if both Permission objects are equivalent.the object we are testing for equality with this object. obj)Overrides java. Checks two |
| public abstract String | |
| public final String | |
| public abstract int | Returns: a hash code value for this object.Overrides java. Returns the hash code value for this |
| public abstract boolean | Returns: true if the specified permission is implied by this
object, false if not.the permission to check against. permission)Checks if the specified permission's actions are "implied by" this object's actions. |
| public PermissionCollection | Returns: a newPermissionCollection object for this type of
Permission, or null if one is not defined.Returns an empty |
| public String | Returns: information about thisPermission.Overrides java. Returns a string describing this |
| name | back to summary |
|---|---|
| private final String name | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID
| |
| Permission | back to summary |
|---|---|
| public Permission(String name) Constructs a permission with the specified name.
| |
| checkGuard | back to summary |
|---|---|
| public void checkGuard(Object object) throws SecurityException Implements java. Implements the guard interface for a permission.
Returns silently if access is granted. Otherwise, throws
a API Note This method originally threw a
| |
| equals | back to summary |
|---|---|
| public abstract boolean equals(Object obj) Overrides java. Checks two
Do not use the | |
| getActions | back to summary |
|---|---|
| public abstract String getActions() Returns the actions as a perm1 = new FilePermission(p1,"read,write"); perm2 = new FilePermission(p2,"write,read");both return "read,write" when the getActions method is invoked.
| |
| getName | back to summary |
|---|---|
| public final String getName() Returns the name of this
| |
| hashCode | back to summary |
|---|---|
| public abstract int hashCode() Overrides java. Returns the hash code value for this
The required
| |
| implies | back to summary |
|---|---|
| public abstract boolean implies(Permission permission) Checks if the specified permission's actions are "implied by" this object's actions.
This must be implemented by subclasses of
| |
| newPermissionCollection | back to summary |
|---|---|
| public PermissionCollection newPermissionCollection() Returns an empty
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a string describing this
| |