Search in sources :

Example 1 with ConfigurationNode

use of org.apache.commons.configuration.tree.ConfigurationNode in project OA4MP by ncsa.

the class AbstractConfigurationLoader method getAuthorizationServletConfig.

public AuthorizationServletConfig getAuthorizationServletConfig() {
    if (authorizationServletConfig == null) {
        List kids = cn.getChildren(OA4MPConfigTags.AUTHORIZATION_SERVLET);
        String headFieldName = null;
        boolean requiredHeader = false;
        boolean useheader = false;
        boolean showLogon = true;
        boolean verifyUsername = true;
        boolean returnDnAsUsername = false;
        boolean convertDNToGlobusID = false;
        String authorizationURI = null;
        if (!kids.isEmpty()) {
            ConfigurationNode sn = (ConfigurationNode) kids.get(0);
            try {
                // implicitly uses the fact that null (so missing parameter) parses to false.
                authorizationURI = getFirstAttribute(sn, OA4MPConfigTags.AUTHORIZATION_SERVLET_URI);
                useheader = getCfgBoolean(sn, OA4MPConfigTags.AUTHORIZATION_SERVLET_HEADER_USE, useheader);
                requiredHeader = getCfgBoolean(sn, OA4MPConfigTags.AUTHORIZATION_SERVLET_HEADER_REQUIRE, requiredHeader);
                headFieldName = getFirstAttribute(sn, OA4MPConfigTags.AUTHORIZATION_SERVLET_HEADER_FIELD_NAME);
                returnDnAsUsername = getCfgBoolean(sn, OA4MPConfigTags.AUTHORIZATION_SERVLET_RETURN_DN_AS_USERNAME, returnDnAsUsername);
                showLogon = getCfgBoolean(sn, OA4MPConfigTags.AUTHORIZATION_SERVLET_SHOW_LOGON, showLogon);
                verifyUsername = getCfgBoolean(sn, OA4MPConfigTags.AUTHORIZATION_SERVLET_VERIFY_USERNAME, verifyUsername);
                convertDNToGlobusID = getCfgBoolean(sn, OA4MPConfigTags.CONVERT_DN_TO_GLOBUS_ID, convertDNToGlobusID);
            } catch (Throwable t) {
                info("Error loading authorization configuration. Disabling use of headers");
            }
        }
        authorizationServletConfig = new AuthorizationServletConfig(authorizationURI, useheader, requiredHeader, headFieldName, returnDnAsUsername, showLogon, verifyUsername, convertDNToGlobusID);
    }
    return authorizationServletConfig;
}
Also used : ConfigurationNode(org.apache.commons.configuration.tree.ConfigurationNode) List(java.util.List)

Example 2 with ConfigurationNode

use of org.apache.commons.configuration.tree.ConfigurationNode in project OA4MP by ncsa.

the class MyProxyConfigurationLoader method getMyProxyFacadeProvider.

protected LinkedList<MyProxyFacadeProvider> getMyProxyFacadeProvider() {
    if (mfp == null) {
        mfp = new LinkedList<MyProxyFacadeProvider>();
        // This is the global default for all instances. It can be overridden below.
        String defaultDN = Configurations.getFirstAttribute(cn, MYPROXY_SERVER_DN);
        if (0 < cn.getChildrenCount(OA4MPConfigTags.MYPROXY)) {
            List kids = cn.getChildren(OA4MPConfigTags.MYPROXY);
            for (int i = 0; i < kids.size(); i++) {
                ConfigurationNode currentNode = (ConfigurationNode) kids.get(i);
                // Fix for CIL-196.
                String currentDN = getFirstAttribute(currentNode, MYPROXY_SERVER_DN);
                mfp.add(new MyProxyFacadeProvider(((ConfigurationNode) kids.get(i)), (currentDN == null ? defaultDN : currentDN)));
            }
        } else {
            // set up with defaults
            mfp.add(new MyProxyFacadeProvider());
        }
    }
    return mfp;
}
Also used : ConfigurationNode(org.apache.commons.configuration.tree.ConfigurationNode) MyProxyFacadeProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.MyProxyFacadeProvider) List(java.util.List) LinkedList(java.util.LinkedList)

Example 3 with ConfigurationNode

use of org.apache.commons.configuration.tree.ConfigurationNode in project OA4MP by ncsa.

the class MyProxyFacadeProvider method get.

