Top Description Fields Constructors Methods
org.osgi.service.dal

public Class DevicePermission

Additional top-level class in compilation unit: DevicePermissionCollection.

extends BasicPermission
Class Inheritance
Imports
java.io.IOException, .NotSerializableException, .ObjectInputStream, .ObjectOutputStream, .ObjectStreamField, java.security.BasicPermission, .Permission, .PermissionCollection, java.util.ArrayList, .Collection, .Collections, .Dictionary, .Enumeration, .HashMap, .Hashtable, .Iterator, org.osgi.framework.Filter, .FrameworkUtil, .InvalidSyntaxException

A bundle's authority to perform specific privileged administrative operations on the devices. The method Device#remove() is protected with REMOVE permission action.

The name of the permission is a filter based. See OSGi Core Specification, Filter Based Permissions. The filter gives an access to all device service properties. Filter attribute names are processed in a case sensitive manner.

Field Summary

Modifier and TypeField and Description
pack-priv transient Device
device

Initialized when the device permission is built with device instance.

private transient Dictionary<String, Object>
deviceProperties

Device properties are initialized on the first request.

private transient Filter
filter

If the permission was built with filter, this filed contains LDAP filter used for matching.

public static final String
REMOVE

A permission action to remove the device.

private static final long

Constructor Summary

AccessConstructor and Description
public
DevicePermission(String
A filter expression that can use any device service property. The filter attribute names are processed in a case insensitive manner. A special value of "*" can be used to match all devices.
filter
,
String
REMOVE action.
action
)

Creates a new DevicePermission with the given filter and actions.

public
DevicePermission(Device
The device that needs to be checked for a permission.
device
,
String
REMOVE action.
action
)

Creates a new DevicePermission with the given device and actions.

Method Summary

Modifier and TypeMethod and Description
private static String
public boolean

Returns:

true if two permissions are equal, false otherwise.
equals
(Object
The object being compared for equality with this object.
obj
)

Overrides java.security.BasicPermission.equals.

Two DevicePermission instances are equal if:

  • Represents the same filter and action.
  • Represents the same device (in respect to device unique identifier) and action.
public String

Returns:

The canonical string representation of the actions.
getActions
()

Overrides java.security.BasicPermission.getActions.

Returns the canonical string representation of REMOVE action.

private Dictionary<String, Object>
public int

Returns:

Hash code value for this object.
hashCode
()

Overrides java.security.BasicPermission.hashCode.

Returns the hash code value for this object.

public boolean

Returns:

true if the specified permission is implied by this permission, false otherwise.
implies
(Permission
The permission to be implied. It must be constructed by DevicePermission(Device, String).
p
)

Overrides java.security.BasicPermission.implies.

Determines if the specified permission is implied by this object.

pack-priv boolean
public PermissionCollection

Returns:

A new PermissionCollection instance.
newPermissionCollection
()

Overrides java.security.BasicPermission.newPermissionCollection.

Returns a new PermissionCollection suitable for storing DevicePermission instances.

private static Filter
private synchronized void
readObject(ObjectInputStream
the ObjectInputStream from which data is read
s
)

Hides java.security.BasicPermission.readObject.

Called to restore the permission state from the stream.

private static void
private synchronized void
writeObject(ObjectOutputStream s)

Called when the permission state is saved to a stream.

Field Detail

deviceback to summary
pack-priv transient Device device

Initialized when the device permission is built with device instance. Such permissions are used only for security checks.

devicePropertiesback to summary
private transient Dictionary<String, Object> deviceProperties

Device properties are initialized on the first request.

filterback to summary
private transient Filter filter

If the permission was built with filter, this filed contains LDAP filter used for matching.

REMOVEback to summary
public static final String REMOVE

A permission action to remove the device.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.security.BasicPermission.serialVersionUID.

Constructor Detail

DevicePermissionback to summary
public DevicePermission(String filter, String action)

Creates a new DevicePermission with the given filter and actions. The constructor must only be used to create a permission that is going to be checked.

A filter example: (dal.device.hardware.vendor=acme)

An action: remove

Parameters
filter:String

A filter expression that can use any device service property. The filter attribute names are processed in a case insensitive manner. A special value of "*" can be used to match all devices.

action:String

REMOVE action.

Exceptions
IllegalArgumentException:
If the filter syntax is not correct or invalid action is specified.
NullPointerException:
If the filter or action is null.
DevicePermissionback to summary
public DevicePermission(Device device, String action)

Creates a new DevicePermission with the given device and actions. The permission must be used for the security checks like:

securityManager.checkPermission(new DevicePermission(this, "remove")) . The permissions constructed by this constructor must not be added to the DevicePermission permission collections.

Parameters
device:Device

The device that needs to be checked for a permission.

action:String

REMOVE action.

Exceptions
IllegalArgumentException:
If an invalid action is specified.
NullPointerException:
If the device or action is null.

Method Detail

createPermissionNameback to summary
private static String createPermissionName(Device device)
equalsback to summary
public boolean equals(Object obj)

Overrides java.security.BasicPermission.equals.

Two DevicePermission instances are equal if:

  • Represents the same filter and action.
  • Represents the same device (in respect to device unique identifier) and action.
Parameters
obj:Object

The object being compared for equality with this object.

Returns:boolean

true if two permissions are equal, false otherwise.

Annotations
@Override
getActionsback to summary
public String getActions()

Overrides java.security.BasicPermission.getActions.

Returns the canonical string representation of REMOVE action.

Returns:String

The canonical string representation of the actions.

Annotations
@Override
getDevicePropertiesback to summary
private Dictionary<String, Object> getDeviceProperties()
hashCodeback to summary
public int hashCode()

Overrides java.security.BasicPermission.hashCode.

Returns the hash code value for this object.

Returns:int

Hash code value for this object.

Annotations
@Override
impliesback to summary
public boolean implies(Permission p)

Overrides java.security.BasicPermission.implies.

Determines if the specified permission is implied by this object. The method will return false if the specified permission was not constructed by DevicePermission(Device, String). Returns true if the specified permission is a DevicePermission and this permission filter matches the specified permission device properties.

Parameters
p:Permission

The permission to be implied. It must be constructed by DevicePermission(Device, String).

Returns:boolean

true if the specified permission is implied by this permission, false otherwise.

Annotations
@Override
Exceptions
IllegalArgumentException:
If the specified permission is not constructed by DevicePermission(Device, String).
implyDevicePermissionback to summary
pack-priv boolean implyDevicePermission(DevicePermission dp)
newPermissionCollectionback to summary
public PermissionCollection newPermissionCollection()

Overrides java.security.BasicPermission.newPermissionCollection.

Returns a new PermissionCollection suitable for storing DevicePermission instances.

Returns:PermissionCollection

A new PermissionCollection instance.

Annotations
@Override
parseFilterback to summary
private static Filter parseFilter(String filter)
readObjectback to summary
private synchronized void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException

Hides java.security.BasicPermission.readObject.

Called to restore the permission state from the stream.

Parameters
s:ObjectInputStream

Doc from java.security.BasicPermission.readObject.

the ObjectInputStream from which data is read

Exceptions
IOException:

Doc from java.security.BasicPermission.readObject.

if an I/O error occurs

ClassNotFoundException:

Doc from java.security.BasicPermission.readObject.

if a serialized class cannot be loaded

validateActionback to summary
private static void validateAction(String action)
writeObjectback to summary
private synchronized void writeObject(ObjectOutputStream s) throws IOException

Called when the permission state is saved to a stream. Permissions with device instance cannot be serialized.