package mit.login;

import java.util.Properties;
import java.io.*;
import java.util.*;

/**
 * <pre>
 * This class contains the configuration parameters needed by the
 * login server.
 *  mit.cert.veriName      - The Kerberos "name" of a service whose
 *                           key we know (see below) and for which tickets
 * 			     are obtained to verify that we have the
 *			     user's proper password
 *  mit.cert.veriInstance  - The Kerberos Instance for above
 *  mit.cert.verikeyfile   - The file that contains the above's DES key
 *  mit.cert.kdc           - The name of the KDC system
 *  mit.cert.realm	   - The name of the Kerberos realm
 * Properties are loaded from mit.login.loginserver.properties.
 * </pre>
 */

public class Config {
    private static Properties props = null;
    private Config() {};

    static {
	try {
	    InputStream is = Config.class.getResourceAsStream("loginserver.properties");
	    props = new Properties();
	    props.load(is);
	    is.close();
	} catch (Exception e) {
	    e.printStackTrace();
	    System.exit(1);
	}
    }

    /**
     * Fetches the requested property. Returns its second argument
     * if the requested property isn't found in the configuration file
     *
     * @param prop The name of the property (see list above)
     * @param def The default value to use
     * @return The properties value
     */
    public static String getProperty(String prop, String def) {
	String retval = props.getProperty(prop);
	if (retval == null) return (def);
	return (retval);
    }
}
