org.eclipse.osgi.framework.internal.core
Class PermissionAdminImpl

java.lang.Object
  extended by org.eclipse.osgi.framework.internal.core.PermissionAdminImpl
All Implemented Interfaces:
PermissionAdmin

public class PermissionAdminImpl
extends java.lang.Object
implements PermissionAdmin

Permission Admin service for the OSGi specification. The Permission Admin service allows operators to manage the permissions of bundles. There is at most one Permission Admin service present in the Framework.

Access to the Permission Admin service is protected by corresponding ServicePermission. In addition the AdminPermission is required to actually set permissions.

Bundle permissions are managed using a permission table. A bundle's location serves as the key into this permission table. The value of a table entry is the set of permissions (of type PermissionInfo) granted to the bundle with the given location. A bundle may have an entry in the permission table prior to being installed in the Framework.

The permissions specified in setDefaultPermissions are used as the default permissions which are granted to all bundles that do not have an entry in the permission table.

Any changes to a bundle's permissions in the permission table will take effect no later than when bundle's java.security.ProtectionDomain is involved in a permission check, and will be made persistent.

Only permission classes on the system classpath or from an exported package are considered during a permission check. Additionally, only permission classes that are subclasses of java.security.Permission and define a 2-argument constructor that takes a name string and an actions string can be used.

