Package org.osgi.service.condpermadmin

# Interface ConditionalPermissionAdmin

@ProviderType public interface ConditionalPermissionAdmin
Framework service to administer Conditional Permissions. Conditional Permissions can be added to, retrieved from, and removed from the framework. Conditional Permissions are conceptually managed in an ordered table called the Conditional Permission Table.

## Method Summary

Modifier and Type
Method
Description
`ConditionalPermissionInfo`
`addConditionalPermissionInfo(ConditionInfo[] conditions, PermissionInfo[] permissions)`
Deprecated.
As of 1.1.
`AccessControlContext`
`getAccessControlContext(String[] signers)`
Returns the Access Control Context that corresponds to the specified signers.
`ConditionalPermissionInfo`
`getConditionalPermissionInfo(String name)`
Deprecated.
As of 1.1.
`Enumeration<ConditionalPermissionInfo>`
`getConditionalPermissionInfos()`
Deprecated.
As of 1.1.
`ConditionalPermissionInfo`
`newConditionalPermissionInfo(String encodedConditionalPermissionInfo)`
Creates a new `ConditionalPermissionInfo` from the specified encoded `ConditionalPermissionInfo` string suitable for insertion into a `ConditionalPermissionUpdate`.
`ConditionalPermissionInfo`
`newConditionalPermissionInfo(String name, ConditionInfo[] conditions, PermissionInfo[] permissions, String access)`
Creates a new ConditionalPermissionInfo with the specified fields suitable for insertion into a `ConditionalPermissionUpdate`.
`ConditionalPermissionUpdate`
`newConditionalPermissionUpdate()`
Creates a new update for the Conditional Permission Table.
`ConditionalPermissionInfo`
`setConditionalPermissionInfo(String name, ConditionInfo[] conditions, PermissionInfo[] permissions)`
Deprecated.
As of 1.1.

## Method Details

### addConditionalPermissionInfo

ConditionalPermissionInfo addConditionalPermissionInfo(ConditionInfo[] conditions, PermissionInfo[] permissions)
Deprecated.
As of 1.1. Use `newConditionalPermissionUpdate()` instead.
Create a new Conditional Permission Info in the Conditional Permission Table.

The Conditional Permission Info will be given a unique, never reused name. This entry will be added at the beginning of the Conditional Permission Table with an access decision of `ALLOW`.

Since this method changes the Conditional Permission Table any `ConditionalPermissionUpdate`s that were created prior to calling this method can no longer be committed.

Parameters:
  `conditions` - The conditions that need to be satisfied to enable the specified permissions. This argument can be `null` or an empty array indicating the specified permissions are not guarded by any conditions.
  `permissions` - The permissions that are enabled when the specified conditions, if any, are satisfied. This argument must not be `null` and must specify at least one permission.
Returns:
  The ConditionalPermissionInfo for the specified Conditions and Permissions.
Throws:
  `IllegalArgumentException` - If no permissions are specified.
  `SecurityException` - If the caller does not have `AllPermission`.

### setConditionalPermissionInfo

ConditionalPermissionInfo setConditionalPermissionInfo(String name, ConditionInfo[] conditions, PermissionInfo[] permissions)
Deprecated.
As of 1.1. Use `newConditionalPermissionUpdate()` instead.
Set or create a Conditional Permission Info with a specified name in the Conditional Permission Table.

If the specified name is `null`, a new Conditional Permission Info must be created and will be given a unique, never reused name. If there is currently no Conditional Permission Info with the specified name, a new Conditional Permission Info must be created with the specified name. Otherwise, the Conditional Permission Info with the specified name must be updated with the specified Conditions and Permissions. If a new entry was created in the Conditional Permission Table it will be added at the beginning of the table with an access decision of `ALLOW`.

Since this method changes the underlying permission table any `ConditionalPermissionUpdate`s that were created prior to calling this method can no longer be committed.

Parameters:
  `name` - The name of the Conditional Permission Info, or `null`.
  `conditions` - The conditions that need to be satisfied to enable the specified permissions. This argument can be `null` or an empty array indicating the specified permissions are not guarded by any conditions.
  `permissions` - The permissions that are enabled when the specified conditions, if any, are satisfied. This argument must not be `null` and must specify at least one permission.
Returns:
  The ConditionalPermissionInfo for the specified name, Conditions and Permissions.
Throws:
  `IllegalArgumentException` - If no permissions are specified.
  `SecurityException` - If the caller does not have `AllPermission`.

### getConditionalPermissionInfos

Enumeration<ConditionalPermissionInfo> getConditionalPermissionInfos()
Deprecated.
As of 1.1. Use `newConditionalPermissionUpdate()` instead.
Returns the Conditional Permission Infos from the Conditional Permission Table.

