aboutsummaryrefslogtreecommitdiffstats
path: root/netx/net/sourceforge
diff options
context:
space:
mode:
Diffstat (limited to 'netx/net/sourceforge')
-rw-r--r--netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java56
1 files changed, 40 insertions, 16 deletions
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"));
}