Search in sources :

Example 6 with ConfigurationNode

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

the class ServiceConfigTest method testClientApprovalStoreProvider.

public void testClientApprovalStoreProvider() throws Exception {
    ConfigurationNode cn = getConfig("postgresql config");
    MultiDSClientApprovalStoreProvider dap = new MultiDSClientApprovalStoreProvider(cn, true, new MyLoggingFacade("test"), null, null);
    ClientApproverConverter cp = new ClientApproverConverter(new ClientApprovalProvider());
    dap.addListener(new DSFSClientApprovalStoreProvider(cn, cp));
    dap.addListener(new DSSQLClientApprovalStoreProvider(cn, new MySQLConnectionPoolProvider("oauth", "oauth"), MYSQL_STORE, cp));
    dap.addListener(new DSSQLClientApprovalStoreProvider(cn, new PGConnectionPoolProvider("oauth", "oauth"), POSTGRESQL_STORE, cp));
    ClientApprovalStore<ClientApproval> as = (ClientApprovalStore<ClientApproval>) dap.get();
}
Also used : MultiDSClientApprovalStoreProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.storage.MultiDSClientApprovalStoreProvider) MyLoggingFacade(edu.uiuc.ncsa.security.core.util.MyLoggingFacade) MySQLConnectionPoolProvider(edu.uiuc.ncsa.security.storage.sql.mysql.MySQLConnectionPoolProvider) PGConnectionPoolProvider(edu.uiuc.ncsa.security.storage.sql.postgres.PGConnectionPoolProvider) ClientApproval(edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval) ConfigurationNode(org.apache.commons.configuration.tree.ConfigurationNode) DSFSClientApprovalStoreProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.storage.filestore.DSFSClientApprovalStoreProvider) ClientApproverConverter(edu.uiuc.ncsa.myproxy.oa4mp.server.util.ClientApproverConverter) ClientApprovalStore(edu.uiuc.ncsa.security.delegation.server.storage.ClientApprovalStore) ClientApprovalProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.ClientApprovalProvider) DSSQLClientApprovalStoreProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.storage.sql.provider.DSSQLClientApprovalStoreProvider)

Example 7 with ConfigurationNode

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

the class OA2ConfigurationLoader method getJSONWebKeys.

protected JSONWebKeys getJSONWebKeys() {
    ConfigurationNode node = getFirstNode(cn, "JSONWebKey");
    if (node == null) {
        warn("Error: No signing keys in the configuration file. Signing is not available");
        // throw new IllegalStateException();
        return new JSONWebKeys(null);
    }
    // if the whole thing is included
    String json = getNodeValue(node, "json", null);
    JSONWebKeys keys = null;
    try {
        if (json != null) {
            keys = JSONWebKeyUtil.fromJSON(json);
        }
        // points to a file that contains it all
        String path = getNodeValue(node, "path", null);
        if (path != null) {
            keys = JSONWebKeyUtil.fromJSON(new File(path));
        }
    } catch (Throwable t) {
        throw new GeneralException("Error reading signing keys", t);
    }
    if (keys == null) {
        throw new IllegalStateException("Error: Could not load signing keys");
    }
    keys.setDefaultKeyID(getFirstAttribute(node, "defaultKeyID"));
    return keys;
}
Also used : GeneralException(edu.uiuc.ncsa.security.core.exceptions.GeneralException) ConfigurationNode(org.apache.commons.configuration.tree.ConfigurationNode) JSONWebKeys(edu.uiuc.ncsa.security.util.jwk.JSONWebKeys) File(java.io.File)

Example 8 with ConfigurationNode

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

the class ServiceConfigTest method testConfig.

@Test
public void testConfig() throws Exception {
    XMLConfiguration c = getConfiguration();
    Iterator iterator = c.getKeys();
    say("echoing configuration to console:");
    ConfigurationNode root = c.getRootNode();
    say("name of root = " + root.getName());
    say("child count = " + root.getChildren().size());
    while (iterator.hasNext()) {
        String key = iterator.next().toString();
        say("(k, v)=(" + key + ", " + c.getString(key) + ")");
    }
    SubnodeConfiguration mailC = c.configurationAt("service.mail");
    say("mail configured? " + mailC.getString("[@enabled]"));
}
Also used : SubnodeConfiguration(org.apache.commons.configuration.SubnodeConfiguration) XMLConfiguration(org.apache.commons.configuration.XMLConfiguration) ConfigurationNode(org.apache.commons.configuration.tree.ConfigurationNode) Iterator(java.util.Iterator) ConfigTest(edu.uiuc.ncsa.security.core.configuration.ConfigTest) Test(org.junit.Test)

