You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by ej...@apache.org on 2012/02/21 23:11:37 UTC
svn commit: r1292060 -
/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ContextHelper.java
Author: ejiang
Date: Tue Feb 21 22:11:37 2012
New Revision: 1292060
URL: http://svn.apache.org/viewvc?rev=1292060&view=rev
Log:
ARIES-831: Java 2 security AccessControlException when getting jndi bundle context
Modified:
aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ContextHelper.java
Modified: aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ContextHelper.java
URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ContextHelper.java?rev=1292060&r1=1292059&r2=1292060&view=diff
==============================================================================
--- aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ContextHelper.java (original)
+++ aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ContextHelper.java Tue Feb 21 22:11:37 2012
@@ -118,10 +118,17 @@ public final class ContextHelper {
public static Context getInitialContext(BundleContext context, Hashtable<?, ?> environment)
throws NamingException {
- Bundle jndiBundle = FrameworkUtil.getBundle(ContextHelper.class);
+ final Bundle jndiBundle = FrameworkUtil.getBundle(ContextHelper.class);
// if we are outside OSGi (like in our unittests) then we would get Null back here, so just make sure we don't.
if (jndiBundle != null) {
- BundleContext jndiBundleContext = jndiBundle.getBundleContext();
+
+ BundleContext jndiBundleContext = AccessController.doPrivileged(new PrivilegedAction<BundleContext>() {
+ public BundleContext run()
+ {
+ return jndiBundle.getBundleContext();
+ }
+ });
+
if (!!!jndiBundleContext.getClass().equals(context.getClass())){
//the context passed in must have come from a child framework
//use the parent context instead