Author: rickhall
Date: Mon May 23 20:39:20 2011
New Revision: 1126730
URL: http://svn.apache.org/viewvc?rev=1126730&view=rev
Log:
Have wiring use protection domain from revision, rename security context
to protection domain. (FELIX-2950)
Modified:
felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleRevisionImpl.java
felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java
felix/trunk/framework/src/main/java/org/apache/felix/framework/ResolverStateImpl.java
Modified:
felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
URL:
http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java?rev=1126730&r1=1126729&r2=1126730&view=diff
==============================================================================
---
felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
(original)
+++
felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
Mon May 23 20:39:20 2011
@@ -1118,7 +1118,7 @@ class BundleImpl implements Bundle
// Set protection domain after adding the revision to the bundle,
// since this requires that the bundle has a revision.
- ((BundleRevisionImpl) revision).setSecurityContext(
+ ((BundleRevisionImpl) revision).setProtectionDomain(
new BundleProtectionDomain(getFramework(), this));
SecurityProvider sp = getFramework().getSecurityProvider();
@@ -1128,7 +1128,7 @@ class BundleImpl implements Bundle
{
sp.checkBundle(this);
}
- catch (Exception ex)
+ catch (Exception ex)
{
m_revisions.remove(m_revisions.size() - 1);
throw ex;
@@ -1201,7 +1201,7 @@ class BundleImpl implements Bundle
for (int i = m_revisions.size() - 1; (i >= 0) && (pd == null); i--)
{
pd = (ProtectionDomain)
- ((BundleRevisionImpl) m_revisions.get(i)).getSecurityContext();
+ ((BundleRevisionImpl)
m_revisions.get(i)).getProtectionDomain();
}
return pd;
@@ -1248,7 +1248,7 @@ class BundleImpl implements Bundle
}
}
- BundleContext _getBundleContext()
+ BundleContext _getBundleContext()
{
return m_context;
}
Modified:
felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleRevisionImpl.java
URL:
http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleRevisionImpl.java?rev=1126730&r1=1126729&r2=1126730&view=diff
==============================================================================
---
felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleRevisionImpl.java
(original)
+++
felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleRevisionImpl.java
Mon May 23 20:39:20 2011
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -154,6 +154,11 @@ public class BundleRevisionImpl implemen
m_isExtension = mp.isExtension();
}
+ static SecureAction getSecureAction()
+ {
+ return m_secureAction;
+ }
+
int getDeclaredActivationPolicy()
{
return m_declaredActivationPolicy;
@@ -334,12 +339,12 @@ public class BundleRevisionImpl implemen
}
}
- public synchronized void setSecurityContext(Object securityContext)
+ public synchronized void setProtectionDomain(ProtectionDomain pd)
{
- m_protectionDomain = (ProtectionDomain) securityContext;
+ m_protectionDomain = pd;
}
- public synchronized Object getSecurityContext()
+ public synchronized ProtectionDomain getProtectionDomain()
{
return m_protectionDomain;
}
@@ -384,7 +389,7 @@ public class BundleRevisionImpl implemen
{
List<Content> contentList = new ArrayList();
calculateContentPath(this, getContent(), contentList, true);
-
+
List<BundleRevision> fragments = null;
List<Content> fragmentContents = null;
if (m_wiring != null)
Modified:
felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java
URL:
http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java?rev=1126730&r1=1126729&r2=1126730&view=diff
==============================================================================
---
felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java
(original)
+++
felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java
Mon May 23 20:39:20 2011
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -84,8 +84,6 @@ public class BundleWiringImpl implements
private BundleClassLoader m_classLoader;
private boolean m_isActivationTriggered = false;
- private ProtectionDomain m_protectionDomain = null;
- private final static SecureAction m_secureAction = new SecureAction();
// Bundle-specific class loader for boot delegation.
private final ClassLoader m_bootClassLoader;
@@ -98,10 +96,11 @@ public class BundleWiringImpl implements
ClassLoader cl = null;
try
{
- Constructor ctor = m_secureAction.getDeclaredConstructor(
+ Constructor ctor =
BundleRevisionImpl.getSecureAction().getDeclaredConstructor(
SecureClassLoader.class, new Class[] { ClassLoader.class });
- m_secureAction.setAccesssible(ctor);
- cl = (ClassLoader) m_secureAction.invoke(ctor, new Object[] { null
});
+ BundleRevisionImpl.getSecureAction().setAccesssible(ctor);
+ cl = (ClassLoader) BundleRevisionImpl.getSecureAction().invoke(
+ ctor, new Object[] { null });
}
catch (Throwable ex)
{
@@ -417,10 +416,10 @@ public class BundleWiringImpl implements
// enabled; otherwise, create it directly.
try
{
- Constructor ctor = (Constructor) m_secureAction.getConstructor(
- clazz, new Class[] { BundleWiringImpl.class,
ClassLoader.class });
+ Constructor ctor = (Constructor)
BundleRevisionImpl.getSecureAction()
+ .getConstructor(clazz, new Class[] {
BundleWiringImpl.class, ClassLoader.class });
m_classLoader = (BundleClassLoader)
- m_secureAction.invoke(ctor,
+ BundleRevisionImpl.getSecureAction().invoke(ctor,
new Object[] { this, determineParentClassLoader() });
}
catch (Exception ex)
@@ -463,7 +462,7 @@ public class BundleWiringImpl implements
try
{
- return m_secureAction.createURL(null,
+ return BundleRevisionImpl.getSecureAction().createURL(null,
FelixConstants.BUNDLE_URL_PROTOCOL + "://" +
m_revision.getId() + ":" + port + path,
m_revision.getURLStreamHandler());
}
@@ -639,22 +638,24 @@ public class BundleWiringImpl implements
final ClassLoader parent;
if (cfg.equalsIgnoreCase(Constants.FRAMEWORK_BUNDLE_PARENT_APP))
{
- parent = m_secureAction.getSystemClassLoader();
+ parent =
BundleRevisionImpl.getSecureAction().getSystemClassLoader();
}
else if (cfg.equalsIgnoreCase(Constants.FRAMEWORK_BUNDLE_PARENT_EXT))
{
- parent =
m_secureAction.getParentClassLoader(m_secureAction.getSystemClassLoader());
+ parent = BundleRevisionImpl.getSecureAction().getParentClassLoader(
+ BundleRevisionImpl.getSecureAction().getSystemClassLoader());
}
else if
(cfg.equalsIgnoreCase(Constants.FRAMEWORK_BUNDLE_PARENT_FRAMEWORK))
{
- parent = m_secureAction.getClassLoader(BundleRevisionImpl.class);
+ parent = BundleRevisionImpl.getSecureAction()
+ .getClassLoader(BundleRevisionImpl.class);
}
// On Android we cannot set the parent class loader to be null, so
// we special case that situation here and set it to the system
// class loader by default instead, which is not really spec.
else if (m_bootClassLoader == null)
{
- parent = m_secureAction.getSystemClassLoader();
+ parent =
BundleRevisionImpl.getSecureAction().getSystemClassLoader();
}
else
{
@@ -732,12 +733,12 @@ public class BundleWiringImpl implements
try
{
- dexFileClassLoadDex = dexFileClass.getMethod("loadDex",
+ dexFileClassLoadDex = dexFileClass.getMethod("loadDex",
new Class[]{String.class, String.class, Integer.TYPE});
}
catch (Exception ex)
{
- // Nothing we need to do
+ // Nothing we need to do
}
dexFileClassConstructor = dexFileClass.getConstructor(
new Class[] { java.io.File.class });
@@ -1105,8 +1106,10 @@ public class BundleWiringImpl implements
{
// Return the class or resource from the parent class
loader.
return (isClass)
- ? (Object)
m_secureAction.getClassLoader(this.getClass()).loadClass(name)
- : (Object)
m_secureAction.getClassLoader(this.getClass()).getResource(name);
+ ? (Object) BundleRevisionImpl.getSecureAction()
+ .getClassLoader(this.getClass()).loadClass(name)
+ : (Object) BundleRevisionImpl.getSecureAction()
+ .getClassLoader(this.getClass()).getResource(name);
}
catch (NoClassDefFoundError ex)
{
@@ -1123,7 +1126,8 @@ public class BundleWiringImpl implements
{
// The target class is loaded by a bundle class loader,
// then return true.
- if
(BundleClassLoader.class.isInstance(m_secureAction.getClassLoader(clazz)))
+ if (BundleClassLoader.class.isInstance(
+ BundleRevisionImpl.getSecureAction().getClassLoader(clazz)))
{
return true;
}
@@ -1131,9 +1135,9 @@ public class BundleWiringImpl implements
// If the target class was loaded from a class loader that
// came from a bundle, then return true.
ClassLoader last = null;
- for (ClassLoader cl = m_secureAction.getClassLoader(clazz);
+ for (ClassLoader cl =
BundleRevisionImpl.getSecureAction().getClassLoader(clazz);
(cl != null) && (last != cl);
- cl = m_secureAction.getClassLoader(cl.getClass()))
+ cl =
BundleRevisionImpl.getSecureAction().getClassLoader(cl.getClass()))
{
last = cl;
if (BundleClassLoader.class.isInstance(cl))
@@ -1341,7 +1345,7 @@ public class BundleWiringImpl implements
if (clazz == null)
{
- int activationPolicy =
+ int activationPolicy =
((BundleImpl)
getBundle()).isDeclaredActivationPolicyUsed()
? ((BundleRevisionImpl) ((BundleImpl)
getBundle())
.getCurrentRevision()).getDeclaredActivationPolicy()
@@ -1413,10 +1417,10 @@ public class BundleWiringImpl implements
// If we have a security context, then use it
to
// define the class with it for security
purposes,
// otherwise define the class without a
protection domain.
- if (m_protectionDomain != null)
+ if (m_revision.getProtectionDomain() != null)
{
clazz = defineClass(name, bytes, 0,
bytes.length,
- m_protectionDomain);
+ m_revision.getProtectionDomain());
}
else
{
@@ -1499,8 +1503,8 @@ public class BundleWiringImpl implements
{
if (m_dexFileClassLoadDex != null)
{
- dexFile = m_dexFileClassLoadDex.invoke(null,
- new Object[]{content.getFile().getAbsolutePath(),
+ dexFile = m_dexFileClassLoadDex.invoke(null,
+ new Object[]{content.getFile().getAbsolutePath(),
content.getFile().getAbsolutePath() + ".dex",
new Integer(0)});
}
else
@@ -1807,7 +1811,8 @@ public class BundleWiringImpl implements
boolean classpath = false;
try
{
-
m_secureAction.getClassLoader(BundleClassLoader.class).loadClass(name);
+ BundleRevisionImpl.getSecureAction()
+ .getClassLoader(BundleClassLoader.class).loadClass(name);
classpath = true;
}
catch (NoClassDefFoundError err)
@@ -1860,7 +1865,8 @@ public class BundleWiringImpl implements
// class loader.
try
{
-
m_secureAction.getClassLoader(BundleClassLoader.class).loadClass(name);
+ BundleRevisionImpl.getSecureAction()
+ .getClassLoader(BundleClassLoader.class).loadClass(name);
StringBuffer sb = new StringBuffer("*** Package '");
sb.append(pkgName);
Modified:
felix/trunk/framework/src/main/java/org/apache/felix/framework/ResolverStateImpl.java
URL:
http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/ResolverStateImpl.java?rev=1126730&r1=1126729&r2=1126730&view=diff
==============================================================================
---
felix/trunk/framework/src/main/java/org/apache/felix/framework/ResolverStateImpl.java
(original)
+++
felix/trunk/framework/src/main/java/org/apache/felix/framework/ResolverStateImpl.java
Mon May 23 20:39:20 2011
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -194,11 +194,11 @@ class ResolverStateImpl implements Resol
if (System.getSecurityManager() != null)
{
if
(req.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE) && (
- !((BundleProtectionDomain) ((BundleRevisionImpl)
cap.getRevision()).getSecurityContext()).impliesDirect(
+ !((BundleProtectionDomain) ((BundleRevisionImpl)
cap.getRevision()).getProtectionDomain()).impliesDirect(
new PackagePermission((String)
cap.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR),
PackagePermission.EXPORTONLY)) ||
!((reqRevision == null) ||
- ((BundleProtectionDomain)
reqRevision.getSecurityContext()).impliesDirect(
+ ((BundleProtectionDomain)
reqRevision.getProtectionDomain()).impliesDirect(
new PackagePermission((String)
cap.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR),
cap.getRevision().getBundle(),PackagePermission.IMPORT))
)))
@@ -209,21 +209,21 @@ class ResolverStateImpl implements Resol
}
}
else if
(req.getNamespace().equals(BundleCapabilityImpl.BUNDLE_NAMESPACE) && (
- !((BundleProtectionDomain) ((BundleRevisionImpl)
cap.getRevision()).getSecurityContext()).impliesDirect(
+ !((BundleProtectionDomain) ((BundleRevisionImpl)
cap.getRevision()).getProtectionDomain()).impliesDirect(
new
BundlePermission(cap.getRevision().getSymbolicName(),
BundlePermission.PROVIDE)) ||
!((reqRevision == null) ||
- ((BundleProtectionDomain)
reqRevision.getSecurityContext()).impliesDirect(
+ ((BundleProtectionDomain)
reqRevision.getProtectionDomain()).impliesDirect(
new
BundlePermission(reqRevision.getSymbolicName(), BundlePermission.REQUIRE))
)))
{
continue;
}
else if
(req.getNamespace().equals(BundleCapabilityImpl.HOST_NAMESPACE) &&
- (!((BundleProtectionDomain)
reqRevision.getSecurityContext())
+ (!((BundleProtectionDomain)
reqRevision.getProtectionDomain())
.impliesDirect(new BundlePermission(
reqRevision.getSymbolicName(),
BundlePermission.FRAGMENT))
- || !((BundleProtectionDomain) ((BundleRevisionImpl)
cap.getRevision()).getSecurityContext())
+ || !((BundleProtectionDomain) ((BundleRevisionImpl)
cap.getRevision()).getProtectionDomain())
.impliesDirect(new BundlePermission(
cap.getRevision().getSymbolicName(),
BundlePermission.HOST))))