aboutsummaryrefslogtreecommitdiffstats
path: root/netx/net/sourceforge/jnlp/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'netx/net/sourceforge/jnlp/runtime')
-rw-r--r--netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java2
-rw-r--r--netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java19
-rw-r--r--netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java45
-rw-r--r--netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java33
4 files changed, 86 insertions, 13 deletions
diff --git a/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java b/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java
index b5266f0..536f6be 100644
--- a/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java
+++ b/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java
@@ -35,7 +35,7 @@ import net.sourceforge.jnlp.SecurityDesc;
import net.sourceforge.jnlp.ShortcutDesc;
import net.sourceforge.jnlp.event.ApplicationEvent;
import net.sourceforge.jnlp.event.ApplicationListener;
-import net.sourceforge.jnlp.security.SecurityWarningDialog.AccessType;
+import net.sourceforge.jnlp.security.SecurityWarning.AccessType;
import net.sourceforge.jnlp.services.ServiceUtil;
import net.sourceforge.jnlp.util.WeakList;
import net.sourceforge.jnlp.util.XDesktopEntry;
diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
index 3dc1939..ebb9558 100644
--- a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
@@ -57,7 +57,8 @@ import net.sourceforge.jnlp.Version;
import net.sourceforge.jnlp.cache.CacheUtil;
import net.sourceforge.jnlp.cache.ResourceTracker;
import net.sourceforge.jnlp.cache.UpdatePolicy;
-import net.sourceforge.jnlp.security.SecurityWarningDialog;
+import net.sourceforge.jnlp.security.SecurityWarning;
+import net.sourceforge.jnlp.security.SecurityWarning.AccessType;
import net.sourceforge.jnlp.tools.JarSigner;
import net.sourceforge.jnlp.util.FileUtils;
import sun.misc.JarIndex;
@@ -292,7 +293,7 @@ public class JNLPClassLoader extends URLClassLoader {
if (extLoader != null && extLoader != loader) {
if (loader.signing && !extLoader.signing)
- if (!SecurityWarningDialog.showNotAllSignedWarningDialog(file))
+ if (!SecurityWarning.showNotAllSignedWarningDialog(file))
throw new LaunchException(file, null, R("LSFatal"), R("LCClient"), R("LSignedAppJarUsingUnsignedJar"), R("LSignedAppJarUsingUnsignedJarInfo"));
loader.merge(extLoader);
@@ -439,7 +440,7 @@ public class JNLPClassLoader extends URLClassLoader {
signing = true;
if (!js.allJarsSigned() &&
- !SecurityWarningDialog.showNotAllSignedWarningDialog(file))
+ !SecurityWarning.showNotAllSignedWarningDialog(file))
throw new LaunchException(file, null, R("LSFatal"), R("LCClient"), R("LSignedAppJarUsingUnsignedJar"), R("LSignedAppJarUsingUnsignedJarInfo"));
@@ -493,19 +494,19 @@ public class JNLPClassLoader extends URLClassLoader {
private void checkTrustWithUser(JarSigner js) throws LaunchException {
if (!js.getRootInCacerts()) { //root cert is not in cacerts
- boolean b = SecurityWarningDialog.showCertWarningDialog(
- SecurityWarningDialog.AccessType.UNVERIFIED, file, js);
+ boolean b = SecurityWarning.showCertWarningDialog(
+ AccessType.UNVERIFIED, file, js);
if (!b)
throw new LaunchException(null, null, R("LSFatal"),
R("LCLaunching"), R("LNotVerified"), "");
} else if (js.getRootInCacerts()) { //root cert is in cacerts
boolean b = false;
if (js.noSigningIssues())
- b = SecurityWarningDialog.showCertWarningDialog(
- SecurityWarningDialog.AccessType.VERIFIED, file, js);
+ b = SecurityWarning.showCertWarningDialog(
+ AccessType.VERIFIED, file, js);
else if (!js.noSigningIssues())
- b = SecurityWarningDialog.showCertWarningDialog(
- SecurityWarningDialog.AccessType.SIGNING_ERROR, file, js);
+ b = SecurityWarning.showCertWarningDialog(
+ AccessType.SIGNING_ERROR, file, js);
if (!b)
throw new LaunchException(null, null, R("LSFatal"),
R("LCLaunching"), R("LCancelOnUserRequest"), "");
diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
index 44cf24e..a6f6304 100644
--- a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
@@ -25,9 +25,11 @@ import java.util.*;
import java.util.List;
import java.security.*;
import javax.jnlp.*;
+import javax.swing.UIManager;
import net.sourceforge.jnlp.*;
import net.sourceforge.jnlp.cache.*;
+import net.sourceforge.jnlp.security.SecurityDialogMessageHandler;
import net.sourceforge.jnlp.services.*;
import net.sourceforge.jnlp.util.*;
@@ -63,6 +65,9 @@ public class JNLPRuntime {
/** the security policy */
private static JNLPPolicy policy;
+ /** handles all security message to show appropriate security dialogs */
+ private static SecurityDialogMessageHandler securityDialogMessageHandler;
+
/** the base dir for cache, etc */
private static File baseDir;
@@ -165,6 +170,8 @@ public class JNLPRuntime {
* security manager and security policy, initializing the JNLP
* standard services, etc.<p>
*
+ * This method should be called from the main AppContext/Thread. <p>
+ *
* This method cannot be called more than once. Once
* initialized, methods that alter the runtime can only be
* called by the exit class.<p>
@@ -206,15 +213,40 @@ public class JNLPRuntime {
policy = new JNLPPolicy();
security = new JNLPSecurityManager(); // side effect: create JWindow
+ try {
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ } catch (Exception e) {
+ // ignore it
+ }
+
if (securityEnabled) {
Policy.setPolicy(policy); // do first b/c our SM blocks setPolicy
System.setSecurityManager(security);
}
+ securityDialogMessageHandler = startSecurityThreads();
+
initialized = true;
}
/**
+ * This must NOT be called form the application ThreadGroup. An application
+ * can inject events into its {@link EventQueue} and bypass the security
+ * dialogs.
+ *
+ * @return a {@link SecurityDialogMessageHandler} that can be used to post
+ * security messages
+ */
+ private static SecurityDialogMessageHandler startSecurityThreads() {
+ ThreadGroup securityThreadGroup = new ThreadGroup("NetxSecurityThreadGroup");
+ SecurityDialogMessageHandler runner = new SecurityDialogMessageHandler();
+ Thread securityThread = new Thread(securityThreadGroup, runner, "NetxSecurityThread");
+ securityThread.setDaemon(true);
+ securityThread.start();
+ return runner;
+ }
+
+ /**
* Returns true if a webstart application has been initialized, and false
* for a plugin applet.
*/
@@ -321,6 +353,19 @@ public class JNLPRuntime {
}
/**
+ *
+ * @return the {@link SecurityDialogMessageHandler} that should be used to
+ * post security dialog messages
+ */
+ public static SecurityDialogMessageHandler getSecurityDialogHandler() {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ sm.checkPermission(new AllPermission());
+ }
+ return securityDialogMessageHandler;
+ }
+
+ /**
* Returns the system default base dir for or if not set,
* prompts the user for the location.
*
diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java b/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java
index a143edb..5c49741 100644
--- a/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java
@@ -34,7 +34,7 @@ import java.util.PropertyPermission;
import javax.swing.JWindow;
import net.sourceforge.jnlp.JNLPFile;
-import net.sourceforge.jnlp.security.SecurityWarningDialog;
+import net.sourceforge.jnlp.security.SecurityWarning.AccessType;
import net.sourceforge.jnlp.services.ServiceUtil;
import net.sourceforge.jnlp.util.WeakList;
import sun.awt.AWTSecurityManager;
@@ -393,7 +393,7 @@ class JNLPSecurityManager extends AWTSecurityManager {
ApplicationInstance app = getApplication();
if (app != null && !app.isSigned()) {
if (perm instanceof SocketPermission
- && ServiceUtil.checkAccess(SecurityWarningDialog.AccessType.NETWORK, perm.getName())) {
+ && ServiceUtil.checkAccess(AccessType.NETWORK, perm.getName())) {
return true;
}
}
@@ -435,7 +435,7 @@ class JNLPSecurityManager extends AWTSecurityManager {
Window w = (Window) window;
if (JNLPRuntime.isDebug())
- System.err.println("SM: app: "+app.getTitle()+" is adding a window: "+window);
+ System.err.println("SM: app: "+app.getTitle()+" is adding a window: "+window+" with appContext "+AppContext.getAppContext());
weakWindows.add(w); // for mapping window -> app
weakApplications.add(app);
@@ -539,4 +539,31 @@ class JNLPSecurityManager extends AWTSecurityManager {
}
+ /**
+ * Tests if a client can get access to the AWT event queue. This version allows
+ * complete access to the EventQueue for its own AppContext-specific EventQueue.
+ *
+ * FIXME there are probably huge security implications for this. Eg:
+ * http://hg.openjdk.java.net/jdk7/awt/jdk/rev/8022709a306d
+ *
+ * @exception SecurityException if the caller does not have
+ * permission to accesss the AWT event queue.
+ */
+ public void checkAwtEventQueueAccess() {
+ /*
+ * this is the templace of the code that should allow applets access to
+ * eventqueues
+ */
+
+ // AppContext appContext = AppContext.getAppContext();
+ // ApplicationInstance instance = getApplication();
+
+ // if ((appContext == mainAppContext) && (instance != null)) {
+ // If we're about to allow access to the main EventQueue,
+ // and anything untrusted is on the class context stack,
+ // disallow access.
+ super.checkAwtEventQueueAccess();
+ // }
+ }
+
}