Rollback an experimental patch
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1052022 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 4569594..651b2cd 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
@@ -34,8 +34,6 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
-import java.util.Collections;
-import java.util.WeakHashMap;
import org.apache.felix.framework.util.SecureAction;
import org.osgi.framework.AdminPermission;
@@ -74,8 +72,6 @@
private static final PermissionInfo[] IMPLICIT = new PermissionInfo[] { new PermissionInfo(
FilePermission.class.getName(), "-", "read,write,delete") };
-
- private static volatile Map m_implicit = new WeakHashMap();
Permissions(PermissionInfo[] permissionInfos, BundleContext context,
SecureAction action)
@@ -109,22 +105,14 @@
public PermissionInfo[] getImplicit(Bundle bundle)
{
- PermissionInfo[] result = (PermissionInfo[]) m_implicit.get(bundle);
- if (result == null)
- {
- result = new PermissionInfo[] {
- IMPLICIT[0],
- new PermissionInfo(AdminPermission.class.getName(), "(id="
- + bundle.getBundleId() + ")", AdminPermission.METADATA),
- new PermissionInfo(AdminPermission.class.getName(), "(id="
- + bundle.getBundleId() + ")", AdminPermission.RESOURCE),
- new PermissionInfo(AdminPermission.class.getName(), "(id="
- + bundle.getBundleId() + ")", AdminPermission.CONTEXT) };
- Map implicit = new WeakHashMap(m_implicit);
- implicit.put(bundle, result);
- m_implicit = implicit;
- }
- return result;
+ return new PermissionInfo[] {
+ IMPLICIT[0],
+ new PermissionInfo(AdminPermission.class.getName(), "(id="
+ + bundle.getBundleId() + ")", AdminPermission.METADATA),
+ new PermissionInfo(AdminPermission.class.getName(), "(id="
+ + bundle.getBundleId() + ")", AdminPermission.RESOURCE),
+ new PermissionInfo(AdminPermission.class.getName(), "(id="
+ + bundle.getBundleId() + ")", AdminPermission.CONTEXT) };
}
public Permissions getPermissions(PermissionInfo[] permissionInfos)
@@ -242,32 +230,31 @@
public boolean implies(Permission perm)
{
- Permission permission = null;
+ Map perms = null;
synchronized (m_perms)
{
- permission = (Permission) m_perms.get(perm);
+ perms = m_perms;
}
+ Permission permission = (Permission) perms.get(perm);
+
if ((permission != null) && permission.implies(perm))
{
return true;
}
-
- synchronized (m_perms)
- {
- for (Iterator iter = m_perms.values().iterator(); iter.hasNext();)
+
+ for (Iterator iter = perms.values().iterator(); iter.hasNext();)
+ {
+ Permission current = (Permission) iter.next();
+ if ((current != null) && (current != permission)
+ && current.implies(perm))
{
- Permission current = (Permission) iter.next();
- if ((current != null) && (current != permission)
- && current.implies(perm))
- {
- return true;
- }
+ return true;
}
- return false;
}
- }
+ return false;
+ }
}
private void cleanUp(ReferenceQueue queue, Map cache)