Top Description Inners Fields Constructors Methods
org.osgi.framework

public final Class CapabilityPermission

Additional top-level class in compilation unit: CapabilityPermissionCollection.

extends BasicPermission
Class Inheritance
Imports
java.io.IOException, .NotSerializableException, .ObjectInputStream, .ObjectOutputStream, .ObjectStreamField, java.security.AccessController, .BasicPermission, .Permission, .PermissionCollection, .PrivilegedAction, java.util.AbstractMap, .ArrayList, .Collection, .Collections, .Enumeration, .HashMap, .HashSet, .List, .Map, .Set

A bundle's authority to provide or require a capability.
Author
$Id: c7bae50cab3a92ba810fcf983081c008f22a6bbd $
Since
1.6

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final int
pack-priv transient int
action_mask

The actions mask.

pack-priv static final int
private static final int
private static final int
private volatile String
actions

The actions in canonical form.

pack-priv final transient Map<String, Object>
attributes

The attributes of the requested capability.

pack-priv final transient Bundle
bundle

The bundle of the requested capability.

pack-priv transient Filter
filter

If this CapabilityPermission was constructed with a filter, this holds a Filter matching object used to evaluate the filter in implies.

private transient volatile Map<String, Object>
properties

This map holds the properties of the permission, used to match a filter in implies.

public static final String
PROVIDE

The action string provide.

public static final String
REQUIRE

The action string require.

pack-priv static final long

Constructor Summary

AccessConstructor and Description
public
CapabilityPermission(String
The capability namespace or a filter over the attributes.
name
,
String
require,provide (canonical order)
actions
)

Create a new CapabilityPermission.

public
CapabilityPermission(String
The requested capability namespace.
namespace
,
Map<String, ?>
The requested capability attributes.
attributes
,
Bundle
The bundle providing the requested capability.
providingBundle
,
String
The action require.
actions
)

Creates a new requested CapabilityPermission object to be used by code that must perform checkPermission for the require action.

pack-priv
CapabilityPermission(String
class name
name
,
int
action mask
mask
)

Package private constructor used by CapabilityPermissionCollection.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if obj is a CapabilityPermission, and has the same name and actions as this CapabilityPermission object; false otherwise.
equals
(Object
The object to test for equality.
obj
)

Overrides java.security.BasicPermission.equals.

Determines the equality of two CapabilityPermission objects.

public String

Returns:

The canonical string representation of the actions.
getActions
()

Overrides java.security.BasicPermission.getActions.

Returns the canonical string representation of the actions.

private Map<String, Object>

Returns:

a map of properties for this permission.
getProperties
()

Called by CapabilityPermission#implies(Permission).

public int

Returns:

Hash code value for this object.
hashCode
()

Overrides java.security.BasicPermission.hashCode.

Returns the hash code value for this object.

public boolean

Returns:

true if the specified permission is implied by this object; false otherwise.
implies
(Permission
The target permission to check.
p
)

Overrides java.security.BasicPermission.implies.

Determines if a CapabilityPermission object "implies" the specified permission.

pack-priv boolean

Returns:

true if the specified permission is implied by this object; false otherwise.
implies0
(CapabilityPermission
The requested CapabilityPermission which has already be validated as a proper argument. The requested CapabilityPermission must not have a filter expression.
requested
,
int
The effective actions with which to start.
effective
)

Internal implies method.

public PermissionCollection

Returns:

A new PermissionCollection object suitable for storing CapabilityPermission objects.
newPermissionCollection
()

Overrides java.security.BasicPermission.newPermissionCollection.

Returns a new PermissionCollection object for storing CapabilityPermission objects.

private static int

Returns:

action mask.
parseActions
(String
Action string.
actions
)

Parse action string into action mask.

private static Filter

Returns:

a Filter for this bundle. If the specified filterString is not a filter expression, then null is returned.
parseFilter
(String
The filter string to parse.
filterString
)

Parse filter string into a Filter object.

private synchronized void
readObject(ObjectInputStream
the ObjectInputStream from which data is read
s
)

Hides java.security.BasicPermission.readObject.

readObject is called to restore the state of this permission from a stream.