Example 9 with ConfigurationNode

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

the class ServiceConfigTest method testClientStoreProvider.

/**
 * Just reads in the configuration and calls "get" on the provider. This should work if the
 * configuration file is read.
 * @throws Exception
 */
@Test
public void testClientStoreProvider() throws Exception {
    ConfigurationNode cn = getConfig("mixed config");
    ClientProvider clientProvider = new ClientProvider(new OA4MPIdentifierProvider(OA4MPIdentifierProvider.CLIENT_ID));
    MultiDSClientStoreProvider csp = new MultiDSClientStoreProvider(cn, true, new MyLoggingFacade("test"), null, null, clientProvider);
    ClientConverter converter = new ClientConverter(clientProvider);
    csp.addListener(new DSFSClientStoreProvider(cn, converter, clientProvider));
    csp.addListener(new DSClientSQLStoreProvider(cn, new MySQLConnectionPoolProvider("oauth", "oauth"), MYSQL_STORE, converter, clientProvider));
    csp.addListener(new DSClientSQLStoreProvider(cn, new PGConnectionPoolProvider("oauth", "oauth"), POSTGRESQL_STORE, converter, clientProvider));
    ClientStore<Client> cs = (ClientStore<Client>) csp.get();
}
Also used : MultiDSClientStoreProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.storage.MultiDSClientStoreProvider) ClientConverter(edu.uiuc.ncsa.security.delegation.storage.impl.ClientConverter) PGConnectionPoolProvider(edu.uiuc.ncsa.security.storage.sql.postgres.PGConnectionPoolProvider) ClientProvider(edu.uiuc.ncsa.security.delegation.storage.ClientProvider) DSFSClientStoreProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.storage.filestore.DSFSClientStoreProvider) MyLoggingFacade(edu.uiuc.ncsa.security.core.util.MyLoggingFacade) MySQLConnectionPoolProvider(edu.uiuc.ncsa.security.storage.sql.mysql.MySQLConnectionPoolProvider) ClientStore(edu.uiuc.ncsa.security.delegation.server.storage.ClientStore) DSClientSQLStoreProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.storage.sql.provider.DSClientSQLStoreProvider) OA4MPIdentifierProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.transactions.OA4MPIdentifierProvider) ConfigurationNode(org.apache.commons.configuration.tree.ConfigurationNode) Client(edu.uiuc.ncsa.security.delegation.storage.Client) ConfigTest(edu.uiuc.ncsa.security.core.configuration.ConfigTest) Test(org.junit.Test)

Example 10 with ConfigurationNode

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

the class ServiceConfigTest method testServerConfig.

@Test
public void testServerConfig() throws Exception {
    // tests getting the configuration and the new providers. A sample test file is in src/main/resources.
    ConfigurationNode zzz = getConfiguration().getRootNode();
    TestProvider service = new TestProvider(getConfig("mixed config"));
    TestProvider fsp = new TestProvider(service.getConfigurationAt(FILE_STORE));
    TestProvider mail = new TestProvider(service.getConfigurationAt(MAIL));
    assert mail.getBooleanAttribute("enabled");
    assert fsp.isA(FILE_STORE) : "NOT a filestore!";
    assert !fsp.isA(MYSQL_STORE) : "Is a mysql store and should not be";
    assert !fsp.hasA(CLIENT_APPROVAL_STORE) : "Should NOT provide client approvals and it does";
    assert fsp.hasA(TRANSACTIONS_STORE) : "Should provide transactions";
}
Also used : ConfigurationNode(org.apache.commons.configuration.tree.ConfigurationNode) ConfigTest(edu.uiuc.ncsa.security.core.configuration.ConfigTest) Test(org.junit.Test)

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