public final class CapabilityPermission
extends java.security.BasicPermission
provide
action allows a bundle to provide a capability
matching the specified filter.require
action allows a bundle to require a capability
matching the specified filter.Modifier and Type | Class and Description |
---|---|
private static class |
CapabilityPermission.Properties |
Modifier and Type | Field and Description |
---|---|
private static int |
ACTION_ALL |
(package private) int |
action_mask
The actions mask.
|
(package private) static int |
ACTION_NONE |
private static int |
ACTION_PROVIDE |
private static int |
ACTION_REQUIRE |
private java.lang.String |
actions
The actions in canonical form.
|
(package private) java.util.Map<java.lang.String,java.lang.Object> |
attributes
The attributes of the requested capability.
|
(package private) Bundle |
bundle
The bundle of the requested capability.
|
(package private) Filter |
filter
If this CapabilityPermission was constructed with a filter, this holds a
Filter matching object used to evaluate the filter in implies.
|
private java.util.Map<java.lang.String,java.lang.Object> |
properties
This map holds the properties of the permission, used to match a filter
in implies.
|
static java.lang.String |
PROVIDE
The action string
provide . |
static java.lang.String |
REQUIRE
The action string
require . |
(package private) static long |
serialVersionUID |
Constructor and Description |
---|
CapabilityPermission(java.lang.String name,
int mask)
Package private constructor used by CapabilityPermissionCollection.
|
CapabilityPermission(java.lang.String namespace,
java.util.Map<java.lang.String,?> attributes,
Bundle providingBundle,
java.lang.String actions)
Creates a new requested
CapabilityPermission object to be used by
code that must perform checkPermission for the require
action. |
CapabilityPermission(java.lang.String name,
java.lang.String actions)
Create a new CapabilityPermission.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
Determines the equality of two CapabilityPermission objects.
|
java.lang.String |
getActions()
Returns the canonical string representation of the actions.
|
private java.util.Map<java.lang.String,java.lang.Object> |
getProperties()
Called by
implies(Permission) . |
int |
hashCode()
Returns the hash code value for this object.
|
boolean |
implies(java.security.Permission p)
Determines if a
CapabilityPermission object "implies" the
specified permission. |
(package private) boolean |
implies0(CapabilityPermission requested,
int effective)
Internal implies method.
|
java.security.PermissionCollection |
newPermissionCollection()
Returns a new
PermissionCollection object for storing
CapabilityPermission objects. |
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(java.lang.String name,
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 REQUIRE
require
.public static final java.lang.String PROVIDE
provide
.private static final int ACTION_REQUIRE
private static final int ACTION_PROVIDE
private static final int ACTION_ALL
static final int ACTION_NONE
transient int action_mask
private volatile java.lang.String actions
final transient java.util.Map<java.lang.String,java.lang.Object> attributes
final transient Bundle bundle
transient Filter filter
private transient volatile java.util.Map<java.lang.String,java.lang.Object> properties
public CapabilityPermission(java.lang.String name, java.lang.String actions)
The name is specified as a dot-separated string. Wildcards may be used.
name ::= <namespace> | <namespace ending in ".*"> | *Examples:
com.acme.capability.* org.foo.capability *For the
require
action, the name can also be a filter expression.
The filter gives access to the capability attributes as well as the
following attributes:
There are two possible actions: require
and provide
. The
require
permission allows the owner of this permission to require
a capability matching the attributes. The provide
permission
allows the bundle to provide a capability in the specified capability
namespace.
name
- The capability namespace or a filter over the attributes.actions
- require
,provide
(canonical order)java.lang.IllegalArgumentException
- If the specified name is a filter
expression and either the specified action is not require
or the filter has an invalid syntax.public CapabilityPermission(java.lang.String namespace, java.util.Map<java.lang.String,?> attributes, Bundle providingBundle, java.lang.String actions)
CapabilityPermission
object to be used by
code that must perform checkPermission
for the require
action. CapabilityPermission
objects created with this
constructor cannot be added to a CapabilityPermission
permission
collection.namespace
- The requested capability namespace.attributes
- The requested capability attributes.providingBundle
- The bundle providing the requested capability.actions
- The action require
.java.lang.IllegalArgumentException
- If the specified action is not
require
or attributes or providingBundle are null
.CapabilityPermission(java.lang.String name, int mask)
name
- class namemask
- action maskprivate void setTransients(java.lang.String name, 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)
CapabilityPermission
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(CapabilityPermission requested, int effective)
requested
- The requested CapabilityPermission which has already be
validated as a proper argument. The requested CapabilityPermission
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()
require
,
provide
.getActions
in class java.security.BasicPermission
public java.security.PermissionCollection newPermissionCollection()
PermissionCollection
object for storing
CapabilityPermission
objects.newPermissionCollection
in class java.security.BasicPermission
PermissionCollection
object suitable for storing
CapabilityPermission
objects.public boolean equals(java.lang.Object obj)
CapabilityPermission
.equals
in class java.security.BasicPermission
obj
- The object to test for equality.CapabilityPermission
, and has the same
name and actions as this CapabilityPermission
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.Map<java.lang.String,java.lang.Object> getProperties()
implies(Permission)
. This method
is only called on a requested permission which cannot have a filter set.