home *** CD-ROM | disk | FTP | other *** search
- package sun.applet;
-
- import java.security.AccessController;
- import sun.awt.AWTSecurityManager;
- import sun.awt.AppContext;
-
- public class AppletSecurity extends AWTSecurityManager {
- private AppContext mainAppContext;
- private static RuntimePermission threadPermission;
- private static RuntimePermission threadGroupPermission;
- private boolean inThreadGroupCheck = false;
-
- public AppletSecurity() {
- this.reset();
- this.mainAppContext = AppContext.getAppContext();
- }
-
- public void reset() {
- }
-
- private AppletClassLoader currentAppletClassLoader() {
- ClassLoader var1 = ((SecurityManager)this).currentClassLoader();
- if (var1 != null && !(var1 instanceof AppletClassLoader)) {
- Class[] var2 = ((SecurityManager)this).getClassContext();
-
- for(int var3 = 0; var3 < var2.length; ++var3) {
- var1 = var2[var3].getClassLoader();
- if (var1 instanceof AppletClassLoader) {
- return (AppletClassLoader)var1;
- }
- }
-
- var1 = Thread.currentThread().getContextClassLoader();
- return var1 instanceof AppletClassLoader ? (AppletClassLoader)var1 : (AppletClassLoader)null;
- } else {
- return (AppletClassLoader)var1;
- }
- }
-
- protected boolean inThreadGroup(ThreadGroup var1) {
- return this.currentAppletClassLoader() == null ? false : this.getThreadGroup().parentOf(var1);
- }
-
- protected boolean inThreadGroup(Thread var1) {
- return this.inThreadGroup(var1.getThreadGroup());
- }
-
- public synchronized void checkAccess(Thread var1) {
- if (!this.inThreadGroup(var1)) {
- if (threadPermission == null) {
- threadPermission = new RuntimePermission("modifyThread");
- }
-
- ((SecurityManager)this).checkPermission(threadPermission);
- }
-
- }
-
- public synchronized void checkAccess(ThreadGroup var1) {
- if (this.inThreadGroupCheck) {
- if (threadGroupPermission == null) {
- threadGroupPermission = new RuntimePermission("modifyThreadGroup");
- }
-
- ((SecurityManager)this).checkPermission(threadGroupPermission);
- } else {
- try {
- this.inThreadGroupCheck = true;
- if (!this.inThreadGroup(var1)) {
- if (threadGroupPermission == null) {
- threadGroupPermission = new RuntimePermission("modifyThreadGroup");
- }
-
- ((SecurityManager)this).checkPermission(threadGroupPermission);
- }
- } finally {
- this.inThreadGroupCheck = false;
- }
- }
-
- }
-
- public void checkPackageAccess(String var1) {
- super.checkPackageAccess(var1);
- boolean[] var2 = new boolean[]{false};
- AccessController.doPrivileged(new 1(this, var1, var2));
- if (var2[0]) {
- ((SecurityManager)this).checkPermission(new RuntimePermission("accessClassInPackage." + var1));
- }
-
- }
-
- public void checkAwtEventQueueAccess() {
- AppContext var1 = AppContext.getAppContext();
- AppletClassLoader var2 = this.currentAppletClassLoader();
- if (var1 == this.mainAppContext && var2 != null) {
- super.checkAwtEventQueueAccess();
- }
-
- }
-
- public ThreadGroup getThreadGroup() {
- AppletClassLoader var1 = this.currentAppletClassLoader();
- ThreadGroup var2 = var1 == null ? null : var1.getThreadGroup();
- return var2 != null ? var2 : super.getThreadGroup();
- }
-
- public AppContext getAppContext() {
- AppletClassLoader var1 = this.currentAppletClassLoader();
- return var1 == null ? null : var1.getAppContext();
- }
- }
-