Top Description Constructors Methods
org.jruby.util

public Class SafePropertyAccessor

extends Object
Class Inheritance
Imports
java.util.Map

Utility class to safely access system properties in security-sensitive environments.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static boolean

Returns:

The boolean value of the system property.
getBoolean
(String
The system property name.
property
)

An extension over Boolean.getBoolean method.

public static boolean

Returns:

The boolean value of the system property, or the default value.
getBoolean
(String
The system property name.
property
,
boolean
The default value.
defValue
)

An extension over Boolean.getBoolean method.

public static String

Returns:

The value of the environment variable, or null.
getenv
(String
The environment variable name.
name
)

An extension over System.getenv method.

public static Map<String, String>

Returns:

The map of the environment variables, or null.
getenv
()

An extension over System.getenv method.

public static int

Returns:

The value of the system property, or the default value.
getInt
(String
The system property name.
property
)

An extension over System.getProperty method that additionally produces an int value.

public static int

Returns:

The value of the system property, or the default value.
getInt
(String
The system property name.
property
,
int
The default value.
defValue
)

An extension over System.getProperty method that additionally produces an int value.

public static String

Returns:

The value of the system property, or the default value.
getProperty
(String
The system property name.
property
)

An extension over System.getProperty method.

public static String

Returns:

The value of the system property, or the default value.
getProperty
(String
The system property name.
property
,
String
The default value.
defValue
)

An extension over System.getProperty method.

public static boolean

Returns:

true if the access is restricted, false otherwise.
isSecurityProtected
(String
The system property name.
property
)

Returns true if the access to the system property is restricted (i.e., when System.getProperty() throws SecurityException).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

SafePropertyAccessorback to summary
public SafePropertyAccessor()

Method Detail

getBooleanback to summary
public static boolean getBoolean(String property)

An extension over Boolean.getBoolean method. Returns true if and only if the system property named by the argument exists and is equal to the string "true". If there is no property with the specified name, or if the specified name is empty or null, or if the access to the property is restricted, then false is returned.

Parameters
property:String

The system property name.

Returns:boolean

The boolean value of the system property.

getBooleanback to summary
public static boolean getBoolean(String property, boolean defValue)

An extension over Boolean.getBoolean method. Handles security restrictions, and provides default value in case when access to the property is restricted, of when the property does not exist.

Parameters
property:String

The system property name.

defValue:boolean

The default value.

Returns:boolean

The boolean value of the system property, or the default value.

getenvback to summary
public static String getenv(String name)

An extension over System.getenv method. Handles security restrictions, and returns null if the access to the environment variable is restricted.

Parameters
name:String

The environment variable name.

Returns:String

The value of the environment variable, or null.

getenvback to summary
public static Map<String, String> getenv()

An extension over System.getenv method. Handles security restrictions, and returns null if the access to the environment map is restricted.

Returns:Map<String, String>

The map of the environment variables, or null.

getIntback to summary
public static int getInt(String property)

An extension over System.getProperty method that additionally produces an int value. Handles security restrictions, and returns 0 if the access to the property is restricted.

Parameters
property:String

The system property name.

Returns:int

The value of the system property, or the default value.

getIntback to summary
public static int getInt(String property, int defValue)

An extension over System.getProperty method that additionally produces an int value. Handles security restrictions, and returns the default value if the access to the property is restricted.

Parameters
property:String

The system property name.

defValue:int

The default value.

Returns:int

The value of the system property, or the default value.

getPropertyback to summary
public static String getProperty(String property)

An extension over System.getProperty method. Handles security restrictions, and returns null if the access to the property is restricted.

Parameters
property:String

The system property name.

Returns:String

The value of the system property, or the default value.

getPropertyback to summary
public static String getProperty(String property, String defValue)

An extension over System.getProperty method. Handles security restrictions, and returns the default value if the access to the property is restricted.

Parameters
property:String

The system property name.

defValue:String

The default value.

Returns:String

The value of the system property, or the default value.

isSecurityProtectedback to summary
public static boolean isSecurityProtected(String property)

Returns true if the access to the system property is restricted (i.e., when System.getProperty() throws SecurityException).

Parameters
property:String

The system property name.

Returns:boolean

true if the access is restricted, false otherwise.