Package org.osgi.service.wireadmin
Class WirePermission
java.lang.Object
java.security.Permission
java.security.BasicPermission
org.osgi.service.wireadmin.WirePermission
- All Implemented Interfaces:
Serializable,Guard
Permission for the scope of a
Wire object. When a Envelope
object is used for communication with the poll or update
method, and the scope is set, then the Wire object must verify that
the Consumer service has WirePermission[name,CONSUME] and the
Producer service has WirePermission[name,PRODUCE] for all names in
the scope.
The names are compared with the normal rules for permission names. This means
that they may end with a "*" to indicate wildcards. E.g. Door.* indicates all
scope names starting with the string "Door". The last period is required due
to the implementations of the BasicPermission class.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate static final intprivate intThe actions mask.private static final intprivate static final intprivate StringThe actions in canonical form.static final StringThe action string for theconsumeaction.static final StringThe action string for theproduceaction.(package private) static final long -
Constructor Summary
ConstructorsConstructorDescriptionWirePermission(String name, int mask) Package private constructor used by WirePermissionCollection.WirePermission(String name, String actions) Create a new WirePermission with the given name (may be wildcard) and actions. -
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermines the equality of twoWirePermissionobjects.Returns the canonical string representation of the actions.(package private) intReturns the current action mask.inthashCode()Returns the hash code value for this object.booleanChecks if thisWirePermissionobjectimpliesthe specified permission.Returns a newPermissionCollectionobject for storingWirePermissionobjects.private static intparseActions(String actions) Parse action string into action mask.private voidreadObject is called to restore the state of the ServicePermission from a stream.private voidsetTransients(int mask) Called by constructors and when deserialized.toString()Returns a string describing thisWirePermission.private voidWriteObject is called to save the state of the ServicePermission to a stream.Methods inherited from class java.security.Permission
checkGuard, getName
-
Field Details
-
serialVersionUID
static final long serialVersionUID- See Also:
-
PRODUCE
The action string for theproduceaction.- See Also:
-
CONSUME
The action string for theconsumeaction.- See Also:
-
ACTION_PRODUCE
private static final int ACTION_PRODUCE- See Also:
-
ACTION_CONSUME
private static final int ACTION_CONSUME- See Also:
-
ACTION_ALL
private static final int ACTION_ALL- See Also:
-
ACTION_NONE
private static final int ACTION_NONE- See Also:
-
action_mask
private transient int action_maskThe actions mask. -
actions
The actions in canonical form.
-
-
Constructor Details
-
WirePermission
Create a new WirePermission with the given name (may be wildcard) and actions.- Parameters:
name- Wire name.actions-produce,consume(canonical order).
-
WirePermission
WirePermission(String name, int mask) Package private constructor used by WirePermissionCollection.- Parameters:
name- class namemask- action mask
-
-
Method Details
-
setTransients
private void setTransients(int mask) Called by constructors and when deserialized.- Parameters:
mask- action mask
-
getActionsMask
int getActionsMask()Returns the current action mask. Used by the WirePermissionCollection object.- Returns:
- The actions mask.
-
parseActions
Parse action string into action mask.- Parameters:
actions- Action string.- Returns:
- action mask.
-
implies
Checks if thisWirePermissionobjectimpliesthe specified permission.More specifically, this method returns
trueif:- p is an instanceof the
WirePermissionclass, - p's actions are a proper subset of this object's actions, and
- p's name is implied by this object's name. For example,
java.*impliesjava.home.
- Overrides:
impliesin classBasicPermission- Parameters:
p- The permission to check against.- Returns:
trueif the specified permission is implied by this object;falseotherwise.
- p is an instanceof the
-
getActions
Returns the canonical string representation of the actions. Always returns present actions in the following order:produce,consume.- Overrides:
getActionsin classBasicPermission- Returns:
- The canonical string representation of the actions.
-
newPermissionCollection
Returns a newPermissionCollectionobject for storingWirePermissionobjects.- Overrides:
newPermissionCollectionin classBasicPermission- Returns:
- A new
PermissionCollectionobject suitable for storingWirePermissionobjects.
-
equals
Determines the equality of twoWirePermissionobjects. Checks that specified object has the same name and actions as thisWirePermissionobject.- Overrides:
equalsin classBasicPermission- Parameters:
obj- The object to test for equality.- Returns:
- true if
objis aWirePermission, and has the same name and actions as thisWirePermissionobject;falseotherwise.
-
hashCode
public int hashCode()Returns the hash code value for this object.- Overrides:
hashCodein classBasicPermission- Returns:
- Hash code value for this object.
-
toString
Returns a string describing thisWirePermission. The convention is to specify the class name, the permission name, and the actions in the following format: '(org.osgi.service.wireadmin.WirePermission "name" "actions")'.- Overrides:
toStringin classPermission- Returns:
- information about this
Permissionobject.
-
writeObject
WriteObject is called to save the state of the ServicePermission to a stream. The actions are serialized, and the superclass takes care of the name.- Throws:
IOException
-
readObject
readObject is called to restore the state of the ServicePermission from a stream.- Throws:
IOExceptionClassNotFoundException
-