Class DevicePermission

  • All Implemented Interfaces:
    java.io.Serializable, java.security.Guard

    public class DevicePermission
    extends java.security.BasicPermission
    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.

    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String REMOVE
      A permission action to remove the device.
    • Constructor Summary

      Constructors 
      Constructor Description
      DevicePermission​(java.lang.String filter, java.lang.String action)
      Creates a new DevicePermission with the given filter and actions.
      DevicePermission​(Device device, java.lang.String action)
      Creates a new DevicePermission with the given device and actions.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)
      Two DevicePermission instances are equal if: Represents the same filter and action. Represents the same device (in respect to device unique identifier) and action.
      java.lang.String getActions()
      Returns the canonical string representation of REMOVE action.
      int hashCode()
      Returns the hash code value for this object.
      boolean implies​(java.security.Permission p)
      Determines if the specified permission is implied by this object.
      java.security.PermissionCollection newPermissionCollection()
      Returns a new PermissionCollection suitable for storing DevicePermission instances.
      • Methods inherited from class java.security.Permission

        checkGuard, getName, toString
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • REMOVE

        public static final java.lang.String REMOVE
        A permission action to remove the device.
        See Also:
        Constant Field Values
    • Constructor Detail

      • DevicePermission

        public DevicePermission​(java.lang.String filter,
                                java.lang.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 - 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 - REMOVE action.
        Throws:
        java.lang.IllegalArgumentException - If the filter syntax is not correct or invalid action is specified.
        java.lang.NullPointerException - If the filter or action is null.
      • DevicePermission

        public DevicePermission​(Device device,
                                java.lang.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 - The device that needs to be checked for a permission.
        action - REMOVE action.
        Throws:
        java.lang.IllegalArgumentException - If an invalid action is specified.
        java.lang.NullPointerException - If the device or action is null.
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object obj)
        Two DevicePermission instances are equal if:
        • Represents the same filter and action.
        • Represents the same device (in respect to device unique identifier) and action.
        Overrides:
        equals in class java.security.BasicPermission
        Parameters:
        obj - The object being compared for equality with this object.
        Returns:
        true if two permissions are equal, false otherwise.
      • hashCode

        public int hashCode()
        Returns the hash code value for this object.
        Overrides:
        hashCode in class java.security.BasicPermission
        Returns:
        Hash code value for this object.
      • getActions

        public java.lang.String getActions()
        Returns the canonical string representation of REMOVE action.
        Overrides:
        getActions in class java.security.BasicPermission
        Returns:
        The canonical string representation of the actions.
      • implies

        public boolean implies​(java.security.Permission p)
        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.
        Overrides:
        implies in class java.security.BasicPermission
        Parameters:
        p - The permission to be implied. It must be constructed by DevicePermission(Device, String).
        Returns:
        true if the specified permission is implied by this permission, false otherwise.
        Throws:
        java.lang.IllegalArgumentException - If the specified permission is not constructed by DevicePermission(Device, String).
      • newPermissionCollection

        public java.security.PermissionCollection newPermissionCollection()
        Returns a new PermissionCollection suitable for storing DevicePermission instances.
        Overrides:
        newPermissionCollection in class java.security.BasicPermission
        Returns:
        A new PermissionCollection instance.