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 next 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

Re: Virgo + ConditionalPermissionAdmin question [message #936620 is a reply to message #936603] Mon, 08 October 2012 02:51 Go to previous messageGo to next message
Borislav Kapukaranov is currently offline Borislav Kapukaranov
Messages: 80
Registered: September 2010
Member
Hi,

This won't work on pre-3.5.0 Virgo because then we used a custom launcher that doesn't recognise the securtity startup options.
3.5.0 and later use the Equinox launcher which supports all those properties.

Best Regards
Bobby

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

Report message to a moderator

Re: Virgo + ConditionalPermissionAdmin question [message #936683 is a reply to message #936620] Mon, 08 October 2012 04:17 Go to previous message
E S is currently offline E S
Messages: 2
Registered: October 2012
Junior Member
Borislav, thank you for fast response!
I tried to deploy the same bundles into virgo-tomcat-350. The result is the same.

BTW vts-350 starts with out additional configuration in dmk.sh (vts-301 doesn't). Implementation of ConditionalPermissionsAdmin I obtain is org.eclipse.osgi.internal.permadmin.SecurityAdmin

Do you have any ideas?
Thanks in advance

[Updated on: Mon, 08 October 2012 04:32]

Report message to a moderator

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


Current Time: Thu Jul 24 11:21:51 EDT 2014

Powered by FUDForum. Page generated in 0.02300 seconds