Top Description Fields Constructors Methods
org.osgi.framework

public final Class AdminPermission

Additional top-level class in compilation unit: AdminPermissionCollection.

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

A bundle's authority to perform specific privileged administrative operations on or to get sensitive information about a bundle. The actions for this permission are:
Action             Methods
class              Bundle.loadClass
execute            Bundle.start
                   Bundle.stop
                   BundleStartLevel.setStartLevel
extensionLifecycle BundleContext.installBundle for extension bundles
                   Bundle.update for extension bundles
                   Bundle.uninstall for extension bundles
lifecycle          BundleContext.installBundle
                   Bundle.update
                   Bundle.uninstall
listener           BundleContext.addBundleListener for
                     SynchronousBundleListener
                   BundleContext.removeBundleListener for
                     SynchronousBundleListener
metadata           Bundle.getHeaders
                   Bundle.getLocation
resolve            FrameworkWiring.refreshBundles
                   FrameworkWiring.resolveBundles
resource           Bundle.getResource
                   Bundle.getResources
                   Bundle.getEntry
                   Bundle.getEntryPaths
                   Bundle.findEntries
                   Bundle resource/entry URL creation
startlevel         FrameworkStartLevel.setStartLevel
                   FrameworkStartLevel.setInitialBundleStartLevel
context            Bundle.getBundleContext
weave              WovenClass.getBytes
                   WovenClass.setBytes
                   WovenClass.getDynamicImports for modification

The special action "*" will represent all actions. The resolve action is implied by the class, execute and resource actions.

The name of this permission is a filter expression. The filter gives access to the following attributes:

Filter attribute names are processed in a case sensitive manner.
Author
$Id: 2a803b07dcdc9af47ca0cb208d96fcd9c0bcfb0c $

Field Summary

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

The actions mask.

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

The actions in canonical form.

pack-priv final transient Bundle
bundle

The bundle governed by this AdminPermission - only used if filter == null

public static final String
CLASS

The action string class.

public static final String
CONTEXT

The action string context.

public static final String
EXECUTE

The action string execute.

public static final String
EXTENSIONLIFECYCLE

The action string extensionLifecycle.

pack-priv transient Filter
filter

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

public static final String
LIFECYCLE

The action string lifecycle.

public static final String
LISTENER

The action string listener.

public static final String
METADATA

The action string metadata.

private transient volatile Map<String, Object>
properties

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

private static final ThreadLocal<Bundle>
recurse

ThreadLocal used to determine if we have recursively called getProperties.

public static final String
RESOLVE

The action string resolve.

public static final String
RESOURCE

The action string resource.

pack-priv static final long
public static final String
STARTLEVEL

The action string startlevel.

public static final String
WEAVE

The action string weave.

Constructor Summary

AccessConstructor and Description
public
AdminPermission()

Creates a new AdminPermission object that matches all bundles and has all actions.

public
AdminPermission(String
A filter expression that can use signer, location, id, and name keys. A value of "*" or null matches all bundle. Filter attribute names are processed in a case sensitive manner.
filter
,
String
class, execute, extensionLifecycle , lifecycle, listener, metadata, resolve , resource, startlevel, context or weave. A value of "*" or null indicates all actions.
actions
)

Create a new AdminPermission.

public
AdminPermission(Bundle
A bundle.
bundle
,
String
class, execute, extensionLifecycle , lifecycle, listener, metadata, resolve , resource, startlevel, context, weave. A value of "*" or null indicates all actions.
actions
)

Creates a new requested AdminPermission object to be used by the code that must perform checkPermission.

pack-priv
AdminPermission(Filter
name filter or null for wildcard.
filter
,
int
action mask
mask
)

Package private constructor used by AdminPermissionCollection.

Method Summary

Modifier and TypeMethod and Description
private static String

Returns:

permission name.
createName
(Bundle
Bundle to use to create permission name.
bundle
)

Create a permission name from a Bundle

public boolean

Returns:

true if obj is equivalent to this AdminPermission; false otherwise.
equals
(Object
The object being compared for equality with this object.
obj
)

