home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 January / PCO0198.ISO / 1&1 / java.z / java_301 / java / lang / SecurityManager.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-10-20  |  5.9 KB  |  260 lines

  1. package java.lang;
  2.  
  3. import java.io.FileDescriptor;
  4. import java.net.URL;
  5.  
  6. public abstract class SecurityManager {
  7.    protected boolean inCheck;
  8.    private boolean initialized = false;
  9.    private static SecurityManager security;
  10.  
  11.    public synchronized boolean getInCheck() {
  12.       return this.inCheck;
  13.    }
  14.  
  15.    protected SecurityManager() {
  16.       if (System.getSecurityManager() != null) {
  17.          throw new SecurityException("can't create SecurityManager");
  18.       } else {
  19.          this.initialized = true;
  20.       }
  21.    }
  22.  
  23.    protected native Class[] getClassContext();
  24.  
  25.    protected native ClassLoader currentClassLoader();
  26.  
  27.    protected native int classDepth(String var1);
  28.  
  29.    protected native int classLoaderDepth();
  30.  
  31.    protected native boolean checkClassLoader(int var1);
  32.  
  33.    protected boolean inClass(String name) {
  34.       this.checkInitialized();
  35.       return this.classDepth(name) >= 0;
  36.    }
  37.  
  38.    protected boolean inClassLoader() {
  39.       this.checkInitialized();
  40.       return this.currentClassLoader() != null;
  41.    }
  42.  
  43.    public Object getSecurityContext() {
  44.       return null;
  45.    }
  46.  
  47.    public void checkCreateClassLoader(int caller_depth) {
  48.       throw new SecurityException();
  49.    }
  50.  
  51.    public void checkCreateClassLoader() {
  52.       this.checkCreateClassLoader(2);
  53.    }
  54.  
  55.    public void checkAccess(Thread g, int caller_depth) {
  56.       throw new SecurityException();
  57.    }
  58.  
  59.    public void checkAccess(Thread g, Throwable o, int caller_depth) {
  60.       throw new SecurityException();
  61.    }
  62.  
  63.    public void checkAccess(Thread g) {
  64.       this.checkAccess((Thread)g, 2);
  65.    }
  66.  
  67.    public void checkAccess(ThreadGroup g, int caller_depth) {
  68.       throw new SecurityException();
  69.    }
  70.  
  71.    public void checkAccess(ThreadGroup g) {
  72.       this.checkAccess((ThreadGroup)g, 4);
  73.    }
  74.  
  75.    public void checkExit(int status) {
  76.       throw new SecurityException();
  77.    }
  78.  
  79.    public void checkExec(String cmd) {
  80.       throw new SecurityException();
  81.    }
  82.  
  83.    public void checkLink(String lib, int caller_depth) {
  84.       throw new SecurityException();
  85.    }
  86.  
  87.    public void checkLink(String lib) {
  88.       this.checkLink(lib, 2);
  89.       this.checkLink(lib, 3);
  90.    }
  91.  
  92.    public void checkRead(FileDescriptor fd) {
  93.       throw new SecurityException();
  94.    }
  95.  
  96.    public void checkRead(String file) {
  97.       throw new SecurityException();
  98.    }
  99.  
  100.    public void checkRead(String file, Object context) {
  101.       throw new SecurityException();
  102.    }
  103.  
  104.    public void checkWrite(FileDescriptor fd) {
  105.       throw new SecurityException();
  106.    }
  107.  
  108.    public void checkWrite(String file) {
  109.       throw new SecurityException();
  110.    }
  111.  
  112.    public void checkDelete(String file) {
  113.       throw new SecurityException();
  114.    }
  115.  
  116.    public void checkConnect(String host, int port) {
  117.       throw new SecurityException();
  118.    }
  119.  
  120.    public void checkConnect(String host, int port, Object context) {
  121.       throw new SecurityException();
  122.    }
  123.  
  124.    public void checkURLConnect(URL url) {
  125.       throw new SecurityException();
  126.    }
  127.  
  128.    public void checkListen(int port) {
  129.       throw new SecurityException();
  130.    }
  131.  
  132.    public void checkAccept(String host, int port) {
  133.       throw new SecurityException();
  134.    }
  135.  
  136.    public void checkPropertiesAccess(int caller_depth) {
  137.       throw new SecurityException();
  138.    }
  139.  
  140.    public void checkPropertiesAccess() {
  141.       this.checkPropertiesAccess(2);
  142.    }
  143.  
  144.    public void checkPropertyAccess(String key, int caller_depth) {
  145.       throw new SecurityException();
  146.    }
  147.  
  148.    public void checkPropertyAccess(String key) {
  149.       this.checkPropertyAccess(key, 2);
  150.    }
  151.  
  152.    public void checkPropertyAccess(String key, String def) {
  153.       throw new SecurityException();
  154.    }
  155.  
  156.    public boolean checkTopLevelWindow(Object window) {
  157.       return false;
  158.    }
  159.  
  160.    public void checkPackageAccess(String pkg) {
  161.       throw new SecurityException();
  162.    }
  163.  
  164.    public void checkPackageDefinition(String pkg) {
  165.       throw new SecurityException();
  166.    }
  167.  
  168.    public void checkSetFactory() {
  169.       throw new SecurityException();
  170.    }
  171.  
  172.    private native boolean checkInitialized();
  173.  
  174.    public static void setSecurityManager() {
  175.       if (security != null) {
  176.          throw new SecurityException("SecurityManager already set");
  177.       } else {
  178.          security = System.getSecurityManager();
  179.       }
  180.    }
  181.  
  182.    public static void checksCreateClassLoader(int caller_depth) {
  183.       if (security != null) {
  184.          security.checkCreateClassLoader(caller_depth + 1);
  185.       }
  186.  
  187.    }
  188.  
  189.    public static void checksExit(int status) {
  190.       if (security != null) {
  191.          security.checkExit(status);
  192.       }
  193.  
  194.    }
  195.  
  196.    public static void checksExec(String cmd) {
  197.       if (security != null) {
  198.          security.checkExec(cmd);
  199.       }
  200.  
  201.    }
  202.  
  203.    public static void checksLink(String lib, int caller_depth) {
  204.       if (security != null) {
  205.          security.checkLink(lib, caller_depth + 1);
  206.       }
  207.  
  208.    }
  209.  
  210.    public static void checksPropertiesAccess(int caller_depth) {
  211.       if (security != null) {
  212.          security.checkPropertiesAccess(caller_depth + 1);
  213.       }
  214.  
  215.    }
  216.  
  217.    public static void checksPropertyAccess(String key, int caller_depth) {
  218.       if (security != null) {
  219.          security.checkPropertyAccess(key, caller_depth + 1);
  220.       }
  221.  
  222.    }
  223.  
  224.    public static void checksAccess(Thread t, int caller_depth) {
  225.       if (security != null) {
  226.          security.checkAccess(t, caller_depth + 1);
  227.       }
  228.  
  229.    }
  230.  
  231.    public static void checksAccess(Thread t, Throwable o, int caller_depth) {
  232.       if (security != null) {
  233.          security.checkAccess(t, o, caller_depth + 1);
  234.       }
  235.  
  236.    }
  237.  
  238.    public static void checksAccess(ThreadGroup g, int caller_depth) {
  239.       if (security != null) {
  240.          security.checkAccess(g, caller_depth + 1);
  241.       }
  242.  
  243.    }
  244.  
  245.    public static void checksURLConnect(URL url) {
  246.       if (security != null) {
  247.          security.checkURLConnect(url);
  248.       }
  249.  
  250.    }
  251.  
  252.    public native boolean checkScopePermission(int var1);
  253.  
  254.    public static native void setScopePermission();
  255.  
  256.    public static native void setAppletScopePermission();
  257.  
  258.    public static native void resetScopePermission();
  259. }
  260.