public abstract class DevicePermission
extends java.security.Permission
DevicePermission abstract class is the superclass of all device permissions.
A DevicePermission permission has a target name and, optionally, a list of actions.
The target name contains hardware addressing information. It takes the following form:
( {controller-spec} ) [ ":" {channel-spec}]
{controller-spec}{controller-spec} takes the following form:
{controller-name-spec} | {controller-number} | "*" | ""
{controller-name-spec}{controller-name-spec} string is the string representation of a controller name as
may be returned by a call to DeviceConfig.HardwareAddressing.getControllerName. A controller name is Operating System specific
such as a device file name on UNIX systems. Occurrences of the semicolon character (
":") must be escaped with a backslash ("\"). A {controller-name-spec}
string that ends with an asterisk ("*") is a prefix pattern that matches all the controller
names starting with the same prefix.{controller-number}{controller-number} string is the decimal string representation of a controller
number as may be returned by a call to
DeviceConfig.HardwareAddressing.getControllerNumber. The characters in the string must all be
decimal digits.{controller-spec} specification consisting of the asterisk ("*") matches all
controller names or numbers. A {controller-spec} specification consisting of the empty
string ("") designates an undefined controller name or number that may only be matched by an
empty string or an asterisk.{channel-spec} takes the following form:
{channel-desc} | "*" | ""
{channel-desc}{channel-desc} string is device type-specific and must be defined by
subclasses.{channel-spec} specification consisting of the asterisk ("*") matches all
channels. A {channel-spec} specification consisting of the empty string ("")
designates an undefined channel that may only be matched by an empty string or an asterisk.DevicePermission may defined additional specific target name formats to
designate devices using their specific hardware addressing information.
The actions to be granted are passed to the constructor in a string containing a list of one or
more comma-separated keywords. The supported common actions are open and
powermanage. Their meaning is defined as follows:
openDeviceManager.open)powermanagePowerManaged)DevicePermission.DeviceManager.open,
PowerManaged,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
OPEN
The
open action. |
static java.lang.String |
POWER_MANAGE
The
powermanage action. |
| Constructor and Description |
|---|
DevicePermission(java.lang.String name)
Constructs a new
DevicePermission with the specified target name and the implicit
open action. |
DevicePermission(java.lang.String name,
java.lang.String actions)
Constructs a new
DevicePermission instance with the specified target name and
action list. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object obj)
Checks two
DevicePermission objects for equality. |
java.lang.String |
getActions()
Returns the list of possible actions in the following order:
open or
powermanage (additional actions may be defined by subclasses). |
int |
hashCode()
Returns the hash code value for this object.
|
boolean |
implies(java.security.Permission permission)
Checks if this
DevicePermission object "implies" the specified permission. |
java.security.PermissionCollection |
newPermissionCollection()
Returns a new
PermissionCollection for storing DevicePermission objects. |
public static final java.lang.String OPEN
open action.public static final java.lang.String POWER_MANAGE
powermanage action.public DevicePermission(java.lang.String name)
DevicePermission with the specified target name and the implicit
open action.name - the target name (as defined above).java.lang.NullPointerException - if name is null.getNamepublic DevicePermission(java.lang.String name,
java.lang.String actions)
DevicePermission instance with the specified target name and
action list.name - the target name (as defined above).actions - comma-separated list of device operations: open or powermanage
(additional actions may be defined by subclasses).java.lang.NullPointerException - if name is null.java.lang.IllegalArgumentException - if actions is null, empty or contains an
action other than the specified possible actions.getNamepublic boolean equals(java.lang.Object obj)
DevicePermission objects for equality.equals in class java.security.Permissionobj - the object to test for equality with this object.true if obj is a DevicePermission and has the same target
name and actions as this DevicePermission object.public java.lang.String getActions()
open or
powermanage (additional actions may be defined by subclasses).getActions in class java.security.Permissionpublic int hashCode()
hashCode in class java.security.Permissionpublic boolean implies(java.security.Permission permission)
DevicePermission object "implies" the specified permission.
More specifically, this method returns true if:
permission is an instance of DevicePermission, andpermission's actions are a proper subset of this object's action list, andpermission's hardware addressing information or range thereof is included in this
DevicePermission's hardware addressing information range.implies in class java.security.Permissionpermission - the permission to check against.true if the specified permission is not null and is implied by this
object, false otherwise.public java.security.PermissionCollection newPermissionCollection()
PermissionCollection for storing DevicePermission objects.
DevicePermission objects must be stored in a manner that allows them to be
inserted into the collection in any order, but that also enables the
PermissionCollection implies method to be implemented in an efficient (and
consistent) manner.
If null is returned, then the caller of this method is free to store permissions of
this type in any PermissionCollection they choose (one that uses a Hashtable, one
that uses a Vector, etc).
newPermissionCollection in class java.security.PermissionPermissionCollection suitable for storing DevicePermission
objects, or null if one is not defined.Copyright © 2012, 2014, Oracle and/or its affiliates. All rights reserved.
Legal Notices