Hi aies team!,
currently im evaluating the possibilites when using the 
ConditionalPermissionAdmin provided by felix 3.2.0.
See attached file for the Consumer code. The consuming bundle does explicitly 
not have the permission to get any service. I want to observe how three 
different ways to get a ServiceReference behave if it is not permitted to get a 
service. The three ways are blueprint, directly the BundleContext and a 
ServiceTracker/Customizer. I read in the OSGi specification that the 
ServiceReference should not be visible to a not permitted bundle. The first 
confusing thing ist that (aries 0.3) blueprint does call the consumers 
bind/unbind-method with the service reference if the bundle has the permission 
or not… (i guess its a bug)
But lets also continue with the two other ways (i know usually i would put them 
into the felix mailing, but i was not able to subscripe) : 
Every time a ServiceReference is injected from blueprint i check the self 
opened ServiceTracker and the BundleContext for current ServiceReferences and 
they work fine:
2011-05-11 16:04:50,817 INFO c.b.m.s.c.c.SimpleServiceConsumer[]: injected with 
blueprint : [....cpa.api.ISimple] |
2011-05-11 16:04:50,817 INFO c.b.m.s.c.c.SimpleServiceConsumer[]: received from 
bundlecontext : | null
2011-05-11 16:04:50,817 INFO c.b.m.s.c.c.SimpleServiceConsumer[]: received from 
tracker : null |  org.osgi.util.tracker.ServiceTracker@19f90e3 
Null means no service reference was found…
If i now add dynamically a ServicePermission for getting services to the 
consumer bundle i assume that my ServiceTrackerCustomizer is called, since a 
new service is now available for the consumer bundle, unfortunatly this is not 
done… to get the new service i either have to reopen the tracker or refresh the 
bundle… but this is not the wanted flexible behaviour. 
AFTER refreshing the consumer bundle the trackercustomizer is notified.
2011-05-11 14:30:00,792 INFO c.b.m.s.c.c.SimpleServiceConsumer[]: 
SimpleCustomizer added from tracker : [....cpa.api.ISimple]
 |  org.osgi.util.tracker.ServiceTracker@1d36f77 
2011-05-11 14:30:00,792 INFO c.b.m.s.c.c.SimpleServiceConsumer[]: 
SimpleCustomizer added from tracker : [....cpa.api.ISimple]
 |  org.osgi.util.tracker.ServiceTracker@1d36f77 
2011-05-11 14:30:00,792 INFO c.b.m.s.c.c.SimpleServiceConsumer[]: injected with 
blueprint : [....cpa.api.ISimple] |
2011-05-11 14:30:00,792 INFO c.b.m.s.c.c.SimpleServiceConsumer[]: received from 
bundlecontext : | [....cpa.api.ISimple]
2011-05-11 14:30:00,807 INFO c.b.m.s.c.c.SimpleServiceConsumer[]: received from 
tracker : [...cpa.api.ISimple] |  org.osgi.util.tracker.ServiceTracker@1d36f77 
Ok now my questions:
1) 1) Im right that that blueprint should not call my unpermitted 
consumerbundles bind and unbind methods with ServiceReference instances?
 2)A Permission state change should trigger the ServiceTrackerCustomizer 
methods and blueprint initiated bind and unbind method calls?

Attachment: SimpleServiceConsumer.java
Description: Binary data

Reply via email to