private void
setTransients(String name, int
action mask
mask
)

Called by constructors and when deserialized.

private synchronized void
writeObject(ObjectOutputStream s)

WriteObject is called to save the state of this permission to a stream.

Field Detail

ACTION_ALLback to summary
private static final int ACTION_ALL
action_maskback to summary
pack-priv transient int action_mask

The actions mask.

ACTION_NONEback to summary
pack-priv static final int ACTION_NONE
ACTION_PROVIDEback to summary
private static final int ACTION_PROVIDE
ACTION_REQUIREback to summary
private static final int ACTION_REQUIRE
actionsback to summary
private volatile String actions

The actions in canonical form.

attributesback to summary
pack-priv final transient Map<String, Object> attributes

The attributes of the requested capability. Must be null if not constructed with attributes.

bundleback to summary
pack-priv final transient Bundle bundle

The bundle of the requested capability. Must be null if not constructed with bundle.

filterback to summary
pack-priv transient Filter filter

If this CapabilityPermission was constructed with a filter, this holds a Filter matching object used to evaluate the filter in implies.

propertiesback to summary
private transient volatile Map<String, Object> properties

This map holds the properties of the permission, used to match a filter in implies. This is not initialized until necessary, and then cached in this object.

PROVIDEback to summary
public static final String PROVIDE

The action string provide.

REQUIREback to summary
public static final String REQUIRE

The action string require.

serialVersionUIDback to summary
pack-priv static final long serialVersionUID

Hides java.security.BasicPermission.serialVersionUID.

Constructor Detail

