public final class TopicPermission
extends java.security.Permission
A topic is a slash-separated string that defines a topic.
For example:
org / osgi / service / foo / FooEvent / ACTION
TopicPermission
has two actions: publish
and
subscribe
.
Modifier and Type | Field and 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 string
publish . |
(package private) static long |
serialVersionUID |
static java.lang.String |
SUBSCRIBE
The action string
subscribe . |
Constructor and 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 publich and/or subscribe to a topic within the
EventAdmin service.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
Determines the equality of two
TopicPermission objects. |
java.lang.String |
getActions()
Returns the canonical string representation of the
TopicPermission 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 new
PermissionCollection object suitable for
storing TopicPermission 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.
|
static final long serialVersionUID
public static final java.lang.String PUBLISH
publish
.public static final java.lang.String SUBSCRIBE
subscribe
.private static final int ACTION_PUBLISH
private static final int ACTION_SUBSCRIBE
private static final int ACTION_ALL
private static final int ACTION_NONE
private transient int action_mask
private transient volatile java.lang.String prefix
private volatile java.lang.String actions
public TopicPermission(java.lang.String name, java.lang.String actions)
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
appropriate TopicPermssion
for that topic.
name
- Topic name.actions
- publish
,subscribe
(canonical
order).TopicPermission(java.lang.String name, int mask)
name
- class namemask
- action maskprivate void setTransients(int mask)
name
- topic namemask
- action maskint getActionsMask()
Used by the TopicPermissionCollection class.
private static int parseActions(java.lang.String actions)
actions
- Action string.public boolean implies(java.security.Permission p)
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 target TopicPermission
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
implies
in class java.security.Permission
p
- The target permission to interrogate.true
if the specified TopicPermission
action is implied by this object; false
otherwise.public java.lang.String getActions()
TopicPermission
actions.
Always returns present TopicPermission
actions in the
following order: publish
,subscribe
.
getActions
in class java.security.Permission
TopicPermission
actions.public java.security.PermissionCollection newPermissionCollection()
PermissionCollection
object suitable for
storing TopicPermission
objects.newPermissionCollection
in class java.security.Permission
PermissionCollection
object.public boolean equals(java.lang.Object obj)
TopicPermission
objects.
This method checks that specified TopicPermission
has the
same topic name and actions as this TopicPermission
object.equals
in class java.security.Permission
obj
- The object to test for equality with this
TopicPermission
object.true
if obj
is a
TopicPermission
, and has the same topic name and
actions as this TopicPermission
object;
false
otherwise.public int hashCode()
hashCode
in class java.security.Permission
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException
java.io.IOException
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException