public abstract class

BasicPermission

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

Class Overview

BasicPermission is the common base class of all permissions which have a name but no action lists. A BasicPermission is granted or it is not.

Names of a BasicPermission follow the dot separated, hierarchical property naming convention. Asterisk '*' can be used as wildcards. Either by itself, matching anything, or at the end of the name, immediately preceded by a '.'. For example:

 com.google.android.*  grants all permissions under the com.google.android permission hierarchy
 *                     grants all permissions
 

While this class ignores the action list in the BasicPermission(String, String) constructor, subclasses may implement actions on top of this class.

Summary

Public Constructors
BasicPermission(String name)
Constructs a new instance of BasicPermission with the specified name.
BasicPermission(String name, String action)
Constructs a new instance of BasicPermission with the specified name.
Public Methods
boolean equals(Object obj)
Compares the specified object with this BasicPermission for equality.
String getActions()
Returns the actions associated with this permission.
int hashCode()
Returns the hash code value for this BasicPermission.
boolean implies(Permission permission)
Indicates whether the specified permission is implied by this permission.
PermissionCollection newPermissionCollection()
Returns an empty PermissionCollection for holding permissions.
[Expand]
Inherited Methods
From class java.security.Permission
From class java.lang.Object
From interface java.security.Guard

Public Constructors

public BasicPermission (String name)

Since: API Level 1

Constructs a new instance of BasicPermission with the specified name.

Parameters
name the name of the permission.
Throws
NullPointerException if name is null.
IllegalArgumentException if name.length() == 0.

public BasicPermission (String name, String action)

Since: API Level 1

Constructs a new instance of BasicPermission with the specified name. The action parameter is ignored.

Parameters
name the name of the permission.
action is ignored.
Throws
NullPointerException if name is null.
IllegalArgumentException if name.length() == 0.

Public Methods

public boolean equals (Object obj)

Since: API Level 1

Compares the specified object with this BasicPermission for equality. Returns true if the specified object has the same class and the two Permissionss have the same name.

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

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

public String getActions ()

Since: API Level 1

Returns the actions associated with this permission. Since BasicPermission instances have no actions, an empty string is returned.

Returns
  • an empty string.

public int hashCode ()

Since: API Level 1

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

Returns
  • the hash code value for this BasicPermission.

public boolean implies (Permission permission)

Since: API Level 1

Indicates whether the specified permission is implied by this permission.

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 ()

Since: API Level 1

Returns an empty PermissionCollection for holding permissions.

For PermissionCollection (and subclasses which do not override this method), the collection which is returned does not invoke the implies(Permission) method of the permissions which are stored in it when checking if the collection implies a permission. Instead, it assumes that if the type of the permission is correct, and the name of the permission is correct, there is a match.

Returns