org.jruby.util
Class SafePropertyAccessor

java.lang.Object
  extended by org.jruby.util.SafePropertyAccessor

public class SafePropertyAccessor
extends java.lang.Object

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


Constructor Summary
SafePropertyAccessor()
           
 
Method Summary
static boolean getBoolean(java.lang.String property)
          An extension over Boolean.getBoolean method.
static boolean getBoolean(java.lang.String property, boolean defValue)
          An extension over Boolean.getBoolean method.
static int getInt(java.lang.String property)
          An extension over System.getProperty method that additionally produces an int value.
static int getInt(java.lang.String property, int defValue)
          An extension over System.getProperty method that additionally produces an int value.
static java.lang.String getProperty(java.lang.String property)
          An extension over System.getProperty method.
static java.lang.String getProperty(java.lang.String property, java.lang.String defValue)
          An extension over System.getProperty method.
static boolean isSecurityProtected(java.lang.String property)
          Returns true if the access to the system property is restricted (i.e., when System.getProperty() throws SecurityException).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SafePropertyAccessor

public SafePropertyAccessor()
Method Detail

getBoolean

public static boolean getBoolean(java.lang.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 - The system property name.
Returns:
The boolean value of the system property.

getBoolean

public static boolean getBoolean(java.lang.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 - The system property name.
defValue - The default value.
Returns:
The boolean value of the system property, or the default value.

getProperty

public static java.lang.String getProperty(java.lang.String property)
An extension over System.getProperty method. Handles security restrictions, and returns null if the access to the property is restricted.

Parameters:
property - The system property name.
Returns:
The value of the system property, or the default value.

getProperty

public static java.lang.String getProperty(java.lang.String property,
                                           java.lang.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 - The system property name.
defValue - The default value.
Returns:
The value of the system property, or the default value.

getInt

public static int getInt(java.lang.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 - The system property name.
Returns:
The value of the system property, or the default value.

getInt

public static int getInt(java.lang.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 - The system property name.
defValue - The default value.
Returns:
The value of the system property, or the default value.

isSecurityProtected

public static boolean isSecurityProtected(java.lang.String property)
Returns true if the access to the system property is restricted (i.e., when System.getProperty() throws SecurityException).

Parameters:
property - The system property name.
Returns:
true if the access is restricted, false otherwise.


Copyright © 2002-2009 JRuby Team. All Rights Reserved.