⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 securitymanager.java

📁 this gcc-g++-3.3.1.tar.gz is a source file of gcc, you can learn more about gcc through this codes f
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
   *   * @param host the host which wishes to connect   * @param port the port the connection will be on   * @throws SecurityException if permission is denied   * @throws NullPointerException if host is null   * @see ServerSocket#accept()   */  public void checkAccept(String host, int port)  {    // Use the toString() hack to do the null check.    checkPermission(new SocketPermission(host.toString() + ":" + port,                                         "accept"));  }  /**   * Check if the current thread is allowed to read and write multicast to   * a particular address. The default implementation checks   * <code>SocketPermission(addr.getHostAddress(), "accept,connect")</code>.   * If you override this, call <code>super.checkMulticast</code> rather than   * throwing an exception.   *   * @param addr the address to multicast to   * @throws SecurityException if permission is denied   * @throws NullPointerException if host is null   * @since 1.1   */  public void checkMulticast(InetAddress addr)  {    checkPermission(new SocketPermission(addr.getHostAddress(),                                         "accept,connect"));  }  /**   *Check if the current thread is allowed to read and write multicast to   * a particular address with a particular ttl (time-to-live) value. The   * default implementation ignores ttl, and checks   * <code>SocketPermission(addr.getHostAddress(), "accept,connect")</code>.   * If you override this, call <code>super.checkMulticast</code> rather than   * throwing an exception.   *   * @param addr the address to multicast to   * @param ttl value in use for multicast send   * @throws SecurityException if permission is denied   * @throws NullPointerException if host is null   * @since 1.1   * @deprecated use {@link #checkPermission(Permission)} instead   */  public void checkMulticast(InetAddress addr, byte ttl)  {    checkPermission(new SocketPermission(addr.getHostAddress(),                                         "accept,connect"));  }  /**   * Check if the current thread is allowed to read or write all the system   * properties at once. This method is called by System.getProperties()   * and setProperties(). The default implementation checks   * <code>PropertyPermission("*", "read,write")</code>. If you override   * this, call <code>super.checkPropertiesAccess</code> rather than   * throwing an exception.   *   * @throws SecurityException if permission is denied   * @see System#getProperties()   * @see System#setProperties(Properties)   */  public void checkPropertiesAccess()  {    checkPermission(new PropertyPermission("*", "read,write"));  }  /**   * Check if the current thread is allowed to read a particular system   * property (writes are checked directly via checkPermission). This method   * is called by System.getProperty() and setProperty(). The default   * implementation checks <code>PropertyPermission(key, "read")</code>. If   * you override this, call <code>super.checkPropertyAccess</code> rather   * than throwing an exception.   *   * @throws SecurityException if permission is denied   * @throws NullPointerException if key is null   * @throws IllegalArgumentException if key is ""   * @see System#getProperty(String)   */  public void checkPropertyAccess(String key)  {    checkPermission(new PropertyPermission(key, "read"));  }  /**   * Check if the current thread is allowed to create a top-level window. If   * it is not, the operation should still go through, but some sort of   * nonremovable warning should be placed on the window to show that it   * is untrusted. This method is called by Window.Window(). The default   * implementation checks   * <code>AWTPermission("showWindowWithoutWarningBanner")</code>, and returns   * true if no exception was thrown. If you override this, use   * <code>return super.checkTopLevelWindow</code> rather than returning   * false.   *   * @param window the window to create   * @return true if there is permission to show the window without warning   * @throws NullPointerException if window is null   * @see Window#Window(Frame)   */  public boolean checkTopLevelWindow(Object window)  {    if (window == null)      throw new NullPointerException();    try      {        checkPermission(new AWTPermission("showWindowWithoutWarningBanner"));        return true;      }    catch (SecurityException e)      {        return false;      }  }  /**   * Check if the current thread is allowed to create a print job. This   * method is called by Toolkit.getPrintJob(). The default implementation   * checks <code>RuntimePermission("queuePrintJob")</code>. If you override   * this, call <code>super.checkPrintJobAccess</code> rather than throwing   * an exception.   *   * @throws SecurityException if permission is denied   * @see Toolkit#getPrintJob(Frame, String, Properties)   * @since 1.1   */  public void checkPrintJobAccess()  {    checkPermission(new RuntimePermission("queuePrintJob"));  }  /**   * Check if the current thread is allowed to use the system clipboard. This   * method is called by Toolkit.getSystemClipboard(). The default   * implementation checks <code>AWTPermission("accessClipboard")</code>. If   * you override this, call <code>super.checkSystemClipboardAccess</code>   * rather than throwing an exception.   *   * @throws SecurityException if permission is denied   * @see Toolkit#getSystemClipboard()   * @since 1.1   */  public void checkSystemClipboardAccess()  {    checkPermission(new AWTPermission("accessClipboard"));  }  /**   * Check if the current thread is allowed to use the AWT event queue. This   * method is called by Toolkit.getSystemEventQueue(). The default   * implementation checks <code>AWTPermission("accessEventQueue")</code>.   * you override this, call <code>super.checkAwtEventQueueAccess</code>   * rather than throwing an exception.   *   * @throws SecurityException if permission is denied   * @see Toolkit#getSystemEventQueue()   * @since 1.1   */  public void checkAwtEventQueueAccess()  {    // Should be: checkPermission(new AWTPermission("accessEventQueue"));    throw new SecurityException("Cannot access the AWT event queue.");  }  /**   * Check if the current thread is allowed to access the specified package   * at all. This method is called by ClassLoader.loadClass() in user-created   * ClassLoaders. The default implementation gets a list of all restricted   * packages, via <code>Security.getProperty("package.access")</code>. Then,   * if packageName starts with or equals any restricted package, it checks   * <code>RuntimePermission("accessClassInPackage." + packageName)</code>.   * If you override this, you should call   * <code>super.checkPackageAccess</code> before doing anything else.   *   * @param packageName the package name to check access to   * @throws SecurityException if permission is denied   * @throws NullPointerException if packageName is null   * @see ClassLoader#loadClass(String, boolean)   * @see Security#getProperty(String)   */  public void checkPackageAccess(String packageName)  {    checkPackageList(packageName, "access", "accessClassInPackage.");  }  /**   * Check if the current thread is allowed to define a class into the   * specified package. This method is called by ClassLoader.loadClass() in   * user-created ClassLoaders. The default implementation gets a list of all   * restricted packages, via   * <code>Security.getProperty("package.definition")</code>. Then, if   * packageName starts with or equals any restricted package, it checks   * <code>RuntimePermission("defineClassInPackage." + packageName)</code>.   * If you override this, you should call   * <code>super.checkPackageDefinition</code> before doing anything else.   *   * @param packageName the package name to check access to   * @throws SecurityException if permission is denied   * @throws NullPointerException if packageName is null   * @see ClassLoader#loadClass(String, boolean)   * @see Security#getProperty(String)   */  public void checkPackageDefinition(String packageName)  {    checkPackageList(packageName, "definition", "defineClassInPackage.");  }  /**   * Check if the current thread is allowed to set the current socket factory.   * This method is called by Socket.setSocketImplFactory(),   * ServerSocket.setSocketFactory(), and URL.setURLStreamHandlerFactory().   * The default implementation checks   * <code>RuntimePermission("setFactory")</code>. If you override this, call   * <code>super.checkSetFactory</code> rather than throwing an exception.   *   * @throws SecurityException if permission is denied   * @see Socket#setSocketImplFactory(SocketImplFactory)   * @see ServerSocket#setSocketFactory(SocketImplFactory)   * @see URL#setURLStreamHandlerFactory(URLStreamHandlerFactory)   */  public void checkSetFactory()  {    checkPermission(new RuntimePermission("setFactory"));  }  /**   * Check if the current thread is allowed to get certain types of Methods,   * Fields and Constructors from a Class object. This method is called by   * Class.getMethod[s](), Class.getField[s](), Class.getConstructor[s],   * Class.getDeclaredMethod[s](), Class.getDeclaredField[s](), and   * Class.getDeclaredConstructor[s](). The default implementation allows   * PUBLIC access, and access to classes defined by the same classloader as   * the code performing the reflection. Otherwise, it checks   * <code>RuntimePermission("accessDeclaredMembers")</code>. If you override   * this, do not call <code>super.checkMemberAccess</code>, as this would   * mess up the stack depth check that determines the ClassLoader requesting   * the access.   *   * @param c the Class to check   * @param memberType either DECLARED or PUBLIC   * @throws SecurityException if permission is denied, including when   *         memberType is not DECLARED or PUBLIC   * @throws NullPointerException if c is null   * @see Class   * @see Member#DECLARED   * @see Member#PUBLIC   * @since 1.1   */  public void checkMemberAccess(Class c, int memberType)  {    if (c == null)      throw new NullPointerException();    if (memberType == Member.PUBLIC)      return;    // XXX Allow access to classes created by same classloader before next    // check.    checkPermission(new RuntimePermission("accessDeclaredMembers"));  }  /**   * Test whether a particular security action may be taken. The default   * implementation checks <code>SecurityPermission(action)</code>. If you   * override this, call <code>super.checkSecurityAccess</code> rather than   * throwing an exception.   *   * @param action the desired action to take   * @throws SecurityException if permission is denied   * @throws NullPointerException if action is null   * @throws IllegalArgumentException if action is ""   * @since 1.1   */  public void checkSecurityAccess(String action)  {    checkPermission(new SecurityPermission(action));  }  /**   * Get the ThreadGroup that a new Thread should belong to by default. Called   * by Thread.Thread(). The default implementation returns the current   * ThreadGroup of the current Thread. <STRONG>Spec Note:</STRONG> it is not   * clear whether the new Thread is guaranteed to pass the   * checkAccessThreadGroup() test when using this ThreadGroup, but I presume   * so.   *   * @return the ThreadGroup to put the new Thread into   * @since 1.1   */  public ThreadGroup getThreadGroup()  {    return Thread.currentThread().getThreadGroup();  }  /**   * Helper that checks a comma-separated list of restricted packages, from   * <code>Security.getProperty("package.definition")</code>, for the given   * package access permission. If packageName starts with or equals any   * restricted package, it checks   * <code>RuntimePermission(permission + packageName)</code>.   *   * @param packageName the package name to check access to   * @param restriction the list of restrictions, after "package."   * @param permission the base permission, including the '.'   * @throws SecurityException if permission is denied   * @throws NullPointerException if packageName is null   * @see #checkPackageAccess(String)   * @see #checkPackageDefinition(String)   */  void checkPackageList(String packageName, String restriction,                        String permission)  {    // Use the toString() hack to do the null check.    Permission p = new RuntimePermission(permission + packageName.toString());    String list = Security.getProperty("package." + restriction);    if (list == null)      return;    while (! "".equals(packageName))      {        for (int index = list.indexOf(packageName);             index != -1; index = list.indexOf(packageName, index + 1))          {	    int packageNameCount = packageName.length();            if (index + packageNameCount == list.length()                || list.charAt(index + packageNameCount) == ',')              {                checkPermission(p);                return;              }          }        int index = packageName.lastIndexOf('.');        packageName = index < 0 ? "" : packageName.substring(0, index);      }  }} // class SecurityManager// XXX This class is unnecessary.class SecurityContext {	Class[] classes;	SecurityContext(Class[] classes) {		this.classes = classes;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -