You can't. Conditions must be available from the classpath (as per spec). You could, however, use an extension bundle to deliver the condition at run-time. Have a look at:
http://felix.apache.org/site/presentations.data/Building%20Secure%20OSGi%20Applications%20Workshop.pdf which has an example of this towards the end. regards, Karl On Wed, Apr 1, 2009 at 12:01 PM, mir <[email protected]> wrote: > Hi, > I implemented a class with a static getCondition-method, that negates > the returned value of BundleLocationCondition.getCondition(). > But when I set a Conditional Permission Info with my class > "NotBundleLocationCondition" and the CPA wants to get the Condition a > ClassNotFoundException occurs. My bundle exports the package containing > the class. > How can I tell the Conditional Permission Admin to import it? > > regards > Manuel > > <code snippet> > cpa.setConditionalPermissionInfo("MyCondition", > new ConditionInfo[]{ > new ConditionInfo(NotBundleLocationCondition.class.getName(), > new String[]{"foobar*"}) > }, > new PermissionInfo[]{ > new PermissionInfo(AllPermission.class.getName(), "", "") > } > ); > </code snippet> > > <exception> > java.lang.ClassNotFoundException: > org.trialox.platform.security.NotBundleLocationCondition > at java.net.URLClassLoader$1.run(URLClassLoader.java:200) > at java.security.AccessController.doPrivileged(Native Method) > at java.net.URLClassLoader.findClass(URLClassLoader.java:188) > at java.lang.ClassLoader.loadClass(ClassLoader.java:306) > at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276) > at java.lang.ClassLoader.loadClass(ClassLoader.java:251) > at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) > at java.lang.Class.forName0(Native Method) > at java.lang.Class.forName(Class.java:169) > at > org.apache.felix.framework.security.util.Conditions.isSatisfied(Conditions.java:142) > at > org.apache.felix.framework.security.condpermadmin.ConditionalPermissionAdminImpl.eval(ConditionalPermissionAdminImpl.java:443) > at > org.apache.felix.framework.security.condpermadmin.ConditionalPermissionAdminImpl.hasPermission(ConditionalPermissionAdminImpl.java:362) > at > org.apache.felix.framework.SecurityProviderImpl.hasBundlePermission(SecurityProviderImpl.java:124) > at > org.apache.felix.framework.Felix.impliesBundlePermission(Felix.java:3363) > at > org.apache.felix.framework.BundleProtectionDomain.implies(BundleProtectionDomain.java:38) > at > java.security.AccessControlContext.checkPermission(AccessControlContext.java:301) > at > java.security.AccessController.checkPermission(AccessController.java:546) > at java.lang.SecurityManager.checkPermission(SecurityManager.java:532) > at > org.apache.felix.framework.security.condpermadmin.ConditionalPermissionInfoImpl.delete(ConditionalPermissionInfoImpl.java:124) > at > org.trialox.platform.security.PermissionManager.deleteUserBundlePermissions(PermissionManager.java:255) > at > org.trialox.platform.security.PermissionManager.activate(PermissionManager.java:166) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) > at > org.apache.felix.scr.impl.ImmediateComponentManager.createImplementationObject(ImmediateComponentManager.java:226) > at > org.apache.felix.scr.impl.ImmediateComponentManager.createComponent(ImmediateComponentManager.java:133) > at > org.apache.felix.scr.impl.AbstractComponentManager.activateInternal(AbstractComponentManager.java:476) > at org.apache.felix.scr.impl.AbstractComponentManager.access > $100(AbstractComponentManager.java:36) > at org.apache.felix.scr.impl.AbstractComponentManager > $2.run(AbstractComponentManager.java:142) > at > org.apache.felix.scr.impl.ComponentActorThread.run(ComponentActorThread.java:85) > > </exception> > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > -- Karl Pauls [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

