1. /*
  2. * @(#)SecurityPermission.java 1.19 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.security;
  8. import java.security.*;
  9. import java.util.Enumeration;
  10. import java.util.Hashtable;
  11. import java.util.StringTokenizer;
  12. /**
  13. * This class is for security permissions.
  14. * A SecurityPermission contains a name (also referred to as a "target name")
  15. * but no actions list; you either have the named permission
  16. * or you don't.
  17. * <P>
  18. * The target name is the name of a security configuration parameter (see below).
  19. * Currently the SecurityPermission object is used to guard access
  20. * to the Policy, Security, Provider, Signer, and Identity
  21. * objects.
  22. * <P>
  23. * The following table lists all the possible SecurityPermission target names,
  24. * and for each provides a description of what the permission allows
  25. * and a discussion of the risks of granting code the permission.
  26. * <P>
  27. *
  28. * <table border=1 cellpadding=5>
  29. * <tr>
  30. * <th>Permission Target Name</th>
  31. * <th>What the Permission Allows</th>
  32. * <th>Risks of Allowing this Permission</th>
  33. * </tr>
  34. *
  35. * <tr>
  36. * <td>getPolicy</td>
  37. * <td>Retrieval of the system-wide security policy (specifically, of the
  38. * currently-installed Policy object)</td>
  39. * <td>This allows someone to query the policy via the
  40. * <code>getPermissions</code> call,
  41. * which discloses which permissions would be granted to a given CodeSource.
  42. * While revealing the policy does not compromise the security of
  43. * the system, it does provide malicious code with additional information
  44. * which it may use to better aim an attack. It is wise
  45. * not to divulge more information than necessary.</td>
  46. * </tr>
  47. *
  48. * <tr>
  49. * <td>setPolicy</td>
  50. * <td>Setting of the system-wide security policy (specifically,
  51. * the Policy object)</td>
  52. * <td>Granting this permission is extremely dangerous, as malicious
  53. * code may grant itself all the necessary permissions it needs
  54. * to successfully mount an attack on the system.</td>
  55. * </tr>
  56. *
  57. * <tr>
  58. * <td>getProperty.{key}</td>
  59. * <td>Retrieval of the security property with the specified key</td>
  60. * <td>Depending on the particular key for which access has
  61. * been granted, the code may have access to the list of security
  62. * providers, as well as the location of the system-wide and user
  63. * security policies. while revealing this information does not
  64. * compromise the security of the system, it does provide malicious
  65. * code with additional information which it may use to better aim
  66. * an attack.
  67. </td>
  68. * </tr>
  69. *
  70. * <tr>
  71. * <td>setProperty.{key}</td>
  72. * <td>Setting of the security property with the specified key</td>
  73. * <td>This could include setting a security provider or defining
  74. * the location of the the system-wide security policy. Malicious
  75. * code that has permission to set a new security provider may
  76. * set a rogue provider that steals confidential information such
  77. * as cryptographic private keys. In addition, malicious code with
  78. * permission to set the location of the system-wide security policy
  79. * may point it to a security policy that grants the attacker
  80. * all the necessary permissions it requires to successfully mount
  81. * an attack on the system.
  82. </td>
  83. * </tr>
  84. *
  85. * <tr>
  86. * <td>insertProvider.{provider name}</td>
  87. * <td>Addition of a new provider, with the specified name</td>
  88. * <td>This would allow somebody to introduce a possibly
  89. * malicious provider (e.g., one that discloses the private keys passed
  90. * to it) as the highest-priority provider. This would be possible
  91. * because the Security object (which manages the installed providers)
  92. * currently does not check the integrity or authenticity of a provider
  93. * before attaching it.</td>
  94. * </tr>
  95. *
  96. * <tr>
  97. * <td>removeProvider.{provider name}</td>
  98. * <td>Removal of the specified provider</td>
  99. * <td>This may change the behavior or disable execution of other
  100. * parts of the program. If a provider subsequently requested by the
  101. * program has been removed, execution may fail. Also, if the removed
  102. * provider is not explicitly requested by the rest of the program, but
  103. * it would normally be the provider chosen when a cryptography service
  104. * is requested (due to its previous order in the list of providers),
  105. * a different provider will be chosen instead, or no suitable provider
  106. * will be found, thereby resulting in program failure.</td>
  107. * </tr>
  108. *
  109. * <tr>
  110. * <td>setSystemScope</td>
  111. * <td>Setting of the system identity scope</td>
  112. * <td>This would allow an attacker to configure the system identity scope with
  113. * certificates that should not be trusted, thereby granting applet or
  114. * application code signed with those certificates privileges that
  115. * would have been denied by the system's original identity scope</td>
  116. * </tr>
  117. *
  118. * <tr>
  119. * <td>setIdentityPublicKey</td>
  120. * <td>Setting of the public key for an Identity</td>
  121. * <td>If the identity is marked as "trusted", this allows an attacker to
  122. * introduce a different public key (e.g., its own) that is not trusted
  123. * by the system's identity scope, thereby granting applet or
  124. * application code signed with that public key privileges that
  125. * would have been denied otherwise.</td>
  126. * </tr>
  127. *
  128. * <tr>
  129. * <td>setIdentityInfo</td>
  130. * <td>Setting of a general information string for an Identity</td>
  131. * <td>This allows attackers to set the general description for
  132. * an identity. This may trick applications into using a different
  133. * identity than intended or may prevent applications from finding a
  134. * particular identity.</td>
  135. * </tr>
  136. *
  137. * <tr>
  138. * <td>addIdentityCertificate</td>
  139. * <td>Addition of a certificate for an Identity</td>
  140. * <td>This allows attackers to set a certificate for
  141. * an identity's public key. This is dangerous because it affects
  142. * the trust relationship across the system. This public key suddenly
  143. * becomes trusted to a wider audience than it otherwise would be.</td>
  144. * </tr>
  145. *
  146. * <tr>
  147. * <td>removeIdentityCertificate</td>
  148. * <td>Removal of a certificate for an Identity</td>
  149. * <td>This allows attackers to remove a certificate for
  150. * an identity's public key. This is dangerous because it affects
  151. * the trust relationship across the system. This public key suddenly
  152. * becomes considered less trustworthy than it otherwise would be.</td>
  153. * </tr>
  154. *
  155. * <tr>
  156. * <td>printIdentity</td>
  157. * <td>Viewing the name of a principal
  158. * and optionally the scope in which it is used, and whether
  159. * or not it is considered "trusted" in that scope</td>
  160. * <td>The scope that is printed out may be a filename, in which case
  161. * it may convey local system information. For example, here's a sample
  162. * printout of an identity named "carol", who is
  163. * marked not trusted in the user's identity database:<br>
  164. * carol[/home/luehe/identitydb.obj][not trusted]</td>
  165. *</tr>
  166. *
  167. * <tr>
  168. * <td>clearProviderProperties.{provider name}</td>
  169. * <td>"Clearing" of a Provider so that it no longer contains the properties
  170. * used to look up services implemented by the provider</td>
  171. * <td>This disables the lookup of services implemented by the provider.
  172. * This may thus change the behavior or disable execution of other
  173. * parts of the program that would normally utilize the Provider, as
  174. * described under the "removeProvider.{provider name}" permission.</td>
  175. * </tr>
  176. *
  177. * <tr>
  178. * <td>putProviderProperty.{provider name}</td>
  179. * <td>Setting of properties for the specified Provider</td>
  180. * <td>The provider properties each specify the name and location
  181. * of a particular service implemented by the provider. By granting
  182. * this permission, you let code replace the service specification
  183. * with another one, thereby specifying a different implementation.</td>
  184. * </tr>
  185. *
  186. * <tr>
  187. * <td>removeProviderProperty.{provider name}</td>
  188. * <td>Removal of properties from the specified Provider</td>
  189. * <td>This disables the lookup of services implemented by the
  190. * provider. They are no longer accessible due to removal of the properties
  191. * specifying their names and locations. This
  192. * may change the behavior or disable execution of other
  193. * parts of the program that would normally utilize the Provider, as
  194. * described under the "removeProvider.{provider name}" permission.</td>
  195. * </tr>
  196. *
  197. * <tr>
  198. * <td>getSignerPrivateKey</td>
  199. * <td>Retrieval of a Signer's private key</td>
  200. * <td>It is very dangerous to allow access to a private key; private
  201. * keys are supposed to be kept secret. Otherwise, code can use the
  202. * private key to sign various files and claim the signature came from
  203. * the Signer.</td>
  204. * </tr>
  205. *
  206. * <tr>
  207. * <td>setSignerKeyPair</td>
  208. * <td>Setting of the key pair (public key and private key) for a Signer</td>
  209. * <td>This would allow an attacker to replace somebody else's (the "target's")
  210. * keypair with a possibly weaker keypair (e.g., a keypair of a smaller
  211. * keysize). This also would allow the attacker to listen in on encrypted
  212. * communication between the target and its peers. The target's peers
  213. * might wrap an encryption session key under the target's "new" public
  214. * key, which would allow the attacker (who possesses the corresponding
  215. * private key) to unwrap the session key and decipher the communication
  216. * data encrypted under that session key.</td>
  217. * </tr>
  218. *
  219. * </table>
  220. *
  221. * @see java.security.BasicPermission
  222. * @see java.security.Permission
  223. * @see java.security.Permissions
  224. * @see java.security.PermissionCollection
  225. * @see java.lang.SecurityManager
  226. *
  227. * @version 1.19 01/11/29
  228. *
  229. * @author Marianne Mueller
  230. * @author Roland Schemers
  231. */
  232. public final class SecurityPermission extends BasicPermission {
  233. /**
  234. * Creates a new SecurityPermission with the specified name.
  235. * The name is the symbolic name of the SecurityPermission. An asterisk
  236. * may appear at the end of the name, following a ".", or by itself, to
  237. * signify a wildcard match.
  238. *
  239. * @param name the name of the SecurityPermission
  240. */
  241. public SecurityPermission(String name)
  242. {
  243. super(name);
  244. }
  245. /**
  246. * Creates a new SecurityPermission object with the specified name.
  247. * The name is the symbolic name of the SecurityPermission, and the
  248. * actions String is currently unused and should be null. This
  249. * constructor exists for use by the <code>Policy</code> object
  250. * to instantiate new Permission objects.
  251. *
  252. * @param name the name of the SecurityPermission
  253. * @param actions should be null.
  254. */
  255. public SecurityPermission(String name, String actions)
  256. {
  257. super(name, actions);
  258. }
  259. }