home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Metrowerks CodeWarrior / Java Support / Java_Source / Java2 / src / java / lang / RuntimePermission.java < prev    next >
Encoding:
Java Source  |  1999-05-28  |  10.3 KB  |  283 lines  |  [TEXT/CWIE]

  1. /*
  2.  * @(#)RuntimePermission.java    1.31 98/09/21
  3.  *
  4.  * Copyright 1997, 1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.lang;
  16.  
  17. import java.security.*;
  18. import java.util.Enumeration;
  19. import java.util.Hashtable;
  20. import java.util.StringTokenizer;
  21.  
  22. /**
  23.  * This class is for runtime permissions. A RuntimePermission
  24.  * contains a name (also referred to as a "target name") but
  25.  * no actions list; you either have the named permission
  26.  * or you don't.
  27.  *
  28.  * <P>
  29.  * The target name is the name of the runtime permission (see below). The
  30.  * naming convention follows the  hierarchical property naming convention.
  31.  * Also, an asterisk
  32.  * may appear at the end of the name, following a ".", or by itself, to
  33.  * signify a wildcard match. For example: "loadLibrary.*" or "*" is valid,
  34.  * "*loadLibrary" or "a*b" is not valid.
  35.  * <P>
  36.  * The following table lists all the possible RuntimePermission target names,
  37.  * and for each provides a description of what the permission allows
  38.  * and a discussion of the risks of granting code the permission.
  39.  * <P>
  40.  *
  41.  * <table border=1 cellpadding=5>
  42.  * <tr>
  43.  * <th>Permission Target Name</th>
  44.  * <th>What the Permission Allows</th>
  45.  * <th>Risks of Allowing this Permission</th>
  46.  * </tr>
  47.  *
  48.  * <tr>
  49.  *   <td>createClassLoader</td>
  50.  *   <td>Creation of a class loader</td>
  51.  *   <td>This is an extremely dangerous permission to grant.
  52.  * Malicious applications that can instantiate their own class
  53.  * loaders could then load their own rogue classes into the system.
  54.  * These newly loaded classes could be placed into any protection
  55.  * domain by the class loader, thereby automatically granting the
  56.  * classes the permissions for that domain.</td>
  57.  * </tr>
  58.  *
  59.  * <tr>
  60.  *   <td>getClassLoader</td>
  61.  *   <td>Retrieval of a class loader (e.g., the class loader for the calling
  62.  * class)</td>
  63.  *   <td>This would grant an attacker permission to get the
  64.  * class loader for a particular class. This is dangerous because
  65.  * having access to a class's class loader allows the attacker to
  66.  * load other classes available to that class loader. The attacker
  67.  * would typically otherwise not have access to those classes.</td>
  68.  * </tr>
  69.  *
  70.  * <tr>
  71.  *   <td>setContextClassLoader</td>
  72.  *   <td>Setting of the context class loader used by a thread</td>
  73.  *   <td>The context class loader is used by system code and extensions
  74.  * when they need to lookup resources that might not exist in the system
  75.  * class loader. Granting setContextClassLoader permission would allow
  76.  * code to change which context class loader is used
  77.  * for a particular thread, including system threads.</td>
  78.  * </tr>
  79.  *
  80.  * <tr>
  81.  *   <td>setSecurityManager</td>
  82.  *   <td>Setting of the security manager (possibly replacing an existing one)
  83.  * </td>
  84.  *   <td>The security manager is a class that allows 
  85.  * applications to implement a security policy. Granting the setSecurityManager
  86.  * permission would allow code to change which security manager is used by
  87.  * installing a different, possibly less restrictive security manager,
  88.  * thereby bypassing checks that would have been enforced by the original
  89.  * security manager.</td>
  90.  * </tr>
  91.  *
  92.  * <tr>
  93.  *   <td>createSecurityManager</td>
  94.  *   <td>Creation of a new security manager</td>
  95.  *   <td>This gives code access to protected, sensitive methods that may
  96.  * disclose information about other classes or the execution stack.</td>
  97.  * </tr>
  98.  *
  99.  * <tr>
  100.  *   <td>exitVM</td>
  101.  *   <td>Halting of the Java Virtual Machine</td>
  102.  *   <td>This allows an attacker to mount a denial-of-service attack
  103.  * by automatically forcing the virtual machine to halt.</td>
  104.  * </tr>
  105.  *
  106.  * <tr>
  107.  *   <td>setFactory</td>
  108.  *   <td>Setting of the socket factory used by ServerSocket or Socket,
  109.  * or of the stream handler factory used by URL</td>
  110.  *   <td>This allows code to set the actual implementation
  111.  * for the socket, server socket, stream handler, or RMI socket factory.
  112.  * An attacker may set a faulty implementation which mangles the data
  113.  * stream.</td>
  114.  * </tr>
  115.  *
  116.  * <tr>
  117.  *   <td>setIO</td>
  118.  *   <td>Setting of System.out, System.in, and System.err</td>
  119.  *   <td>This allows changing the value of the standard system streams.
  120.  * An attacker may change System.in to monitor and
  121.  * steal user input, or may set System.err to a "null" OutputSteam,
  122.  * which would hide any error messages sent to System.err. </td>
  123.  * </tr>
  124.  *
  125.  * <tr>
  126.  *   <td>modifyThread</td>
  127.  *   <td>Modification of threads, e.g., via calls to Thread <code>stop</code>,
  128.  * <code>suspend</code>, <code>resume</code>, <code>setPriority</code>,
  129.  * and <code>setName</code> methods</td>
  130.  *   <td>This allows an attacker to start or suspend any thread
  131.  * in the system.</td>
  132.  * </tr>
  133.  *
  134.  * <tr>
  135.  *   <td>stopThread</td>
  136.  *   <td>Stopping of threads via calls to the Thread <code>stop</code>
  137.  * method</td>
  138.  *   <td>This allows code to stop any thread in the system provided that it is
  139.  * already granted permission to access that thread.
  140.  * This poses as a threat, because that code may corrupt the system by
  141.  * killing existing threads.</td>
  142.  * </tr>
  143.  *
  144.  * <tr>
  145.  *   <td>modifyThreadGroup</td>
  146.  *   <td>modification of thread groups, e.g., via calls to ThreadGroup
  147.  * <code>destroy</code>, <code>resume</code>, <code>setDaemon</code>,
  148.  * <code>setMaxPriority</code>, <code>stop</code>, and <code>suspend</code>
  149.  * methods</td>
  150.  *   <td>This allows an attacker to create thread groups and
  151.  * set their run priority.</td>
  152.  * </tr>
  153.  *
  154.  * <tr>
  155.  *   <td>getProtectionDomain</td>
  156.  *   <td>Retrieval of the ProtectionDomain for a class</td>
  157.  *   <td>This allows code to obtain policy information
  158.  * for a particular code source. While obtaining policy information
  159.  * does not compromise the security of the system, it does give
  160.  * attackers additional information, such as local file names for
  161.  * example, to better aim an attack.</td>
  162.  * </tr>
  163.  *
  164.  * <tr>
  165.  *   <td>readFileDescriptor</td>
  166.  *   <td>Reading of file descriptors</td>
  167.  *   <td>This would allow code to read the particular file associated
  168. with the file descriptor read. This is dangerous if the file contains
  169. confidential data.</td>
  170.  * </tr>
  171.  *
  172.  * <tr>
  173.  *   <td>writeFileDescriptor</td>
  174.  *   <td>Writing to file descriptors</td>
  175.  *   <td>This allows code to write to a particular file associated
  176. with the descriptor. This is dangerous because it may allow malicous
  177. code to plant viruses or at the very least, fill up your entire disk.</td>
  178.  * </tr>
  179.  *
  180.  * <tr>
  181.  *   <td>loadLibrary.{library name}</td>
  182.  *   <td>Dynamic linking of the specified library</td>
  183.  *   <td>It is dangerous to allow an applet permission to load native code
  184.  * libraries, because the Java security architecture is not designed to and
  185.  * does not prevent malicious behavior at the level of native code.</td>
  186.  * </tr>
  187.  *
  188.  * <tr>
  189.  *   <td>accessClassInPackage.{package name}</td>
  190.  *   <td>Access to the specified package via a class loader's
  191.  * <code>loadClass</code> method when that class loader calls
  192.  * the SecurityManager <code>checkPackageAcesss</code> method</td>
  193.  *   <td>This gives code access to classes in packages
  194.  * to which it normally does not have access. Malicious code
  195.  * may use these classes to help in its attempt to compromise
  196.  * security in the system.</td>
  197.  * </tr>
  198.  *
  199.  * <tr>
  200.  *   <td>defineClassInPackage.{package name}</td>
  201.  *   <td>Definition of classes in the specified package, via a class
  202.  * loader's <code>defineClass</code> method when that class loader calls
  203.  * the SecurityManager <code>checkPackageDefinition</code> method.</td>
  204.  *   <td>This grants code permission to define a class
  205.  * in a particular package. This is dangerous because malicious
  206.  * code with this permission may define rogue classes in
  207.  * trusted packages like <code>java.security</code> or <code>java.lang</code>,
  208.  * for example.</td>
  209.  * </tr>
  210.  *
  211.  * <tr>
  212.  *   <td>accessDeclaredMembers</td>
  213.  *   <td>Access to the declared members of a class</td>
  214.  *   <td>This grants code permission to query a class for its public,
  215.  * protected, default (package) access, and private fields and/or
  216.  * methods. Although the code would have
  217.  * access to the private and protected field and method names, it would not
  218.  * have access to the private/protected field data and would not be able
  219.  * to invoke any private methods. Nevertheless, malicious code
  220.  * may use this information to better aim an attack.
  221.  * Additionally, it may invoke any public methods and/or access public fields
  222.  * in the class.  This could be dangerous if
  223.  * the code would normally not be able to invoke those methods and/or
  224.  * access the fields  because
  225.  * it can't cast the object to the class/interface with those methods
  226.  * and fields.
  227. </td>
  228.  * </tr>
  229.  * <tr>
  230.  *   <td>queuePrintJob</td>
  231.  *   <td>Initiation of a print job request</td>
  232.  *   <td>This could print sensitive information to a printer,
  233.  * or simply waste paper.</td>
  234.  * </tr>
  235.  *
  236.  * </table>
  237.  *
  238.  * @see java.security.BasicPermission
  239.  * @see java.security.Permission
  240.  * @see java.security.Permissions
  241.  * @see java.security.PermissionCollection
  242.  * @see java.lang.SecurityManager
  243.  *
  244.  * @version 1.31 99/03/26
  245.  *
  246.  * @author Marianne Mueller
  247.  * @author Roland Schemers
  248.  */
  249.  
  250. public final class RuntimePermission extends BasicPermission {
  251.  
  252.     /**
  253.      * Creates a new RuntimePermission with the specified name.
  254.      * The name is the symbolic name of the RuntimePermission, such as
  255.      * "exit", "setFactory", etc. An asterisk
  256.      * may appear at the end of the name, following a ".", or by itself, to
  257.      * signify a wildcard match.
  258.      *
  259.      * @param name the name of the RuntimePermission.
  260.      */
  261.  
  262.     public RuntimePermission(String name)
  263.     {
  264.     super(name);
  265.     }
  266.  
  267.     /**
  268.      * Creates a new RuntimePermission object with the specified name.
  269.      * The name is the symbolic name of the RuntimePermission, and the
  270.      * actions String is currently unused and should be null. This
  271.      * constructor exists for use by the <code>Policy</code> object
  272.      * to instantiate new Permission objects.
  273.      *
  274.      * @param name the name of the RuntimePermission.
  275.      * @param actions should be null.
  276.      */
  277.  
  278.     public RuntimePermission(String name, String actions)
  279.     {
  280.     super(name, actions);
  281.     }
  282. }
  283.