The returned Enumeration will return elements in the order they are kept in the Conditional Permission Table.

The Enumeration returned is based on a copy of the Conditional Permission Table and therefore will not throw exceptions if the Conditional Permission Table is changed during the course of reading elements from the Enumeration.

Returns:
  An enumeration of the Conditional Permission Infos that are currently in the Conditional Permission Table.

### getConditionalPermissionInfo

ConditionalPermissionInfo getConditionalPermissionInfo(String name)
Deprecated.
As of 1.1. Use `newConditionalPermissionUpdate()` instead.
Return the Conditional Permission Info with the specified name.

Parameters:
  `name` - The name of the Conditional Permission Info to be returned.
Returns:
  The Conditional Permission Info with the specified name or `null` if no Conditional Permission Info with the specified name exists in the Conditional Permission Table.

### getAccessControlContext

AccessControlContext getAccessControlContext(String[] signers)
Returns the Access Control Context that corresponds to the specified signers. The returned Access Control Context must act as if its protection domain came from a bundle that has the following characteristics:

- It is signed by all of the given signers
- It has a bundle id of -1
- Its location is the empty string
- Its state is UNINSTALLED
- It has no headers
- It has the empty version (0.0.0)
- Its last modified time=0
- Many methods will throw `IllegalStateException` because the state is UNINSTALLED
- All other methods return a `null`

Parameters:
  `signers` - The signers for which to return an Access Control Context.
Returns:
  An `AccessControlContext` that has the Permissions associated with the signer.

### newConditionalPermissionUpdate

ConditionalPermissionUpdate newConditionalPermissionUpdate()
Creates a new update for the Conditional Permission Table. The update is a working copy of the current Conditional Permission Table. If the running Conditional Permission Table is modified before commit is called on the returned update, then the call to commit on the returned update will fail. That is, the commit method will return false and no change will be made to the running Conditional Permission Table. There is no requirement that commit is eventually called on the returned update.

Returns:
  A new update for the Conditional Permission Table.
Since:
  1.1

### newConditionalPermissionInfo

ConditionalPermissionInfo newConditionalPermissionInfo(String name, ConditionInfo[] conditions, PermissionInfo[] permissions, String access)
Creates a new ConditionalPermissionInfo with the specified fields suitable for insertion into a `ConditionalPermissionUpdate`. The `delete` method on `ConditionalPermissionInfo` objects created with this method must throw UnsupportedOperationException.

Parameters:
  `name` - The name of the created `ConditionalPermissionInfo` or `null` to have a unique name generated when the returned `ConditionalPermissionInfo` is committed in an update to the Conditional Permission Table.
  `conditions` - The conditions that need to be satisfied to enable the specified permissions. This argument can be `null` or an empty array indicating the specified permissions are not guarded by any conditions.
  `permissions` - The permissions that are enabled when the specified conditions, if any, are satisfied. This argument must not be `null` and must specify at least one permission.
  `access` - Access decision. Must be one of the following values:
  - `allow`
  - `deny`
  The specified access decision value must be evaluated case insensitively.
Returns:
  A `ConditionalPermissionInfo` object suitable for insertion into a `ConditionalPermissionUpdate`.
Throws:
  `IllegalArgumentException` - If no permissions are specified or if the specified access decision is not a valid value.
Since:
  1.1

### newConditionalPermissionInfo

ConditionalPermissionInfo newConditionalPermissionInfo(String encodedConditionalPermissionInfo)
Creates a new `ConditionalPermissionInfo` from the specified encoded `ConditionalPermissionInfo` string suitable for insertion into a `ConditionalPermissionUpdate`. The `delete` method on `ConditionalPermissionInfo` objects created with this method must throw UnsupportedOperationException.

Parameters:
  `encodedConditionalPermissionInfo` - The encoded `ConditionalPermissionInfo`. White space in the encoded `ConditionalPermissionInfo` is ignored. The access decision value in the encoded `ConditionalPermissionInfo` must be evaluated case insensitively. If the encoded `ConditionalPermissionInfo` does not contain the optional name, `null` must be used for the name and a unique name will be generated when the returned `ConditionalPermissionInfo` is committed in an update to the Conditional Permission Table.
Returns:
  A `ConditionalPermissionInfo` object suitable for insertion into a `ConditionalPermissionUpdate`.
Throws:
  `IllegalArgumentException` - If the specified `encodedConditionalPermissionInfo` is not properly formatted.
Since:
  1.1
See Also:
  - `ConditionalPermissionInfo.getEncoded()`