Create module class loaded in privileged block. (FELIX-1154)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@774918 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleImpl.java b/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleImpl.java
index 19171dc..16827e6 100644
--- a/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleImpl.java
@@ -27,6 +27,8 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLStreamHandler;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.security.ProtectionDomain;
import java.security.SecureClassLoader;
import java.util.ArrayList;
@@ -1173,8 +1175,21 @@
{
if (m_classLoader == null)
{
-// TODO: REFACTOR - SecureAction fix needed.
- m_classLoader = new ModuleClassLoader();
+ if (System.getSecurityManager() != null)
+ {
+ m_classLoader = (ModuleClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run()
+ {
+ return new ModuleClassLoader();
+ }
+ });
+ }
+ else
+ {
+ m_classLoader = new ModuleClassLoader();
+ }
+// TODO: SECURITY - Would be nice if this could use SecureAction again.
// m_classLoader = m_secureAction.createModuleClassLoader(
// this, m_protectionDomain);
}