Class TopicPermission
- java.lang.Object
-
- java.security.Permission
-
- org.osgi.service.event.TopicPermission
-
- All Implemented Interfaces:
java.io.Serializable
,java.security.Guard
public final class TopicPermission extends java.security.Permission
A bundle's authority to publish or subscribe to event on a topic.A topic is a slash-separated string that defines a topic.
For example:
org/osgi/service/foo/FooEvent/ACTION
TopicPermission
has two actions:publish
andsubscribe
.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static int
ACTION_ALL
private int
action_mask
The actions mask.private static int
ACTION_NONE
private static int
ACTION_PUBLISH
private static int
ACTION_SUBSCRIBE
private java.lang.String
actions
The actions in canonical form.private java.lang.String
prefix
prefix if the name is wildcarded.static java.lang.String
PUBLISH
The action stringpublish
.(package private) static long
serialVersionUID
static java.lang.String
SUBSCRIBE
The action stringsubscribe
.
-
Constructor Summary
Constructors Constructor Description TopicPermission(java.lang.String name, int mask)
Package private constructor used by TopicPermissionCollection.TopicPermission(java.lang.String name, java.lang.String actions)
Defines the authority to publish and/or subscribe to a topic within the EventAdmin service.
-
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 twoTopicPermission
objects.java.lang.String
getActions()
Returns the canonical string representation of theTopicPermission
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)
Determines if the specified permission is implied by this object.java.security.PermissionCollection
newPermissionCollection()
Returns a newPermissionCollection
object suitable for storingTopicPermission
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 this permission from a stream.private void
setTransients(int mask)
Called by constructors and when deserialized.private void
writeObject(java.io.ObjectOutputStream s)
WriteObject is called to save the state of this permission object to a stream.
-
-
-
Field Detail
-
serialVersionUID
static final long serialVersionUID
- See Also:
- Constant Field Values
-
PUBLISH
public static final java.lang.String PUBLISH
The action stringpublish
.- See Also:
- Constant Field Values
-
SUBSCRIBE
public static final java.lang.String SUBSCRIBE
The action stringsubscribe
.- See Also:
- Constant Field Values
-
ACTION_PUBLISH
private static final int ACTION_PUBLISH
- See Also:
- Constant Field Values
-
ACTION_SUBSCRIBE
private static final int ACTION_SUBSCRIBE
- 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.
-
prefix
private transient volatile java.lang.String prefix
prefix if the name is wildcarded.
-
actions
private volatile java.lang.String actions
The actions in canonical form.
-
-
Constructor Detail
-
TopicPermission
public TopicPermission(java.lang.String name, java.lang.String actions)
Defines the authority to publish and/or subscribe to a topic within the EventAdmin service.The name is specified as a slash-separated string. Wildcards may be used. For example:
org/osgi/service/fooFooEvent/ACTION com/isv/* *
A bundle that needs to publish events on a topic must have the appropriate
TopicPermission
for that topic; similarly, a bundle that needs to subscribe to events on a topic must have the appropriateTopicPermssion
for that topic.- Parameters:
name
- Topic name.actions
-publish
,subscribe
(canonical order).
-
TopicPermission
TopicPermission(java.lang.String name, int mask)
Package private constructor used by TopicPermissionCollection.- Parameters:
name
- class namemask
- action mask
-
-
Method Detail
-
setTransients
private void setTransients(int mask)
Called by constructors and when deserialized.- Parameters:
name
- topic namemask
- action mask
-
getActionsMask
int getActionsMask()
Returns the current action mask.Used by the TopicPermissionCollection class.
- Returns:
- Current action 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)
Determines if the specified permission is implied by this object.This method checks that the topic name of the target is implied by the topic name of this object. The list of
TopicPermission
actions must either match or allow for the list of the target object to imply the targetTopicPermission
action.x/y/*,"publish" -> x/y/z,"publish" is true *,"subscribe" -> x/y,"subscribe" is true *,"publish" -> x/y,"subscribe" is false x/y,"publish" -> x/y/z,"publish" is false
- Specified by:
implies
in classjava.security.Permission
- Parameters:
p
- The target permission to interrogate.- Returns:
true
if the specifiedTopicPermission
action is implied by this object;false
otherwise.
-
getActions
public java.lang.String getActions()
Returns the canonical string representation of theTopicPermission
actions.Always returns present
TopicPermission
actions in the following order:publish
,subscribe
.- Specified by:
getActions
in classjava.security.Permission
- Returns:
- Canonical string representation of the
TopicPermission
actions.
-
newPermissionCollection
public java.security.PermissionCollection newPermissionCollection()
Returns a newPermissionCollection
object suitable for storingTopicPermission
objects.- Overrides:
newPermissionCollection
in classjava.security.Permission
- Returns:
- A new
PermissionCollection
object.
-
equals
public boolean equals(java.lang.Object obj)
Determines the equality of twoTopicPermission
objects. This method checks that specifiedTopicPermission
has the same topic name and actions as thisTopicPermission
object.- Specified by:
equals
in classjava.security.Permission
- Parameters:
obj
- The object to test for equality with thisTopicPermission
object.- Returns:
true
ifobj
is aTopicPermission
, and has the same topic name and actions as thisTopicPermission
object;false
otherwise.
-
hashCode
public int hashCode()
Returns the hash code value for this object.- Specified by:
hashCode
in classjava.security.Permission
- Returns:
- A hash code value for this object.
-
writeObject
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException
WriteObject is called to save the state of this permission object 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 this permission from a stream.- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
-