Use doPriv to get PackageAdmin reference otherwise we might have somebody with not enough permissions on the stack (FELIX-849).

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@727069 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework.security/src/main/java/org/apache/felix/framework/security/util/Permissions.java b/framework.security/src/main/java/org/apache/felix/framework/security/util/Permissions.java
index 2b359dc..1eb5660 100644
--- a/framework.security/src/main/java/org/apache/felix/framework/security/util/Permissions.java
+++ b/framework.security/src/main/java/org/apache/felix/framework/security/util/Permissions.java
@@ -26,6 +26,7 @@
 import java.security.AllPermission;
 import java.security.Permission;
 import java.security.PermissionCollection;
+import java.security.*;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -464,9 +465,12 @@
         return null;
     }
 
-    private Permission createPermission(PermissionInfo permissionInfo,
-        Class target)
+    private Permission createPermission(final PermissionInfo permissionInfo,
+        final Class target)
     {
+        return (Permission) AccessController.doPrivileged(new PrivilegedAction() {
+            public Object run()
+            {
         Permission cached = getFromCache(permissionInfo.getEncoded(), target);
 
         if (cached != null)
@@ -539,6 +543,7 @@
         }
 
         return null;
+        }});
     }
 
     private Permission createPermission(String name, String action, Class target)