tags:

views:

22

answers:

1

I have an application consisting of several OSGi bundles. I would like to enforce that some of them only provide other bundles access to their services if a valid token (e. g. a license key) has been presented.

Here's why I would want to restrict access to those bundles:

  • Security: They don't have their own access policies because these depend on what application is using the bundle. This means they have to trust in the client bundle to have verified the permissions of the application or user they are representing. I would like to keep control over what access control schemes I trust.
  • Reliability: I allow and encourage the development of third-party modules to add functionality to my system. To be able to guarantee some reliability, I want to control at which level those extensions interact with my system. Also, I want to make sure that my own bundles are only used in combinations that have been tested.
  • Licensing: There might be functionality in some modules that can only be used with the proper license, or, I might want to ensure that customers can't swap bundles between different installations.

I have read some about the ServicePermission class and related from the OSGi framework, but it appears to me that these let the site administrator control the access policy, as opposed to the bundle manufacturer, which is what I want.

+1  A: 

Your use-case seems to be quite complex, so I'm not sure if this answers your question fully. However you might take a look at Service Hooks, a new feature added in OSGi Release 4, Version 4.2.

With Find Hook it should be possible to "look at, and reduce, the results of the getServiceReference and getServiceReferences methods. This hook can remove Service Reference objects from the result, also effectively hiding the service from the caller." (from article written by Peter Kriens)

Using this feature you can implement your own mechanism for client bundles to "authorize" themselves to access specific services (or conversely "inspect" the client bundle to determine if access to a specific service should be granted).

Pavol Juhos