Class MonitorPermission
- java.lang.Object
-
- java.security.Permission
-
- org.osgi.service.monitor.MonitorPermission
-
- All Implemented Interfaces:
java.io.Serializable,java.security.Guard
public class MonitorPermission extends java.security.PermissionIndicates the callers authority to publish, read or resetStatusVariables, to switch event sending on or off or to start monitoring jobs. The target of the permission is the identifier of theStatusVariable, the action can beread,publish,reset,startjob,switchevents, or the combination of these separated by commas. Action names are interpreted case-insensitively, but the canonical action string returned bygetActions()uses the forms defined by the action constants.If the wildcard
*appears in the actions field, all legal monitoring commands are allowed on the designated target(s) by the owner of the permission.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static intALL_FLAGSprivate intmaskprivate intminJobIntervalprivate java.lang.StringmonIdprivate booleanprefixMonIdprivate booleanprefixVarIdstatic java.lang.StringPUBLISHHolders ofMonitorPermissionwith thepublishaction present areMonitorableservices that are allowed to publish theStatusVariables specified in the permission's target field.private static intPUBLISH_FLAGstatic java.lang.StringREADHolders ofMonitorPermissionwith thereadaction present are allowed to read the value of theStatusVariables specified in the permission's target field.private static intREAD_FLAGstatic java.lang.StringRESETHolders ofMonitorPermissionwith theresetaction present are allowed to reset the value of theStatusVariables specified in the permission's target field.private static intRESET_FLAGprivate static longserialVersionUIDstatic java.lang.StringSTARTJOBHolders ofMonitorPermissionwith thestartjobaction present are allowed to initiate monitoring jobs involving theStatusVariables specified in the permission's target field.private static intSTARTJOB_FLAGstatic java.lang.StringSWITCHEVENTSHolders ofMonitorPermissionwith theswitcheventsaction present are allowed to switch event sending on or off for the value of theStatusVariables specified in the permission's target field.private static intSWITCHEVENTS_FLAGprivate java.lang.StringvarId
-
Constructor Summary
Constructors Constructor Description MonitorPermission(java.lang.String statusVariable, java.lang.String actions)Create aMonitorPermissionobject, specifying the target and actions.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddToMask(int action, java.lang.String actionString)private voidappendAction(java.lang.StringBuilder sb, int flag, java.lang.String actionName)private voidcheckId(java.lang.String id, java.lang.String idName)booleanequals(java.lang.Object o)Determines the equality of twoMonitorPermissionobjects.java.lang.StringgetActions()Get the action string associated with this permission.inthashCode()Create an integer hash of the object.private booleanimplies(java.lang.String id, boolean prefix, java.lang.String oid, boolean oprefix)booleanimplies(java.security.Permission p)Determines if the specified permission is implied by this permission.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
READ
public static final java.lang.String READ
Holders ofMonitorPermissionwith thereadaction present are allowed to read the value of theStatusVariables specified in the permission's target field.- See Also:
- Constant Field Values
-
RESET
public static final java.lang.String RESET
Holders ofMonitorPermissionwith theresetaction present are allowed to reset the value of theStatusVariables specified in the permission's target field.- See Also:
- Constant Field Values
-
PUBLISH
public static final java.lang.String PUBLISH
Holders ofMonitorPermissionwith thepublishaction present areMonitorableservices that are allowed to publish theStatusVariables specified in the permission's target field. Note, that this permission cannot be enforced when aMonitorableregisters to the framework, because the Service Registry does not know about this permission. Instead, anyStatusVariables published by aMonitorablewithout the correspondingpublishpermission are silently ignored byMonitorAdmin, and are therefore invisible to the users of the monitoring service.- See Also:
- Constant Field Values
-
STARTJOB
public static final java.lang.String STARTJOB
Holders ofMonitorPermissionwith thestartjobaction present are allowed to initiate monitoring jobs involving theStatusVariables specified in the permission's target field.A minimal sampling interval can be optionally defined in the following form:
startjob:n. This allows the holder of the permission to initiate time based jobs with a measurement interval of at leastnseconds. Ifnis not specified or 0 then the holder of this permission is allowed to start monitoring jobs specifying any frequency.- See Also:
- Constant Field Values
-
SWITCHEVENTS
public static final java.lang.String SWITCHEVENTS
Holders ofMonitorPermissionwith theswitcheventsaction present are allowed to switch event sending on or off for the value of theStatusVariables specified in the permission's target field.- See Also:
- Constant Field Values
-
READ_FLAG
private static final int READ_FLAG
- See Also:
- Constant Field Values
-
RESET_FLAG
private static final int RESET_FLAG
- See Also:
- Constant Field Values
-
PUBLISH_FLAG
private static final int PUBLISH_FLAG
- See Also:
- Constant Field Values
-
STARTJOB_FLAG
private static final int STARTJOB_FLAG
- See Also:
- Constant Field Values
-
SWITCHEVENTS_FLAG
private static final int SWITCHEVENTS_FLAG
- See Also:
- Constant Field Values
-
ALL_FLAGS
private static final int ALL_FLAGS
- See Also:
- Constant Field Values
-
monId
private java.lang.String monId
-
varId
private java.lang.String varId
-
prefixMonId
private boolean prefixMonId
-
prefixVarId
private boolean prefixVarId
-
mask
private int mask
-
minJobInterval
private int minJobInterval
-
-
Constructor Detail
-
MonitorPermission
public MonitorPermission(java.lang.String statusVariable, java.lang.String actions) throws java.lang.IllegalArgumentExceptionCreate aMonitorPermissionobject, specifying the target and actions.The
statusVariableparameter is the target of the permission, defining one or more status variable names to which the specified actions apply. Multiple status variable names can be selected by using the wildcard*in the target string. The wildcard is allowed in both fragments, but only at the end of the fragments.For example, the following targets are valid:
com.mycomp.myapp/queue_length,com.mycomp.myapp/*,com.mycomp.*/*,*/*,*/queue_length,*/queue*.The following targets are invalid:
*.myapp/queue_length,com.*.myapp/*,*.The
actionsparameter specifies the allowed action(s):read,publish,startjob,reset,switchevents, or the combination of these separated by commas. String constants are defined in this class for each valid action. Passing"*"as the action string is equivalent to listing all actions.- Parameters:
statusVariable- the identifier of theStatusVariablein [Monitorable_id]/[StatusVariable_id] formatactions- the list of allowed actions separated by commas, or*for all actions- Throws:
java.lang.IllegalArgumentException- if either parameter isnull, or invalid with regard to the constraints defined above and in the documentation of the used actions
-
-
Method Detail
-
addToMask
private void addToMask(int action, java.lang.String actionString)
-
checkId
private void checkId(java.lang.String id, java.lang.String idName) throws java.lang.IllegalArgumentException- Throws:
java.lang.IllegalArgumentException
-
hashCode
public int hashCode()
Create an integer hash of the object. The hash codes ofMonitorPermissionsp1andp2are the same ifp1.equals(p2).- Specified by:
hashCodein classjava.security.Permission- Returns:
- the hash of the object
-
equals
public boolean equals(java.lang.Object o)
Determines the equality of twoMonitorPermissionobjects. TwoMonitorPermissionobjects are equal if their target strings are equal and the same set of actions are listed in their action strings.- Specified by:
equalsin classjava.security.Permission- Parameters:
o- the object being compared for equality with this object- Returns:
trueif the two permissions are equal
-
getActions
public java.lang.String getActions()
Get the action string associated with this permission. The actions are returned in the following order:read,reset,publish,startjob,switchevents.- Specified by:
getActionsin classjava.security.Permission- Returns:
- the allowed actions separated by commas, cannot be
null
-
appendAction
private void appendAction(java.lang.StringBuilder sb, int flag, java.lang.String actionName)
-
implies
public boolean implies(java.security.Permission p)
Determines if the specified permission is implied by this permission.This method returns
falseif and only if at least one of the following conditions are fulfilled for the specified permission:- it is not a
MonitorPermission - it has a broader set of actions allowed than this one
- it allows initiating time based monitoring jobs with a lower minimal sampling interval
- the target set of
Monitorables is not the same nor a subset of the target set ofMonitorables of this permission - the target set of
StatusVariables is not the same nor a subset of the target set ofStatusVariables of this permission
- Specified by:
impliesin classjava.security.Permission- Parameters:
p- the permission to be checked- Returns:
trueif the given permission is implied by this permission
- it is not a
-
implies
private boolean implies(java.lang.String id, boolean prefix, java.lang.String oid, boolean oprefix)
-
-