Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Virgo + ConditionalPermissionAdmin question
Virgo + ConditionalPermissionAdmin question [message #936603] Mon, 08 October 2012 02:28 Go to previous message
E S is currently offline E S
Messages: 2
Registered: October 2012
Junior Member
Greetings!
I need to change my application bundles permissions on the fly. I'm trying to use ConditionalPermissionAdmin inside the BundleListener in following way:

@Component
public class PermissionBundleListener implements BundleListener, InitializingBean {

    @Autowired
    private BundleContext bundleContext;

    @Autowired
    private ConditionalPermissionAdmin condPermissionAdmin;

    public void afterPropertiesSet() throws Exception {
	bundleContext.addBundleListener(this);
    }

    public void bundleChanged(BundleEvent event) {
	if (event.getType() != BundleEvent.INSTALLED) {
	    return;
	}

	if (!isMyBundle(event)) {
	    return;
	}

	String location = event.getBundle().getLocation();

	PermissionInfo[] permissionInfos = new PermissionInfo[1];
	permissionInfos[0] = new PermissionInfo(PackagePermission.class.getName(), "org.osgi.*",
		PackagePermission.IMPORT);

	ConditionInfo[] conditionInfos = new ConditionInfo[1];
	conditionInfos[0] = new ConditionInfo(BundleLocationCondition.class.getName(), new String[] { location });

	ConditionalPermissionUpdate update = condPermissionAdmin.newConditionalPermissionUpdate();

	List<ConditionalPermissionInfo> infos = update.getConditionalPermissionInfos();
	infos.clear();
	infos.add(condPermissionAdmin.newConditionalPermissionInfo("deny.import.org.osgi", conditionInfos,
		permissionInfos, ConditionalPermissionInfo.DENY));

	update.commit();
    }

    private boolean isMyBundle(BundleEvent event) {
	return true;
    }
}


But this doesnt help. Bundles are still able to Import org.osgi.*
What I'm doing wrong?
Thanks!

PS
I have read this thread http://www.eclipse.org/forums/index.php/t/279813/ and start virgo with mentioned properties.
I use Virgo 3.0.1.

[Updated on: Mon, 08 October 2012 02:46]

Report message to a moderator

 
Read Message
Read Message
Read Message
Previous Topic:Spring Web Services & Virgo 3.0.x
Next Topic:Statement of direction: OSGi Subsystems spec support
Goto Forum:
  


Current Time: Thu May 23 19:32:35 EDT 2013

Powered by FUDForum. Page generated in 0.01999 seconds