public final class ServicePermission
extends java.security.BasicPermission
register
action allows a bundle to register a service on
the specified names.
get
action allows a bundle to detect a service and get
it.
ServicePermission
to get the specific service.Modifier and Type | Class and Description |
---|---|
private static class |
ServicePermission.Properties |
Modifier and Type | Field and Description |
---|---|
private static int |
ACTION_ALL |
private static int |
ACTION_GET |
(package private) int |
action_mask
The actions mask.
|
(package private) static int |
ACTION_NONE |
private static int |
ACTION_REGISTER |
private java.lang.String |
actions
The actions in canonical form.
|
(package private) Filter |
filter
If this ServicePermission was constructed with a filter, this holds a
Filter matching object used to evaluate the filter in implies.
|
static java.lang.String |
GET
The action string
get . |
(package private) java.lang.String[] |
objectClass
The object classes for this ServicePermission.
|
private java.lang.String |
prefix
If constructed with a name and the name ends with ".*", this contains the
name without the final "*".
|
private java.util.Dictionary |
properties
This dictionary holds the properties of the permission, used to match a
filter in implies.
|
static java.lang.String |
REGISTER
The action string
register . |
(package private) static long |
serialVersionUID |
(package private) ServiceReference |
service
The service used by this ServicePermission.
|
private boolean |
wildcard
True if constructed with a name and the name is "*" or ends with ".*".
|
Constructor and Description |
---|
ServicePermission(ServiceReference reference,
java.lang.String actions)
Creates a new requested
ServicePermission object to be used
by code that must perform checkPermission for the
get action. |
ServicePermission(java.lang.String name,
int mask)
Package private constructor used by ServicePermissionCollection.
|
ServicePermission(java.lang.String name,
java.lang.String actions)
Create a new ServicePermission.
|
Modifier and Type | Method and Description |
---|---|
private static java.lang.String |
createName(ServiceReference reference)
Create a permission name from a ServiceReference
|
boolean |
equals(java.lang.Object obj)
Determines the equality of two ServicePermission objects.
|
java.lang.String |
getActions()
Returns the canonical string representation of the actions.
|
private java.util.Dictionary |
getProperties()
Called by
<@link ServicePermission#implies(Permission)> . |
int |
hashCode()
Returns the hash code value for this object.
|
boolean |
implies(java.security.Permission p)
Determines if a
ServicePermission object "implies" the
specified permission. |
(package private) boolean |
implies0(ServicePermission requested,
int effective)
Internal implies method.
|
java.security.PermissionCollection |
newPermissionCollection()
Returns a new
PermissionCollection object for storing
ServicePermission |
private static int |
parseActions(java.lang.String actions)
Parse action string into action mask.
|
private static Filter |
parseFilter(java.lang.String filterString)
Parse filter string into a Filter object.
|
private void |
readObject(java.io.ObjectInputStream s)
readObject is called to restore the state of this permission from a
stream.
|
private void |
setTransients(Filter f,
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 to a stream.
|
static final long serialVersionUID
public static final java.lang.String GET
get
.public static final java.lang.String REGISTER
register
.private static final int ACTION_GET
private static final int ACTION_REGISTER
private static final int ACTION_ALL
static final int ACTION_NONE
transient int action_mask
private volatile java.lang.String actions
final transient ServiceReference service
final transient java.lang.String[] objectClass
transient Filter filter
private transient volatile java.util.Dictionary properties
private transient boolean wildcard
private transient java.lang.String prefix
public ServicePermission(java.lang.String name, java.lang.String actions)
The name of the service is specified as a fully qualified class name. Wildcards may be used.
name ::= <class name> | <class name ending in ".*"> | *Examples:
org.osgi.service.http.HttpService org.osgi.service.http.* *For the
get
action, the name can also be a filter
expression. The filter gives access to the service properties as well as
the following attributes:
There are two possible actions: get
and
register
. The get
permission allows the owner
of this permission to obtain a service with this name. The
register
permission allows the bundle to register a service
under that name.
name
- The service class nameactions
- get
,register
(canonical order)java.lang.IllegalArgumentException
- If the specified name is a filter
expression and either the specified action is not
get
or the filter has an invalid syntax.public ServicePermission(ServiceReference reference, java.lang.String actions)
ServicePermission
object to be used
by code that must perform checkPermission
for the
get
action. ServicePermission
objects created
with this constructor cannot be added to a ServicePermission
permission collection.reference
- The requested service.actions
- The action get
.java.lang.IllegalArgumentException
- If the specified action is not
get
or reference is null
.ServicePermission(java.lang.String name, int mask)
name
- class namemask
- action maskprivate static java.lang.String createName(ServiceReference reference)
reference
- ServiceReference to use to create permission name.private void setTransients(Filter f, int mask)
mask
- action maskprivate static int parseActions(java.lang.String actions)
actions
- Action string.private static Filter parseFilter(java.lang.String filterString)
filterString
- The filter string to parse.null
is returned.java.lang.IllegalArgumentException
- If the filter syntax is invalid.public boolean implies(java.security.Permission p)
ServicePermission
object "implies" the
specified permission.implies
in class java.security.BasicPermission
p
- The target permission to check.true
if the specified permission is implied by this
object; false
otherwise.boolean implies0(ServicePermission requested, int effective)
requested
- The requested ServicePermission which has already be
validated as a proper argument. The requested ServicePermission
must not have a filter expression.effective
- The effective actions with which to start.true
if the specified permission is implied by this
object; false
otherwise.public java.lang.String getActions()
get
,
register
.getActions
in class java.security.BasicPermission
public java.security.PermissionCollection newPermissionCollection()
PermissionCollection
object for storing
ServicePermission objects.
newPermissionCollection
in class java.security.BasicPermission
PermissionCollection
object suitable for storing
ServicePermission
objects.public boolean equals(java.lang.Object obj)
ServicePermission
.equals
in class java.security.BasicPermission
obj
- The object to test for equality.ServicePermission
, and has the same
class name and actions as this ServicePermission
object; false
otherwise.public int hashCode()
hashCode
in class java.security.BasicPermission
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
private java.util.Dictionary getProperties()
<@link ServicePermission#implies(Permission)>
.