01: package abbot.script;
02:
03: import abbot.ExitException;
04: import javax.swing.SwingUtilities;
05:
06: /** This security manager extends sun.applet.AppletSecurity b/c
07: * AppletViewer does some casts that assume that is the only security
08: * manager that will be installed. It has to permit everything, though, or
09: * the framework will be hampered. Because of this, it isn't a reliable test
10: * of an applet responding well to restricted permissions.
11: */
12: // FIXME need to determine what causes the class circularity errors and then
13: // defer to the AppletSecurity
14: // NOTE: don't see the class circularity any more, maybe the class loading
15: // restructuring in 0.9/0.10 has fixed it?
16: public class AppletSecurityManager extends sun.applet.AppletSecurity {
17:
18: SecurityManager parent;
19: boolean removeOnExit;
20:
21: public AppletSecurityManager(SecurityManager sm) {
22: this (sm, false);
23: }
24:
25: public AppletSecurityManager(SecurityManager sm,
26: boolean removeOnExit) {
27: parent = sm;
28: this .removeOnExit = removeOnExit;
29: }
30:
31: public void checkPermission(java.security.Permission perm,
32: Object context) {
33: if (parent != null) {
34: parent.checkPermission(perm, context);
35: }
36: }
37:
38: public void checkPermission(java.security.Permission perm) {
39: if (parent != null) {
40: parent.checkPermission(perm);
41: }
42: }
43:
44: public void checkExit(int status) {
45: if (removeOnExit) {
46: System.setSecurityManager(parent);
47: }
48: throw new ExitException("Applet System.exit disallowed on "
49: + Thread.currentThread(), status);
50: }
51: }
|