RuntimePermission.java 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /* RuntimePermission.java -- permission for a secure runtime action
  2. Copyright (C) 1998, 2000, 2002, 2005 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package java.lang;
  32. import java.security.BasicPermission;
  33. import java.security.Permission;
  34. /**
  35. * A <code>RuntimePermission</code> contains a permission name, but no
  36. * actions list. This means you either have the permission or you don't.
  37. *
  38. * Permission names have the follow the hierarchial property naming
  39. * convention. In addition, an asterisk may appear at the end of a
  40. * name if following a period or by itself.
  41. *
  42. * <table border=1>
  43. * <tr><th>Valid names</th><th>Invalid names</th></tr>
  44. * <tr><td>"accessClassInPackage.*","*"</td>
  45. * <td>"**", "*x", "*.a"</td></tr>
  46. * </table>
  47. * <br>
  48. *
  49. * The following table provides a list of all the possible RuntimePermission
  50. * permission names with a description of what that permission allows.<br>
  51. * <table border=1>
  52. * <tr><th>Permission Name</th><th>Permission Allows</th><th>Risks</th</tr>
  53. * <tr>
  54. * <td><code>createClassLoader</code></td>
  55. * <td>creation of a class loader</td>
  56. * <td>a class loader can load rogue classes which bypass all security
  57. * permissions</td></tr>
  58. * <tr>
  59. * <td><code>getClassLoader</code></td>
  60. * <td>retrieval of the class loader for the calling class</td>
  61. * <td>rogue code could load classes not otherwise available</td></tr>
  62. * <tr>
  63. * <td><code>setContextClassLoader</code></td>
  64. * <td>allows the setting of the context class loader used by a thread</td>
  65. * <td>rogue code could change the context class loader needed by system
  66. * threads</td></tr>
  67. * <tr>
  68. * <td><code>setSecurityManager</code></td>
  69. * <td>allows the application to replace the security manager</td>
  70. * <td>the new manager may be less restrictive, so that rogue code can
  71. * bypass existing security checks</td></tr>
  72. * <tr>
  73. * <td><code>createSecurityManager</code></td>
  74. * <td>allows the application to create a new security manager</td>
  75. * <td>rogue code can use the new security manager to discover information
  76. * about the execution stack</td></tr>
  77. * <tr>
  78. * <td><code>exitVM</code></td>
  79. * <td>allows the application to halt the virtual machine</td>
  80. * <td>rogue code can mount a denial-of-service attack by killing the
  81. * virtual machine</td></tr>
  82. * <tr>
  83. * <td><code>shutdownHooks</code></td>
  84. * <td>allows registration and modification of shutdown hooks</td>
  85. * <td>rogue code can add a hook that interferes with clean
  86. * virtual machine shutdown</td></tr>
  87. * <tr>
  88. * <td><code>setFactory</code></td>
  89. * <td>allows the application to set the socket factory for socket,
  90. * server socket, stream handler, or RMI socket factory.</td>
  91. * <td>rogue code can create a rogue network object which mangles or
  92. * intercepts data</td></tr>
  93. * <tr>
  94. * <td><code>setIO</code></td>
  95. * <td>allows the application to set System.out, System.in, and
  96. * System.err</td>
  97. * <td>rogue code could sniff user input and intercept or mangle
  98. * output</td></tr>
  99. * <tr>
  100. * <td><code>modifyThread</code></td>
  101. * <td>allows the application to modify any thread in the virtual machine
  102. * using any of the methods <code>stop</code>, <code>resume</code>,
  103. * <code>suspend</code>, <code>setPriority</code>, and
  104. * <code>setName</code> of classs <code>Thread</code></td>
  105. * <td>rogue code could adversely modify system or user threads</td></tr>
  106. * <tr>
  107. * <td><code>stopThread</code></td>
  108. * <td>allows the application to <code>stop</code> any thread it has
  109. * access to in the system</td>
  110. * <td>rogue code can stop arbitrary threads</td></tr>
  111. * <tr>
  112. * <td><code>modifyThreadGroup</code></td>
  113. * <td>allows the application to modify thread groups using any of the
  114. * methods <code>destroy</code>, <code>resume</code>,
  115. * <code>setDaemon</code>, <code>setMaxPriority</code>,
  116. * <code>stop</code>, and <code>suspend</code> of the class
  117. * <code>ThreadGroup</code></td>
  118. * <td>rogue code can mount a denial-of-service attack by changing run
  119. * priorities</td></tr>
  120. * <tr>
  121. * <td><code>getProtectionDomain</code></td>
  122. * <td>retrieve a class's ProtectionDomain</td>
  123. * <td>rogue code can gain information about the security policy, to
  124. * prepare a better attack</td></tr>
  125. * <tr>
  126. * <td><code>readFileDescriptor</code></td>
  127. * <td>read a file descriptor</td>
  128. * <td>rogue code can read sensitive information</td></tr>
  129. * <tr>
  130. * <td><code>writeFileDescriptor</code></td>
  131. * <td>write a file descriptor</td>
  132. * <td>rogue code can write files, including viruses, and can modify the
  133. * virtual machine binary; if not just fill up the disk</td></tr>
  134. * <tr>
  135. * <td><code>loadLibrary.</code><em>library name</em></td>
  136. * <td>dynamic linking of the named library</td>
  137. * <td>native code can bypass many security checks of pure Java</td></tr>
  138. * <tr>
  139. * <td><code>accessClassInPackage.</code><em>package name</em></td>
  140. * <td>access to a package via a ClassLoader</td>
  141. * <td>rogue code can access classes not normally available</td></tr>
  142. * <tr>
  143. * <td><code>defineClassInPackage.</code><em>package name</em></td>
  144. * <td>define a class inside a given package</td>
  145. * <td>rogue code can install rogue classes, including in trusted packages
  146. * like java.security or java.lang</td></tr>
  147. * <tr>
  148. * <td><code>accessDeclaredMembers</code></td>
  149. * <td>access declared class members via reflection</td>
  150. * <td>rogue code can discover information, invoke methods, or modify fields
  151. * that are not otherwise available</td></tr>
  152. * <tr>
  153. * <td><code>queuePrintJob</code></td>
  154. * <td>initiate a print job</td>
  155. * <td>rogue code could make a hard copy of sensitive information, or
  156. * simply waste paper</td></tr>
  157. * </table>
  158. *
  159. * @author Brian Jones
  160. * @author Eric Blake (ebb9@email.byu.edu)
  161. * @see BasicPermission
  162. * @see Permission
  163. * @see SecurityManager
  164. * @since 1.2
  165. * @status updated to 1.4
  166. */
  167. public final class RuntimePermission extends BasicPermission
  168. {
  169. /**
  170. * Compatible with JDK 1.2+.
  171. */
  172. private static final long serialVersionUID = 7399184964622342223L;
  173. /**
  174. * Create a new permission with the specified name.
  175. *
  176. * @param permissionName the name of the granted permission
  177. * @throws NullPointerException if name is null
  178. * @throws IllegalArgumentException thrown if name is empty or invalid
  179. */
  180. public RuntimePermission(String permissionName)
  181. {
  182. super(permissionName);
  183. }
  184. /**
  185. * Create a new permission with the specified name. The actions argument
  186. * is ignored, as runtime permissions have no actions.
  187. *
  188. * @param permissionName the name of the granted permission
  189. * @param actions ignored
  190. * @throws NullPointerException if name is null
  191. * @throws IllegalArgumentException thrown if name is empty or invalid
  192. */
  193. public RuntimePermission(String permissionName, String actions)
  194. {
  195. super(permissionName);
  196. }
  197. }