[jira] [Created] (FELIX-3221) NPE when uninstall a bundle on enabled OSGi security

2011-11-14 Thread Michael Hirsch (Created) (JIRA)
NPE when uninstall a bundle on enabled OSGi security


 Key: FELIX-3221
 URL: https://issues.apache.org/jira/browse/FELIX-3221
 Project: Felix
  Issue Type: Bug
  Components: Framework Security
Affects Versions: framework.security-2.0.0
Reporter: Michael Hirsch


org.apache.felix.framework.BundleImpl#adapt returns null:
{code}
public synchronized  A adapt(Class type)
{

else if (type == BundleRevision.class)
{
if (m_state == Bundle.UNINSTALLED)
{
return null;
}
.
{code}

This causes a NPE: 
StackTrace:
java.lang.NullPointerException
at 
org.apache.felix.framework.SecurityProviderImpl.getSignerMatcher(SecurityProviderImpl.java:73)
at org.apache.felix.framework.Felix.getSignerMatcher(Felix.java:4130)
at 
org.apache.felix.framework.BundleImpl.getSignerCertificates(BundleImpl.java:901)
at 
org.osgi.framework.SignerProperty.isBundleSigned(SignerProperty.java:110)
at org.osgi.framework.AdminPermission$1.run(AdminPermission.java:884)
at java.security.AccessController.doPrivileged(Native Method)
at 
org.osgi.framework.AdminPermission.getProperties(AdminPermission.java:875)
at org.osgi.framework.AdminPermission.implies0(AdminPermission.java:671)
at 
org.osgi.framework.AdminPermissionCollection.implies(AdminPermission.java:1014)
at 
org.apache.felix.framework.security.util.Permissions.implies(Permissions.java:469)
at 
org.apache.felix.framework.security.condpermadmin.ConditionalPermissionAdminImpl.eval(ConditionalPermissionAdminImpl.java:949)
at 
org.apache.felix.framework.security.condpermadmin.ConditionalPermissionAdminImpl.hasPermission(ConditionalPermissionAdminImpl.java:882)
at 
org.apache.felix.framework.SecurityProviderImpl.hasBundlePermission(SecurityProviderImpl.java:122)
at 
org.apache.felix.framework.Felix.impliesBundlePermission(Felix.java:4139)
at 
org.apache.felix.framework.BundleProtectionDomain.implies(BundleProtectionDomain.java:66)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at 
org.apache.felix.framework.BundleImpl.getLocation(BundleImpl.java:583)
at 
org.apache.felix.cm.impl.ConfigurationManager.bundleChanged(ConfigurationManager.java:607)
at 
org.apache.felix.framework.util.EventDispatcher$3.run(EventDispatcher.java:861)
at java.security.AccessController.doPrivileged(Native Method)
at 
org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:858)
at 
org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:789)
at 
org.apache.felix.framework.util.EventDispatcher.run(EventDispatcher.java:1088)
at 
org.apache.felix.framework.util.EventDispatcher.access$000(EventDispatcher.java:54)
at 
org.apache.felix.framework.util.EventDispatcher$1.run(EventDispatcher.java:101)
at java.lang.Thread.run(Unknown Source)


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira




[jira] [Created] (FELIX-3220) Multiple ClassCastException(s) when invoking OSGi Service-Hooks (EventHook, FindHook)

2011-11-14 Thread Michael Hirsch (Created) (JIRA)
Multiple ClassCastException(s) when invoking OSGi Service-Hooks (EventHook, 
FindHook)
-

 Key: FELIX-3220
 URL: https://issues.apache.org/jira/browse/FELIX-3220
 Project: Felix
  Issue Type: Bug
  Components: Framework
Affects Versions: framework-4.0.1
 Environment: Enable OSGi Security, using Felix security bundle version 
2.0.0
Reporter: Michael Hirsch
Priority: Critical
 Fix For: framework-4.2.0


*Scenario:*
- Register a EventHook in the OSGi service registry as described in the OSGi 
core specification 4.2. 
- Run felix with a SecurityManager
- The framework is not calling the EventHook during framework service 
(register, modify, and unregister service) operations.

*Expected Behavior*
- The framework code calls the EventHook during framework service (register, 
modify, and unregister service) operations. 

*Current Behavior:*
- A ClassCastException occurs in the framework code 
org.apache.felix.framework.util.SecureAction:1628
- Logged on "WARNING" Level

*Probably Caused By:*
The ClassCastException is caused by calling the wrong setter-method within the 
org.apache.felix.framework.util.SecureAction:1135 class. 
The ServiceEvent will never be set which causes that in line 1628 when invoking 
the EventHook the ServiceEvent argument is missing and parameters for the 
EventHook will be casted wrong.

Method: org.apache.felix.framework.util.SecureAction # invokeServiceEventHook
{code}
public void invokeServiceEventHook(
org.osgi.framework.hooks.service.EventHook eh,
ServiceEvent event, Collection contexts)
throws Exception
{ 
  actions.set(Actions.INVOKE_SERVICE_EVENT_HOOK, eh, contexts);
 
}
{code}

Method: org.apache.felix.framework.util.SecureAction.Actions # run
has wrong arguments: 
arg1 = EventHook
arg2 = Collection
arg3 = null
{code}
case INVOKE_SERVICE_EVENT_HOOK:
((org.osgi.framework.hooks.service.EventHook) arg1).event(
(ServiceEvent) arg2, (Collection) arg3);
return null;
{code}


*Solution:*
Changing the method of setting the arguments for the Action class. Set also the 
ServiceEvent!
{code}
public void invokeServiceEventHook(
org.osgi.framework.hooks.service.EventHook eh,
ServiceEvent event, Collection contexts)
throws Exception
{ 
  actions.set(Actions.INVOKE_SERVICE_EVENT_HOOK, eh, event, contexts);
 
}
{code}


*Additional:*
# Meanwhile investigating code I found that also invoking the 
ServiceEventListenerHook has probably the same behavior! When calling the 
setter-method for setting the arguments for the Action class there is missing 
the ServiceEvent.

# Invoking FindHook using wrong action constant which causes a 
ClassCastException!
Actions.INVOKE_SERVICE_EVENT_HOOK need to be changed to 
Actions.INVOKE_SERVICE_FIND_HOOK
{code}
public void invokeServiceFindHook(
org.osgi.framework.hooks.service.FindHook fh,
BundleContext context, String name, String filter,
boolean allServices, Collection> references)
throws Exception
{
   actions.set(
Actions.INVOKE_SERVICE_EVENT_HOOK, fh, context, name, filter,
(allServices) ? Boolean.TRUE : Boolean.FALSE, references);
 }
{code}


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira