Package org.apache.commons.daemon
Class DaemonPermission
- java.lang.Object
-
- java.security.Permission
-
- org.apache.commons.daemon.DaemonPermission
-
- All Implemented Interfaces:
java.io.Serializable
,java.security.Guard
public final class DaemonPermission extends java.security.Permission
Represents the permissions to control and query the status of aDaemon
. ADaemonPermission
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:
Target"Name Action Description "control" "start" The permission to call the start()
method in an instance of aDaemonController
interface."stop" The permission to call the stop()
method in an instance of aDaemonController
interface."shutdown" The permission to call the shutdown()
method in an instance of aDaemonController
interface."reload" The permission to call the reload()
method in an instance of aDaemonController
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. - Version:
- $Id: DaemonPermission.java 1204010 2011-11-19 16:15:23Z ggregory $
- Author:
- Pier Fumagalli
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String
CONTROL
The target name when associated with control actions ("control").protected static java.lang.String
CONTROL_RELOAD
The action name associated with the permission to call theDaemonController.reload()
method.protected static java.lang.String
CONTROL_SHUTDOWN
The action name associated with the permission to call theDaemonController.shutdown()
method.protected static java.lang.String
CONTROL_START
The action name associated with the permission to call theDaemonController.start()
method.protected static java.lang.String
CONTROL_STOP
The action name associated with the permission to call theDaemonController.stop()
method.protected static int
MASK_CONTROL_RELOAD
The action mask associated with the permission to call theDaemonController.reload()
method.protected static int
MASK_CONTROL_SHUTDOWN
The action mask associated with the permission to call theDaemonController.shutdown()
method.protected static int
MASK_CONTROL_START
The action mask associated with the permission to call theDaemonController.start()
method.protected static int
MASK_CONTROL_STOP
The action mask associated with the permission to call theDaemonController.stop()
method.protected static int
TYPE_CONTROL
The target type when associated with control actions.protected static java.lang.String
WILDCARD
The "wildcard" action implying all actions for the given target name.
-
Constructor Summary
Constructors Constructor Description DaemonPermission(java.lang.String target)
Creates a newDaemonPermission
instance with a specified permission name.DaemonPermission(java.lang.String target, java.lang.String actions)
Creates a newDaemonPermission
instance with a specified permission name and a specified list of actions.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object object)
Checks if a specified object equalsDaemonPermission
.java.lang.String
getActions()
Returns the list of actions permitted by this instance ofDaemonPermission
in its canonical form.int
hashCode()
Returns the hash code for thisDaemonPermission
instance.boolean
implies(java.security.Permission permission)
Checks if thisDaemonPermission
implies anotherPermission
.java.lang.String
toString()
Returns aString
representation of this instance.
-
-
-
Field Detail
-
CONTROL
protected static final java.lang.String CONTROL
The target name when associated with control actions ("control").- See Also:
- Constant Field Values
-
TYPE_CONTROL
protected static final int TYPE_CONTROL
The target type when associated with control actions.- See Also:
- Constant Field Values
-
CONTROL_START
protected static final java.lang.String CONTROL_START
The action name associated with the permission to call theDaemonController.start()
method.- See Also:
- Constant Field Values
-
CONTROL_STOP
protected static final java.lang.String CONTROL_STOP
The action name associated with the permission to call theDaemonController.stop()
method.- See Also:
- Constant Field Values
-
CONTROL_SHUTDOWN
protected static final java.lang.String CONTROL_SHUTDOWN
The action name associated with the permission to call theDaemonController.shutdown()
method.- See Also:
- Constant Field Values
-
CONTROL_RELOAD
protected static final java.lang.String CONTROL_RELOAD
The action name associated with the permission to call theDaemonController.reload()
method.- See Also:
- Constant Field Values
-
MASK_CONTROL_START
protected static final int MASK_CONTROL_START
The action mask associated with the permission to call theDaemonController.start()
method.- See Also:
- Constant Field Values
-
MASK_CONTROL_STOP
protected static final int MASK_CONTROL_STOP
The action mask associated with the permission to call theDaemonController.stop()
method.- See Also:
- Constant Field Values
-
MASK_CONTROL_SHUTDOWN
protected static final int MASK_CONTROL_SHUTDOWN
The action mask associated with the permission to call theDaemonController.shutdown()
method.- See Also:
- Constant Field Values
-
MASK_CONTROL_RELOAD
protected static final int MASK_CONTROL_RELOAD
The action mask associated with the permission to call theDaemonController.reload()
method.- See Also:
- Constant Field Values
-
WILDCARD
protected static final java.lang.String WILDCARD
The "wildcard" action implying all actions for the given target name.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DaemonPermission
public DaemonPermission(java.lang.String target) throws java.lang.IllegalArgumentException
Creates a newDaemonPermission
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:
java.lang.IllegalArgumentException
- If the specified target name is not supported.
-
DaemonPermission
public DaemonPermission(java.lang.String target, java.lang.String actions) throws java.lang.IllegalArgumentException
Creates a newDaemonPermission
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:
java.lang.IllegalArgumentException
- If the specified target name is not supported, or the specified list of actions includes an invalid value.
-
-
Method Detail
-
getActions
public java.lang.String getActions()
Returns the list of actions permitted by this instance ofDaemonPermission
in its canonical form.- Specified by:
getActions
in classjava.security.Permission
- Returns:
- The canonicalized list of actions.
-
hashCode
public int hashCode()
Returns the hash code for thisDaemonPermission
instance.- Specified by:
hashCode
in classjava.security.Permission
- Returns:
- An hash code value.
-
equals
public boolean equals(java.lang.Object object)
Checks if a specified object equalsDaemonPermission
.- Specified by:
equals
in classjava.security.Permission
- Returns:
- true or false wether the specified object equals
this
DaemonPermission
instance or not.
-
implies
public boolean implies(java.security.Permission permission)
Checks if thisDaemonPermission
implies anotherPermission
.- Specified by:
implies
in classjava.security.Permission
- Returns:
- true or false wether the specified permission
is implied by this
DaemonPermission
instance or not.
-
toString
public java.lang.String toString()
Returns aString
representation of this instance.- Overrides:
toString
in classjava.security.Permission
- Returns:
- A
String
representing thisDaemonPermission
instance.
-
-