Class BundlePermission
- java.lang.Object
-
- java.security.Permission
-
- java.security.BasicPermission
-
- org.osgi.framework.BundlePermission
-
- All Implemented Interfaces:
java.io.Serializable,java.security.Guard
public final class BundlePermission extends java.security.BasicPermissionA bundle's authority to require or provide a bundle or to receive or attach fragments.A bundle symbolic name defines a unique fully qualified name. Wildcards may be used.
name ::= <symbolic name> | <symbolic name ending in ".*"> | *
Examples:org.osgi.example.bundle org.osgi.example.* *
BundlePermissionhas four actions:provide,require,host, andfragment. Theprovideaction implies therequireaction.- Since:
- 1.3
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static intACTION_ALLprivate static intACTION_FRAGMENTprivate static intACTION_HOSTprivate intaction_maskThe actions mask.(package private) static intACTION_NONEprivate static intACTION_PROVIDEprivate static intACTION_REQUIREprivate java.lang.StringactionsThe actions in canonical form.static java.lang.StringFRAGMENTThe action stringfragment.static java.lang.StringHOSTThe action stringhost.static java.lang.StringPROVIDEThe action stringprovide.static java.lang.StringREQUIREThe action stringrequire.private static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description BundlePermission(java.lang.String symbolicName, int mask)Package private constructor used by BundlePermissionCollection.BundlePermission(java.lang.String symbolicName, java.lang.String actions)Defines the authority to provide and/or require and or specify a host fragment symbolic name within the OSGi environment.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)Determines the equality of twoBundlePermissionobjects.java.lang.StringgetActions()Returns the canonical string representation of theBundlePermissionactions.(package private) intgetActionsMask()Returns the current action mask.inthashCode()Returns the hash code value for this object.booleanimplies(java.security.Permission p)Determines if the specified permission is implied by this object.java.security.PermissionCollectionnewPermissionCollection()Returns a newPermissionCollectionobject suitable for storingBundlePermissionobjects.private static intparseActions(java.lang.String actions)Parse action string into action mask.private voidreadObject(java.io.ObjectInputStream s)readObject is called to restore the state of the BundlePermission from a stream.private voidsetTransients(int mask)Called by constructors and when deserialized.private voidwriteObject(java.io.ObjectOutputStream s)WriteObject is called to save the state of theBundlePermissionobject to a stream.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
PROVIDE
public static final java.lang.String PROVIDE
The action stringprovide. Theprovideaction implies therequireaction.- See Also:
- Constant Field Values
-
REQUIRE
public static final java.lang.String REQUIRE
The action stringrequire. Therequireaction is implied by theprovideaction.- See Also:
- Constant Field Values
-
HOST
public static final java.lang.String HOST
The action stringhost.- See Also:
- Constant Field Values
-
FRAGMENT
public static final java.lang.String FRAGMENT
The action stringfragment.- See Also:
- Constant Field Values
-
ACTION_PROVIDE
private static final int ACTION_PROVIDE
- See Also:
- Constant Field Values
-
ACTION_REQUIRE
private static final int ACTION_REQUIRE
- See Also:
- Constant Field Values
-
ACTION_HOST
private static final int ACTION_HOST
- See Also:
- Constant Field Values
-
ACTION_FRAGMENT
private static final int ACTION_FRAGMENT
- See Also:
- Constant Field Values
-
ACTION_ALL
private static final int ACTION_ALL
- See Also:
- Constant Field Values
-
ACTION_NONE
static final int ACTION_NONE
- See Also:
- Constant Field Values
-
action_mask
private transient int action_mask
The actions mask.
-
actions
private volatile java.lang.String actions
The actions in canonical form.
-
-
Constructor Detail
-
BundlePermission
public BundlePermission(java.lang.String symbolicName, java.lang.String actions)Defines the authority to provide and/or require and or specify a host fragment symbolic name within the OSGi environment.Bundle Permissions are granted over all possible versions of a bundle. A bundle that needs to provide a bundle must have the appropriate
BundlePermissionfor the symbolic name; a bundle that requires a bundle must have the appropriateBundlePermssionfor that symbolic name; a bundle that specifies a fragment host must have the appropriateBundlePermissionfor that symbolic name.- Parameters:
symbolicName- The bundle symbolic name.actions-provide,require,host,fragment(canonical order).
-
BundlePermission
BundlePermission(java.lang.String symbolicName, int mask)Package private constructor used by BundlePermissionCollection.- Parameters:
symbolicName- the bundle symbolic namemask- the action mask
-
-
Method Detail
-
setTransients
private void setTransients(int mask)
Called by constructors and when deserialized.- Parameters:
mask-
-
getActionsMask
int getActionsMask()
Returns the current action mask.Used by the BundlePermissionCollection class.
- Returns:
- Current action mask.
-
parseActions
private static int parseActions(java.lang.String actions)
Parse action string into action mask.- Parameters:
actions- Action string.- Returns:
- action mask.
-
implies
public boolean implies(java.security.Permission p)
Determines if the specified permission is implied by this object.This method checks that the symbolic name of the target is implied by the symbolic name of this object. The list of
BundlePermissionactions must either match or allow for the list of the target object to imply the targetBundlePermissionaction.The permission to provide a bundle implies the permission to require the named symbolic name.
x.y.*,"provide" -> x.y.z,"provide" is true *,"require" -> x.y, "require" is true *,"provide" -> x.y, "require" is true x.y,"provide" -> x.y.z, "provide" is false- Overrides:
impliesin classjava.security.BasicPermission- Parameters:
p- The requested permission.- Returns:
trueif the specifiedBundlePermissionaction is implied by this object;falseotherwise.
-
getActions
public java.lang.String getActions()
Returns the canonical string representation of theBundlePermissionactions.Always returns present
BundlePermissionactions in the following order:provide,require,host,fragment.- Overrides:
getActionsin classjava.security.BasicPermission- Returns:
- Canonical string representation of the
BundlePermissionactions.
-
newPermissionCollection
public java.security.PermissionCollection newPermissionCollection()
Returns a newPermissionCollectionobject suitable for storingBundlePermissionobjects.- Overrides:
newPermissionCollectionin classjava.security.BasicPermission- Returns:
- A new
PermissionCollectionobject.
-
equals
public boolean equals(java.lang.Object obj)
Determines the equality of twoBundlePermissionobjects. This method checks that specified bundle has the same bundle symbolic name andBundlePermissionactions as thisBundlePermissionobject.- Overrides:
equalsin classjava.security.BasicPermission- Parameters:
obj- The object to test for equality with thisBundlePermissionobject.- Returns:
trueifobjis aBundlePermission, and has the same bundle symbolic name and actions as thisBundlePermissionobject;falseotherwise.
-
hashCode
public int hashCode()
Returns the hash code value for this object.- Overrides:
hashCodein classjava.security.BasicPermission- Returns:
- A hash code value for this object.
-
writeObject
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOExceptionWriteObject is called to save the state of theBundlePermissionobject to a stream. The actions are serialized, and the superclass takes care of the name.- Throws:
java.io.IOException
-
readObject
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, java.lang.ClassNotFoundExceptionreadObject is called to restore the state of the BundlePermission from a stream.- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
-