Package org.osgi.service.wireadmin
Class WirePermission
- java.lang.Object
-
- java.security.Permission
-
- java.security.BasicPermission
-
- org.osgi.service.wireadmin.WirePermission
-
- All Implemented Interfaces:
java.io.Serializable
,java.security.Guard
public final class WirePermission extends java.security.BasicPermission
Permission for the scope of aWire
object. When aEnvelope
object is used for communication with thepoll
orupdate
method, and the scope is set, then theWire
object must verify that the Consumer service hasWirePermission[name,CONSUME]
and the Producer service hasWirePermission[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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static int
ACTION_ALL
private static int
ACTION_CONSUME
private int
action_mask
The actions mask.private static int
ACTION_NONE
private static int
ACTION_PRODUCE
private java.lang.String
actions
The actions in canonical form.static java.lang.String
CONSUME
The action string for theconsume
action.static java.lang.String
PRODUCE
The action string for theproduce
action.(package private) static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description WirePermission(java.lang.String name, int mask)
Package private constructor used by WirePermissionCollection.WirePermission(java.lang.String name, java.lang.String actions)
Create a new WirePermission with the given name (may be wildcard) and actions.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Determines the equality of twoWirePermission
objects.java.lang.String
getActions()
Returns the canonical string representation of the actions.(package private) int
getActionsMask()
Returns the current action mask.int
hashCode()
Returns the hash code value for this object.boolean
implies(java.security.Permission p)
Checks if thisWirePermission
objectimplies
the specified permission.java.security.PermissionCollection
newPermissionCollection()
Returns a newPermissionCollection
object for storingWirePermission
objects.private static int
parseActions(java.lang.String actions)
Parse action string into action mask.private void
readObject(java.io.ObjectInputStream s)
readObject is called to restore the state of the ServicePermission from a stream.private void
setTransients(int mask)
Called by constructors and when deserialized.java.lang.String
toString()
Returns a string describing thisWirePermission
.private void
writeObject(java.io.ObjectOutputStream s)
WriteObject is called to save the state of the ServicePermission to a stream.
-
-
-
Field Detail
-
serialVersionUID
static final long serialVersionUID
- See Also:
- Constant Field Values
-
PRODUCE
public static final java.lang.String PRODUCE
The action string for theproduce
action.- See Also:
- Constant Field Values
-
CONSUME
public static final java.lang.String CONSUME
The action string for theconsume
action.- See Also:
- Constant Field Values
-
ACTION_PRODUCE
private static final int ACTION_PRODUCE
- See Also:
- Constant Field Values
-
ACTION_CONSUME
private static final int ACTION_CONSUME
- See Also:
- Constant Field Values
-
ACTION_ALL
private static final int ACTION_ALL
- See Also:
- Constant Field Values
-
ACTION_NONE
private static final int ACTION_NONE
- See Also:
- Constant Field Values
-
action_mask
private transient int action_mask
The actions mask.
-
actions
private volatile java.lang.String actions
The actions in canonical form.
-
-
Constructor Detail
-
WirePermission
public WirePermission(java.lang.String name, java.lang.String actions)
Create a new WirePermission with the given name (may be wildcard) and actions.- Parameters:
name
- Wire name.actions
-produce
,consume
(canonical order).
-
WirePermission
WirePermission(java.lang.String name, int mask)
Package private constructor used by WirePermissionCollection.- Parameters:
name
- class namemask
- action mask
-
-
Method Detail
-
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
private static int parseActions(java.lang.String actions)
Parse action string into action mask.- Parameters:
actions
- Action string.- Returns:
- action mask.
-
implies
public boolean implies(java.security.Permission p)
Checks if thisWirePermission
objectimplies
the specified permission.More specifically, this method returns
true
if:- p is an instanceof the
WirePermission
class, - 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:
implies
in classjava.security.BasicPermission
- Parameters:
p
- The permission to check against.- Returns:
true
if the specified permission is implied by this object;false
otherwise.
- p is an instanceof the
-
getActions
public java.lang.String getActions()
Returns the canonical string representation of the actions. Always returns present actions in the following order:produce
,consume
.- Overrides:
getActions
in classjava.security.BasicPermission
- Returns:
- The canonical string representation of the actions.
-
newPermissionCollection
public java.security.PermissionCollection newPermissionCollection()
Returns a newPermissionCollection
object for storingWirePermission
objects.- Overrides:
newPermissionCollection
in classjava.security.BasicPermission
- Returns:
- A new
PermissionCollection
object suitable for storingWirePermission
objects.
-
equals
public boolean equals(java.lang.Object obj)
Determines the equality of twoWirePermission
objects. Checks that specified object has the same name and actions as thisWirePermission
object.- Overrides:
equals
in classjava.security.BasicPermission
- Parameters:
obj
- The object to test for equality.- Returns:
- true if
obj
is aWirePermission
, and has the same name and actions as thisWirePermission
object;false
otherwise.
-
hashCode
public int hashCode()
Returns the hash code value for this object.- Overrides:
hashCode
in classjava.security.BasicPermission
- Returns:
- Hash code value for this object.
-
toString
public java.lang.String 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:
toString
in classjava.security.Permission
- Returns:
- information about this
Permission
object.
-
writeObject
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException
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:
java.io.IOException
-
readObject
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, java.lang.ClassNotFoundException
readObject is called to restore the state of the ServicePermission from a stream.- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
-