org.apache.commons.daemon

Class DaemonPermission


public final class DaemonPermission
extends Permission

This class 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:

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.

Version:
1.0 (CVS $Revision: 1.2 $)

Authors:
Pier Fumagalli
Copyright © 2000-2001 The Apache Software Foundation. All rights reserved.

Field Summary

protected static String
CONTROL
The target name when associated with control actions ("control").
protected static String
CONTROL_RELOAD
The action name associated with the permission to call the DaemonController.reload() method.
protected static String
CONTROL_SHUTDOWN
The action name associated with the permission to call the DaemonController.shutdown() method.
protected static String
CONTROL_START
The action name associated with the permission to call the DaemonController.start() method.
protected static String
CONTROL_STOP
The action name associated with the permission to call the DaemonController.stop() method.
protected static int
MASK_CONTROL_RELOAD
The action mask associated with the permission to call the DaemonController.reload() method.
protected static int
MASK_CONTROL_SHUTDOWN
The action mask associated with the permission to call the DaemonController.shutdown() method.
protected static int
MASK_CONTROL_START
The action mask associated with the permission to call the DaemonController.start() method.
protected static int
MASK_CONTROL_STOP
The action mask associated with the permission to call the DaemonController.stop() method.
protected static int
TYPE_CONTROL
The target type when associated with control actions.
protected static String
WILDCARD
The "wildcard" action implying all actions for the given target name.

Constructor Summary

DaemonPermission(String target)
Create a new DaemonPermission instance with a specified permission name.
DaemonPermission(String target, String actions)
Create a new DaemonPermission instance with a specified permission name and a specified list of actions.

Method Summary

boolean
equals(Object object)
Check if a specified object equals DaemonPermission.
String
getActions()
Return the list of actions permitted by this instance of DaemonPermission in its canonical form.
int
hashCode()
Return the hash code for this DaemonPermission instance.
boolean
implies(Permission permission)
Check if this DaemonPermission implies another Permission.
String
toString()
Return a String representation of this instance.

Field Details

CONTROL

protected static final String CONTROL
The target name when associated with control actions ("control").


CONTROL_RELOAD

protected static final String CONTROL_RELOAD
The action name associated with the permission to call the DaemonController.reload() method.


CONTROL_SHUTDOWN

protected static final String CONTROL_SHUTDOWN
The action name associated with the permission to call the DaemonController.shutdown() method.


CONTROL_START

protected static final String CONTROL_START
The action name associated with the permission to call the DaemonController.start() method.


CONTROL_STOP

protected static final String CONTROL_STOP
The action name associated with the permission to call the DaemonController.stop() method.


MASK_CONTROL_RELOAD

protected static final int MASK_CONTROL_RELOAD
The action mask associated with the permission to call the DaemonController.reload() method.

Field Value:
8


MASK_CONTROL_SHUTDOWN

protected static final int MASK_CONTROL_SHUTDOWN
The action mask associated with the permission to call the DaemonController.shutdown() method.

Field Value:
4


MASK_CONTROL_START

protected static final int MASK_CONTROL_START
The action mask associated with the permission to call the DaemonController.start() method.

Field Value:
1


MASK_CONTROL_STOP

protected static final int MASK_CONTROL_STOP
The action mask associated with the permission to call the DaemonController.stop() method.

Field Value:
2


TYPE_CONTROL

protected static final int TYPE_CONTROL
The target type when associated with control actions.

Field Value:
1


WILDCARD

protected static final String WILDCARD
The "wildcard" action implying all actions for the given target name.

Constructor Details

DaemonPermission

public DaemonPermission(String target)
            throws IllegalArgumentException
Create 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.


DaemonPermission

public DaemonPermission(String target,
                        String actions)
            throws IllegalArgumentException
Create 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.

Method Details

equals

public boolean equals(Object object)
Check if a specified object equals DaemonPermission.

Returns:
true or false wether the specified object equals this DaemonPermission instance or not.


getActions

public String getActions()
Return the list of actions permitted by this instance of DaemonPermission in its canonical form.

Returns:
The canonicalized list of actions.


hashCode

public int hashCode()
Return the hash code for this DaemonPermission instance.

Returns:
An hash code value.


implies

public boolean implies(Permission permission)
Check if this DaemonPermission implies another Permission.

Returns:
true or false wether the specified permission is implied by this DaemonPermission instance or not.


toString

public String toString()
Return a String representation of this instance.

Returns:
A String representing this DaemonPermission instance.


Copyright (c) 2001-2002 - Apache Software Foundation