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