public abstract class

Permission

extends Object
implements Serializable Guard
java.lang.Object
   ↳ java.security.Permission
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Permission is the common base class of all permissions that participate in the access control security framework around AccessController and AccessControlContext. A permission constitutes of a name and associated actions.

Summary

Public Constructors
Permission(String name)
Constructs a new instance of Permission with its name.
Public Methods
void checkGuard(Object obj)
Invokes checkPermission(Permission) with this permission as its argument.
abstract boolean equals(Object obj)
Compares the specified object with this Permission for equality and returns true if the specified object is equal, false otherwise.
abstract String getActions()
Returns a comma separated string identifying the actions associated with this permission.
final String getName()
Returns the name of this permission.
abstract int hashCode()
Returns the hash code value for this Permission.
abstract boolean implies(Permission permission)
Indicates whether the specified permission is implied by this permission.
PermissionCollection newPermissionCollection()
Returns a specific PermissionCollection container for permissions of this type.
String toString()
Returns a string containing a concise, human-readable description of the this Permission including its name and its actions.
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.security.Guard

Public Constructors

public Permission (String name)

Constructs a new instance of Permission with its name.

Parameters
name the name of the permission.

Public Methods

public void checkGuard (Object obj)

Invokes checkPermission(Permission) with this permission as its argument. This method implements the Guard interface.

Parameters
obj as specified in checkGuard(Object) but ignored in this implementation.
Throws
SecurityException if this permission is not granted.

public abstract boolean equals (Object obj)

Compares the specified object with this Permission for equality and returns true if the specified object is equal, false otherwise.

The implies(Permission) method should be used for making access control checks.

Parameters
obj object to be compared for equality with this Permission.
Returns
  • true if the specified object is equal to this Permission, otherwise false.

public abstract String getActions ()

Returns a comma separated string identifying the actions associated with this permission. The returned actions are in canonical form. For example:

 sp0 = new SocketPermission("www.google.com", "connect,resolve")
 sp1 = new SocketPermission("www.google.com", "resolve,connect")
 sp0.getActions().equals(sp1.getActions()) //yields true
 
Both permissions return "connect,resolve" (in that order) if #getActions() is invoked. Returns an empty String, if no actions are associated with this permission.

Returns
  • the actions associated with this permission or an empty string if no actions are associated with this permission.

public final String getName ()

Returns the name of this permission.

Returns
  • the name of this permission.

public abstract int hashCode ()

Returns the hash code value for this Permission. Returns the same hash code for Permissions that are equal to each other as required by the general contract of hashCode().

Returns
  • the hash code value for this Permission.

public abstract boolean implies (Permission permission)

Indicates whether the specified permission is implied by this permission. The AccessController uses this method to check whether permission protected access is allowed with the present policy.

Parameters
permission the permission to check against this permission.
Returns
  • true if the specified permission is implied by this permission, false otherwise.

public PermissionCollection newPermissionCollection ()

Returns a specific PermissionCollection container for permissions of this type. Returns null if any permission collection can be used.

Subclasses may override this method to return an appropriate collection for the specific permissions they implement.

Returns

public String toString ()

Returns a string containing a concise, human-readable description of the this Permission including its name and its actions.

Returns
  • a printable representation for this Permission.