Port to latest framework trunk
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1167140 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework.security/pom.xml b/framework.security/pom.xml
index 69b924d..83d6f7a 100644
--- a/framework.security/pom.xml
+++ b/framework.security/pom.xml
@@ -35,7 +35,7 @@
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
- <version>4.2.0</version>
+ <version>4.3.0</version>
</dependency>
<dependency>
<groupId>${pom.groupId}</groupId>
diff --git a/framework.security/src/main/java/org/apache/felix/framework/SecurityProviderImpl.java b/framework.security/src/main/java/org/apache/felix/framework/SecurityProviderImpl.java
index 2d24fb3..5427a83 100644
--- a/framework.security/src/main/java/org/apache/felix/framework/SecurityProviderImpl.java
+++ b/framework.security/src/main/java/org/apache/felix/framework/SecurityProviderImpl.java
@@ -27,9 +27,8 @@
import org.apache.felix.framework.security.util.TrustManager;
import org.apache.felix.framework.security.verifier.BundleDNParser;
import org.apache.felix.framework.util.SecureAction;
-//import org.apache.felix.moduleloader.IModule;
-import org.apache.felix.framework.resolver.Module;
import org.osgi.framework.Bundle;
+import org.osgi.framework.wiring.BundleRevision;
/**
* This class is the entry point to the security. It is used to determine
@@ -60,7 +59,7 @@
*/
public void checkBundle(Bundle bundle) throws Exception
{
- Module module = ((BundleImpl) bundle).getCurrentModule();
+ BundleRevisionImpl module = (BundleRevisionImpl) bundle.adapt(BundleRevision.class);
m_parser.checkDNChains(module, module.getContent(),
Bundle.SIGNERS_TRUSTED);
}
@@ -70,7 +69,7 @@
*/
public Object getSignerMatcher(final Bundle bundle, int signersType)
{
- Module module = ((BundleImpl) bundle).getCurrentModule();
+ BundleRevisionImpl module = ((BundleRevisionImpl) bundle.adapt(BundleRevision.class));
return m_parser.getDNChains(module, module.getContent(), signersType);
}
@@ -85,7 +84,7 @@
{
BundleProtectionDomain pd = (BundleProtectionDomain) bundleProtectionDomain;
BundleImpl bundle = pd.getBundle();
- Module module = pd.getModule();
+ BundleRevisionImpl module = (BundleRevisionImpl) pd.getRevision();
if (bundle.getBundleId() == 0)
{
@@ -98,7 +97,7 @@
if (m_pai != null)
{
result = m_pai.hasPermission(bundle._getLocation(), pd.getBundle(),
- permission, m_cpai, pd, bundle.getCurrentModule().getContent());
+ permission, m_cpai, pd, module.getContent());
}
if (result != null)
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 06aa6d3..aff71aa 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
@@ -18,6 +18,7 @@
*/
package org.apache.felix.framework.security.condpermadmin;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
@@ -49,6 +50,7 @@
import java.util.Map.Entry;
import org.apache.felix.framework.BundleProtectionDomain;
+import org.apache.felix.framework.BundleRevisionImpl;
import org.apache.felix.framework.security.permissionadmin.PermissionAdminImpl;
import org.apache.felix.framework.security.util.Conditions;
import org.apache.felix.framework.security.util.LocalPermissions;
@@ -63,11 +65,7 @@
import org.apache.felix.moduleloader.IRequirement;
import org.apache.felix.moduleloader.IWire;
*/
-import org.apache.felix.framework.capabilityset.Capability;
-import org.apache.felix.framework.capabilityset.Requirement;
-import org.apache.felix.framework.resolver.Content;
-import org.apache.felix.framework.resolver.Module;
-import org.apache.felix.framework.resolver.Wire;
+import org.apache.felix.framework.cache.Content;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -457,6 +455,21 @@
{
return System.identityHashCode(this);
}
+
+ public int compareTo(Bundle o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public <A> A adapt(Class<A> arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public File getDataFile(String arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
private static class FakeCert extends X509Certificate
@@ -662,132 +675,7 @@
{
return result.booleanValue();
}
- if (eval(posts, new Module()
- {
-
- public Bundle getBundle()
- {
- return fake;
- }
-
- public List<Capability> getCapabilities()
- {
- return null;
- }
-
- public Class getClassByDelegation(String arg0)
- throws ClassNotFoundException
- {
- return null;
- }
-
- public Content getContent()
- {
- return null;
- }
-
- public int getDeclaredActivationPolicy()
- {
- return 0;
- }
-
- public List<Requirement> getDynamicRequirements()
- {
- return null;
- }
-
- public URL getEntry(String arg0)
- {
- return null;
- }
-
- public Map getHeaders()
- {
- return null;
- }
-
- public String getId()
- {
- return null;
- }
-
- public InputStream getInputStream(int arg0, String arg1)
- throws IOException
- {
- return null;
- }
-
- public List<R4Library> getNativeLibraries()
- {
- return null;
- }
-
- public List<Requirement> getRequirements()
- {
- return null;
- }
-
- public URL getResourceByDelegation(String arg0)
- {
- return null;
- }
-
- public Enumeration getResourcesByDelegation(String arg0)
- {
- return null;
- }
-
- public Object getSecurityContext()
- {
- return null;
- }
-
- public String getSymbolicName()
- {
- return null;
- }
-
- public Version getVersion()
- {
- return null;
- }
-
- public List<Wire> getWires()
- {
- return null;
- }
-
- public boolean hasInputStream(int arg0, String arg1)
- throws IOException
- {
- return false;
- }
-
- public boolean isExtension()
- {
- return false;
- }
-
- public boolean isResolved()
- {
- return false;
- }
-
- public void setSecurityContext(Object arg0)
- {
- }
-
- public URL getLocalURL(int arg0, String arg1)
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public boolean isRemovalPending()
- {
- return false;
- }
- }, permission, m_pai))
+ if (eval(posts, new BundleRevisionImpl(fake, Long.toString(fake.getBundleId())), permission, m_pai))
{
if (!posts.isEmpty())
{
@@ -940,7 +828,7 @@
* @return true in case the permission is granted or there are postponed
* tuples false if not. Again, see the spec for more explanations.
*/
- public boolean hasPermission(Module module, Content content,
+ public boolean hasPermission(BundleRevisionImpl module, Content content,
ProtectionDomain pd, Permission permission, boolean direct, Object admin)
{
// System.out.println(felixBundle + "-" + permission);
@@ -1043,7 +931,7 @@
// then we make sure their permissions imply the permission and add them
// to the list of posts. Return true in case we pass or have posts
// else falls and clear the posts first.
- private boolean eval(List posts, Module module, Permission permission,
+ private boolean eval(List posts, BundleRevisionImpl module, Permission permission,
Object admin)
{
List condPermInfos = null;
diff --git a/framework.security/src/main/java/org/apache/felix/framework/security/permissionadmin/PermissionAdminImpl.java b/framework.security/src/main/java/org/apache/felix/framework/security/permissionadmin/PermissionAdminImpl.java
index 07088ee..92617d8 100644
--- a/framework.security/src/main/java/org/apache/felix/framework/security/permissionadmin/PermissionAdminImpl.java
+++ b/framework.security/src/main/java/org/apache/felix/framework/security/permissionadmin/PermissionAdminImpl.java
@@ -32,7 +32,7 @@
import org.apache.felix.framework.security.util.PropertiesCache;
//import org.apache.felix.moduleloader.IContent;
-import org.apache.felix.framework.resolver.Content;
+import org.apache.felix.framework.cache.Content;
import org.osgi.framework.Bundle;
import org.osgi.service.permissionadmin.PermissionAdmin;
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 d4d8f76..c0eac02 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
@@ -31,7 +31,7 @@
import java.util.jar.JarOutputStream;
//import org.apache.felix.moduleloader.IContent;
-import org.apache.felix.framework.resolver.Content;
+import org.apache.felix.framework.cache.Content;
/**
* This class makes a given content available as a inputstream with a jar
diff --git a/framework.security/src/main/java/org/apache/felix/framework/security/util/Conditions.java b/framework.security/src/main/java/org/apache/felix/framework/security/util/Conditions.java
index 8c4ee37..485652c 100644
--- a/framework.security/src/main/java/org/apache/felix/framework/security/util/Conditions.java
+++ b/framework.security/src/main/java/org/apache/felix/framework/security/util/Conditions.java
@@ -28,12 +28,9 @@
import java.util.Map;
import java.util.WeakHashMap;
+import org.apache.felix.framework.BundleRevisionImpl;
import org.apache.felix.framework.security.condpermadmin.ConditionalPermissionInfoImpl;
import org.apache.felix.framework.util.SecureAction;
-
-//import org.apache.felix.moduleloader.IModule;
-import org.apache.felix.framework.resolver.Module;
-
import org.osgi.framework.Bundle;
import org.osgi.service.condpermadmin.Condition;
import org.osgi.service.condpermadmin.ConditionInfo;
@@ -50,7 +47,7 @@
private final Map m_cache = new WeakHashMap();
- private final Module m_module;
+ private final BundleRevisionImpl m_module;
private final ConditionInfo[] m_conditionInfos;
private final Condition[] m_conditions;
@@ -61,7 +58,7 @@
this(null, null, action);
}
- private Conditions(Module module, ConditionInfo[] conditionInfos,
+ private Conditions(BundleRevisionImpl module, ConditionInfo[] conditionInfos,
SecureAction action)
{
m_module = module;
@@ -95,7 +92,7 @@
m_action = action;
}
- public Conditions getConditions(Module key, ConditionInfo[] conditions)
+ public Conditions getConditions(BundleRevisionImpl key, ConditionInfo[] conditions)
{
Conditions result = null;
Map index = null;
diff --git a/framework.security/src/main/java/org/apache/felix/framework/security/util/LocalPermissions.java b/framework.security/src/main/java/org/apache/felix/framework/security/util/LocalPermissions.java
index 18331d1..4f921c3 100644
--- a/framework.security/src/main/java/org/apache/felix/framework/security/util/LocalPermissions.java
+++ b/framework.security/src/main/java/org/apache/felix/framework/security/util/LocalPermissions.java
@@ -29,7 +29,7 @@
import java.util.WeakHashMap;
//import org.apache.felix.moduleloader.IContent;
-import org.apache.felix.framework.resolver.Content;
+import org.apache.felix.framework.cache.Content;
import org.osgi.framework.Bundle;
import org.osgi.service.permissionadmin.PermissionInfo;
diff --git a/framework.security/src/main/java/org/apache/felix/framework/security/verifier/BundleDNParser.java b/framework.security/src/main/java/org/apache/felix/framework/security/verifier/BundleDNParser.java
index da14faa..8eb555a 100644
--- a/framework.security/src/main/java/org/apache/felix/framework/security/verifier/BundleDNParser.java
+++ b/framework.security/src/main/java/org/apache/felix/framework/security/verifier/BundleDNParser.java
@@ -34,14 +34,14 @@
import java.util.jar.JarEntry;
import java.util.jar.JarInputStream;
+import org.apache.felix.framework.BundleRevisionImpl;
import org.apache.felix.framework.security.util.BundleInputStream;
import org.apache.felix.framework.security.util.TrustManager;
/*
import org.apache.felix.moduleloader.IContent;
import org.apache.felix.moduleloader.IModule;
*/
-import org.apache.felix.framework.resolver.Content;
-import org.apache.felix.framework.resolver.Module;
+import org.apache.felix.framework.cache.Content;
import org.osgi.framework.Bundle;
@@ -104,7 +104,7 @@
}
}
- public void checkDNChains(Module root, Content content, int signersType)
+ public void checkDNChains(BundleRevisionImpl root, Content content, int signersType)
throws Exception
{
if (signersType == Bundle.SIGNERS_TRUSTED)
@@ -171,7 +171,7 @@
}
}
- public Map getDNChains(Module root, Content bundleRevision,
+ public Map getDNChains(BundleRevisionImpl root, Content bundleRevision,
int signersType)
{
if (signersType == Bundle.SIGNERS_TRUSTED)