Class DaemonPermission

java.lang.Object
java.security.Permission
org.apache.commons.daemon.DaemonPermission
All Implemented Interfaces:
Serializable, Guard

public final class DaemonPermission extends Permission
Represents the permissions to control and query the status of a Daemon. A DaemonPermission consists of a target name and a list of actions associated with it.

In this specification version the only available target name for this permission is "control", but further releases may add more target names to fine-tune the access that needs to be granted to the caller.

Actions are defined by a string of comma-separated values, as shown in the table below. The empty string implies no permission at all, while the special "*" value implies all permissions for the given name:

Supported Actions
Target"Name Action Description
"control" "start" The permission to call the start() method in an instance of a DaemonController interface.
"stop" The permission to call the stop() method in an instance of a DaemonController interface.
"shutdown" The permission to call the shutdown() method in an instance of a DaemonController interface.
"reload" The permission to call the reload() method in an instance of a DaemonController interface.
"*" The special wildcard action implies all above-mentioned action. This is equal to construct a permission with the "start, stop, shutdown, reload" list of actions.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final String
    The target name when associated with control actions ("control").
    protected static final String
    The action name associated with the permission to call the DaemonController.reload() method.
    protected static final String
    The action name associated with the permission to call the DaemonController.shutdown() method.
    protected static final String
    The action name associated with the permission to call the DaemonController.start() method.
    protected static final String
    The action name associated with the permission to call the DaemonController.stop() method.
    protected static final int
    The action mask associated with the permission to call the DaemonController.reload() method.
    protected static final int
    The action mask associated with the permission to call the DaemonController.shutdown() method.
    protected static final int
    The action mask associated with the permission to call the DaemonController.start() method.
    protected static final int
    The action mask associated with the permission to call the DaemonController.stop() method.
    protected static final int
    The target type when associated with control actions.
    protected static final String
    The "wildcard" action implying all actions for the given target name.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new DaemonPermission instance with a specified permission name.
    DaemonPermission(String target, String actions)
    Creates a new DaemonPermission instance with a specified permission name and a specified list of actions.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(Object object)
    Checks if a specified object equals DaemonPermission.
    Returns the list of actions permitted by this instance of DaemonPermission in its canonical form.
    int
    Returns the hash code for this DaemonPermission instance.
    boolean
    implies(Permission permission)
    Checks if this DaemonPermission implies another Permission.
    Returns a String representation of this instance.

    Methods inherited from class java.security.Permission

    checkGuard, getName, newPermissionCollection

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • DaemonPermission

      Creates a new DaemonPermission instance with a specified permission name.

      This constructor will create a new DaemonPermission instance that will not grant any permission to the caller.

      Parameters:
      target - The target name of this permission.
      Throws:
      IllegalArgumentException - If the specified target name is not supported.
    • DaemonPermission

      public DaemonPermission(String target, String actions) throws IllegalArgumentException
      Creates a new DaemonPermission instance with a specified permission name and a specified list of actions.
      Parameters:
      target - The target name of this permission.
      actions - The list of actions permitted by this permission.
      Throws:
      IllegalArgumentException - If the specified target name is not supported, or the specified list of actions includes an invalid value.
  • Method Details

    • getActions

      public String getActions()
      Returns the list of actions permitted by this instance of DaemonPermission in its canonical form.
      Specified by:
      getActions in class Permission
      Returns:
      The canonicalized list of actions.
    • hashCode

      public int hashCode()
      Returns the hash code for this DaemonPermission instance.
      Specified by:
      hashCode in class Permission
      Returns:
      An hash code value.
    • equals

      public boolean equals(Object object)
      Checks if a specified object equals DaemonPermission.
      Specified by:
      equals in class Permission
      Returns:
      true or false whether the specified object equals this DaemonPermission instance or not.
    • implies

      public boolean implies(Permission permission)
      Checks if this DaemonPermission implies another Permission.
      Specified by:
      implies in class Permission
      Returns:
      true or false whether the specified permission is implied by this DaemonPermission instance or not.
    • toString

      public String toString()
      Returns a String representation of this instance.
      Overrides:
      toString in class Permission
      Returns:
      A String representing this DaemonPermission instance.