Update to latest framework snapshot (FELIX-2739).
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1052018 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework.security/pom.xml b/framework.security/pom.xml
index d401403..603d252 100644
--- a/framework.security/pom.xml
+++ b/framework.security/pom.xml
@@ -40,7 +40,7 @@
<dependency>
<groupId>${pom.groupId}</groupId>
<artifactId>org.apache.felix.framework</artifactId>
- <version>3.0.2</version>
+ <version>3.1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
diff --git a/framework.security/src/main/java/org/apache/felix/framework/security/condpermadmin/ConditionalPermissionAdminImpl.java b/framework.security/src/main/java/org/apache/felix/framework/security/condpermadmin/ConditionalPermissionAdminImpl.java
index 7414a74..3bef55e 100644
--- a/framework.security/src/main/java/org/apache/felix/framework/security/condpermadmin/ConditionalPermissionAdminImpl.java
+++ b/framework.security/src/main/java/org/apache/felix/framework/security/condpermadmin/ConditionalPermissionAdminImpl.java
@@ -54,7 +54,6 @@
import org.apache.felix.framework.security.util.LocalPermissions;
import org.apache.felix.framework.security.util.Permissions;
import org.apache.felix.framework.security.util.PropertiesCache;
-import org.apache.felix.framework.util.IteratorToEnumeration;
import org.apache.felix.framework.util.manifestparser.R4Library;
/*
@@ -777,6 +776,12 @@
public void setSecurityContext(Object arg0)
{
}
+
+ public URL getLocalURL(int arg0, String arg1)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
}, permission, m_pai))
{
if (!posts.isEmpty())
@@ -818,8 +823,8 @@
{
synchronized (m_condPermInfos)
{
- return new IteratorToEnumeration((new ArrayList(m_condPermInfos
- .values())).iterator());
+ return Collections.enumeration(new ArrayList(m_condPermInfos
+ .values()));
}
}
diff --git a/framework.security/src/main/java/org/apache/felix/framework/security/util/BundleInputStream.java b/framework.security/src/main/java/org/apache/felix/framework/security/util/BundleInputStream.java
index babbfbc..d4d8f76 100644
--- a/framework.security/src/main/java/org/apache/felix/framework/security/util/BundleInputStream.java
+++ b/framework.security/src/main/java/org/apache/felix/framework/security/util/BundleInputStream.java
@@ -24,12 +24,12 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
-import org.apache.felix.framework.util.IteratorToEnumeration;
//import org.apache.felix.moduleloader.IContent;
import org.apache.felix.framework.resolver.Content;
@@ -77,7 +77,7 @@
{
manifest = "META-INF/MANIFEST.MF";
}
- m_content = new IteratorToEnumeration(entries.iterator());
+ m_content = Collections.enumeration(entries);
try
{
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 651b2cd..4569594 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,6 +34,8 @@
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;
@@ -72,6 +74,8 @@
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)
@@ -105,14 +109,22 @@
public PermissionInfo[] getImplicit(Bundle bundle)
{
- 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) };
+ 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;
}
public Permissions getPermissions(PermissionInfo[] permissionInfos)
@@ -230,31 +242,32 @@
public boolean implies(Permission perm)
{
- Map perms = null;
+ Permission permission = null;
synchronized (m_perms)
{
- perms = m_perms;
+ permission = (Permission) m_perms.get(perm);
}
- Permission permission = (Permission) perms.get(perm);
-
if ((permission != null) && permission.implies(perm))
{
return true;
}
-
- for (Iterator iter = perms.values().iterator(); iter.hasNext();)
- {
- Permission current = (Permission) iter.next();
- if ((current != null) && (current != permission)
- && current.implies(perm))
+
+ synchronized (m_perms)
+ {
+ for (Iterator iter = m_perms.values().iterator(); iter.hasNext();)
{
- return true;
+ Permission current = (Permission) iter.next();
+ if ((current != null) && (current != permission)
+ && current.implies(perm))
+ {
+ return true;
+ }
}
+ return false;
}
- return false;
- }
+ }
}
private void cleanUp(ReferenceQueue queue, Map cache)