Class CapabilityPermission
java.lang.Object
java.security.Permission
java.security.BasicPermission
org.osgi.framework.CapabilityPermission
- All Implemented Interfaces:
Serializable, Guard
A bundle's authority to provide or require a capability.
- The
provideaction allows a bundle to provide a capability matching the specified filter. - The
requireaction allows a bundle to require a capability matching the specified filter.
- Since:
- 1.6
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int(package private) intThe actions mask.(package private) static final intprivate static final intprivate static final intprivate StringThe actions in canonical form.The attributes of the requested capability.(package private) final BundleThe bundle of the requested capability.(package private) FilterIf this CapabilityPermission was constructed with a filter, this holds a Filter matching object used to evaluate the filter in implies.This map holds the properties of the permission, used to match a filter in implies.static final StringThe action stringprovide.static final StringThe action stringrequire.(package private) static final long -
Constructor Summary
ConstructorsConstructorDescriptionCapabilityPermission(String name, int mask) Package private constructor used by CapabilityPermissionCollection.CapabilityPermission(String name, String actions) Create a new CapabilityPermission.CapabilityPermission(String namespace, Map<String, ?> attributes, Bundle providingBundle, String actions) Creates a new requestedCapabilityPermissionobject to be used by code that must performcheckPermissionfor therequireaction. -
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermines the equality of two CapabilityPermission objects.Returns the canonical string representation of the actions.Called byimplies(Permission).inthashCode()Returns the hash code value for this object.booleanDetermines if aCapabilityPermissionobject "implies" the specified permission.(package private) booleanimplies0(CapabilityPermission requested, int effective) Internal implies method.Returns a newPermissionCollectionobject for storingCapabilityPermissionobjects.private static intparseActions(String actions) Parse action string into action mask.private static FilterparseFilter(String filterString) Parse filter string into a Filter object.private voidreadObject is called to restore the state of this permission from a stream.private voidsetTransients(String name, int mask) Called by constructors and when deserialized.private voidWriteObject is called to save the state of this permission to a stream.Methods inherited from class Permission
checkGuard, getName, toString
-
Field Details
-
serialVersionUID
static final long serialVersionUID- See Also:
-
REQUIRE
-
PROVIDE
-
ACTION_REQUIRE
private static final int ACTION_REQUIRE- See Also:
-
ACTION_PROVIDE
private static final int ACTION_PROVIDE- See Also:
-
ACTION_ALL
private static final int ACTION_ALL- See Also:
-
ACTION_NONE
static final int ACTION_NONE- See Also:
-
action_mask
transient int action_maskThe actions mask. -
actions
The actions in canonical form. -
attributes
-
bundle
The bundle of the requested capability. Must be null if not constructed with bundle. -
filter
If this CapabilityPermission was constructed with a filter, this holds a Filter matching object used to evaluate the filter in implies. -
properties
-
-
Constructor Details
-
CapabilityPermission
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 therequireaction, 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:
requireandprovide. Therequirepermission allows the owner of this permission to require a capability matching the attributes. Theprovidepermission 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:
IllegalArgumentException- If the specified name is a filter expression and either the specified action is notrequireor the filter has an invalid syntax.
-
CapabilityPermission
public CapabilityPermission(String namespace, Map<String, ?> attributes, Bundle providingBundle, String actions) Creates a new requestedCapabilityPermissionobject to be used by code that must performcheckPermissionfor therequireaction.CapabilityPermissionobjects created with this constructor cannot be added to aCapabilityPermissionpermission collection.- Parameters:
namespace- The requested capability namespace.attributes- The requested capability attributes.providingBundle- The bundle providing the requested capability.actions- The actionrequire.- Throws:
IllegalArgumentException- If the specified action is notrequireor attributes or providingBundle arenull.
-
CapabilityPermission
CapabilityPermission(String name, int mask) Package private constructor used by CapabilityPermissionCollection.- Parameters:
name- class namemask- action mask
-
-
Method Details
-
setTransients
Called by constructors and when deserialized.- Parameters:
mask- action mask
-
parseActions
Parse action string into action mask.- Parameters:
actions- Action string.- Returns:
- action mask.
-
parseFilter
Parse filter string into a Filter object.- Parameters:
filterString- The filter string to parse.- Returns:
- a Filter for this bundle. If the specified filterString is not a
filter expression, then
nullis returned. - Throws:
IllegalArgumentException- If the filter syntax is invalid.
-
implies
Determines if aCapabilityPermissionobject "implies" the specified permission.- Overrides:
impliesin classBasicPermission- Parameters:
p- The target permission to check.- Returns:
trueif the specified permission is implied by this object;falseotherwise.
-
implies0
Internal implies method. Used by the implies and the permission collection implies methods.- Parameters:
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.- Returns:
trueif the specified permission is implied by this object;falseotherwise.
-
getActions
Returns the canonical string representation of the actions. Always returns present actions in the following order:require,provide.- Overrides:
getActionsin classBasicPermission- Returns:
- The canonical string representation of the actions.
-
newPermissionCollection
Returns a newPermissionCollectionobject for storingCapabilityPermissionobjects.- Overrides:
newPermissionCollectionin classBasicPermission- Returns:
- A new
PermissionCollectionobject suitable for storingCapabilityPermissionobjects.
-
equals
Determines the equality of two CapabilityPermission objects. Checks that specified object has the same name and action as thisCapabilityPermission.- Overrides:
equalsin classBasicPermission- Parameters:
obj- The object to test for equality.- Returns:
- true if obj is a
CapabilityPermission, and has the same name and actions as thisCapabilityPermissionobject;falseotherwise.
-
hashCode
public int hashCode()Returns the hash code value for this object.- Overrides:
hashCodein classBasicPermission- Returns:
- Hash code value for this object.
-
writeObject
WriteObject is called to save the state of this permission to a stream. The actions are serialized, and the superclass takes care of the name.- Throws:
IOException
-
readObject
readObject is called to restore the state of this permission from a stream.- Throws:
IOExceptionClassNotFoundException
-
getProperties
Called byimplies(Permission). This method is only called on a requested permission which cannot have a filter set.- Returns:
- a map of properties for this permission.
-