CapabilityPermissionback to summary
public CapabilityPermission(String name, 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 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:
  • 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.
Since the above attribute names may conflict with attribute names of a capability, you can prefix an attribute name with '@' in the filter expression to match against the capability attributes and not one of the above attributes. Filter attribute names are processed in a case sensitive manner.

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.

Parameters
name:String

The capability namespace or a filter over the attributes.

actions:String

require,provide (canonical order)

Exceptions
IllegalArgumentException:
If the specified name is a filter expression and either the specified action is not require or the filter has an invalid syntax.
CapabilityPermissionback to summary
public CapabilityPermission(String namespace, Map<String, ?> attributes, Bundle providingBundle, String actions)

Creates a new requested 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.

Parameters
namespace:String

The requested capability namespace.

attributes:Map<String, ?>

The requested capability attributes.

providingBundle:Bundle

The bundle providing the requested capability.

actions:String

The action require.

Exceptions
IllegalArgumentException:
If the specified action is not require or attributes or providingBundle are null .
CapabilityPermissionback to summary
pack-priv CapabilityPermission(String name, int mask)

Package private constructor used by CapabilityPermissionCollection.

Parameters
name:String

class name

mask:int

action mask

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.security.BasicPermission.equals.

Determines the equality of two CapabilityPermission objects. Checks that specified object has the same name and action as this CapabilityPermission.

Parameters
obj:Object

The object to test for equality.

Returns:boolean

true if obj is a CapabilityPermission, and has the same name and actions as this CapabilityPermission object; false otherwise.

Annotations
@Override
getActionsback to summary
public String getActions()

Overrides java.security.BasicPermission.getActions.

Returns the canonical string representation of the actions. Always returns present actions in the following order: require, provide.

Returns:String

The canonical string representation of the actions.

Annotations
@Override
getPropertiesback to summary
private Map<String, Object> getProperties()

Called by CapabilityPermission#implies(Permission). This method is only called on a requested permission which cannot have a filter set.

Returns:Map<String, Object>

a map of properties for this permission.

hashCodeback to summary
public int hashCode()

Overrides java.security.BasicPermission.hashCode.

Returns the hash code value for this object.

Returns:int

Hash code value for this object.

Annotations
@Override
impliesback to summary
public boolean implies(Permission p)

Overrides java.security.BasicPermission.implies.

Determines if a CapabilityPermission object "implies" the specified permission.

Parameters
p:Permission

The target permission to check.

Returns:boolean

true if the specified permission is implied by this object; false otherwise.

Annotations
@Override
implies0back to summary
pack-priv boolean implies0(CapabilityPermission requested, int effective)

Internal implies method. Used by the implies and the permission collection implies methods.

Parameters
requested:CapabilityPermission

The requested CapabilityPermission which has already be validated as a proper argument. The requested CapabilityPermission must not have a filter expression.

effective:int

The effective actions with which to start.

Returns:boolean

true if the specified permission is implied by this object; false otherwise.

newPermissionCollectionback to summary
public PermissionCollection newPermissionCollection()

Overrides java.security.BasicPermission.newPermissionCollection.

Returns a new PermissionCollection object for storing CapabilityPermission objects.

Returns:PermissionCollection

A new PermissionCollection object suitable for storing CapabilityPermission objects.

Annotations
@Override
parseActionsback to summary
private static int parseActions(String actions)

Parse action string into action mask.

Parameters
actions:String

Action string.

Returns:int

action mask.

parseFilterback to summary
private static Filter parseFilter(String filterString)

Parse filter string into a Filter object.

Parameters
filterString:String

The filter string to parse.

Returns:Filter

a Filter for this bundle. If the specified filterString is not a filter expression, then null is returned.

Exceptions
IllegalArgumentException:
If the filter syntax is invalid.
readObjectback to summary
private synchronized void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException

Hides java.security.BasicPermission.readObject.

readObject is called to restore the state of this permission from a stream.

Parameters
s:ObjectInputStream

Doc from java.security.BasicPermission.readObject.

the ObjectInputStream from which data is read

Exceptions
IOException:

Doc from java.security.BasicPermission.readObject.

if an I/O error occurs

ClassNotFoundException:

Doc from java.security.BasicPermission.readObject.

if a serialized class cannot be loaded

setTransientsback to summary
private void setTransients(String name, int mask)

Called by constructors and when deserialized.

Parameters
mask:int

action mask

writeObjectback to summary
private synchronized void writeObject(ObjectOutputStream s) throws IOException

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.

org.osgi.framework back to summary

private final Class CapabilityPermission.Properties

extends AbstractMap<String, Object>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Map<String, Object>
private transient volatile Set<Map.Entry<String, Object>>
private final Map<String, Object>

Constructor Summary

AccessConstructor and Description
pack-priv
Properties(Map<String, Object> properties, Map<String, Object> attributes)

Method Summary

Modifier and TypeMethod and Description
public Set<Map.Entry<String, Object>>
entrySet()

Implements abstract java.util.AbstractMap.entrySet.

Implements java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map.

public Object
get(Object
the key whose associated value is to be returned
k
)

Overrides java.util.AbstractMap.get.

Implements java.util.Map.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Inherited from java.util.AbstractMap:
clearclonecontainsKeycontainsValueequalshashCodeisEmptykeySetputputAllremovesizetoStringvalues

Field Detail

attributesback to summary
private final Map<String, Object> attributes
entriesback to summary
private transient volatile Set<Map.Entry<String, Object>> entries
propertiesback to summary
private final Map<String, Object> properties

Constructor Detail

Propertiesback to summary
pack-priv Properties(Map<String, Object> properties, Map<String, Object> attributes)

Method Detail

entrySetback to summary
public Set<Map.Entry<String, Object>> entrySet()

Implements abstract java.util.AbstractMap.entrySet.

Implements java.util.Map.entrySet.

Doc from java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation, or through the setValue operation on a map entry returned by the iterator) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.

Returns:Set<Map.Entry<String, Object>>

a set view of the mappings contained in this map

Annotations
@Override
getback to summary
public Object get(Object k)

Overrides java.util.AbstractMap.get.

Implements java.util.Map.get.

Doc from java.util.AbstractMap.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

More formally, if this map contains a mapping from a key k to a value v such that Objects.equals(key, k), then this method returns v; otherwise it returns null. (There can be at most one such mapping.)

If this map permits null values, then a return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.

Parameters
k:Object

Doc from java.util.Map.get.

the key whose associated value is to be returned

Returns:Object

Doc from java.util.Map.get.

the value to which the specified key is mapped, or null if this map contains no mapping for the key

Annotations
@Override