equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
22 * or visit www.oracle.com if you need additional information or have any |
22 * or visit www.oracle.com if you need additional information or have any |
23 * questions. |
23 * questions. |
24 */ |
24 */ |
25 |
25 |
26 package sun.security.action; |
26 package sun.security.action; |
|
27 |
|
28 import java.security.AccessController; |
27 |
29 |
28 /** |
30 /** |
29 * A convenience class for retrieving the boolean value of a system property |
31 * A convenience class for retrieving the boolean value of a system property |
30 * as a privileged action. |
32 * as a privileged action. |
31 * |
33 * |
67 * @return the <code>Boolean</code> value of the system property. |
69 * @return the <code>Boolean</code> value of the system property. |
68 */ |
70 */ |
69 public Boolean run() { |
71 public Boolean run() { |
70 return Boolean.getBoolean(theProp); |
72 return Boolean.getBoolean(theProp); |
71 } |
73 } |
|
74 |
|
75 /** |
|
76 * Convenience method to get a property without going through doPrivileged |
|
77 * if no security manager is present. This is unsafe for inclusion in a |
|
78 * public API but allowable here since this class is now encapsulated. |
|
79 * |
|
80 * Note that this method performs a privileged action using caller-provided |
|
81 * inputs. The caller of this method should take care to ensure that the |
|
82 * inputs are not tainted and the returned property is not made accessible |
|
83 * to untrusted code if it contains sensitive information. |
|
84 * |
|
85 * @param theProp the name of the system property. |
|
86 */ |
|
87 public static boolean privilegedGetProperty(String theProp) { |
|
88 if (System.getSecurityManager() == null) { |
|
89 return Boolean.getBoolean(theProp); |
|
90 } else { |
|
91 return AccessController.doPrivileged( |
|
92 new GetBooleanAction(theProp)); |
|
93 } |
|
94 } |
72 } |
95 } |