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();
}
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;
}
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]"));
}
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();
}
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";
}
Aggregations