An instance of this class can be used as the argument of
AccessController.doPrivileged
.
The following code retrieves the integer value of the system
property named "prop"
as a privileged action. Since it does
not pass a default value to be used in case the property
"prop"
is not defined, it has to check the result for
null
:
Integer tmp = java.security.AccessController.doPrivileged (new sun.security.action.GetIntegerAction("prop")); int i; if (tmp != null) { i = tmp.intValue(); }
The following code retrieves the integer value of the system
property named "prop"
as a privileged action, and also passes
a default value to be used in case the property "prop"
is not
defined:
int i = ((Integer)java.security.AccessController.doPrivileged( new GetIntegerAction("prop", 3))).intValue();
java.security.PrivilegedAction
, java.security.AccessController
Modifier and Type | Field and Description |
---|---|
private final boolean | |
private final int | |
private final String |
Access | Constructor and Description |
---|---|
public | GetIntegerAction(String
the name of the system property. theProp)Constructor that takes the name of the system property whose integer value needs to be determined. |
public | GetIntegerAction(String
the name of the system property. theProp, int the default value. defaultVal)Constructor that takes the name of the system property and the default value of that property. |
Modifier and Type | Method and Description |
---|---|
public static Integer | privilegedGetProperty(String
the name of the system property. theProp)Convenience method to get a property without going through doPrivileged if no security manager is present. |
public static Integer | privilegedGetProperty(String
the name of the system property. theProp, int the default value. defaultVal)Convenience method to get a property without going through doPrivileged if no security manager is present. |
public Integer | Returns: theInteger value of the property.Implements java. Determines the integer value of the system property whose name was specified in the constructor. |
defaultSet | back to summary |
---|---|
private final boolean defaultSet |
defaultVal | back to summary |
---|---|
private final int defaultVal |
theProp | back to summary |
---|---|
private final String theProp |
GetIntegerAction | back to summary |
---|---|
public GetIntegerAction(String theProp) Constructor that takes the name of the system property whose integer value needs to be determined.
|
GetIntegerAction | back to summary |
---|---|
public GetIntegerAction(String theProp, int defaultVal) Constructor that takes the name of the system property and the default value of that property.
|
privilegedGetProperty | back to summary |
---|---|
public static Integer privilegedGetProperty(String theProp) Convenience method to get a property without going through doPrivileged if no security manager is present. This is unsafe for inclusion in a public API but allowable here since this class is now encapsulated. Note that this method performs a privileged action using caller-provided inputs. The caller of this method should take care to ensure that the inputs are not tainted and the returned property is not made accessible to untrusted code if it contains sensitive information.
|
privilegedGetProperty | back to summary |
---|---|
public static Integer privilegedGetProperty(String theProp, int defaultVal) Convenience method to get a property without going through doPrivileged if no security manager is present. This is unsafe for inclusion in a public API but allowable here since this class is now encapsulated. Note that this method performs a privileged action using caller-provided inputs. The caller of this method should take care to ensure that the inputs are not tainted and the returned property is not made accessible to untrusted code if it contains sensitive information.
|
run | back to summary |
---|---|
public Integer run() Implements java. Determines the integer value of the system property whose name was specified in the constructor. If there is no property of the specified name, or if the property
does not have the correct numeric format, then an
|