FELIX-4084 : [Core R5] Enhance Bundle.adapt() to provider AccessControlContext.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1550008 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/BundleImpl.java b/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
index 3dd1ddb..7508022 100644
--- a/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
@@ -22,8 +22,20 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import java.security.AccessControlContext;
import java.security.ProtectionDomain;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.StringTokenizer;
import org.apache.felix.framework.cache.BundleArchive;
import org.apache.felix.framework.util.SecurityManagerEx;
@@ -171,7 +183,7 @@
else
{
// Get current revision, since we can reuse it.
- BundleRevisionImpl current = (BundleRevisionImpl) adapt(BundleRevisionImpl.class);
+ BundleRevisionImpl current = adapt(BundleRevisionImpl.class);
// Close all existing revisions.
closeRevisions();
// Clear all revisions.
@@ -1080,6 +1092,20 @@
}
return (A) m_revisions.get(0).getWiring();
}
+ else if ( type == AccessControlContext.class)
+ {
+ if (m_state == Bundle.UNINSTALLED)
+ {
+ return null;
+ }
+ final ProtectionDomain pd = this.getProtectionDomain();
+ if (pd == null)
+ {
+ return null;
+ }
+ return (A) new AccessControlContext(new ProtectionDomain[] {pd});
+
+ }
return null;
}
@@ -1271,8 +1297,7 @@
for (int i = m_revisions.size() - 1; (i >= 0) && (pd == null); i--)
{
- pd = (ProtectionDomain)
- ((BundleRevisionImpl) m_revisions.get(i)).getProtectionDomain();
+ pd = ((BundleRevisionImpl) m_revisions.get(i)).getProtectionDomain();
}
return pd;