# HG changeset patch # User mullan # Date 1408365908 14400 # Node ID 6a57ce3f21f143cd7b776e4ca1d0916e6268a576 # Parent 76e62811f63b50fef6b7719178a316fccddb49ee 7026255: Methods of Subject that throw SecurityException do not specify what permissions are required Reviewed-by: xuelei diff -r 76e62811f63b -r 6a57ce3f21f1 jdk/src/share/classes/javax/security/auth/Subject.java --- a/jdk/src/share/classes/javax/security/auth/Subject.java Fri Aug 15 12:28:58 2014 +0200 +++ b/jdk/src/share/classes/javax/security/auth/Subject.java Mon Aug 18 08:45:08 2014 -0400 @@ -182,21 +182,20 @@ * {@code AuthPermission("modifyPublicCredentials")}. * To modify the private credential Set, the caller must have * {@code AuthPermission("modifyPrivateCredentials")}. - *
* * @param readOnly true if the {@code Subject} is to be read-only, - * and false otherwise.
+ * and false otherwise. * * @param principals the {@code Set} of Principals - * to be associated with this {@code Subject}.
+ * to be associated with this {@code Subject}. * * @param pubCredentials the {@code Set} of public credentials - * to be associated with this {@code Subject}.
+ * to be associated with this {@code Subject}. * * @param privCredentials the {@code Set} of private credentials * to be associated with this {@code Subject}. * - * @exception NullPointerException if the specified + * @throws NullPointerException if the specified * {@code principals}, {@code pubCredentials}, * or {@code privCredentials} are {@code null}, * or a null value exists within any of these three @@ -233,10 +232,11 @@ * Also, once a {@code Subject} is read-only, * it can not be reset to being writable again. * - *
- * - * @exception SecurityException if the caller does not have permission - * to set this {@code Subject} to be read-only. + * @throws SecurityException if a security manager is installed and the + * caller does not have an + * {@link AuthPermission#AuthPermission(String) + * AuthPermission("setReadOnly")} permission to set this + * {@code Subject} to be read-only. */ public void setReadOnly() { java.lang.SecurityManager sm = System.getSecurityManager(); @@ -250,8 +250,6 @@ /** * Query whether this {@code Subject} is read-only. * - *
- * * @return true if this {@code Subject} is read-only, false otherwise. */ public boolean isReadOnly() { @@ -267,8 +265,6 @@ * In this situation, the most recent {@code Subject} associated * with the {@code AccessControlContext} is returned. * - *
- * * @param acc the {@code AccessControlContext} from which to retrieve * the {@code Subject}. * @@ -277,10 +273,13 @@ * if no {@code Subject} is associated * with the provided {@code AccessControlContext}. * - * @exception SecurityException if the caller does not have permission - * to get the {@code Subject}.
+ * @throws SecurityException if a security manager is installed and the + * caller does not have an + * {@link AuthPermission#AuthPermission(String) + * AuthPermission("getSubject")} permission to get the + * {@code Subject}. * - * @exception NullPointerException if the provided + * @throws NullPointerException if the provided * {@code AccessControlContext} is {@code null}. */ public static Subject getSubject(final AccessControlContext acc) { @@ -321,26 +320,27 @@ * passing it the provided {@code PrivilegedAction}, * as well as the newly constructed {@code AccessControlContext}. * - *
- * * @param subject the {@code Subject} that the specified * {@code action} will run as. This parameter - * may be {@code null}.
+ * may be {@code null}.
*
* @param
+ * {@code Subject}.
*
* @return the value returned by the PrivilegedAction's
* {@code run} method.
*
- * @exception NullPointerException if the {@code PrivilegedAction}
- * is {@code null}.
+ * @throws NullPointerException if the {@code PrivilegedAction}
+ * is {@code null}.
*
- * @exception SecurityException if the caller does not have permission
- * to invoke this method.
+ * @throws SecurityException if a security manager is installed and the
+ * caller does not have an
+ * {@link AuthPermission#AuthPermission(String)
+ * AuthPermission("doAs")} permission to invoke this
+ * method.
*/
public static
- *
* @param subject the {@code Subject} that the specified
* {@code action} will run as. This parameter
- * may be {@code null}.
+ * may be {@code null}.
*
* @param
+ * {@code Subject}.
*
* @return the value returned by the
* PrivilegedExceptionAction's {@code run} method.
*
- * @exception PrivilegedActionException if the
+ * @throws PrivilegedActionException if the
* {@code PrivilegedExceptionAction.run}
- * method throws a checked exception.
+ * method throws a checked exception.
*
- * @exception NullPointerException if the specified
+ * @throws NullPointerException if the specified
* {@code PrivilegedExceptionAction} is
- * {@code null}.
+ * {@code null}.
*
- * @exception SecurityException if the caller does not have permission
- * to invoke this method.
+ * @throws SecurityException if a security manager is installed and the
+ * caller does not have an
+ * {@link AuthPermission#AuthPermission(String)
+ * AuthPermission("doAs")} permission to invoke this
+ * method.
*/
public static
- *
* @param subject the {@code Subject} that the specified
* {@code action} will run as. This parameter
- * may be {@code null}.
+ * may be {@code null}.
*
* @param
+ * {@code Subject}.
*
* @param acc the {@code AccessControlContext} to be tied to the
- * specified subject and action.
+ * specified subject and action.
*
* @return the value returned by the PrivilegedAction's
* {@code run} method.
*
- * @exception NullPointerException if the {@code PrivilegedAction}
- * is {@code null}.
+ * @throws NullPointerException if the {@code PrivilegedAction}
+ * is {@code null}.
*
- * @exception SecurityException if the caller does not have permission
- * to invoke this method.
+ * @throws SecurityException if a security manager is installed and the
+ * caller does not have a
+ * {@link AuthPermission#AuthPermission(String)
+ * AuthPermission("doAsPrivileged")} permission to invoke
+ * this method.
*/
public static
- *
* @param subject the {@code Subject} that the specified
* {@code action} will run as. This parameter
- * may be {@code null}.
+ * may be {@code null}.
*
* @param
+ * {@code Subject}.
*
* @param acc the {@code AccessControlContext} to be tied to the
- * specified subject and action.
+ * specified subject and action.
*
* @return the value returned by the
* PrivilegedExceptionAction's {@code run} method.
*
- * @exception PrivilegedActionException if the
+ * @throws PrivilegedActionException if the
* {@code PrivilegedExceptionAction.run}
- * method throws a checked exception.
+ * method throws a checked exception.
*
- * @exception NullPointerException if the specified
+ * @throws NullPointerException if the specified
* {@code PrivilegedExceptionAction} is
- * {@code null}.
+ * {@code null}.
*
- * @exception SecurityException if the caller does not have permission
- * to invoke this method.
+ * @throws SecurityException if a security manager is installed and the
+ * caller does not have a
+ * {@link AuthPermission#AuthPermission(String)
+ * AuthPermission("doAsPrivileged")} permission to invoke
+ * this method.
*/
public static
+ * If a security manager is installed, the caller must have a
+ * {@link AuthPermission#AuthPermission(String)
+ * AuthPermission("modifyPrincipals")} permission to modify
+ * the returned set, or a {@code SecurityException} will be thrown.
*
- * @return The {@code Set} of Principals associated with this
+ * @return the {@code Set} of Principals associated with this
* {@code Subject}.
*/
public Set
- *
* @param
+ * If a security manager is installed, the caller must have a
+ * {@link AuthPermission#AuthPermission(String)
+ * AuthPermission("modifyPublicCredentials")} permission to modify
+ * the returned set, or a {@code SecurityException} will be thrown.
*
- * @return A {@code Set} of public credentials held by this
+ * @return a {@code Set} of public credentials held by this
* {@code Subject}.
*/
public Set