aQute.junit.runtime
Class SimplePermissionPolicy

java.lang.Object
  extended by aQute.junit.runtime.SimplePermissionPolicy
All Implemented Interfaces:
EventListener, org.osgi.framework.BundleListener, org.osgi.framework.SynchronousBundleListener

public class SimplePermissionPolicy
extends Object
implements org.osgi.framework.SynchronousBundleListener

Implements a permissionpolicy. It will tried to read a resource from the bundle. This resource should have the following format:

 
  
    '(' permission-class [ '"' name-parameter '"' [ '"' action [ ',' action ] ... '"' ] ] ')'
   Or
    '#' *
   
  
 
Each valid line is translated into a PermissionInfo object and these objects together form the permissions for a specific bundle. The class will also attempt to read a file called "default.perm" from the current bundle that will have the same format. This is used for the default permissions.

If there is no permission admin service, this class does nothing relevant.


Method Summary
 void bundleChanged(org.osgi.framework.BundleEvent event)
          Event when a bundle has changed so we need to inspect if it is installed, and if so we need to set the permissions or remove it when it is uninstalled.
 void clearPermissions(org.osgi.framework.Bundle bundle)
          Clear the permissions for a bundle.
 org.osgi.service.permissionadmin.PermissionInfo[] getPermissions(org.osgi.framework.Bundle bundle)
          Get the resource and parse it into PermissionInfo objects.
 org.osgi.service.permissionadmin.PermissionInfo[] parse(InputStream in)
          Parse a permission info file.
 void setDefaultPermissions(org.osgi.service.permissionadmin.PermissionInfo[] defaultPermissions)
           
 void setPermissions(org.osgi.framework.Bundle bundle)
          Sets the permissions of a bundle from a resource, if exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setPermissions

public void setPermissions(org.osgi.framework.Bundle bundle)
Sets the permissions of a bundle from a resource, if exists.


getPermissions

public org.osgi.service.permissionadmin.PermissionInfo[] getPermissions(org.osgi.framework.Bundle bundle)
Get the resource and parse it into PermissionInfo objects.


parse

public org.osgi.service.permissionadmin.PermissionInfo[] parse(InputStream in)
                                                        throws IOException
Parse a permission info file.

Throws:
IOException

clearPermissions

public void clearPermissions(org.osgi.framework.Bundle bundle)
Clear the permissions for a bundle.


bundleChanged

public void bundleChanged(org.osgi.framework.BundleEvent event)
Event when a bundle has changed so we need to inspect if it is installed, and if so we need to set the permissions or remove it when it is uninstalled.

Specified by:
bundleChanged in interface org.osgi.framework.BundleListener

setDefaultPermissions

public void setDefaultPermissions(org.osgi.service.permissionadmin.PermissionInfo[] defaultPermissions)


Copyright © 2010 aQute SARL. All Rights Reserved.