Overrides java.security.BasicPermission.equals.

Determines the equality of two AdminPermission objects.

public String

Returns:

Canonical string representation of the AdminPermission actions.
getActions
()

Overrides java.security.BasicPermission.getActions.

Returns the canonical string representation of the AdminPermission actions.

private Map<String, Object>

Returns:

a map of properties for this bundle
getProperties
()

Called by implies0 on an AdminPermission which was constructed with a Bundle.

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 requested permission.
p
)

Overrides java.security.BasicPermission.implies.

Determines if the specified permission is implied by this object.

pack-priv boolean

Returns:

true if the specified permission is implied by this object; false otherwise.
implies0
(AdminPermission
The requested AdminPermision which has already be validated as a proper argument. The requested AdminPermission 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.
newPermissionCollection
()

Overrides java.security.BasicPermission.newPermissionCollection.

Returns a new PermissionCollection object suitable for storing AdminPermissions.

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 null or equals "*", then null is returned to indicate a wildcard.
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(Filter
Permission's filter or null for wildcard.
filter
,
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 object to a stream.

Field Detail

ACTION_ALLback to summary
private static final int ACTION_ALL
ACTION_CLASSback to summary
private static final int ACTION_CLASS
ACTION_CONTEXTback to summary
private static final int ACTION_CONTEXT
ACTION_EXECUTEback to summary
private static final int ACTION_EXECUTE
ACTION_EXTENSIONLIFECYCLEback to summary
private static final int ACTION_EXTENSIONLIFECYCLE
ACTION_LIFECYCLEback to summary
private static final int ACTION_LIFECYCLE
ACTION_LISTENERback to summary
private static final int ACTION_LISTENER
action_maskback to summary
pack-priv transient int action_mask

The actions mask.

ACTION_METADATAback to summary
private static final int ACTION_METADATA
ACTION_NONEback to summary
pack-priv static final int ACTION_NONE
ACTION_RESOLVEback to summary
private static final int ACTION_RESOLVE
ACTION_RESOURCEback to summary
private static final int ACTION_RESOURCE
ACTION_STARTLEVELback to summary
private static final int ACTION_STARTLEVEL
ACTION_WEAVEback to summary
private static final int ACTION_WEAVE
actionsback to summary
private volatile String actions

The actions in canonical form.

bundleback to summary
pack-priv final transient Bundle bundle

The bundle governed by this AdminPermission - only used if filter == null

CLASSback to summary
public static final String CLASS

The action string class. The class action implies the resolve action.

Since
1.3
CONTEXTback to summary
public static final String CONTEXT

The action string context.

Since
1.4
EXECUTEback to summary
public static final String EXECUTE

The action string execute. The execute action implies the resolve action.

Since
1.3
EXTENSIONLIFECYCLEback to summary
public static final String EXTENSIONLIFECYCLE

The action string extensionLifecycle.

Since
1.3
filterback to summary
pack-priv transient Filter filter

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

LIFECYCLEback to summary
public static final String LIFECYCLE

The action string lifecycle.

Since
1.3
LISTENERback to summary
public static final String LISTENER

The action string listener.

Since
1.3
METADATAback to summary
public static final String METADATA

The action string metadata.

Since
1.3
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.

recurseback to summary
private static final ThreadLocal<Bundle> recurse

ThreadLocal used to determine if we have recursively called getProperties.

RESOLVEback to summary
public static final String RESOLVE

The action string resolve. The resolve action is implied by the class, execute and resource actions.

Since
1.3
RESOURCEback to summary
public static final String RESOURCE

The action string resource. The resource action implies the resolve action.

Since
1.3
serialVersionUIDback to summary
pack-priv static final long serialVersionUID

Hides java.security.BasicPermission.serialVersionUID.

STARTLEVELback to summary
public static final String STARTLEVEL

The action string startlevel.

Since
1.3
WEAVEback to summary
public static final String WEAVE

The action string weave.

Since
1.6

Constructor Detail

AdminPermissionback to summary
public AdminPermission()

Creates a new AdminPermission object that matches all bundles and has all actions. Equivalent to AdminPermission("*","*");

AdminPermissionback to summary
public AdminPermission(String filter, String actions)

Create a new AdminPermission. This constructor must only be used to create a permission that is going to be checked.

Examples:

(signer=\*,o=ACME,c=US)
(&(signer=\*,o=ACME,c=US)(name=com.acme.*)
  (location=http://www.acme.com/bundles/*))
(id>=1)

When a signer key is used within the filter expression the signer value must escape the special filter chars ('*', '(', ')').

Null arguments are equivalent to "*".

Parameters
filter:String

A filter expression that can use signer, location, id, and name keys. A value of "*" or null matches all bundle. Filter attribute names are processed in a case sensitive manner.

actions:String

class, execute, extensionLifecycle , lifecycle, listener, metadata, resolve , resource, startlevel, context or weave. A value of "*" or null indicates all actions.

Exceptions
IllegalArgumentException:
If the filter has an invalid syntax.
AdminPermissionback to summary
public AdminPermission(Bundle bundle, String actions)

Creates a new requested AdminPermission object to be used by the code that must perform checkPermission. AdminPermission objects created with this constructor cannot be added to an AdminPermission permission collection.

Parameters
bundle:Bundle

A bundle.

actions:String

class, execute, extensionLifecycle , lifecycle, listener, metadata, resolve , resource, startlevel, context, weave. A value of "*" or null indicates all actions.

Since
1.3
AdminPermissionback to summary
pack-priv AdminPermission(Filter filter, int mask)

Package private constructor used by AdminPermissionCollection.

Parameters
filter:Filter

name filter or null for wildcard.

mask:int

action mask

Method Detail

createNameback to summary
private static String createName(Bundle bundle)

Create a permission name from a Bundle

Parameters
bundle:Bundle

Bundle to use to create permission name.

Returns:String

permission name.

equalsback to summary
public boolean equals(Object obj)

Overrides java.security.BasicPermission.equals.

Determines the equality of two AdminPermission objects.

Parameters
obj:Object

The object being compared for equality with this object.

Returns:boolean

true if obj is equivalent to this AdminPermission; false otherwise.

Annotations
@Override
getActionsback to summary
public String getActions()

Overrides java.security.BasicPermission.getActions.

Returns the canonical string representation of the AdminPermission actions.

Always returns present AdminPermission actions in the following order: class, execute, extensionLifecycle, lifecycle, listener, metadata, resolve, resource, startlevel, context, weave.

Returns:String

Canonical string representation of the AdminPermission actions.

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

Called by implies0 on an AdminPermission which was constructed with a Bundle. This method loads a map with the filter-matchable properties of this bundle. The map is cached so this lookup only happens once. This method should only be called on an AdminPermission which was constructed with a bundle

Returns:Map<String, Object>

a map of properties for this bundle

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 the specified permission is implied by this object. This method throws an exception if the specified permission was not constructed with a bundle.

This method returns true if the specified permission is an AdminPermission AND

  • this object's filter matches the specified permission's bundle ID, bundle symbolic name, bundle location and bundle signer distinguished name chain OR
  • this object's filter is "*"
AND this object's actions include all of the specified permission's actions.

Special case: if the specified permission was constructed with "*" filter, then this method returns true if this object's filter is "*" and this object's actions include all of the specified permission's actions

Parameters
p:Permission

The requested permission.

Returns:boolean

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

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

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

Parameters
requested:AdminPermission

The requested AdminPermision which has already be validated as a proper argument. The requested AdminPermission 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 suitable for storing AdminPermissions.

Returns:PermissionCollection

A new PermissionCollection object.

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 null or equals "*", then null is returned to indicate a wildcard.

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(Filter filter, int mask)

Called by constructors and when deserialized.

Parameters
filter:Filter

Permission's filter or null for wildcard.

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 object to a stream. The actions are serialized, and the superclass takes care of the name.