You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

permissions.html 7.7 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <!--
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. -->
  15. <html>
  16. <head>
  17. <meta http-equiv="Content-Language" content="en-us">
  18. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  19. <title>Permissions type</title>
  20. </head>
  21. <body>
  22. <h2><a name="permissions">Permissions</a></h2>
  23. <p>
  24. Permissions represents a set of security permissions granted or revoked to
  25. a specific part code executed in the JVM where Apache Ant is running in.
  26. The actual Permissions are specified via a set of nested permission items either
  27. <code>&lt;grant&gt;</code>ed or <code>&lt;revoke&gt;</code>d.</p>
  28. <p>
  29. In the base situation a <a href="#baseset">base set</a> of permissions granted.
  30. Extra permissions can be
  31. granted. A granted permission can be overruled by revoking a permission.
  32. The security manager installed by the permissions will throw an
  33. <code>SecurityException</code> if
  34. the code subject to these permissions try to use an permission that has not been
  35. granted or that has been revoked.</p>
  36. <h3>Nested elements</h3>
  37. <h4>grant</h4>
  38. <p>
  39. Indicates a specific permission is always granted. Its attributes indicate which
  40. permissions are granted.</p>
  41. <table border="1" cellpadding="2" cellspacing="0">
  42. <tr>
  43. <td valign="top"><b>Attribute</b></td>
  44. <td valign="top"><b>Description</b></td>
  45. <td align="center" valign="top"><b>Required</b></td>
  46. </tr>
  47. <tr>
  48. <td valign="top">class</td>
  49. <td valign="top">The fully qualified name of the Permission class.</td>
  50. <td valign="top" align="center">Yes</td>
  51. </tr>
  52. <tr>
  53. <td valign="top">name</td>
  54. <td valign="top">The name of the Permission. The actual contents depends on the
  55. Permission class.</td>
  56. <td valign="top" align="center">No</td>
  57. </tr>
  58. <tr>
  59. <td valign="top">actions</td>
  60. <td valign="top">The actions allowed. The actual contents depend on the
  61. Permission class and name.</td>
  62. <td valign="top" align="center">No</td>
  63. </tr>
  64. </table>
  65. <p>
  66. Implied permissions are granted.
  67. </p>
  68. <p>
  69. Please note that some Permission classes may actually need a name and / or actions in order to function properly. The name and actions are parsed by the actual
  70. Permission class.
  71. </p>
  72. <h4>revoke</h4>
  73. <p>
  74. Indicates a specific permission is revoked.</p>
  75. <table border="1" cellpadding="2" cellspacing="0">
  76. <tr>
  77. <td valign="top"><b>Attribute</b></td>
  78. <td valign="top"><b>Description</b></td>
  79. <td align="center" valign="top"><b>Required</b></td>
  80. </tr>
  81. <tr>
  82. <td valign="top">class</td>
  83. <td valign="top">The fully qualified name of the Permission class.</td>
  84. <td valign="top" align="center">Yes</td>
  85. </tr>
  86. <tr>
  87. <td valign="top">name</td>
  88. <td valign="top">The name of the Permission. The actual contents depends on the
  89. Permission class.</td>
  90. <td valign="top" align="center">No</td>
  91. </tr>
  92. <tr>
  93. <td valign="top">actions</td>
  94. <td valign="top">The actions allowed. The actual contents depend on the
  95. Permission class and name.</td>
  96. <td valign="top" align="center">No</td>
  97. </tr>
  98. </table>
  99. <p>
  100. Implied permissions are not resolved and therefore also not revoked.
  101. </p>
  102. <p>
  103. The name can handle the * wildcard at the end of the name, in which case all
  104. permissions of the specified class of which the name starts with the specified name
  105. (excluding the *) are revoked. Note that the - wildcard often supported by the
  106. granted properties is not supported.
  107. If the name is left empty all names match, and are revoked.
  108. If the actions are left empty all actions match, and are revoked.
  109. </p>
  110. <h3><a name="baseset">Base set</a></h3>
  111. A permissions set implicitly contains the following permissions:
  112. <blockquote><pre>
  113. &lt;grant class=&quot;java.net.SocketPermission&quot; name=&quot;localhost:1024-&quot; actions=&quot;listen&quot;&gt;
  114. &lt;grant class=&quot;java.util.PropertyPermission&quot; name=&quot;java.version&quot; actions=&quot;read&quot;&gt;
  115. &lt;grant class=&quot;java.util.PropertyPermission&quot; name=&quot;java.vendor&quot; actions=&quot;read&quot;&gt;
  116. &lt;grant class=&quot;java.util.PropertyPermission&quot; name=&quot;java.vendor.url&quot; actions=&quot;read&quot;&gt;
  117. &lt;grant class=&quot;java.util.PropertyPermission&quot; name=&quot;java.class.version&quot; actions=&quot;read&quot;&gt;
  118. &lt;grant class=&quot;java.util.PropertyPermission&quot; name=&quot;os.name&quot; actions=&quot;read&quot;&gt;
  119. &lt;grant class=&quot;java.util.PropertyPermission&quot; name=&quot;os.version&quot; actions=&quot;read&quot;&gt;
  120. &lt;grant class=&quot;java.util.PropertyPermission&quot; name=&quot;os.arch&quot; actions=&quot;read&quot;&gt;
  121. &lt;grant class=&quot;java.util.PropertyPermission&quot; name=&quot;file.encoding&quot; actions=&quot;read&quot;&gt;
  122. &lt;grant class=&quot;java.util.PropertyPermission&quot; name=&quot;file.separator&quot; actions=&quot;read&quot;&gt;
  123. &lt;grant class=&quot;java.util.PropertyPermission&quot; name=&quot;path.separator&quot; actions=&quot;read&quot;&gt;
  124. &lt;grant class=&quot;java.util.PropertyPermission&quot; name=&quot;line.separator&quot; actions=&quot;read&quot;&gt;
  125. &lt;grant class=&quot;java.util.PropertyPermission&quot; name=&quot;java.specification.version&quot; actions=&quot;read&quot;&gt;
  126. &lt;grant class=&quot;java.util.PropertyPermission&quot; name=&quot;java.specification.vendor&quot; actions=&quot;read&quot;&gt;
  127. &lt;grant class=&quot;java.util.PropertyPermission&quot; name=&quot;java.specification.name&quot; actions=&quot;read&quot;&gt;
  128. &lt;grant class=&quot;java.util.PropertyPermission&quot; name=&quot;java.vm.specification.version&quot; actions=&quot;read&quot;&gt;
  129. &lt;grant class=&quot;java.util.PropertyPermission&quot; name=&quot;java.vm.specification.vendor&quot; actions=&quot;read&quot;&gt;
  130. &lt;grant class=&quot;java.util.PropertyPermission&quot; name=&quot;java.vm.specification.name&quot; actions=&quot;read&quot;&gt;
  131. &lt;grant class=&quot;java.util.PropertyPermission&quot; name=&quot;java.vm.version&quot; actions=&quot;read&quot;&gt;
  132. &lt;grant class=&quot;java.util.PropertyPermission&quot; name=&quot;java.vm.vendor&quot; actions=&quot;read&quot;&gt;
  133. &lt;grant class=&quot;java.util.PropertyPermission&quot; name=&quot;java.vm.name&quot; actions=&quot;read&quot;&gt;
  134. </blockquote></pre>
  135. These permissions can be revoked via <code>&lt;revoke&gt;</code> elements if necessary.
  136. <h3>Examples</h3>
  137. <blockquote><pre>
  138. &lt;permissions&gt;
  139. &lt;grant class=&quot;java.security.AllPermission&quot;/&gt;
  140. &lt;revoke class=&quot;java.util.PropertyPermission&quot;/&gt;
  141. &lt;/permissions&gt;
  142. </pre></blockquote>
  143. <p>
  144. Grants all permissions to the code except for those handling Properties.
  145. </p>
  146. <blockquote><pre>
  147. &lt;permissions&gt;
  148. &lt;grant class=&quot;java.net.SocketPermission&quot; name=&quot;foo.bar.com&quot; action=&quot;connect&quot;/&gt;
  149. &lt;grant class=&quot;java.util.PropertyPermission&quot; name=&quot;user.home&quot; action=&quot;read,write&quot;/&gt;
  150. &lt;/permissions&gt;
  151. </pre></blockquote>
  152. <p>
  153. Grants the base set of permissions with the addition of a SocketPermission to connect
  154. to foo.bar.com and the permission to read and write the user.home system property.
  155. </p>
  156. </body>
  157. </html>