Package org.osgi.framework
Class CapabilityPermission
- java.lang.Object
-
- java.security.Permission
-
- java.security.BasicPermission
-
- org.osgi.framework.CapabilityPermission
-
- All Implemented Interfaces:
java.io.Serializable
,java.security.Guard
public final class CapabilityPermission extends java.security.BasicPermission
A bundle's authority to provide or require a capability.- The
provide
action allows a bundle to provide a capability matching the specified filter. - The
require
action allows a bundle to require a capability matching the specified filter.
- Since:
- 1.6
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CapabilityPermission(java.lang.String name, java.lang.String actions)
Create a new CapabilityPermission.CapabilityPermission(java.lang.String namespace, java.util.Map<java.lang.String,?> attributes, Bundle providingBundle, java.lang.String actions)
Creates a new requestedCapabilityPermission
object to be used by code that must performcheckPermission
for therequire
action.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.int
hashCode()
Returns the hash code value for this object.boolean
implies(java.security.Permission p)
Determines if aCapabilityPermission
object "implies" the specified permission.java.security.PermissionCollection
newPermissionCollection()
Returns a newPermissionCollection
object for storingCapabilityPermission
objects.
-
-
-
Field Detail
-
REQUIRE
public static final java.lang.String REQUIRE
The action stringrequire
.- See Also:
- Constant Field Values
-
PROVIDE
public static final java.lang.String PROVIDE
The action stringprovide
.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CapabilityPermission
public CapabilityPermission(java.lang.String name, java.lang.String actions)
Create a new CapabilityPermission.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 therequire
action, the name can also be a filter expression. The filter gives access to the capability attributes as well as the following attributes:- signer - A Distinguished Name chain used to sign the bundle providing the capability. Wildcards in a DN are not matched according to the filter string rules, but according to the rules defined for a DN chain.
- location - The location of the bundle providing the capability.
- id - The bundle ID of the bundle providing the capability.
- name - The symbolic name of the bundle providing the capability.
- capability.namespace - The namespace of the required capability.
There are two possible actions:
require
andprovide
. Therequire
permission allows the owner of this permission to require a capability matching the attributes. Theprovide
permission allows the bundle to provide a capability in the specified capability namespace.- Parameters:
name
- The capability namespace or a filter over the attributes.actions
-require
,provide
(canonical order)- Throws:
java.lang.IllegalArgumentException
- If the specified name is a filter expression and either the specified action is notrequire
or the filter has an invalid syntax.
-
CapabilityPermission
public CapabilityPermission(java.lang.String namespace, java.util.Map<java.lang.String,?> attributes, Bundle providingBundle, java.lang.String actions)
Creates a new requestedCapabilityPermission
object to be used by code that must performcheckPermission
for therequire
action.CapabilityPermission
objects created with this constructor cannot be added to aCapabilityPermission
permission collection.- Parameters:
namespace
- The requested capability namespace.attributes
- The requested capability attributes.providingBundle
- The bundle providing the requested capability.actions
- The actionrequire
.- Throws:
java.lang.IllegalArgumentException
- If the specified action is notrequire
or attributes or providingBundle arenull
.
-
-
Method Detail
-
implies
public boolean implies(java.security.Permission p)
Determines if aCapabilityPermission
object "implies" the specified permission.- Overrides:
implies
in classjava.security.BasicPermission
- Parameters:
p
- The target permission to check.- Returns:
true
if the specified permission is implied by this object;false
otherwise.
-
getActions
public java.lang.String getActions()
Returns the canonical string representation of the actions. Always returns present actions in the following order:require
,provide
.- 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 storingCapabilityPermission
objects.- Overrides:
newPermissionCollection
in classjava.security.BasicPermission
- Returns:
- A new
PermissionCollection
object suitable for storingCapabilityPermission
objects.
-
equals
public boolean equals(java.lang.Object obj)
Determines the equality of two CapabilityPermission objects. Checks that specified object has the same name and action as thisCapabilityPermission
.- Overrides:
equals
in classjava.security.BasicPermission
- Parameters:
obj
- The object to test for equality.- Returns:
- true if obj is a
CapabilityPermission
, and has the same name and actions as thisCapabilityPermission
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.
-
-