author | mullan |
Mon, 18 Aug 2014 08:45:08 -0400 | |
changeset 25989 | 6a57ce3f21f1 |
parent 25188 | e680ab7f208e |
permissions | -rw-r--r-- |
2 | 1 |
/* |
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
2 |
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package javax.security.auth; |
|
27 |
||
28 |
import java.util.*; |
|
29 |
import java.io.*; |
|
30 |
import java.lang.reflect.*; |
|
31 |
import java.text.MessageFormat; |
|
32 |
import java.security.AccessController; |
|
33 |
import java.security.AccessControlContext; |
|
34 |
import java.security.DomainCombiner; |
|
35 |
import java.security.Permission; |
|
36 |
import java.security.PermissionCollection; |
|
37 |
import java.security.Principal; |
|
38 |
import java.security.PrivilegedAction; |
|
39 |
import java.security.PrivilegedExceptionAction; |
|
40 |
import java.security.PrivilegedActionException; |
|
41 |
import java.security.ProtectionDomain; |
|
42 |
import sun.security.util.ResourcesMgr; |
|
43 |
||
44 |
/** |
|
18830 | 45 |
* <p> A {@code Subject} represents a grouping of related information |
2 | 46 |
* for a single entity, such as a person. |
47 |
* Such information includes the Subject's identities as well as |
|
48 |
* its security-related attributes |
|
49 |
* (passwords and cryptographic keys, for example). |
|
50 |
* |
|
51 |
* <p> Subjects may potentially have multiple identities. |
|
18830 | 52 |
* Each identity is represented as a {@code Principal} |
53 |
* within the {@code Subject}. Principals simply bind names to a |
|
54 |
* {@code Subject}. For example, a {@code Subject} that happens |
|
2 | 55 |
* to be a person, Alice, might have two Principals: |
56 |
* one which binds "Alice Bar", the name on her driver license, |
|
18830 | 57 |
* to the {@code Subject}, and another which binds, |
2 | 58 |
* "999-99-9999", the number on her student identification card, |
18830 | 59 |
* to the {@code Subject}. Both Principals refer to the same |
60 |
* {@code Subject} even though each has a different name. |
|
2 | 61 |
* |
18830 | 62 |
* <p> A {@code Subject} may also own security-related attributes, |
2 | 63 |
* which are referred to as credentials. |
64 |
* Sensitive credentials that require special protection, such as |
|
65 |
* private cryptographic keys, are stored within a private credential |
|
18830 | 66 |
* {@code Set}. Credentials intended to be shared, such as |
2 | 67 |
* public key certificates or Kerberos server tickets are stored |
18830 | 68 |
* within a public credential {@code Set}. Different permissions |
2 | 69 |
* are required to access and modify the different credential Sets. |
70 |
* |
|
18830 | 71 |
* <p> To retrieve all the Principals associated with a {@code Subject}, |
72 |
* invoke the {@code getPrincipals} method. To retrieve |
|
73 |
* all the public or private credentials belonging to a {@code Subject}, |
|
74 |
* invoke the {@code getPublicCredentials} method or |
|
75 |
* {@code getPrivateCredentials} method, respectively. |
|
76 |
* To modify the returned {@code Set} of Principals and credentials, |
|
77 |
* use the methods defined in the {@code Set} class. |
|
2 | 78 |
* For example: |
79 |
* <pre> |
|
80 |
* Subject subject; |
|
81 |
* Principal principal; |
|
82 |
* Object credential; |
|
83 |
* |
|
84 |
* // add a Principal and credential to the Subject |
|
85 |
* subject.getPrincipals().add(principal); |
|
86 |
* subject.getPublicCredentials().add(credential); |
|
87 |
* </pre> |
|
88 |
* |
|
18830 | 89 |
* <p> This {@code Subject} class implements {@code Serializable}. |
90 |
* While the Principals associated with the {@code Subject} are serialized, |
|
91 |
* the credentials associated with the {@code Subject} are not. |
|
92 |
* Note that the {@code java.security.Principal} class |
|
93 |
* does not implement {@code Serializable}. Therefore all concrete |
|
94 |
* {@code Principal} implementations associated with Subjects |
|
95 |
* must implement {@code Serializable}. |
|
2 | 96 |
* |
97 |
* @see java.security.Principal |
|
98 |
* @see java.security.DomainCombiner |
|
99 |
*/ |
|
100 |
public final class Subject implements java.io.Serializable { |
|
101 |
||
102 |
private static final long serialVersionUID = -8308522755600156056L; |
|
103 |
||
104 |
/** |
|
18830 | 105 |
* A {@code Set} that provides a view of all of this |
2 | 106 |
* Subject's Principals |
107 |
* |
|
108 |
* <p> |
|
109 |
* |
|
110 |
* @serial Each element in this set is a |
|
18830 | 111 |
* {@code java.security.Principal}. |
112 |
* The set is a {@code Subject.SecureSet}. |
|
2 | 113 |
*/ |
114 |
Set<Principal> principals; |
|
115 |
||
116 |
/** |
|
117 |
* Sets that provide a view of all of this |
|
118 |
* Subject's Credentials |
|
119 |
*/ |
|
120 |
transient Set<Object> pubCredentials; |
|
121 |
transient Set<Object> privCredentials; |
|
122 |
||
123 |
/** |
|
124 |
* Whether this Subject is read-only |
|
125 |
* |
|
126 |
* @serial |
|
127 |
*/ |
|
128 |
private volatile boolean readOnly = false; |
|
129 |
||
130 |
private static final int PRINCIPAL_SET = 1; |
|
131 |
private static final int PUB_CREDENTIAL_SET = 2; |
|
132 |
private static final int PRIV_CREDENTIAL_SET = 3; |
|
133 |
||
134 |
private static final ProtectionDomain[] NULL_PD_ARRAY |
|
135 |
= new ProtectionDomain[0]; |
|
136 |
||
137 |
/** |
|
18830 | 138 |
* Create an instance of a {@code Subject} |
139 |
* with an empty {@code Set} of Principals and empty |
|
2 | 140 |
* Sets of public and private credentials. |
141 |
* |
|
18830 | 142 |
* <p> The newly constructed Sets check whether this {@code Subject} |
2 | 143 |
* has been set read-only before permitting subsequent modifications. |
144 |
* The newly created Sets also prevent illegal modifications |
|
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
145 |
* by ensuring that callers have sufficient permissions. These Sets |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
146 |
* also prohibit null elements, and attempts to add or query a null |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
147 |
* element will result in a {@code NullPointerException}. |
2 | 148 |
* |
149 |
* <p> To modify the Principals Set, the caller must have |
|
18830 | 150 |
* {@code AuthPermission("modifyPrincipals")}. |
2 | 151 |
* To modify the public credential Set, the caller must have |
18830 | 152 |
* {@code AuthPermission("modifyPublicCredentials")}. |
2 | 153 |
* To modify the private credential Set, the caller must have |
18830 | 154 |
* {@code AuthPermission("modifyPrivateCredentials")}. |
2 | 155 |
*/ |
156 |
public Subject() { |
|
157 |
||
158 |
this.principals = Collections.synchronizedSet |
|
159 |
(new SecureSet<Principal>(this, PRINCIPAL_SET)); |
|
160 |
this.pubCredentials = Collections.synchronizedSet |
|
161 |
(new SecureSet<Object>(this, PUB_CREDENTIAL_SET)); |
|
162 |
this.privCredentials = Collections.synchronizedSet |
|
163 |
(new SecureSet<Object>(this, PRIV_CREDENTIAL_SET)); |
|
164 |
} |
|
165 |
||
166 |
/** |
|
18830 | 167 |
* Create an instance of a {@code Subject} with |
2 | 168 |
* Principals and credentials. |
169 |
* |
|
170 |
* <p> The Principals and credentials from the specified Sets |
|
171 |
* are copied into newly constructed Sets. |
|
18830 | 172 |
* These newly created Sets check whether this {@code Subject} |
2 | 173 |
* has been set read-only before permitting subsequent modifications. |
174 |
* The newly created Sets also prevent illegal modifications |
|
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
175 |
* by ensuring that callers have sufficient permissions. These Sets |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
176 |
* also prohibit null elements, and attempts to add or query a null |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
177 |
* element will result in a {@code NullPointerException}. |
2 | 178 |
* |
179 |
* <p> To modify the Principals Set, the caller must have |
|
18830 | 180 |
* {@code AuthPermission("modifyPrincipals")}. |
2 | 181 |
* To modify the public credential Set, the caller must have |
18830 | 182 |
* {@code AuthPermission("modifyPublicCredentials")}. |
2 | 183 |
* To modify the private credential Set, the caller must have |
18830 | 184 |
* {@code AuthPermission("modifyPrivateCredentials")}. |
2 | 185 |
* |
18830 | 186 |
* @param readOnly true if the {@code Subject} is to be read-only, |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
187 |
* and false otherwise. |
2 | 188 |
* |
18830 | 189 |
* @param principals the {@code Set} of Principals |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
190 |
* to be associated with this {@code Subject}. |
2 | 191 |
* |
18830 | 192 |
* @param pubCredentials the {@code Set} of public credentials |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
193 |
* to be associated with this {@code Subject}. |
2 | 194 |
* |
18830 | 195 |
* @param privCredentials the {@code Set} of private credentials |
196 |
* to be associated with this {@code Subject}. |
|
2 | 197 |
* |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
198 |
* @throws NullPointerException if the specified |
18830 | 199 |
* {@code principals}, {@code pubCredentials}, |
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
200 |
* or {@code privCredentials} are {@code null}, |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
201 |
* or a null value exists within any of these three |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
202 |
* Sets. |
2 | 203 |
*/ |
204 |
public Subject(boolean readOnly, Set<? extends Principal> principals, |
|
205 |
Set<?> pubCredentials, Set<?> privCredentials) |
|
206 |
{ |
|
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
207 |
collectionNullClean(principals); |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
208 |
collectionNullClean(pubCredentials); |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
209 |
collectionNullClean(privCredentials); |
2 | 210 |
|
211 |
this.principals = Collections.synchronizedSet(new SecureSet<Principal> |
|
212 |
(this, PRINCIPAL_SET, principals)); |
|
213 |
this.pubCredentials = Collections.synchronizedSet(new SecureSet<Object> |
|
214 |
(this, PUB_CREDENTIAL_SET, pubCredentials)); |
|
215 |
this.privCredentials = Collections.synchronizedSet(new SecureSet<Object> |
|
216 |
(this, PRIV_CREDENTIAL_SET, privCredentials)); |
|
217 |
this.readOnly = readOnly; |
|
218 |
} |
|
219 |
||
220 |
/** |
|
18830 | 221 |
* Set this {@code Subject} to be read-only. |
2 | 222 |
* |
223 |
* <p> Modifications (additions and removals) to this Subject's |
|
18830 | 224 |
* {@code Principal} {@code Set} and |
2 | 225 |
* credential Sets will be disallowed. |
18830 | 226 |
* The {@code destroy} operation on this Subject's credentials will |
2 | 227 |
* still be permitted. |
228 |
* |
|
18830 | 229 |
* <p> Subsequent attempts to modify the Subject's {@code Principal} |
2 | 230 |
* and credential Sets will result in an |
18830 | 231 |
* {@code IllegalStateException} being thrown. |
232 |
* Also, once a {@code Subject} is read-only, |
|
2 | 233 |
* it can not be reset to being writable again. |
234 |
* |
|
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
235 |
* @throws SecurityException if a security manager is installed and the |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
236 |
* caller does not have an |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
237 |
* {@link AuthPermission#AuthPermission(String) |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
238 |
* AuthPermission("setReadOnly")} permission to set this |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
239 |
* {@code Subject} to be read-only. |
2 | 240 |
*/ |
241 |
public void setReadOnly() { |
|
242 |
java.lang.SecurityManager sm = System.getSecurityManager(); |
|
243 |
if (sm != null) { |
|
4331
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
244 |
sm.checkPermission(AuthPermissionHolder.SET_READ_ONLY_PERMISSION); |
2 | 245 |
} |
246 |
||
247 |
this.readOnly = true; |
|
248 |
} |
|
249 |
||
250 |
/** |
|
18830 | 251 |
* Query whether this {@code Subject} is read-only. |
2 | 252 |
* |
18830 | 253 |
* @return true if this {@code Subject} is read-only, false otherwise. |
2 | 254 |
*/ |
255 |
public boolean isReadOnly() { |
|
256 |
return this.readOnly; |
|
257 |
} |
|
258 |
||
259 |
/** |
|
18830 | 260 |
* Get the {@code Subject} associated with the provided |
261 |
* {@code AccessControlContext}. |
|
2 | 262 |
* |
18830 | 263 |
* <p> The {@code AccessControlContext} may contain many |
264 |
* Subjects (from nested {@code doAs} calls). |
|
265 |
* In this situation, the most recent {@code Subject} associated |
|
266 |
* with the {@code AccessControlContext} is returned. |
|
2 | 267 |
* |
18830 | 268 |
* @param acc the {@code AccessControlContext} from which to retrieve |
269 |
* the {@code Subject}. |
|
2 | 270 |
* |
18830 | 271 |
* @return the {@code Subject} associated with the provided |
272 |
* {@code AccessControlContext}, or {@code null} |
|
273 |
* if no {@code Subject} is associated |
|
274 |
* with the provided {@code AccessControlContext}. |
|
2 | 275 |
* |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
276 |
* @throws SecurityException if a security manager is installed and the |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
277 |
* caller does not have an |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
278 |
* {@link AuthPermission#AuthPermission(String) |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
279 |
* AuthPermission("getSubject")} permission to get the |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
280 |
* {@code Subject}. |
2 | 281 |
* |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
282 |
* @throws NullPointerException if the provided |
18830 | 283 |
* {@code AccessControlContext} is {@code null}. |
2 | 284 |
*/ |
285 |
public static Subject getSubject(final AccessControlContext acc) { |
|
286 |
||
287 |
java.lang.SecurityManager sm = System.getSecurityManager(); |
|
288 |
if (sm != null) { |
|
4331
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
289 |
sm.checkPermission(AuthPermissionHolder.GET_SUBJECT_PERMISSION); |
2 | 290 |
} |
291 |
||
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
292 |
Objects.requireNonNull(acc, ResourcesMgr.getString |
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
5506
diff
changeset
|
293 |
("invalid.null.AccessControlContext.provided")); |
2 | 294 |
|
295 |
// return the Subject from the DomainCombiner of the provided context |
|
296 |
return AccessController.doPrivileged |
|
297 |
(new java.security.PrivilegedAction<Subject>() { |
|
298 |
public Subject run() { |
|
299 |
DomainCombiner dc = acc.getDomainCombiner(); |
|
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
300 |
if (!(dc instanceof SubjectDomainCombiner)) { |
2 | 301 |
return null; |
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
302 |
} |
2 | 303 |
SubjectDomainCombiner sdc = (SubjectDomainCombiner)dc; |
304 |
return sdc.getSubject(); |
|
305 |
} |
|
306 |
}); |
|
307 |
} |
|
308 |
||
309 |
/** |
|
18830 | 310 |
* Perform work as a particular {@code Subject}. |
2 | 311 |
* |
312 |
* <p> This method first retrieves the current Thread's |
|
18830 | 313 |
* {@code AccessControlContext} via |
314 |
* {@code AccessController.getContext}, |
|
315 |
* and then instantiates a new {@code AccessControlContext} |
|
2 | 316 |
* using the retrieved context along with a new |
18830 | 317 |
* {@code SubjectDomainCombiner} (constructed using |
318 |
* the provided {@code Subject}). |
|
319 |
* Finally, this method invokes {@code AccessController.doPrivileged}, |
|
320 |
* passing it the provided {@code PrivilegedAction}, |
|
321 |
* as well as the newly constructed {@code AccessControlContext}. |
|
2 | 322 |
* |
18830 | 323 |
* @param subject the {@code Subject} that the specified |
324 |
* {@code action} will run as. This parameter |
|
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
325 |
* may be {@code null}. |
2 | 326 |
* |
18771
9dadb0719cea
8019772: Fix doclint issues in javax.crypto and javax.security subpackages
juh
parents:
14342
diff
changeset
|
327 |
* @param <T> the type of the value returned by the PrivilegedAction's |
9dadb0719cea
8019772: Fix doclint issues in javax.crypto and javax.security subpackages
juh
parents:
14342
diff
changeset
|
328 |
* {@code run} method. |
9dadb0719cea
8019772: Fix doclint issues in javax.crypto and javax.security subpackages
juh
parents:
14342
diff
changeset
|
329 |
* |
2 | 330 |
* @param action the code to be run as the specified |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
331 |
* {@code Subject}. |
2 | 332 |
* |
333 |
* @return the value returned by the PrivilegedAction's |
|
18830 | 334 |
* {@code run} method. |
2 | 335 |
* |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
336 |
* @throws NullPointerException if the {@code PrivilegedAction} |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
337 |
* is {@code null}. |
2 | 338 |
* |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
339 |
* @throws SecurityException if a security manager is installed and the |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
340 |
* caller does not have an |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
341 |
* {@link AuthPermission#AuthPermission(String) |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
342 |
* AuthPermission("doAs")} permission to invoke this |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
343 |
* method. |
2 | 344 |
*/ |
345 |
public static <T> T doAs(final Subject subject, |
|
346 |
final java.security.PrivilegedAction<T> action) { |
|
347 |
||
348 |
java.lang.SecurityManager sm = System.getSecurityManager(); |
|
349 |
if (sm != null) { |
|
4331
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
350 |
sm.checkPermission(AuthPermissionHolder.DO_AS_PERMISSION); |
2 | 351 |
} |
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
352 |
|
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
353 |
Objects.requireNonNull(action, |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
354 |
ResourcesMgr.getString("invalid.null.action.provided")); |
2 | 355 |
|
356 |
// set up the new Subject-based AccessControlContext |
|
357 |
// for doPrivileged |
|
358 |
final AccessControlContext currentAcc = AccessController.getContext(); |
|
359 |
||
360 |
// call doPrivileged and push this new context on the stack |
|
361 |
return java.security.AccessController.doPrivileged |
|
362 |
(action, |
|
363 |
createContext(subject, currentAcc)); |
|
364 |
} |
|
365 |
||
366 |
/** |
|
18830 | 367 |
* Perform work as a particular {@code Subject}. |
2 | 368 |
* |
369 |
* <p> This method first retrieves the current Thread's |
|
18830 | 370 |
* {@code AccessControlContext} via |
371 |
* {@code AccessController.getContext}, |
|
372 |
* and then instantiates a new {@code AccessControlContext} |
|
2 | 373 |
* using the retrieved context along with a new |
18830 | 374 |
* {@code SubjectDomainCombiner} (constructed using |
375 |
* the provided {@code Subject}). |
|
376 |
* Finally, this method invokes {@code AccessController.doPrivileged}, |
|
377 |
* passing it the provided {@code PrivilegedExceptionAction}, |
|
378 |
* as well as the newly constructed {@code AccessControlContext}. |
|
2 | 379 |
* |
18830 | 380 |
* @param subject the {@code Subject} that the specified |
381 |
* {@code action} will run as. This parameter |
|
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
382 |
* may be {@code null}. |
2 | 383 |
* |
18771
9dadb0719cea
8019772: Fix doclint issues in javax.crypto and javax.security subpackages
juh
parents:
14342
diff
changeset
|
384 |
* @param <T> the type of the value returned by the |
9dadb0719cea
8019772: Fix doclint issues in javax.crypto and javax.security subpackages
juh
parents:
14342
diff
changeset
|
385 |
* PrivilegedExceptionAction's {@code run} method. |
9dadb0719cea
8019772: Fix doclint issues in javax.crypto and javax.security subpackages
juh
parents:
14342
diff
changeset
|
386 |
* |
2 | 387 |
* @param action the code to be run as the specified |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
388 |
* {@code Subject}. |
2 | 389 |
* |
390 |
* @return the value returned by the |
|
18830 | 391 |
* PrivilegedExceptionAction's {@code run} method. |
2 | 392 |
* |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
393 |
* @throws PrivilegedActionException if the |
18830 | 394 |
* {@code PrivilegedExceptionAction.run} |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
395 |
* method throws a checked exception. |
2 | 396 |
* |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
397 |
* @throws NullPointerException if the specified |
18830 | 398 |
* {@code PrivilegedExceptionAction} is |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
399 |
* {@code null}. |
2 | 400 |
* |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
401 |
* @throws SecurityException if a security manager is installed and the |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
402 |
* caller does not have an |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
403 |
* {@link AuthPermission#AuthPermission(String) |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
404 |
* AuthPermission("doAs")} permission to invoke this |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
405 |
* method. |
2 | 406 |
*/ |
407 |
public static <T> T doAs(final Subject subject, |
|
408 |
final java.security.PrivilegedExceptionAction<T> action) |
|
409 |
throws java.security.PrivilegedActionException { |
|
410 |
||
411 |
java.lang.SecurityManager sm = System.getSecurityManager(); |
|
412 |
if (sm != null) { |
|
4331
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
413 |
sm.checkPermission(AuthPermissionHolder.DO_AS_PERMISSION); |
2 | 414 |
} |
415 |
||
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
416 |
Objects.requireNonNull(action, |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
417 |
ResourcesMgr.getString("invalid.null.action.provided")); |
2 | 418 |
|
419 |
// set up the new Subject-based AccessControlContext for doPrivileged |
|
420 |
final AccessControlContext currentAcc = AccessController.getContext(); |
|
421 |
||
422 |
// call doPrivileged and push this new context on the stack |
|
423 |
return java.security.AccessController.doPrivileged |
|
424 |
(action, |
|
425 |
createContext(subject, currentAcc)); |
|
426 |
} |
|
427 |
||
428 |
/** |
|
18830 | 429 |
* Perform privileged work as a particular {@code Subject}. |
2 | 430 |
* |
18830 | 431 |
* <p> This method behaves exactly as {@code Subject.doAs}, |
2 | 432 |
* except that instead of retrieving the current Thread's |
18830 | 433 |
* {@code AccessControlContext}, it uses the provided |
434 |
* {@code AccessControlContext}. If the provided |
|
435 |
* {@code AccessControlContext} is {@code null}, |
|
436 |
* this method instantiates a new {@code AccessControlContext} |
|
2 | 437 |
* with an empty collection of ProtectionDomains. |
438 |
* |
|
18830 | 439 |
* @param subject the {@code Subject} that the specified |
440 |
* {@code action} will run as. This parameter |
|
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
441 |
* may be {@code null}. |
2 | 442 |
* |
18771
9dadb0719cea
8019772: Fix doclint issues in javax.crypto and javax.security subpackages
juh
parents:
14342
diff
changeset
|
443 |
* @param <T> the type of the value returned by the PrivilegedAction's |
9dadb0719cea
8019772: Fix doclint issues in javax.crypto and javax.security subpackages
juh
parents:
14342
diff
changeset
|
444 |
* {@code run} method. |
9dadb0719cea
8019772: Fix doclint issues in javax.crypto and javax.security subpackages
juh
parents:
14342
diff
changeset
|
445 |
* |
2 | 446 |
* @param action the code to be run as the specified |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
447 |
* {@code Subject}. |
2 | 448 |
* |
18830 | 449 |
* @param acc the {@code AccessControlContext} to be tied to the |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
450 |
* specified <i>subject</i> and <i>action</i>. |
2 | 451 |
* |
452 |
* @return the value returned by the PrivilegedAction's |
|
18830 | 453 |
* {@code run} method. |
2 | 454 |
* |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
455 |
* @throws NullPointerException if the {@code PrivilegedAction} |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
456 |
* is {@code null}. |
2 | 457 |
* |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
458 |
* @throws SecurityException if a security manager is installed and the |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
459 |
* caller does not have a |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
460 |
* {@link AuthPermission#AuthPermission(String) |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
461 |
* AuthPermission("doAsPrivileged")} permission to invoke |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
462 |
* this method. |
2 | 463 |
*/ |
464 |
public static <T> T doAsPrivileged(final Subject subject, |
|
465 |
final java.security.PrivilegedAction<T> action, |
|
466 |
final java.security.AccessControlContext acc) { |
|
467 |
||
468 |
java.lang.SecurityManager sm = System.getSecurityManager(); |
|
469 |
if (sm != null) { |
|
4331
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
470 |
sm.checkPermission(AuthPermissionHolder.DO_AS_PRIVILEGED_PERMISSION); |
2 | 471 |
} |
472 |
||
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
473 |
Objects.requireNonNull(action, |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
474 |
ResourcesMgr.getString("invalid.null.action.provided")); |
2 | 475 |
|
476 |
// set up the new Subject-based AccessControlContext |
|
477 |
// for doPrivileged |
|
478 |
final AccessControlContext callerAcc = |
|
479 |
(acc == null ? |
|
480 |
new AccessControlContext(NULL_PD_ARRAY) : |
|
481 |
acc); |
|
482 |
||
483 |
// call doPrivileged and push this new context on the stack |
|
484 |
return java.security.AccessController.doPrivileged |
|
485 |
(action, |
|
486 |
createContext(subject, callerAcc)); |
|
487 |
} |
|
488 |
||
489 |
/** |
|
18830 | 490 |
* Perform privileged work as a particular {@code Subject}. |
2 | 491 |
* |
18830 | 492 |
* <p> This method behaves exactly as {@code Subject.doAs}, |
2 | 493 |
* except that instead of retrieving the current Thread's |
18830 | 494 |
* {@code AccessControlContext}, it uses the provided |
495 |
* {@code AccessControlContext}. If the provided |
|
496 |
* {@code AccessControlContext} is {@code null}, |
|
497 |
* this method instantiates a new {@code AccessControlContext} |
|
2 | 498 |
* with an empty collection of ProtectionDomains. |
499 |
* |
|
18830 | 500 |
* @param subject the {@code Subject} that the specified |
501 |
* {@code action} will run as. This parameter |
|
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
502 |
* may be {@code null}. |
2 | 503 |
* |
18771
9dadb0719cea
8019772: Fix doclint issues in javax.crypto and javax.security subpackages
juh
parents:
14342
diff
changeset
|
504 |
* @param <T> the type of the value returned by the |
9dadb0719cea
8019772: Fix doclint issues in javax.crypto and javax.security subpackages
juh
parents:
14342
diff
changeset
|
505 |
* PrivilegedExceptionAction's {@code run} method. |
9dadb0719cea
8019772: Fix doclint issues in javax.crypto and javax.security subpackages
juh
parents:
14342
diff
changeset
|
506 |
* |
2 | 507 |
* @param action the code to be run as the specified |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
508 |
* {@code Subject}. |
2 | 509 |
* |
18830 | 510 |
* @param acc the {@code AccessControlContext} to be tied to the |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
511 |
* specified <i>subject</i> and <i>action</i>. |
2 | 512 |
* |
513 |
* @return the value returned by the |
|
18830 | 514 |
* PrivilegedExceptionAction's {@code run} method. |
2 | 515 |
* |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
516 |
* @throws PrivilegedActionException if the |
18830 | 517 |
* {@code PrivilegedExceptionAction.run} |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
518 |
* method throws a checked exception. |
2 | 519 |
* |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
520 |
* @throws NullPointerException if the specified |
18830 | 521 |
* {@code PrivilegedExceptionAction} is |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
522 |
* {@code null}. |
2 | 523 |
* |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
524 |
* @throws SecurityException if a security manager is installed and the |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
525 |
* caller does not have a |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
526 |
* {@link AuthPermission#AuthPermission(String) |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
527 |
* AuthPermission("doAsPrivileged")} permission to invoke |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
528 |
* this method. |
2 | 529 |
*/ |
530 |
public static <T> T doAsPrivileged(final Subject subject, |
|
531 |
final java.security.PrivilegedExceptionAction<T> action, |
|
532 |
final java.security.AccessControlContext acc) |
|
533 |
throws java.security.PrivilegedActionException { |
|
534 |
||
535 |
java.lang.SecurityManager sm = System.getSecurityManager(); |
|
536 |
if (sm != null) { |
|
4331
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
537 |
sm.checkPermission(AuthPermissionHolder.DO_AS_PRIVILEGED_PERMISSION); |
2 | 538 |
} |
539 |
||
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
540 |
Objects.requireNonNull(action, |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
541 |
ResourcesMgr.getString("invalid.null.action.provided")); |
2 | 542 |
|
543 |
// set up the new Subject-based AccessControlContext for doPrivileged |
|
544 |
final AccessControlContext callerAcc = |
|
545 |
(acc == null ? |
|
546 |
new AccessControlContext(NULL_PD_ARRAY) : |
|
547 |
acc); |
|
548 |
||
549 |
// call doPrivileged and push this new context on the stack |
|
550 |
return java.security.AccessController.doPrivileged |
|
551 |
(action, |
|
552 |
createContext(subject, callerAcc)); |
|
553 |
} |
|
554 |
||
555 |
private static AccessControlContext createContext(final Subject subject, |
|
556 |
final AccessControlContext acc) { |
|
557 |
||
558 |
||
559 |
return java.security.AccessController.doPrivileged |
|
560 |
(new java.security.PrivilegedAction<AccessControlContext>() { |
|
561 |
public AccessControlContext run() { |
|
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
562 |
if (subject == null) { |
2 | 563 |
return new AccessControlContext(acc, null); |
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
564 |
} else { |
2 | 565 |
return new AccessControlContext |
566 |
(acc, |
|
567 |
new SubjectDomainCombiner(subject)); |
|
568 |
} |
|
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
569 |
} |
2 | 570 |
}); |
571 |
} |
|
572 |
||
573 |
/** |
|
18830 | 574 |
* Return the {@code Set} of Principals associated with this |
575 |
* {@code Subject}. Each {@code Principal} represents |
|
576 |
* an identity for this {@code Subject}. |
|
2 | 577 |
* |
18830 | 578 |
* <p> The returned {@code Set} is backed by this Subject's |
579 |
* internal {@code Principal} {@code Set}. Any modification |
|
580 |
* to the returned {@code Set} affects the internal |
|
581 |
* {@code Principal} {@code Set} as well. |
|
2 | 582 |
* |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
583 |
* <p> If a security manager is installed, the caller must have a |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
584 |
* {@link AuthPermission#AuthPermission(String) |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
585 |
* AuthPermission("modifyPrincipals")} permission to modify |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
586 |
* the returned set, or a {@code SecurityException} will be thrown. |
2 | 587 |
* |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
588 |
* @return the {@code Set} of Principals associated with this |
18830 | 589 |
* {@code Subject}. |
2 | 590 |
*/ |
591 |
public Set<Principal> getPrincipals() { |
|
592 |
||
593 |
// always return an empty Set instead of null |
|
594 |
// so LoginModules can add to the Set if necessary |
|
595 |
return principals; |
|
596 |
} |
|
597 |
||
598 |
/** |
|
18830 | 599 |
* Return a {@code Set} of Principals associated with this |
600 |
* {@code Subject} that are instances or subclasses of the specified |
|
601 |
* {@code Class}. |
|
2 | 602 |
* |
18830 | 603 |
* <p> The returned {@code Set} is not backed by this Subject's |
604 |
* internal {@code Principal} {@code Set}. A new |
|
605 |
* {@code Set} is created and returned for each method invocation. |
|
606 |
* Modifications to the returned {@code Set} |
|
607 |
* will not affect the internal {@code Principal} {@code Set}. |
|
2 | 608 |
* |
18771
9dadb0719cea
8019772: Fix doclint issues in javax.crypto and javax.security subpackages
juh
parents:
14342
diff
changeset
|
609 |
* @param <T> the type of the class modeled by {@code c} |
9dadb0719cea
8019772: Fix doclint issues in javax.crypto and javax.security subpackages
juh
parents:
14342
diff
changeset
|
610 |
* |
18830 | 611 |
* @param c the returned {@code Set} of Principals will all be |
2 | 612 |
* instances of this class. |
613 |
* |
|
18830 | 614 |
* @return a {@code Set} of Principals that are instances of the |
615 |
* specified {@code Class}. |
|
2 | 616 |
* |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
617 |
* @throws NullPointerException if the specified {@code Class} |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
618 |
* is {@code null}. |
2 | 619 |
*/ |
620 |
public <T extends Principal> Set<T> getPrincipals(Class<T> c) { |
|
621 |
||
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
622 |
Objects.requireNonNull(c, |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
623 |
ResourcesMgr.getString("invalid.null.Class.provided")); |
2 | 624 |
|
625 |
// always return an empty Set instead of null |
|
626 |
// so LoginModules can add to the Set if necessary |
|
627 |
return new ClassSet<T>(PRINCIPAL_SET, c); |
|
628 |
} |
|
629 |
||
630 |
/** |
|
18830 | 631 |
* Return the {@code Set} of public credentials held by this |
632 |
* {@code Subject}. |
|
2 | 633 |
* |
18830 | 634 |
* <p> The returned {@code Set} is backed by this Subject's |
635 |
* internal public Credential {@code Set}. Any modification |
|
636 |
* to the returned {@code Set} affects the internal public |
|
637 |
* Credential {@code Set} as well. |
|
2 | 638 |
* |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
639 |
* <p> If a security manager is installed, the caller must have a |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
640 |
* {@link AuthPermission#AuthPermission(String) |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
641 |
* AuthPermission("modifyPublicCredentials")} permission to modify |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
642 |
* the returned set, or a {@code SecurityException} will be thrown. |
2 | 643 |
* |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
644 |
* @return a {@code Set} of public credentials held by this |
18830 | 645 |
* {@code Subject}. |
2 | 646 |
*/ |
647 |
public Set<Object> getPublicCredentials() { |
|
648 |
||
649 |
// always return an empty Set instead of null |
|
650 |
// so LoginModules can add to the Set if necessary |
|
651 |
return pubCredentials; |
|
652 |
} |
|
653 |
||
654 |
/** |
|
18830 | 655 |
* Return the {@code Set} of private credentials held by this |
656 |
* {@code Subject}. |
|
2 | 657 |
* |
18830 | 658 |
* <p> The returned {@code Set} is backed by this Subject's |
659 |
* internal private Credential {@code Set}. Any modification |
|
660 |
* to the returned {@code Set} affects the internal private |
|
661 |
* Credential {@code Set} as well. |
|
2 | 662 |
* |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
663 |
* <p> If a security manager is installed, the caller must have a |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
664 |
* {@link AuthPermission#AuthPermission(String) |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
665 |
* AuthPermission("modifyPrivateCredentials")} permission to modify |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
666 |
* the returned set, or a {@code SecurityException} will be thrown. |
2 | 667 |
* |
18830 | 668 |
* <p> While iterating through the {@code Set}, |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
669 |
* a {@code SecurityException} is thrown if a security manager is installed |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
670 |
* and the caller does not have a {@link PrivateCredentialPermission} |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
671 |
* to access a particular Credential. The {@code Iterator} |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
672 |
* is nevertheless advanced to the next element in the {@code Set}. |
2 | 673 |
* |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
674 |
* @return a {@code Set} of private credentials held by this |
18830 | 675 |
* {@code Subject}. |
2 | 676 |
*/ |
677 |
public Set<Object> getPrivateCredentials() { |
|
678 |
||
679 |
// XXX |
|
680 |
// we do not need a security check for |
|
681 |
// AuthPermission(getPrivateCredentials) |
|
682 |
// because we already restrict access to private credentials |
|
683 |
// via the PrivateCredentialPermission. all the extra AuthPermission |
|
684 |
// would do is protect the set operations themselves |
|
685 |
// (like size()), which don't seem security-sensitive. |
|
686 |
||
687 |
// always return an empty Set instead of null |
|
688 |
// so LoginModules can add to the Set if necessary |
|
689 |
return privCredentials; |
|
690 |
} |
|
691 |
||
692 |
/** |
|
18830 | 693 |
* Return a {@code Set} of public credentials associated with this |
694 |
* {@code Subject} that are instances or subclasses of the specified |
|
695 |
* {@code Class}. |
|
2 | 696 |
* |
18830 | 697 |
* <p> The returned {@code Set} is not backed by this Subject's |
698 |
* internal public Credential {@code Set}. A new |
|
699 |
* {@code Set} is created and returned for each method invocation. |
|
700 |
* Modifications to the returned {@code Set} |
|
701 |
* will not affect the internal public Credential {@code Set}. |
|
2 | 702 |
* |
18771
9dadb0719cea
8019772: Fix doclint issues in javax.crypto and javax.security subpackages
juh
parents:
14342
diff
changeset
|
703 |
* @param <T> the type of the class modeled by {@code c} |
9dadb0719cea
8019772: Fix doclint issues in javax.crypto and javax.security subpackages
juh
parents:
14342
diff
changeset
|
704 |
* |
18830 | 705 |
* @param c the returned {@code Set} of public credentials will all be |
2 | 706 |
* instances of this class. |
707 |
* |
|
18830 | 708 |
* @return a {@code Set} of public credentials that are instances |
709 |
* of the specified {@code Class}. |
|
2 | 710 |
* |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
711 |
* @throws NullPointerException if the specified {@code Class} |
18830 | 712 |
* is {@code null}. |
2 | 713 |
*/ |
714 |
public <T> Set<T> getPublicCredentials(Class<T> c) { |
|
715 |
||
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
716 |
Objects.requireNonNull(c, |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
717 |
ResourcesMgr.getString("invalid.null.Class.provided")); |
2 | 718 |
|
719 |
// always return an empty Set instead of null |
|
720 |
// so LoginModules can add to the Set if necessary |
|
721 |
return new ClassSet<T>(PUB_CREDENTIAL_SET, c); |
|
722 |
} |
|
723 |
||
724 |
/** |
|
18830 | 725 |
* Return a {@code Set} of private credentials associated with this |
726 |
* {@code Subject} that are instances or subclasses of the specified |
|
727 |
* {@code Class}. |
|
2 | 728 |
* |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
729 |
* <p> If a security manager is installed, the caller must have a |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
730 |
* {@link PrivateCredentialPermission} to access all of the requested |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
731 |
* Credentials, or a {@code SecurityException} will be thrown. |
2 | 732 |
* |
18830 | 733 |
* <p> The returned {@code Set} is not backed by this Subject's |
734 |
* internal private Credential {@code Set}. A new |
|
735 |
* {@code Set} is created and returned for each method invocation. |
|
736 |
* Modifications to the returned {@code Set} |
|
737 |
* will not affect the internal private Credential {@code Set}. |
|
2 | 738 |
* |
18771
9dadb0719cea
8019772: Fix doclint issues in javax.crypto and javax.security subpackages
juh
parents:
14342
diff
changeset
|
739 |
* @param <T> the type of the class modeled by {@code c} |
9dadb0719cea
8019772: Fix doclint issues in javax.crypto and javax.security subpackages
juh
parents:
14342
diff
changeset
|
740 |
* |
18830 | 741 |
* @param c the returned {@code Set} of private credentials will all be |
2 | 742 |
* instances of this class. |
743 |
* |
|
18830 | 744 |
* @return a {@code Set} of private credentials that are instances |
745 |
* of the specified {@code Class}. |
|
2 | 746 |
* |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
747 |
* @throws NullPointerException if the specified {@code Class} |
18830 | 748 |
* is {@code null}. |
2 | 749 |
*/ |
750 |
public <T> Set<T> getPrivateCredentials(Class<T> c) { |
|
751 |
||
752 |
// XXX |
|
753 |
// we do not need a security check for |
|
754 |
// AuthPermission(getPrivateCredentials) |
|
755 |
// because we already restrict access to private credentials |
|
756 |
// via the PrivateCredentialPermission. all the extra AuthPermission |
|
757 |
// would do is protect the set operations themselves |
|
758 |
// (like size()), which don't seem security-sensitive. |
|
759 |
||
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
760 |
Objects.requireNonNull(c, |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
761 |
ResourcesMgr.getString("invalid.null.Class.provided")); |
2 | 762 |
|
763 |
// always return an empty Set instead of null |
|
764 |
// so LoginModules can add to the Set if necessary |
|
765 |
return new ClassSet<T>(PRIV_CREDENTIAL_SET, c); |
|
766 |
} |
|
767 |
||
768 |
/** |
|
18830 | 769 |
* Compares the specified Object with this {@code Subject} |
2 | 770 |
* for equality. Returns true if the given object is also a Subject |
18830 | 771 |
* and the two {@code Subject} instances are equivalent. |
772 |
* More formally, two {@code Subject} instances are |
|
773 |
* equal if their {@code Principal} and {@code Credential} |
|
2 | 774 |
* Sets are equal. |
775 |
* |
|
776 |
* @param o Object to be compared for equality with this |
|
18830 | 777 |
* {@code Subject}. |
2 | 778 |
* |
779 |
* @return true if the specified Object is equal to this |
|
18830 | 780 |
* {@code Subject}. |
2 | 781 |
* |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
782 |
* @throws SecurityException if a security manager is installed and the |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
783 |
* caller does not have a {@link PrivateCredentialPermission} |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
784 |
* permission to access the private credentials for this |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
785 |
* {@code Subject} or the provided {@code Subject}. |
2 | 786 |
*/ |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
787 |
@Override |
2 | 788 |
public boolean equals(Object o) { |
789 |
||
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
790 |
if (o == null) { |
2 | 791 |
return false; |
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
792 |
} |
2 | 793 |
|
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
794 |
if (this == o) { |
2 | 795 |
return true; |
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
796 |
} |
2 | 797 |
|
798 |
if (o instanceof Subject) { |
|
799 |
||
800 |
final Subject that = (Subject)o; |
|
801 |
||
802 |
// check the principal and credential sets |
|
803 |
Set<Principal> thatPrincipals; |
|
804 |
synchronized(that.principals) { |
|
805 |
// avoid deadlock from dual locks |
|
806 |
thatPrincipals = new HashSet<Principal>(that.principals); |
|
807 |
} |
|
808 |
if (!principals.equals(thatPrincipals)) { |
|
809 |
return false; |
|
810 |
} |
|
811 |
||
812 |
Set<Object> thatPubCredentials; |
|
813 |
synchronized(that.pubCredentials) { |
|
814 |
// avoid deadlock from dual locks |
|
815 |
thatPubCredentials = new HashSet<Object>(that.pubCredentials); |
|
816 |
} |
|
817 |
if (!pubCredentials.equals(thatPubCredentials)) { |
|
818 |
return false; |
|
819 |
} |
|
820 |
||
821 |
Set<Object> thatPrivCredentials; |
|
822 |
synchronized(that.privCredentials) { |
|
823 |
// avoid deadlock from dual locks |
|
824 |
thatPrivCredentials = new HashSet<Object>(that.privCredentials); |
|
825 |
} |
|
826 |
if (!privCredentials.equals(thatPrivCredentials)) { |
|
827 |
return false; |
|
828 |
} |
|
829 |
return true; |
|
830 |
} |
|
831 |
return false; |
|
832 |
} |
|
833 |
||
834 |
/** |
|
18830 | 835 |
* Return the String representation of this {@code Subject}. |
2 | 836 |
* |
18830 | 837 |
* @return the String representation of this {@code Subject}. |
2 | 838 |
*/ |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
839 |
@Override |
2 | 840 |
public String toString() { |
841 |
return toString(true); |
|
842 |
} |
|
843 |
||
844 |
/** |
|
845 |
* package private convenience method to print out the Subject |
|
846 |
* without firing off a security check when trying to access |
|
847 |
* the Private Credentials |
|
848 |
*/ |
|
849 |
String toString(boolean includePrivateCredentials) { |
|
850 |
||
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
5506
diff
changeset
|
851 |
String s = ResourcesMgr.getString("Subject."); |
2 | 852 |
String suffix = ""; |
853 |
||
854 |
synchronized(principals) { |
|
855 |
Iterator<Principal> pI = principals.iterator(); |
|
856 |
while (pI.hasNext()) { |
|
857 |
Principal p = pI.next(); |
|
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
5506
diff
changeset
|
858 |
suffix = suffix + ResourcesMgr.getString(".Principal.") + |
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
5506
diff
changeset
|
859 |
p.toString() + ResourcesMgr.getString("NEWLINE"); |
2 | 860 |
} |
861 |
} |
|
862 |
||
863 |
synchronized(pubCredentials) { |
|
864 |
Iterator<Object> pI = pubCredentials.iterator(); |
|
865 |
while (pI.hasNext()) { |
|
866 |
Object o = pI.next(); |
|
867 |
suffix = suffix + |
|
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
5506
diff
changeset
|
868 |
ResourcesMgr.getString(".Public.Credential.") + |
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
5506
diff
changeset
|
869 |
o.toString() + ResourcesMgr.getString("NEWLINE"); |
2 | 870 |
} |
871 |
} |
|
872 |
||
873 |
if (includePrivateCredentials) { |
|
874 |
synchronized(privCredentials) { |
|
875 |
Iterator<Object> pI = privCredentials.iterator(); |
|
876 |
while (pI.hasNext()) { |
|
877 |
try { |
|
878 |
Object o = pI.next(); |
|
879 |
suffix += ResourcesMgr.getString |
|
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
5506
diff
changeset
|
880 |
(".Private.Credential.") + |
2 | 881 |
o.toString() + |
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
5506
diff
changeset
|
882 |
ResourcesMgr.getString("NEWLINE"); |
2 | 883 |
} catch (SecurityException se) { |
884 |
suffix += ResourcesMgr.getString |
|
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
5506
diff
changeset
|
885 |
(".Private.Credential.inaccessible."); |
2 | 886 |
break; |
887 |
} |
|
888 |
} |
|
889 |
} |
|
890 |
} |
|
891 |
return s + suffix; |
|
892 |
} |
|
893 |
||
894 |
/** |
|
18830 | 895 |
* Returns a hashcode for this {@code Subject}. |
2 | 896 |
* |
18830 | 897 |
* @return a hashcode for this {@code Subject}. |
2 | 898 |
* |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
899 |
* @throws SecurityException if a security manager is installed and the |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
900 |
* caller does not have a {@link PrivateCredentialPermission} |
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
901 |
* permission to access this Subject's private credentials. |
2 | 902 |
*/ |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
903 |
@Override |
2 | 904 |
public int hashCode() { |
905 |
||
906 |
/** |
|
907 |
* The hashcode is derived exclusive or-ing the |
|
908 |
* hashcodes of this Subject's Principals and credentials. |
|
909 |
* |
|
910 |
* If a particular credential was destroyed |
|
18830 | 911 |
* ({@code credential.hashCode()} throws an |
912 |
* {@code IllegalStateException}), |
|
2 | 913 |
* the hashcode for that credential is derived via: |
18830 | 914 |
* {@code credential.getClass().toString().hashCode()}. |
2 | 915 |
*/ |
916 |
||
917 |
int hashCode = 0; |
|
918 |
||
919 |
synchronized(principals) { |
|
920 |
Iterator<Principal> pIterator = principals.iterator(); |
|
921 |
while (pIterator.hasNext()) { |
|
922 |
Principal p = pIterator.next(); |
|
923 |
hashCode ^= p.hashCode(); |
|
924 |
} |
|
925 |
} |
|
926 |
||
927 |
synchronized(pubCredentials) { |
|
928 |
Iterator<Object> pubCIterator = pubCredentials.iterator(); |
|
929 |
while (pubCIterator.hasNext()) { |
|
930 |
hashCode ^= getCredHashCode(pubCIterator.next()); |
|
931 |
} |
|
932 |
} |
|
933 |
return hashCode; |
|
934 |
} |
|
935 |
||
936 |
/** |
|
937 |
* get a credential's hashcode |
|
938 |
*/ |
|
939 |
private int getCredHashCode(Object o) { |
|
940 |
try { |
|
941 |
return o.hashCode(); |
|
942 |
} catch (IllegalStateException ise) { |
|
943 |
return o.getClass().toString().hashCode(); |
|
944 |
} |
|
945 |
} |
|
946 |
||
947 |
/** |
|
948 |
* Writes this object out to a stream (i.e., serializes it). |
|
949 |
*/ |
|
950 |
private void writeObject(java.io.ObjectOutputStream oos) |
|
951 |
throws java.io.IOException { |
|
952 |
synchronized(principals) { |
|
953 |
oos.defaultWriteObject(); |
|
954 |
} |
|
955 |
} |
|
956 |
||
957 |
/** |
|
958 |
* Reads this object from a stream (i.e., deserializes it) |
|
959 |
*/ |
|
23913
049a0df69b88
8030655: Regression: 14_01 Security fix 8024306 causes test failures
weijun
parents:
22317
diff
changeset
|
960 |
@SuppressWarnings("unchecked") |
2 | 961 |
private void readObject(java.io.ObjectInputStream s) |
962 |
throws java.io.IOException, ClassNotFoundException { |
|
963 |
||
23913
049a0df69b88
8030655: Regression: 14_01 Security fix 8024306 causes test failures
weijun
parents:
22317
diff
changeset
|
964 |
ObjectInputStream.GetField gf = s.readFields(); |
049a0df69b88
8030655: Regression: 14_01 Security fix 8024306 causes test failures
weijun
parents:
22317
diff
changeset
|
965 |
|
049a0df69b88
8030655: Regression: 14_01 Security fix 8024306 causes test failures
weijun
parents:
22317
diff
changeset
|
966 |
readOnly = gf.get("readOnly", false); |
049a0df69b88
8030655: Regression: 14_01 Security fix 8024306 causes test failures
weijun
parents:
22317
diff
changeset
|
967 |
|
049a0df69b88
8030655: Regression: 14_01 Security fix 8024306 causes test failures
weijun
parents:
22317
diff
changeset
|
968 |
Set<Principal> inputPrincs = (Set<Principal>)gf.get("principals", null); |
2 | 969 |
|
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
970 |
Objects.requireNonNull(inputPrincs, |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
971 |
ResourcesMgr.getString("invalid.null.input.s.")); |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
972 |
|
22310 | 973 |
// Rewrap the principals into a SecureSet |
23913
049a0df69b88
8030655: Regression: 14_01 Security fix 8024306 causes test failures
weijun
parents:
22317
diff
changeset
|
974 |
try { |
049a0df69b88
8030655: Regression: 14_01 Security fix 8024306 causes test failures
weijun
parents:
22317
diff
changeset
|
975 |
principals = Collections.synchronizedSet(new SecureSet<Principal> |
049a0df69b88
8030655: Regression: 14_01 Security fix 8024306 causes test failures
weijun
parents:
22317
diff
changeset
|
976 |
(this, PRINCIPAL_SET, inputPrincs)); |
049a0df69b88
8030655: Regression: 14_01 Security fix 8024306 causes test failures
weijun
parents:
22317
diff
changeset
|
977 |
} catch (NullPointerException npe) { |
049a0df69b88
8030655: Regression: 14_01 Security fix 8024306 causes test failures
weijun
parents:
22317
diff
changeset
|
978 |
// Sometimes people deserialize the principals set only. |
049a0df69b88
8030655: Regression: 14_01 Security fix 8024306 causes test failures
weijun
parents:
22317
diff
changeset
|
979 |
// Subject is not accessible, so just don't fail. |
049a0df69b88
8030655: Regression: 14_01 Security fix 8024306 causes test failures
weijun
parents:
22317
diff
changeset
|
980 |
principals = Collections.synchronizedSet |
049a0df69b88
8030655: Regression: 14_01 Security fix 8024306 causes test failures
weijun
parents:
22317
diff
changeset
|
981 |
(new SecureSet<Principal>(this, PRINCIPAL_SET)); |
049a0df69b88
8030655: Regression: 14_01 Security fix 8024306 causes test failures
weijun
parents:
22317
diff
changeset
|
982 |
} |
22310 | 983 |
|
18830 | 984 |
// The Credential {@code Set} is not serialized, but we do not |
2 | 985 |
// want the default deserialization routine to set it to null. |
986 |
this.pubCredentials = Collections.synchronizedSet |
|
987 |
(new SecureSet<Object>(this, PUB_CREDENTIAL_SET)); |
|
988 |
this.privCredentials = Collections.synchronizedSet |
|
989 |
(new SecureSet<Object>(this, PRIV_CREDENTIAL_SET)); |
|
990 |
} |
|
991 |
||
992 |
/** |
|
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
993 |
* Tests for null-clean collections (both non-null reference and |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
994 |
* no null elements) |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
995 |
* |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
996 |
* @param coll A {@code Collection} to be tested for null references |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
997 |
* |
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
998 |
* @throws NullPointerException if the specified collection is either |
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
999 |
* {@code null} or contains a {@code null} element |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1000 |
*/ |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1001 |
private static void collectionNullClean(Collection<?> coll) { |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1002 |
boolean hasNullElements = false; |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1003 |
|
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1004 |
Objects.requireNonNull(coll, |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1005 |
ResourcesMgr.getString("invalid.null.input.s.")); |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1006 |
|
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1007 |
try { |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1008 |
hasNullElements = coll.contains(null); |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1009 |
} catch (NullPointerException npe) { |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1010 |
// A null-hostile collection may choose to throw |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1011 |
// NullPointerException if contains(null) is called on it |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1012 |
// rather than returning false. |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1013 |
// If this happens we know the collection is null-clean. |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1014 |
hasNullElements = false; |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1015 |
} finally { |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1016 |
if (hasNullElements) { |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1017 |
throw new NullPointerException |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1018 |
(ResourcesMgr.getString("invalid.null.input.s.")); |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1019 |
} |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1020 |
} |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1021 |
} |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1022 |
|
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1023 |
/** |
2 | 1024 |
* Prevent modifications unless caller has permission. |
1025 |
* |
|
1026 |
* @serial include |
|
1027 |
*/ |
|
1028 |
private static class SecureSet<E> |
|
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1029 |
implements Set<E>, java.io.Serializable { |
2 | 1030 |
|
1031 |
private static final long serialVersionUID = 7911754171111800359L; |
|
1032 |
||
1033 |
/** |
|
1034 |
* @serialField this$0 Subject The outer Subject instance. |
|
1035 |
* @serialField elements LinkedList The elements in this set. |
|
1036 |
*/ |
|
1037 |
private static final ObjectStreamField[] serialPersistentFields = { |
|
1038 |
new ObjectStreamField("this$0", Subject.class), |
|
1039 |
new ObjectStreamField("elements", LinkedList.class), |
|
1040 |
new ObjectStreamField("which", int.class) |
|
1041 |
}; |
|
1042 |
||
1043 |
Subject subject; |
|
1044 |
LinkedList<E> elements; |
|
1045 |
||
1046 |
/** |
|
1047 |
* @serial An integer identifying the type of objects contained |
|
18830 | 1048 |
* in this set. If {@code which == 1}, |
2 | 1049 |
* this is a Principal set and all the elements are |
18830 | 1050 |
* of type {@code java.security.Principal}. |
1051 |
* If {@code which == 2}, this is a public credential |
|
1052 |
* set and all the elements are of type {@code Object}. |
|
1053 |
* If {@code which == 3}, this is a private credential |
|
1054 |
* set and all the elements are of type {@code Object}. |
|
2 | 1055 |
*/ |
1056 |
private int which; |
|
1057 |
||
1058 |
SecureSet(Subject subject, int which) { |
|
1059 |
this.subject = subject; |
|
1060 |
this.which = which; |
|
1061 |
this.elements = new LinkedList<E>(); |
|
1062 |
} |
|
1063 |
||
1064 |
SecureSet(Subject subject, int which, Set<? extends E> set) { |
|
1065 |
this.subject = subject; |
|
1066 |
this.which = which; |
|
1067 |
this.elements = new LinkedList<E>(set); |
|
1068 |
} |
|
1069 |
||
1070 |
public int size() { |
|
1071 |
return elements.size(); |
|
1072 |
} |
|
1073 |
||
1074 |
public Iterator<E> iterator() { |
|
1075 |
final LinkedList<E> list = elements; |
|
1076 |
return new Iterator<E>() { |
|
1077 |
ListIterator<E> i = list.listIterator(0); |
|
1078 |
||
1079 |
public boolean hasNext() {return i.hasNext();} |
|
1080 |
||
1081 |
public E next() { |
|
1082 |
if (which != Subject.PRIV_CREDENTIAL_SET) { |
|
1083 |
return i.next(); |
|
1084 |
} |
|
1085 |
||
1086 |
SecurityManager sm = System.getSecurityManager(); |
|
1087 |
if (sm != null) { |
|
1088 |
try { |
|
1089 |
sm.checkPermission(new PrivateCredentialPermission |
|
1090 |
(list.get(i.nextIndex()).getClass().getName(), |
|
1091 |
subject.getPrincipals())); |
|
1092 |
} catch (SecurityException se) { |
|
1093 |
i.next(); |
|
1094 |
throw (se); |
|
1095 |
} |
|
1096 |
} |
|
1097 |
return i.next(); |
|
1098 |
} |
|
1099 |
||
1100 |
public void remove() { |
|
1101 |
||
1102 |
if (subject.isReadOnly()) { |
|
1103 |
throw new IllegalStateException(ResourcesMgr.getString |
|
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
5506
diff
changeset
|
1104 |
("Subject.is.read.only")); |
2 | 1105 |
} |
1106 |
||
1107 |
java.lang.SecurityManager sm = System.getSecurityManager(); |
|
1108 |
if (sm != null) { |
|
1109 |
switch (which) { |
|
1110 |
case Subject.PRINCIPAL_SET: |
|
4331
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
1111 |
sm.checkPermission(AuthPermissionHolder.MODIFY_PRINCIPALS_PERMISSION); |
2 | 1112 |
break; |
1113 |
case Subject.PUB_CREDENTIAL_SET: |
|
4331
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
1114 |
sm.checkPermission(AuthPermissionHolder.MODIFY_PUBLIC_CREDENTIALS_PERMISSION); |
2 | 1115 |
break; |
1116 |
default: |
|
4331
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
1117 |
sm.checkPermission(AuthPermissionHolder.MODIFY_PRIVATE_CREDENTIALS_PERMISSION); |
2 | 1118 |
break; |
1119 |
} |
|
1120 |
} |
|
1121 |
i.remove(); |
|
1122 |
} |
|
1123 |
}; |
|
1124 |
} |
|
1125 |
||
1126 |
public boolean add(E o) { |
|
1127 |
||
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1128 |
Objects.requireNonNull(o, |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1129 |
ResourcesMgr.getString("invalid.null.input.s.")); |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1130 |
|
2 | 1131 |
if (subject.isReadOnly()) { |
1132 |
throw new IllegalStateException |
|
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
5506
diff
changeset
|
1133 |
(ResourcesMgr.getString("Subject.is.read.only")); |
2 | 1134 |
} |
1135 |
||
1136 |
java.lang.SecurityManager sm = System.getSecurityManager(); |
|
1137 |
if (sm != null) { |
|
1138 |
switch (which) { |
|
1139 |
case Subject.PRINCIPAL_SET: |
|
4331
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
1140 |
sm.checkPermission(AuthPermissionHolder.MODIFY_PRINCIPALS_PERMISSION); |
2 | 1141 |
break; |
1142 |
case Subject.PUB_CREDENTIAL_SET: |
|
4331
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
1143 |
sm.checkPermission(AuthPermissionHolder.MODIFY_PUBLIC_CREDENTIALS_PERMISSION); |
2 | 1144 |
break; |
1145 |
default: |
|
4331
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
1146 |
sm.checkPermission(AuthPermissionHolder.MODIFY_PRIVATE_CREDENTIALS_PERMISSION); |
2 | 1147 |
break; |
1148 |
} |
|
1149 |
} |
|
1150 |
||
1151 |
switch (which) { |
|
1152 |
case Subject.PRINCIPAL_SET: |
|
1153 |
if (!(o instanceof Principal)) { |
|
1154 |
throw new SecurityException(ResourcesMgr.getString |
|
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
5506
diff
changeset
|
1155 |
("attempting.to.add.an.object.which.is.not.an.instance.of.java.security.Principal.to.a.Subject.s.Principal.Set")); |
2 | 1156 |
} |
1157 |
break; |
|
1158 |
default: |
|
1159 |
// ok to add Objects of any kind to credential sets |
|
1160 |
break; |
|
1161 |
} |
|
1162 |
||
1163 |
// check for duplicates |
|
1164 |
if (!elements.contains(o)) |
|
1165 |
return elements.add(o); |
|
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1166 |
else { |
2 | 1167 |
return false; |
1168 |
} |
|
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1169 |
} |
2 | 1170 |
|
1171 |
public boolean remove(Object o) { |
|
1172 |
||
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1173 |
Objects.requireNonNull(o, |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1174 |
ResourcesMgr.getString("invalid.null.input.s.")); |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1175 |
|
2 | 1176 |
final Iterator<E> e = iterator(); |
1177 |
while (e.hasNext()) { |
|
1178 |
E next; |
|
1179 |
if (which != Subject.PRIV_CREDENTIAL_SET) { |
|
1180 |
next = e.next(); |
|
1181 |
} else { |
|
1182 |
next = java.security.AccessController.doPrivileged |
|
1183 |
(new java.security.PrivilegedAction<E>() { |
|
1184 |
public E run() { |
|
1185 |
return e.next(); |
|
1186 |
} |
|
1187 |
}); |
|
1188 |
} |
|
1189 |
||
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1190 |
if (next.equals(o)) { |
2 | 1191 |
e.remove(); |
1192 |
return true; |
|
1193 |
} |
|
1194 |
} |
|
1195 |
return false; |
|
1196 |
} |
|
1197 |
||
1198 |
public boolean contains(Object o) { |
|
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1199 |
|
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1200 |
Objects.requireNonNull(o, |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1201 |
ResourcesMgr.getString("invalid.null.input.s.")); |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1202 |
|
2 | 1203 |
final Iterator<E> e = iterator(); |
1204 |
while (e.hasNext()) { |
|
1205 |
E next; |
|
1206 |
if (which != Subject.PRIV_CREDENTIAL_SET) { |
|
1207 |
next = e.next(); |
|
1208 |
} else { |
|
1209 |
||
1210 |
// For private credentials: |
|
1211 |
// If the caller does not have read permission for |
|
1212 |
// for o.getClass(), we throw a SecurityException. |
|
1213 |
// Otherwise we check the private cred set to see whether |
|
1214 |
// it contains the Object |
|
1215 |
||
1216 |
SecurityManager sm = System.getSecurityManager(); |
|
1217 |
if (sm != null) { |
|
1218 |
sm.checkPermission(new PrivateCredentialPermission |
|
1219 |
(o.getClass().getName(), |
|
1220 |
subject.getPrincipals())); |
|
1221 |
} |
|
1222 |
next = java.security.AccessController.doPrivileged |
|
1223 |
(new java.security.PrivilegedAction<E>() { |
|
1224 |
public E run() { |
|
1225 |
return e.next(); |
|
1226 |
} |
|
1227 |
}); |
|
1228 |
} |
|
1229 |
||
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1230 |
if (next.equals(o)) { |
2 | 1231 |
return true; |
1232 |
} |
|
1233 |
} |
|
1234 |
return false; |
|
1235 |
} |
|
1236 |
||
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1237 |
public boolean addAll(Collection<? extends E> c) { |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1238 |
boolean result = false; |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1239 |
|
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1240 |
collectionNullClean(c); |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1241 |
|
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1242 |
for (E item : c) { |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1243 |
result |= this.add(item); |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1244 |
} |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1245 |
|
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1246 |
return result; |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1247 |
} |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1248 |
|
2 | 1249 |
public boolean removeAll(Collection<?> c) { |
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1250 |
collectionNullClean(c); |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1251 |
|
2 | 1252 |
boolean modified = false; |
1253 |
final Iterator<E> e = iterator(); |
|
1254 |
while (e.hasNext()) { |
|
1255 |
E next; |
|
1256 |
if (which != Subject.PRIV_CREDENTIAL_SET) { |
|
1257 |
next = e.next(); |
|
1258 |
} else { |
|
1259 |
next = java.security.AccessController.doPrivileged |
|
1260 |
(new java.security.PrivilegedAction<E>() { |
|
1261 |
public E run() { |
|
1262 |
return e.next(); |
|
1263 |
} |
|
1264 |
}); |
|
1265 |
} |
|
1266 |
||
1267 |
Iterator<?> ce = c.iterator(); |
|
1268 |
while (ce.hasNext()) { |
|
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1269 |
if (next.equals(ce.next())) { |
2 | 1270 |
e.remove(); |
1271 |
modified = true; |
|
1272 |
break; |
|
1273 |
} |
|
1274 |
} |
|
1275 |
} |
|
1276 |
return modified; |
|
1277 |
} |
|
1278 |
||
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1279 |
public boolean containsAll(Collection<?> c) { |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1280 |
collectionNullClean(c); |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1281 |
|
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1282 |
for (Object item : c) { |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1283 |
if (this.contains(item) == false) { |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1284 |
return false; |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1285 |
} |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1286 |
} |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1287 |
|
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1288 |
return true; |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1289 |
} |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1290 |
|
2 | 1291 |
public boolean retainAll(Collection<?> c) { |
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1292 |
collectionNullClean(c); |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1293 |
|
2 | 1294 |
boolean modified = false; |
1295 |
final Iterator<E> e = iterator(); |
|
1296 |
while (e.hasNext()) { |
|
1297 |
E next; |
|
1298 |
if (which != Subject.PRIV_CREDENTIAL_SET) { |
|
1299 |
next = e.next(); |
|
1300 |
} else { |
|
1301 |
next = java.security.AccessController.doPrivileged |
|
1302 |
(new java.security.PrivilegedAction<E>() { |
|
1303 |
public E run() { |
|
1304 |
return e.next(); |
|
1305 |
} |
|
1306 |
}); |
|
1307 |
} |
|
1308 |
||
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1309 |
if (c.contains(next) == false) { |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1310 |
e.remove(); |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1311 |
modified = true; |
2 | 1312 |
} |
1313 |
} |
|
1314 |
||
1315 |
return modified; |
|
1316 |
} |
|
1317 |
||
1318 |
public void clear() { |
|
1319 |
final Iterator<E> e = iterator(); |
|
1320 |
while (e.hasNext()) { |
|
1321 |
E next; |
|
1322 |
if (which != Subject.PRIV_CREDENTIAL_SET) { |
|
1323 |
next = e.next(); |
|
1324 |
} else { |
|
1325 |
next = java.security.AccessController.doPrivileged |
|
1326 |
(new java.security.PrivilegedAction<E>() { |
|
1327 |
public E run() { |
|
1328 |
return e.next(); |
|
1329 |
} |
|
1330 |
}); |
|
1331 |
} |
|
1332 |
e.remove(); |
|
1333 |
} |
|
1334 |
} |
|
1335 |
||
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1336 |
public boolean isEmpty() { |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1337 |
return elements.isEmpty(); |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1338 |
} |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1339 |
|
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1340 |
public Object[] toArray() { |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1341 |
final Iterator<E> e = iterator(); |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1342 |
while (e.hasNext()) { |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1343 |
// The next() method performs a security manager check |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1344 |
// on each element in the SecureSet. If we make it all |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1345 |
// the way through we should be able to simply return |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1346 |
// element's toArray results. Otherwise we'll let |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1347 |
// the SecurityException pass up the call stack. |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1348 |
e.next(); |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1349 |
} |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1350 |
|
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1351 |
return elements.toArray(); |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1352 |
} |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1353 |
|
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1354 |
public <T> T[] toArray(T[] a) { |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1355 |
final Iterator<E> e = iterator(); |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1356 |
while (e.hasNext()) { |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1357 |
// The next() method performs a security manager check |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1358 |
// on each element in the SecureSet. If we make it all |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1359 |
// the way through we should be able to simply return |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1360 |
// element's toArray results. Otherwise we'll let |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1361 |
// the SecurityException pass up the call stack. |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1362 |
e.next(); |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1363 |
} |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1364 |
|
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1365 |
return elements.toArray(a); |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1366 |
} |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1367 |
|
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1368 |
public boolean equals(Object o) { |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1369 |
if (o == this) { |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1370 |
return true; |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1371 |
} |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1372 |
|
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1373 |
if (!(o instanceof Set)) { |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1374 |
return false; |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1375 |
} |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1376 |
|
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1377 |
Collection<?> c = (Collection<?>) o; |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1378 |
if (c.size() != size()) { |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1379 |
return false; |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1380 |
} |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1381 |
|
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1382 |
try { |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1383 |
return containsAll(c); |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1384 |
} catch (ClassCastException unused) { |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1385 |
return false; |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1386 |
} catch (NullPointerException unused) { |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1387 |
return false; |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1388 |
} |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1389 |
} |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1390 |
|
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1391 |
public int hashCode() { |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1392 |
int h = 0; |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1393 |
Iterator<E> i = iterator(); |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1394 |
while (i.hasNext()) { |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1395 |
E obj = i.next(); |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1396 |
if (obj != null) { |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1397 |
h += obj.hashCode(); |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1398 |
} |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1399 |
} |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1400 |
return h; |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1401 |
} |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1402 |
|
2 | 1403 |
/** |
1404 |
* Writes this object out to a stream (i.e., serializes it). |
|
1405 |
* |
|
1406 |
* <p> |
|
1407 |
* |
|
1408 |
* @serialData If this is a private credential set, |
|
1409 |
* a security check is performed to ensure that |
|
1410 |
* the caller has permission to access each credential |
|
1411 |
* in the set. If the security check passes, |
|
1412 |
* the set is serialized. |
|
1413 |
*/ |
|
1414 |
private void writeObject(java.io.ObjectOutputStream oos) |
|
1415 |
throws java.io.IOException { |
|
1416 |
||
1417 |
if (which == Subject.PRIV_CREDENTIAL_SET) { |
|
1418 |
// check permissions before serializing |
|
1419 |
Iterator<E> i = iterator(); |
|
1420 |
while (i.hasNext()) { |
|
1421 |
i.next(); |
|
1422 |
} |
|
1423 |
} |
|
1424 |
ObjectOutputStream.PutField fields = oos.putFields(); |
|
1425 |
fields.put("this$0", subject); |
|
1426 |
fields.put("elements", elements); |
|
1427 |
fields.put("which", which); |
|
1428 |
oos.writeFields(); |
|
1429 |
} |
|
1430 |
||
10709
d865c9f21240
7092375: Security Libraries don't build with javac -Werror
xuelei
parents:
7179
diff
changeset
|
1431 |
@SuppressWarnings("unchecked") |
2 | 1432 |
private void readObject(ObjectInputStream ois) |
1433 |
throws IOException, ClassNotFoundException |
|
1434 |
{ |
|
1435 |
ObjectInputStream.GetField fields = ois.readFields(); |
|
1436 |
subject = (Subject) fields.get("this$0", null); |
|
1437 |
which = fields.get("which", 0); |
|
20806
d94588b7854d
8015731: Subject java.security.auth.subject to improvements
weijun
parents:
14342
diff
changeset
|
1438 |
|
d94588b7854d
8015731: Subject java.security.auth.subject to improvements
weijun
parents:
14342
diff
changeset
|
1439 |
LinkedList<E> tmp = (LinkedList<E>) fields.get("elements", null); |
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1440 |
|
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1441 |
Subject.collectionNullClean(tmp); |
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1442 |
|
20806
d94588b7854d
8015731: Subject java.security.auth.subject to improvements
weijun
parents:
14342
diff
changeset
|
1443 |
if (tmp.getClass() != LinkedList.class) { |
d94588b7854d
8015731: Subject java.security.auth.subject to improvements
weijun
parents:
14342
diff
changeset
|
1444 |
elements = new LinkedList<E>(tmp); |
d94588b7854d
8015731: Subject java.security.auth.subject to improvements
weijun
parents:
14342
diff
changeset
|
1445 |
} else { |
d94588b7854d
8015731: Subject java.security.auth.subject to improvements
weijun
parents:
14342
diff
changeset
|
1446 |
elements = tmp; |
d94588b7854d
8015731: Subject java.security.auth.subject to improvements
weijun
parents:
14342
diff
changeset
|
1447 |
} |
2 | 1448 |
} |
25188
e680ab7f208e
8015081: javax.security.auth.Subject.toString() throws NPE
ascarpino
parents:
23913
diff
changeset
|
1449 |
|
2 | 1450 |
} |
1451 |
||
1452 |
/** |
|
18830 | 1453 |
* This class implements a {@code Set} which returns only |
2 | 1454 |
* members that are an instance of a specified Class. |
1455 |
*/ |
|
1456 |
private class ClassSet<T> extends AbstractSet<T> { |
|
1457 |
||
1458 |
private int which; |
|
1459 |
private Class<T> c; |
|
1460 |
private Set<T> set; |
|
1461 |
||
1462 |
ClassSet(int which, Class<T> c) { |
|
1463 |
this.which = which; |
|
1464 |
this.c = c; |
|
1465 |
set = new HashSet<T>(); |
|
1466 |
||
1467 |
switch (which) { |
|
1468 |
case Subject.PRINCIPAL_SET: |
|
1469 |
synchronized(principals) { populateSet(); } |
|
1470 |
break; |
|
1471 |
case Subject.PUB_CREDENTIAL_SET: |
|
1472 |
synchronized(pubCredentials) { populateSet(); } |
|
1473 |
break; |
|
1474 |
default: |
|
1475 |
synchronized(privCredentials) { populateSet(); } |
|
1476 |
break; |
|
1477 |
} |
|
1478 |
} |
|
1479 |
||
10709
d865c9f21240
7092375: Security Libraries don't build with javac -Werror
xuelei
parents:
7179
diff
changeset
|
1480 |
@SuppressWarnings("unchecked") /*To suppress warning from line 1374*/ |
2 | 1481 |
private void populateSet() { |
1482 |
final Iterator<?> iterator; |
|
1483 |
switch(which) { |
|
1484 |
case Subject.PRINCIPAL_SET: |
|
1485 |
iterator = Subject.this.principals.iterator(); |
|
1486 |
break; |
|
1487 |
case Subject.PUB_CREDENTIAL_SET: |
|
1488 |
iterator = Subject.this.pubCredentials.iterator(); |
|
1489 |
break; |
|
1490 |
default: |
|
1491 |
iterator = Subject.this.privCredentials.iterator(); |
|
1492 |
break; |
|
1493 |
} |
|
1494 |
||
1495 |
// Check whether the caller has permisson to get |
|
1496 |
// credentials of Class c |
|
1497 |
||
1498 |
while (iterator.hasNext()) { |
|
1499 |
Object next; |
|
1500 |
if (which == Subject.PRIV_CREDENTIAL_SET) { |
|
1501 |
next = java.security.AccessController.doPrivileged |
|
1502 |
(new java.security.PrivilegedAction<Object>() { |
|
1503 |
public Object run() { |
|
1504 |
return iterator.next(); |
|
1505 |
} |
|
1506 |
}); |
|
1507 |
} else { |
|
1508 |
next = iterator.next(); |
|
1509 |
} |
|
1510 |
if (c.isAssignableFrom(next.getClass())) { |
|
1511 |
if (which != Subject.PRIV_CREDENTIAL_SET) { |
|
1512 |
set.add((T)next); |
|
1513 |
} else { |
|
1514 |
// Check permission for private creds |
|
1515 |
SecurityManager sm = System.getSecurityManager(); |
|
1516 |
if (sm != null) { |
|
1517 |
sm.checkPermission(new PrivateCredentialPermission |
|
1518 |
(next.getClass().getName(), |
|
1519 |
Subject.this.getPrincipals())); |
|
1520 |
} |
|
1521 |
set.add((T)next); |
|
1522 |
} |
|
1523 |
} |
|
1524 |
} |
|
1525 |
} |
|
1526 |
||
1527 |
public int size() { |
|
1528 |
return set.size(); |
|
1529 |
} |
|
1530 |
||
1531 |
public Iterator<T> iterator() { |
|
1532 |
return set.iterator(); |
|
1533 |
} |
|
1534 |
||
1535 |
public boolean add(T o) { |
|
1536 |
||
1537 |
if (!o.getClass().isAssignableFrom(c)) { |
|
1538 |
MessageFormat form = new MessageFormat(ResourcesMgr.getString |
|
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
5506
diff
changeset
|
1539 |
("attempting.to.add.an.object.which.is.not.an.instance.of.class")); |
2 | 1540 |
Object[] source = {c.toString()}; |
1541 |
throw new SecurityException(form.format(source)); |
|
1542 |
} |
|
1543 |
||
1544 |
return set.add(o); |
|
1545 |
} |
|
1546 |
} |
|
4331
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
1547 |
|
25989
6a57ce3f21f1
7026255: Methods of Subject that throw SecurityException do not specify what permissions are required
mullan
parents:
25188
diff
changeset
|
1548 |
static final class AuthPermissionHolder { |
4331
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
1549 |
static final AuthPermission DO_AS_PERMISSION = |
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
1550 |
new AuthPermission("doAs"); |
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
1551 |
|
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
1552 |
static final AuthPermission DO_AS_PRIVILEGED_PERMISSION = |
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
1553 |
new AuthPermission("doAsPrivileged"); |
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
1554 |
|
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
1555 |
static final AuthPermission SET_READ_ONLY_PERMISSION = |
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
1556 |
new AuthPermission("setReadOnly"); |
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
1557 |
|
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
1558 |
static final AuthPermission GET_SUBJECT_PERMISSION = |
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
1559 |
new AuthPermission("getSubject"); |
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
1560 |
|
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
1561 |
static final AuthPermission MODIFY_PRINCIPALS_PERMISSION = |
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
1562 |
new AuthPermission("modifyPrincipals"); |
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
1563 |
|
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
1564 |
static final AuthPermission MODIFY_PUBLIC_CREDENTIALS_PERMISSION = |
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
1565 |
new AuthPermission("modifyPublicCredentials"); |
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
1566 |
|
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
1567 |
static final AuthPermission MODIFY_PRIVATE_CREDENTIALS_PERMISSION = |
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
1568 |
new AuthPermission("modifyPrivateCredentials"); |
ba7050c934f2
6903638: Remove dependency on AuthPermission from SecurityConstants
mchung
parents:
2
diff
changeset
|
1569 |
} |
2 | 1570 |
} |