Search in sources :

Example 1 with ConfigurationLoader

use of edu.uiuc.ncsa.security.core.util.ConfigurationLoader in project OA4MP by ncsa.

the class CopyTool method getEnv.

protected ServiceEnvironmentImpl getEnv(String cfgFileOption, String cfgNameOption) {
    if (getCommandLine().getOptionValue(SOURCE_CONFIG_NAME_OPTION).equals(getCommandLine().getOptionValue(TARGET_CONFIG_NAME_OPTION))) {
        throw new MyConfigurationException("Error! You have specified that source and target as the same.");
    }
    String fileName = getCommandLine().getOptionValue(cfgFileOption);
    if (fileName == null) {
        fileName = getCommandLine().getOptionValue(SOURCE_CONFIG_FILE_OPTION);
    }
    String configName = getCommandLine().getOptionValue(cfgNameOption);
    sayv("loading configuration \"" + (configName == null ? "(none)" : configName) + "\" from file " + fileName);
    ConfigurationNode node = ConfigUtil.findConfiguration(fileName, getCommandLine().getOptionValue(cfgNameOption), OA4MPConfigTags.COMPONENT);
    // override the logging in the configuration file, since that might be remote.
    ConfigurationLoader loader = null;
    setConfigurationNode(node);
    try {
        loader = getLoader();
    } catch (Exception e) {
        throw new GeneralException("Error: Could not get loader", e);
    }
    // new CILogonConfigurationLoader(node, getMyLogger());
    ServiceEnvironmentImpl env = (ServiceEnvironmentImpl) loader.load();
    return env;
}
Also used : MyConfigurationException(edu.uiuc.ncsa.security.core.exceptions.MyConfigurationException) GeneralException(edu.uiuc.ncsa.security.core.exceptions.GeneralException) ConfigurationNode(org.apache.commons.configuration.tree.ConfigurationNode) ConfigurationLoader(edu.uiuc.ncsa.security.core.util.ConfigurationLoader) OA4MPConfigurationLoader(edu.uiuc.ncsa.myproxy.oa4mp.loader.OA4MPConfigurationLoader) MyConfigurationException(edu.uiuc.ncsa.security.core.exceptions.MyConfigurationException) GeneralException(edu.uiuc.ncsa.security.core.exceptions.GeneralException)

Example 2 with ConfigurationLoader

use of edu.uiuc.ncsa.security.core.util.ConfigurationLoader in project OA4MP by ncsa.

the class AbstractClientBootstrapper method getConfigurationLoader.

@Override
public ConfigurationLoader getConfigurationLoader(ServletContext servletContext) throws Exception {
    MyLoggingFacade logger = new MyLoggingFacade(getClass().getSimpleName());
    logger.info("Starting to load configuration");
    try {
        ConfigurationLoader x = getConfigurationLoader(ServletConfigUtil.findConfigurationNode(servletContext, getOa4mpConfigFileKey(), getOa4mpConfigNameKey(), ClientXMLTags.COMPONENT));
        logger.info("Loaded configuration named " + servletContext.getInitParameter(getOa4mpConfigNameKey()) + " from file " + servletContext.getInitParameter(getOa4mpConfigFileKey()));
        return x;
    } catch (MyConfigurationException ce) {
        logger.info("Did not find a configuration via the servlet context:" + ce.getMessage());
    }
    logger.info("No configuration found in servlet context. Trying default locations");
    // That didn't work, so try to look for it in a few other places.
    String configName = servletContext.getInitParameter(getOa4mpConfigNameKey());
    ConfigurationLoader loader = loadFromDefaultLocations(logger, configName);
    if (loader != null) {
        return loader;
    }
    MyConfigurationException cx = new MyConfigurationException("Error: No configuration found anyplace. OA4MP client startup aborted!");
    logger.error(cx);
    throw cx;
}
Also used : MyLoggingFacade(edu.uiuc.ncsa.security.core.util.MyLoggingFacade) MyConfigurationException(edu.uiuc.ncsa.security.core.exceptions.MyConfigurationException) ConfigurationLoader(edu.uiuc.ncsa.security.core.util.ConfigurationLoader)

Aggregations

MyConfigurationException (edu.uiuc.ncsa.security.core.exceptions.MyConfigurationException)2 ConfigurationLoader (edu.uiuc.ncsa.security.core.util.ConfigurationLoader)2 OA4MPConfigurationLoader (edu.uiuc.ncsa.myproxy.oa4mp.loader.OA4MPConfigurationLoader)1 GeneralException (edu.uiuc.ncsa.security.core.exceptions.GeneralException)1 MyLoggingFacade (edu.uiuc.ncsa.security.core.util.MyLoggingFacade)1 ConfigurationNode (org.apache.commons.configuration.tree.ConfigurationNode)1