aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java56
2 files changed, 49 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index fb3e556..4dc897a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2011-04-20 Omair Majid <[email protected]>
+ * netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java
+ (getApplication(Class[],int)): Renamed to ...
+ (getApplication(Thread,Class[],int)): New method. Check the thread's
+ context ClassLoader as well as parents of the classloader.
+ (getJnlpClassLoader): New method.
+ (getApplication, checkExit): Update to work with new method signatures.
+
+2011-04-20 Omair Majid <[email protected]>
+
* plugin/icedteanp/java/sun/applet/PluginAppletSecurityContext.java
(PluginAppletSecurityContext): Set the launch handler to the stdout/stderr
based one.
diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java b/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java
index b45dd8b..a6a4ea7 100644
--- a/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java
@@ -165,7 +165,7 @@ class JNLPSecurityManager extends AWTSecurityManager {
* determined.
*/
protected ApplicationInstance getApplication() {
- return getApplication(getClassContext(), 0);
+ return getApplication(Thread.currentThread(), getClassContext(), 0);
}
/**
@@ -190,28 +190,52 @@ class JNLPSecurityManager extends AWTSecurityManager {
/**
* Return the current Application, or null.
*/
- protected ApplicationInstance getApplication(Class stack[], int maxDepth) {
+ protected ApplicationInstance getApplication(Thread thread, Class<?> stack[], int maxDepth) {
+ ClassLoader cl;
+ JNLPClassLoader jnlpCl;
+
+ cl = thread.getContextClassLoader();
+ while (cl != null) {
+ jnlpCl = getJnlpClassLoader(cl);
+ if (jnlpCl != null && jnlpCl.getApplication() != null) {
+ return jnlpCl.getApplication();
+ }
+ cl = cl.getParent();
+ }
+
if (maxDepth <= 0)
maxDepth = stack.length;
// this needs to be tightened up
for (int i = 0; i < stack.length && i < maxDepth; i++) {
- ClassLoader cl = stack[i].getClassLoader();
-
- // Since we want to deal with JNLPClassLoader, extract it if this
- // is a codebase loader
- if (cl instanceof JNLPClassLoader.CodeBaseClassLoader)
- cl = ((JNLPClassLoader.CodeBaseClassLoader) cl).getParentJNLPClassLoader();
-
- if (cl instanceof JNLPClassLoader) {
-
- JNLPClassLoader loader = (JNLPClassLoader) cl;
-
- if (loader != null && loader.getApplication() != null) {
- return loader.getApplication();
+ cl = stack[i].getClassLoader();
+ while (cl != null) {
+ jnlpCl = getJnlpClassLoader(cl);
+ if (jnlpCl != null && jnlpCl.getApplication() != null) {
+ return jnlpCl.getApplication();
}
+ cl = cl.getParent();
}
}
+ return null;
+ }
+
+ /**
+ * Returns the JNLPClassLoader associated with the given ClassLoader, or
+ * null.
+ * @param cl a ClassLoader
+ * @return JNLPClassLoader or null
+ */
+ private JNLPClassLoader getJnlpClassLoader(ClassLoader cl) {
+ // Since we want to deal with JNLPClassLoader, extract it if this
+ // is a codebase loader
+ if (cl instanceof JNLPClassLoader.CodeBaseClassLoader)
+ cl = ((JNLPClassLoader.CodeBaseClassLoader) cl).getParentJNLPClassLoader();
+
+ if (cl instanceof JNLPClassLoader) {
+ JNLPClassLoader loader = (JNLPClassLoader) cl;
+ return loader;
+ }
return null;
}
@@ -444,7 +468,7 @@ class JNLPSecurityManager extends AWTSecurityManager {
}
// but when they really call, stop only the app instead of the JVM
- ApplicationInstance app = getApplication(stack, 0);
+ ApplicationInstance app = getApplication(Thread.currentThread(), stack, 0);
if (app == null) {
throw new SecurityException(R("RExitNoApp"));
}