@Override
public MyProxyServiceFacade get() {
    ServiceFacadeConfiguration sfc;
    HashMap<String, Integer> loas = new HashMap<String, Integer>();
    String localhostname = null;
    String serverDN = null;
    try {
        localhostname = java.net.InetAddress.getLocalHost().getCanonicalHostName();
    } catch (UnknownHostException e) {
        localhostname = "localhost";
    }
    // start with default port.
    int port = 7512;
    // start with default
    long socketTimeout = 0L;
    if (getConfig() == null) {
        // No configuration, so use the defaults.
        sfc = new ServiceFacadeConfiguration(localhostname, port, socketTimeout, loas, serverDN);
    // return new MyProxyServiceFacade(sfc);
    } else {
        serverDN = getAttribute(MYPROXY_SERVER_DN);
        if (serverDN == null && hasDefaultServerDN()) {
            serverDN = getDefaultServerDN();
        }
        try {
            port = getIntAttribute(MYPROXY_PORT);
        } catch (Throwable t) {
        // do nothing. If the port is not given, use the default
        }
        try {
            socketTimeout = getIntAttribute(MYPROXY_SOCKET_TIMEOUT);
        } catch (Throwable t) {
        // do nix.
        }
        if (getAttribute(MYPROXY_HOST) != null) {
            localhostname = getAttribute(MYPROXY_HOST);
        }
        sfc = new ServiceFacadeConfiguration(localhostname, port, socketTimeout, loas, serverDN);
        List list = getConfig().getChildren(MYPROXY_LOA);
        if (!list.isEmpty()) {
            for (Object obj : list) {
                ConfigurationNode cn = (ConfigurationNode) obj;
                loas.put(Configurations.getFirstAttribute(cn, MYPROXY_LOA_NAME), Integer.parseInt(Configurations.getFirstAttribute(cn, MYPROXY_LOA_PORT)));
            }
        }
    }
    // Unless there is something very exotic about your setup, a basic configuration that
    // points to the standard keystore available in java should be more than sufficient.
    SSLKeystoreConfiguration sslKeystoreConfiguration = SSLConfigurationUtil.getSSLConfiguration(null, getConfig());
    return new MyProxyServiceFacade(sfc, sslKeystoreConfiguration);
}
Also used : UnknownHostException(java.net.UnknownHostException) HashMap(java.util.HashMap) SSLKeystoreConfiguration(edu.uiuc.ncsa.security.util.ssl.SSLKeystoreConfiguration) ServiceFacadeConfiguration(edu.uiuc.ncsa.myproxy.ServiceFacadeConfiguration) ConfigurationNode(org.apache.commons.configuration.tree.ConfigurationNode) MyProxyServiceFacade(edu.uiuc.ncsa.myproxy.MyProxyServiceFacade) List(java.util.List)

Example 4 with ConfigurationNode

use of org.apache.commons.configuration.tree.ConfigurationNode in project OA4MP by ncsa.

the class ClientConfigTest method testConfig.

@Test
public void testConfig() throws Exception {
    ConfigurationNode cn = getConfig("sample");
    say("id = " + Configurations.getNodeValue(cn, "id"));
    printNodes(cn);
}
Also used : ConfigurationNode(org.apache.commons.configuration.tree.ConfigurationNode) ConfigTest(edu.uiuc.ncsa.security.core.configuration.ConfigTest) Test(org.junit.Test)

Example 5 with ConfigurationNode

use of org.apache.commons.configuration.tree.ConfigurationNode 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)

Aggregations

ConfigurationNode (org.apache.commons.configuration.tree.ConfigurationNode)13 ConfigTest (edu.uiuc.ncsa.security.core.configuration.ConfigTest)4 List (java.util.List)4 Test (org.junit.Test)4 File (java.io.File)3 GeneralException (edu.uiuc.ncsa.security.core.exceptions.GeneralException)2 MyConfigurationException (edu.uiuc.ncsa.security.core.exceptions.MyConfigurationException)2 MyLoggingFacade (edu.uiuc.ncsa.security.core.util.MyLoggingFacade)2 MySQLConnectionPoolProvider (edu.uiuc.ncsa.security.storage.sql.mysql.MySQLConnectionPoolProvider)2 PGConnectionPoolProvider (edu.uiuc.ncsa.security.storage.sql.postgres.PGConnectionPoolProvider)2 XMLConfiguration (org.apache.commons.configuration.XMLConfiguration)2 MyProxyServiceFacade (edu.uiuc.ncsa.myproxy.MyProxyServiceFacade)1 ServiceFacadeConfiguration (edu.uiuc.ncsa.myproxy.ServiceFacadeConfiguration)1 OA4MPConfigurationLoader (edu.uiuc.ncsa.myproxy.oa4mp.loader.OA4MPConfigurationLoader)1 ClientApprovalProvider (edu.uiuc.ncsa.myproxy.oa4mp.server.ClientApprovalProvider)1 MyProxyFacadeProvider (edu.uiuc.ncsa.myproxy.oa4mp.server.MyProxyFacadeProvider)1 OA4MPIdentifierProvider (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.transactions.OA4MPIdentifierProvider)1 MultiDSClientApprovalStoreProvider (edu.uiuc.ncsa.myproxy.oa4mp.server.storage.MultiDSClientApprovalStoreProvider)1 MultiDSClientStoreProvider (edu.uiuc.ncsa.myproxy.oa4mp.server.storage.MultiDSClientStoreProvider)1 DSFSClientApprovalStoreProvider (edu.uiuc.ncsa.myproxy.oa4mp.server.storage.filestore.DSFSClientApprovalStoreProvider)1