/*
 * $Id: GetPropertyAction.java,v 1.1 2004/03/14 09:20:08 epr Exp $
 */
package gnu.java.security.actions;

import java.security.PrivilegedAction;


/**
 * Utility class for getting properties in a privileged action.
 * 
 * @author Ewout Prangsma (epr@users.sourceforge.net)
 */
public class GetPropertyAction implements PrivilegedAction {
    
    private final String key;
    private final String defaultValue;
    
    /**
     * Initialize this instance.
     * @param key
     */
    public GetPropertyAction(String key) {
        this(key, null);
    }
    
    /**
     * Initialize this instance.
     * @param key
     */
    public GetPropertyAction(String key, String defaultValue) {
        this.key = key;
        this.defaultValue = defaultValue;
    }
    
    /**
     * Get the property
     * @see java.security.PrivilegedAction#run()
     */
    public Object run() {
        return System.getProperty(key, defaultValue);
    }
}
