org.osgi.framework

## Class BundlePermission

- java.lang.Object
- - java.security.Permission
  - - java.security.BasicPermission
    - - org.osgi.framework.BundlePermission

All Implemented Interfaces:
  Serializable, Guard

    public final class BundlePermission
    extends BasicPermission

A 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.*
     *

`BundlePermission` has four actions: `provide`, `require`, `host`, and `fragment`. The `provide` action implies the `require` action.

Since:
  1.3
Author:
  $Id: 7b0816059dc9b3e37f0375039bebbe5f0b18d998 $
See Also:
  Serialized Form

### Field Summary

Fields
`static String` `FRAGMENT` The action string `fragment`.
`static String` `HOST` The action string `host`.
`static String` `PROVIDE` The action string `provide`.
`static String` `REQUIRE` The action string `require`.

### Constructor Summary

Constructors
Constructor and Description
`BundlePermission(String symbolicName, 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 Instance Methods Concrete Methods
`boolean` `equals(Object obj)` Determines the equality of two `BundlePermission` objects.
`String` `getActions()` Returns the canonical string representation of the `BundlePermission` actions.
`int` `hashCode()` Returns the hash code value for this object.
`boolean` `implies(Permission p)` Determines if the specified permission is implied by this object.
`PermissionCollection` `newPermissionCollection()` Returns a new `PermissionCollection` object suitable for storing `BundlePermission` objects.

### Methods inherited from class java.security.Permission

`checkGuard, getName, toString`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Field Detail

#### PROVIDE

    public static final String PROVIDE

The action string `provide`. The `provide` action implies the `require` action.

See Also:
  Constant Field Values

#### REQUIRE

    public static final String REQUIRE

The action string `require`. The `require` action is implied by the `provide` action.

See Also:
  Constant Field Values

#### HOST

    public static final String HOST

The action string `host`.

See Also:
  Constant Field Values

#### FRAGMENT

    public static final String FRAGMENT

The action string `fragment`.

See Also:
  Constant Field Values

### Constructor Detail

#### BundlePermission

    public BundlePermission(String symbolicName,
                            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 `BundlePermission` for the symbolic name; a bundle that requires a bundle must have the appropriate `BundlePermssion` for that symbolic name; a bundle that specifies a fragment host must have the appropriate `BundlePermission` for that symbolic name.

Parameters:
  `symbolicName` - The bundle symbolic name.
  `actions` - `provide`,`require`, `host`, `fragment` (canonical order).

### Method Detail

#### implies

    public boolean implies(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 `BundlePermission` actions must either match or allow for the list of the target object to imply the target `BundlePermission` action.

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:
  `implies` in class `BasicPermission`
Parameters:
  `p` - The requested permission.
Returns:
  `true` if the specified `BundlePermission` action is implied by this object; `false` otherwise.

#### getActions

    public String getActions()

Returns the canonical string representation of the `BundlePermission` actions.

Always returns present `BundlePermission` actions in the following order: `provide`, `require`, `host`, `fragment`.

Overrides:
  `getActions` in class `BasicPermission`
Returns:
  Canonical string representation of the `BundlePermission` actions.

#### newPermissionCollection

    public PermissionCollection newPermissionCollection()

Returns a new `PermissionCollection` object suitable for storing `BundlePermission` objects.

Overrides:
  `newPermissionCollection` in class `BasicPermission`
Returns:
  A new `PermissionCollection` object.

#### equals

    public boolean equals(Object obj)

Determines the equality of two `BundlePermission` objects. This method checks that specified bundle has the same bundle symbolic name and `BundlePermission` actions as this `BundlePermission` object.

Overrides:
  `equals` in class `BasicPermission`
Parameters:
  `obj` - The object to test for equality with this `BundlePermission` object.
Returns:
  `true` if `obj` is a `BundlePermission`, and has the same bundle symbolic name and actions as this `BundlePermission` object; `false` otherwise.

#### hashCode

    public int hashCode()

Returns the hash code value for this object.

Overrides:
  `hashCode` in class `BasicPermission`
Returns:
  A hash code value for this object.