Class AdminPermission
- All Implemented Interfaces:
Serializable
,Guard
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:
- signer - A Distinguished Name chain used to sign a bundle. 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 a bundle.
- id - The bundle ID of the designated bundle.
- name - The symbolic name of a bundle.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate 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
(package private) int
The actions mask.private static final int
(package private) static final int
private static final int
private static final int
private static final int
private static final int
private String
The actions in canonical form.(package private) final Bundle
The bundle governed by this AdminPermission - only used if filter == nullstatic final String
The action stringclass
.static final String
The action stringcontext
.static final String
The action stringexecute
.static final String
The action stringextensionLifecycle
.(package private) Filter
If this AdminPermission was constructed with a filter, this holds a Filter matching object used to evaluate the filter in implies.static final String
The action stringlifecycle
.static final String
The action stringlistener
.static final String
The action stringmetadata
.This map holds the properties of the permission, used to match a filter in implies.private static final ThreadLocal<Bundle>
ThreadLocal used to determine if we have recursively called getProperties.static final String
The action stringresolve
.static final String
The action stringresource
.(package private) static final long
static final String
The action stringstartlevel
.static final String
The action stringweave
. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newAdminPermission
object that matches all bundles and has all actions.AdminPermission
(String filter, String actions) Create a new AdminPermission.AdminPermission
(Bundle bundle, String actions) Creates a new requestedAdminPermission
object to be used by the code that must performcheckPermission
.AdminPermission
(Filter filter, int mask) Package private constructor used by AdminPermissionCollection. -
Method Summary
Modifier and TypeMethodDescriptionprivate static String
createName
(Bundle bundle) Create a permission name from a Bundleboolean
Determines the equality of twoAdminPermission
objects.Returns the canonical string representation of theAdminPermission
actions.Called byimplies0
on an AdminPermission which was constructed with a Bundle.int
hashCode()
Returns the hash code value for this object.boolean
Determines if the specified permission is implied by this object.(package private) boolean
implies0
(AdminPermission requested, int effective) Internal implies method.Returns a newPermissionCollection
object suitable for storingAdminPermission
s.private static int
parseActions
(String actions) Parse action string into action mask.private static Filter
parseFilter
(String filterString) Parse filter string into a Filter object.private void
readObject is called to restore the state of this permission from a stream.private void
setTransients
(Filter filter, int mask) Called by constructors and when deserialized.private void
WriteObject is called to save the state of this permission object to a stream.Methods inherited from class java.security.Permission
checkGuard, getName, toString
-
Field Details
-
serialVersionUID
static final long serialVersionUID- See Also:
-
CLASS
The action stringclass
. Theclass
action implies theresolve
action.- Since:
- 1.3
- See Also:
-
EXECUTE
The action stringexecute
. Theexecute
action implies theresolve
action.- Since:
- 1.3
- See Also:
-
EXTENSIONLIFECYCLE
The action stringextensionLifecycle
.- Since:
- 1.3
- See Also:
-
LIFECYCLE
The action stringlifecycle
.- Since:
- 1.3
- See Also:
-
LISTENER
The action stringlistener
.- Since:
- 1.3
- See Also:
-
METADATA
The action stringmetadata
.- Since:
- 1.3
- See Also:
-
RESOLVE
The action stringresolve
. Theresolve
action is implied by theclass
,execute
andresource
actions.- Since:
- 1.3
- See Also:
-
RESOURCE
The action stringresource
. Theresource
action implies theresolve
action.- Since:
- 1.3
- See Also:
-
STARTLEVEL
The action stringstartlevel
.- Since:
- 1.3
- See Also:
-
CONTEXT
The action stringcontext
.- Since:
- 1.4
- See Also:
-
WEAVE
The action stringweave
.- Since:
- 1.6
- See Also:
-
ACTION_CLASS
private static final int ACTION_CLASS- See Also:
-
ACTION_EXECUTE
private static final int ACTION_EXECUTE- See Also:
-
ACTION_LIFECYCLE
private static final int ACTION_LIFECYCLE- See Also:
-
ACTION_LISTENER
private static final int ACTION_LISTENER- See Also:
-
ACTION_METADATA
private static final int ACTION_METADATA- See Also:
-
ACTION_RESOLVE
private static final int ACTION_RESOLVE- See Also:
-
ACTION_RESOURCE
private static final int ACTION_RESOURCE- See Also:
-
ACTION_STARTLEVEL
private static final int ACTION_STARTLEVEL- See Also:
-
ACTION_EXTENSIONLIFECYCLE
private static final int ACTION_EXTENSIONLIFECYCLE- See Also:
-
ACTION_CONTEXT
private static final int ACTION_CONTEXT- See Also:
-
ACTION_WEAVE
private static final int ACTION_WEAVE- See Also:
-
ACTION_ALL
private static final int ACTION_ALL- See Also:
-
ACTION_NONE
static final int ACTION_NONE- See Also:
-
actions
The actions in canonical form. -
action_mask
transient int action_maskThe actions mask. -
filter
If this AdminPermission was constructed with a filter, this holds a Filter matching object used to evaluate the filter in implies. -
bundle
The bundle governed by this AdminPermission - only used if filter == null -
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. -
recurse
ThreadLocal used to determine if we have recursively called getProperties.
-
-
Constructor Details
-
AdminPermission
public AdminPermission()Creates a newAdminPermission
object that matches all bundles and has all actions. Equivalent to AdminPermission("*","*"); -
AdminPermission
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
- A filter expression that can use signer, location, id, and name keys. A value of "*" ornull
matches all bundle. Filter attribute names are processed in a case sensitive manner.actions
-class
,execute
,extensionLifecycle
,lifecycle
,listener
,metadata
,resolve
,resource
,startlevel
,context
orweave
. A value of "*" ornull
indicates all actions.- Throws:
IllegalArgumentException
- If the filter has an invalid syntax.
-
AdminPermission
Creates a new requestedAdminPermission
object to be used by the code that must performcheckPermission
.AdminPermission
objects created with this constructor cannot be added to anAdminPermission
permission collection.- Parameters:
bundle
- A bundle.actions
-class
,execute
,extensionLifecycle
,lifecycle
,listener
,metadata
,resolve
,resource
,startlevel
,context
,weave
. A value of "*" ornull
indicates all actions.- Since:
- 1.3
-
AdminPermission
AdminPermission(Filter filter, int mask) Package private constructor used by AdminPermissionCollection.- Parameters:
filter
- name filter ornull
for wildcard.mask
- action mask
-
-
Method Details
-
createName
Create a permission name from a Bundle- Parameters:
bundle
- Bundle to use to create permission name.- Returns:
- permission name.
-
setTransients
Called by constructors and when deserialized.- Parameters:
filter
- Permission's filter ornull
for wildcard.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
null
or equals "*", thennull
is returned to indicate a wildcard. - Throws:
IllegalArgumentException
- If the filter syntax is invalid.
-
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 "*"
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- Overrides:
implies
in classBasicPermission
- Parameters:
p
- The requested permission.- Returns:
true
if the specified permission is implied by this object;false
otherwise.
-
implies0
Internal implies method. Used by the implies and the permission collection implies methods.- Parameters:
requested
- The requested AdminPermision which has already be validated as a proper argument. The requested AdminPermission must not have a filter expression.effective
- The effective actions with which to start.- Returns:
true
if the specified permission is implied by this object;false
otherwise.
-
getActions
Returns the canonical string representation of theAdminPermission
actions.Always returns present
AdminPermission
actions in the following order:class
,execute
,extensionLifecycle
,lifecycle
,listener
,metadata
,resolve
,resource
,startlevel
,context
,weave
.- Overrides:
getActions
in classBasicPermission
- Returns:
- Canonical string representation of the
AdminPermission
actions.
-
newPermissionCollection
Returns a newPermissionCollection
object suitable for storingAdminPermission
s.- Overrides:
newPermissionCollection
in classBasicPermission
- Returns:
- A new
PermissionCollection
object.
-
equals
Determines the equality of twoAdminPermission
objects.- Overrides:
equals
in classBasicPermission
- Parameters:
obj
- The object being compared for equality with this object.- Returns:
true
ifobj
is equivalent to thisAdminPermission
;false
otherwise.
-
hashCode
public int hashCode()Returns the hash code value for this object.- Overrides:
hashCode
in classBasicPermission
- Returns:
- Hash code value for this object.
-
writeObject
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.- Throws:
IOException
-
readObject
readObject is called to restore the state of this permission from a stream.- Throws:
IOException
ClassNotFoundException
-
getProperties
Called byimplies0
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:
- a map of properties for this bundle
-