java.security
public abstract class Permission extends Object implements Guard, Serializable
The most important method in this class is implies
. This
checks whether if one has this permission, then the specified
permission is also implied. As a conceptual example, consider the
permissions "Read All Files" and "Read File foo". The permission
"Read All Files" implies that the caller has permission to read the
file foo.
Permission
's must be immutable - do not change their
state after creation.
Permissions
,
PermissionCollection
,
Serialized FormConstructor and Description |
---|
Permission(String name)
Create an instance with the specified name.
|
Modifier and Type | Method and Description |
---|---|
void |
checkGuard(Object obj)
This method implements the
Guard interface for this class. |
abstract boolean |
equals(Object obj)
Check to see if this object equals obj.
|
abstract String |
getActions()
This method returns the list of actions for this
Permission
as a String . |
String |
getName()
Get the name of this
Permission . |
abstract int |
hashCode()
This method returns a hash code for this
Permission . |
abstract boolean |
implies(Permission perm)
This method tests whether this
Permission implies that the
specified Permission is also granted. |
PermissionCollection |
newPermissionCollection()
This method returns an empty
PermissionCollection object
that can store permissions of this type, or null if no
such collection is defined. |
String |
toString()
This method returns a
String representation of this
Permission object. |
public Permission(String name)
name
- the permission namepublic void checkGuard(Object obj)
Guard
interface for this class.
It calls the checkPermission
method in
SecurityManager
with this Permission
as its
argument. This method returns silently if the security check succeeds
or throws an exception if it fails.checkGuard
in interface Guard
obj
- the Object
being guarded - ignored by this classSecurityException
- if the security check failsGuardedObject
,
SecurityManager.checkPermission(Permission)
public abstract boolean implies(Permission perm)
Permission
implies that the
specified Permission
is also granted.perm
- the Permission
to test againstpublic abstract boolean equals(Object obj)
implies
, rather
than equals
, when making access control decisions.equals
in class Object
obj
- the object to compare toObject.hashCode()
public abstract int hashCode()
Permission
. It
must satisfy the contract of Object.hashCode
: it must be
the same for all objects that equals considers to be the same.hashCode
in class Object
Object.equals(Object)
,
System.identityHashCode(Object)
public abstract String getActions()
Permission
as a String
. The string should be in canonical order, for
example, both new FilePermission(f, "write,read")
and
new FilePermission(f, "read,write")
have the action list
"read,write".Permission
public PermissionCollection newPermissionCollection()
PermissionCollection
object
that can store permissions of this type, or null
if no
such collection is defined. Subclasses must override this to provide
an appropriate collection when one is needed to accurately calculate
implies
.PermissionCollection
public String toString()
String
representation of this
Permission
object. This is in the format:
'(' + getClass().getName() + ' ' + getName() + ' ' + getActions
+ ')'
.toString
in class Object
String
Object.getClass()
,
Object.hashCode()
,
Class.getName()
,
Integer.toHexString(int)