Permissions implicitly granted by the Framework (for example, a bundle's permission to access its persistent storage area) cannot be changed, and are not reflected in the permissions returned by getPermissions and getDefaultPermissions.


Field Summary
protected  PermissionInfo[] baseImpliedPermissionInfos
          The basic implied permissions for a bundle
protected  org.eclipse.osgi.framework.internal.core.BundleCombinedPermissions defaultAssignedPermissions
          The permission collection containing the default assigned permissions
protected  PermissionInfo[] defaultDefaultPermissionInfos
          The permissions to use if no other permissions can be determined
protected  Framework framework
          framework object
protected  PermissionStorage storage
          permission storage object
 
Constructor Summary
protected PermissionAdminImpl(Framework framework, PermissionStorage storage)
          Construstor.
 
Method Summary
protected  org.eclipse.osgi.framework.internal.core.BundlePermissionCollection createDefaultAssignedPermissions(PermissionInfo[] info)
          Creates the default assigned permissions for bundles that have no assigned permissions.
protected  org.eclipse.osgi.framework.internal.core.BundlePermissionCollection createPermissions(PermissionInfo[] info, AbstractBundle bundle, boolean implied)
          Create a PermissionCollection from a PermissionInfo array.
protected  BundleProtectionDomain createProtectionDomain(AbstractBundle bundle)
          This method is called by the Bundle object to create the PermissionCollection used by the bundle's ProtectionDomain.
protected  org.eclipse.osgi.framework.internal.core.BundlePermissionCollection getAssignedPermissions(AbstractBundle bundle)
          Returns the assigned permissions for a bundle.
 PermissionInfo[] getDefaultPermissions()
          Gets the default permissions.
protected  org.eclipse.osgi.framework.internal.core.BundlePermissionCollection getImpliedPermissions(AbstractBundle bundle)
          Returns the implied permissions for a bundle.
 java.lang.String[] getLocations()
          Returns the bundle locations that have permissions assigned to them, that is, bundle locations for which an entry exists in the permission table.
protected  PermissionInfo[] getPermissionInfos(java.net.URL resource)
          Read the permissions from the specified resource.
 PermissionInfo[] getPermissions(java.lang.String location)
          Gets the permissions assigned to the bundle with the specified location.
protected  java.lang.String[] makePermissionData(PermissionInfo[] permissions)
          Make an array of encoded permission Strings from a PermissionInfo array.
protected  PermissionInfo[] makePermissionInfo(java.lang.String[] data)
          Make a PermissionInfo array from an array of encoded permission Strings.
 void setDefaultPermissions(PermissionInfo[] permissions)
          Sets the default permissions.
 void setPermissions(java.lang.String location, PermissionInfo[] permissions)
          Assigns the specified permissions to the bundle with the specified location.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

framework

protected Framework framework
framework object


storage

protected PermissionStorage storage
permission storage object


defaultDefaultPermissionInfos

protected PermissionInfo[] defaultDefaultPermissionInfos
The permissions to use if no other permissions can be determined


baseImpliedPermissionInfos

protected PermissionInfo[] baseImpliedPermissionInfos
The basic implied permissions for a bundle


defaultAssignedPermissions

protected org.eclipse.osgi.framework.internal.core.BundleCombinedPermissions defaultAssignedPermissions
The permission collection containing the default assigned permissions

Constructor Detail

PermissionAdminImpl

protected PermissionAdminImpl(Framework framework,
                              PermissionStorage storage)
Construstor.

Parameters:
framework - Framework object.
Method Detail

getPermissions

public PermissionInfo[] getPermissions(java.lang.String location)
Gets the permissions assigned to the bundle with the specified location.

Specified by:
getPermissions in interface PermissionAdmin
Parameters:
location - The location of the bundle whose permissions are to be returned.
Returns:
The permissions assigned to the bundle with the specified location, or null if that bundle has not been assigned any permissions.

setPermissions

public void setPermissions(java.lang.String location,
                           PermissionInfo[] permissions)
Assigns the specified permissions to the bundle with the specified location.

Specified by:
setPermissions in interface PermissionAdmin
Parameters:
location - The location of the bundle that will be assigned the permissions.
permissions - The permissions to be assigned, or null if the specified location is to be removed from the permission table.
Throws:
java.lang.SecurityException - if the caller does not have the AllPermission.

getLocations

public java.lang.String[] getLocations()
Returns the bundle locations that have permissions assigned to them, that is, bundle locations for which an entry exists in the permission table.

Specified by:
getLocations in interface PermissionAdmin
Returns:
The locations of bundles that have been assigned any permissions, or null if the permission table is empty.

getDefaultPermissions

public PermissionInfo[] getDefaultPermissions()
Gets the default permissions.

These are the permissions granted to any bundle that does not have permissions assigned to its location.

Specified by:
getDefaultPermissions in interface PermissionAdmin
Returns:
The default permissions, or null if default permissions have not been defined.

setDefaultPermissions

public void setDefaultPermissions(PermissionInfo[] permissions)
Sets the default permissions.

These are the permissions granted to any bundle that does not have permissions assigned to its location.

Specified by:
setDefaultPermissions in interface PermissionAdmin
Parameters:
permissions - The default permissions.
Throws:
java.lang.SecurityException - if the caller does not have the AllPermission.

makePermissionInfo

protected PermissionInfo[] makePermissionInfo(java.lang.String[] data)
Make a PermissionInfo array from an array of encoded permission Strings.

Parameters:
data - Array of encoded permission Strings
Returns:
Array of PermissionInfo objects.

makePermissionData

protected java.lang.String[] makePermissionData(PermissionInfo[] permissions)
Make an array of encoded permission Strings from a PermissionInfo array.

Parameters:
permissions - Array of PermissionInfor objects.
Returns:
Array of encoded permission Strings

createProtectionDomain

protected BundleProtectionDomain createProtectionDomain(AbstractBundle bundle)
This method is called by the Bundle object to create the PermissionCollection used by the bundle's ProtectionDomain.

Parameters:
bundle - the bundle object
Returns:
BundleCombinedPermission object with the bundle's dynamic permissions.

createDefaultAssignedPermissions

protected org.eclipse.osgi.framework.internal.core.BundlePermissionCollection createDefaultAssignedPermissions(PermissionInfo[] info)
Creates the default assigned permissions for bundles that have no assigned permissions. The default permissions are assigned via the PermissionAdmin service and may change dynamically.

Returns:
A PermissionCollection of the default assigned permissions.

getAssignedPermissions

protected org.eclipse.osgi.framework.internal.core.BundlePermissionCollection getAssignedPermissions(AbstractBundle bundle)
Returns the assigned permissions for a bundle. These permissions are assigned via the PermissionAdmin service and may change dynamically.

Parameters:
bundle - The bundle to create the permissions for.
Returns:
A PermissionCollection of the assigned permissions.

getImpliedPermissions

protected org.eclipse.osgi.framework.internal.core.BundlePermissionCollection getImpliedPermissions(AbstractBundle bundle)
Returns the implied permissions for a bundle. These permissions never change.

Parameters:
bundle - The bundle to create the permissions for.
Returns:
A PermissionCollection of the implied permissions.

getPermissionInfos

protected PermissionInfo[] getPermissionInfos(java.net.URL resource)
Read the permissions from the specified resource.

Returns:
An array of PermissionInfo objects from the specified resource.

createPermissions

protected org.eclipse.osgi.framework.internal.core.BundlePermissionCollection createPermissions(PermissionInfo[] info,
                                                                                                AbstractBundle bundle,
                                                                                                boolean implied)
Create a PermissionCollection from a PermissionInfo array.

Parameters:
info - Array of PermissionInfo objects.
bundle - The target bundle for the permissions.
Returns:
A PermissionCollection containing Permission objects.