Top Description Fields Constructors Methods
sun.security.action

public Class GetIntegerAction

extends Object
implements PrivilegedAction<Integer>
Class Inheritance
All Implemented Interfaces
java.security.PrivilegedAction
Imports
java.security.AccessController

A convenience class for retrieving the integer value of a system property as a privileged action.

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();
Author
Roland Schemers
Since
1.2
See Also
java.security.PrivilegedAction, java.security.AccessController

Field Summary

Modifier and TypeField and Description
private final boolean
private final int
private final String

Constructor Summary

AccessConstructor 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.

Method Summary

Modifier and TypeMethod 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:

the Integer value of the property.
run
()

Implements java.security.PrivilegedAction.run.

Determines the integer value of the system property whose name was specified in the constructor.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

defaultSetback to summary
private final boolean defaultSet
defaultValback to summary
private final int defaultVal
thePropback to summary
private final String theProp

Constructor Detail

GetIntegerActionback to summary
public GetIntegerAction(String theProp)

Constructor that takes the name of the system property whose integer value needs to be determined.

Parameters
theProp:String

the name of the system property.

GetIntegerActionback to summary
public GetIntegerAction(String theProp, int defaultVal)

Constructor that takes the name of the system property and the default value of that property.

Parameters
theProp:String

the name of the system property.

defaultVal:int

the default value.

Method Detail

privilegedGetPropertyback 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.

Parameters
theProp:String

the name of the system property.

Annotations
@SuppressWarnings:removal
privilegedGetPropertyback 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.

Parameters
theProp:String

the name of the system property.

defaultVal:int

the default value.

Annotations
@SuppressWarnings:removal
runback to summary
public Integer run()

Implements java.security.PrivilegedAction.run.

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 Integer object representing the default value that was specified in the constructor is returned, or null if no default value was specified.

Returns:Integer

the Integer value of the property.