Added Bundle.hasPermission() patch from Karl Pauls.


git-svn-id: https://svn.apache.org/repos/asf/incubator/felix/trunk@371631 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/org.apache.felix.framework/src/main/java/org/apache/felix/framework/Felix.java b/org.apache.felix.framework/src/main/java/org/apache/felix/framework/Felix.java
index 867c72e..05dd2f0 100644
--- a/org.apache.felix.framework/src/main/java/org/apache/felix/framework/Felix.java
+++ b/org.apache.felix.framework/src/main/java/org/apache/felix/framework/Felix.java
@@ -1135,8 +1135,28 @@
             throw new IllegalStateException("The bundle is uninstalled.");
         }
 
-// TODO: IMPLEMENT THIS CORRECTLY.
-        return true;
+        if (null != System.getSecurityManager())
+        {
+            try
+            {
+               return (obj instanceof java.security.Permission)
+                   ? java.security.Policy.getPolicy().getPermissions(
+                        new java.security.CodeSource(
+                            new java.net.URL(bundle.getInfo().getLocation()), null))
+                                .implies((java.security.Permission) obj)
+                   : false;
+            }
+            catch (Exception ex)
+            {
+                m_logger.log(
+                    LogWrapper.LOG_WARNING,
+                    "Exception while evaluating the permission.",
+                    ex);
+                return false; 
+            }
+         }
+
+         return true;
     }
 
     /**