equal
deleted
inserted
replaced
154 @Deprecated |
154 @Deprecated |
155 public abstract class Policy { |
155 public abstract class Policy { |
156 |
156 |
157 private static Policy policy; |
157 private static Policy policy; |
158 private static ClassLoader contextClassLoader; |
158 private static ClassLoader contextClassLoader; |
159 |
159 private final static String AUTH_POLICY = |
160 // true if a custom (not com.sun.security.auth.PolicyFile) system-wide |
160 "sun.security.provider.AuthPolicyFile"; |
161 // policy object is set |
161 |
|
162 // true if a custom (not AUTH_POLICY) system-wide policy object is set |
162 private static boolean isCustomPolicy; |
163 private static boolean isCustomPolicy; |
163 |
164 |
164 static { |
165 static { |
165 contextClassLoader = java.security.AccessController.doPrivileged |
166 contextClassLoader = java.security.AccessController.doPrivileged |
166 (new java.security.PrivilegedAction<ClassLoader>() { |
167 (new java.security.PrivilegedAction<ClassLoader>() { |
218 return java.security.Security.getProperty |
219 return java.security.Security.getProperty |
219 ("auth.policy.provider"); |
220 ("auth.policy.provider"); |
220 } |
221 } |
221 }); |
222 }); |
222 if (policy_class == null) { |
223 if (policy_class == null) { |
223 policy_class = "com.sun.security.auth.PolicyFile"; |
224 policy_class = AUTH_POLICY; |
224 } |
225 } |
225 |
226 |
226 try { |
227 try { |
227 final String finalClass = policy_class; |
228 final String finalClass = policy_class; |
228 policy = java.security.AccessController.doPrivileged |
229 policy = java.security.AccessController.doPrivileged |
234 (finalClass, |
235 (finalClass, |
235 true, |
236 true, |
236 contextClassLoader).newInstance(); |
237 contextClassLoader).newInstance(); |
237 } |
238 } |
238 }); |
239 }); |
239 isCustomPolicy = |
240 isCustomPolicy = !finalClass.equals(AUTH_POLICY); |
240 !finalClass.equals("com.sun.security.auth.PolicyFile"); |
|
241 } catch (Exception e) { |
241 } catch (Exception e) { |
242 throw new SecurityException |
242 throw new SecurityException |
243 (sun.security.util.ResourcesMgr.getString |
243 (sun.security.util.ResourcesMgr.getString |
244 ("unable.to.instantiate.Subject.based.policy")); |
244 ("unable.to.instantiate.Subject.based.policy")); |
245 } |
245 } |
272 // all non-null policy objects are assumed to be custom |
272 // all non-null policy objects are assumed to be custom |
273 isCustomPolicy = policy != null ? true : false; |
273 isCustomPolicy = policy != null ? true : false; |
274 } |
274 } |
275 |
275 |
276 /** |
276 /** |
277 * Returns true if a custom (not com.sun.security.auth.PolicyFile) |
277 * Returns true if a custom (not AUTH_POLICY) system-wide policy object |
278 * system-wide policy object has been set or installed. This method is |
278 * has been set or installed. This method is called by |
279 * called by SubjectDomainCombiner to provide backwards compatibility for |
279 * SubjectDomainCombiner to provide backwards compatibility for |
280 * developers that provide their own javax.security.auth.Policy |
280 * developers that provide their own javax.security.auth.Policy |
281 * implementations. |
281 * implementations. |
282 * |
282 * |
283 * @return true if a custom (not com.sun.security.auth.PolicyFile) |
283 * @return true if a custom (not AUTH_POLICY) system-wide policy object |
284 * system-wide policy object has been set; false otherwise |
284 * has been set; false otherwise |
285 */ |
285 */ |
286 static boolean isCustomPolicySet(Debug debug) { |
286 static boolean isCustomPolicySet(Debug debug) { |
287 if (policy != null) { |
287 if (policy != null) { |
288 if (debug != null && isCustomPolicy) { |
288 if (debug != null && isCustomPolicy) { |
289 debug.println("Providing backwards compatibility for " + |
289 debug.println("Providing backwards compatibility for " + |
297 (new java.security.PrivilegedAction<String>() { |
297 (new java.security.PrivilegedAction<String>() { |
298 public String run() { |
298 public String run() { |
299 return Security.getProperty("auth.policy.provider"); |
299 return Security.getProperty("auth.policy.provider"); |
300 } |
300 } |
301 }); |
301 }); |
302 if (policyClass != null |
302 if (policyClass != null && !policyClass.equals(AUTH_POLICY)) { |
303 && !policyClass.equals("com.sun.security.auth.PolicyFile")) { |
|
304 if (debug != null) { |
303 if (debug != null) { |
305 debug.println("Providing backwards compatibility for " + |
304 debug.println("Providing backwards compatibility for " + |
306 "javax.security.auth.policy implementation: " + |
305 "javax.security.auth.policy implementation: " + |
307 policyClass); |
306 policyClass); |
308 } |
307 } |