use of edu.uiuc.ncsa.security.delegation.storage.Client in project OA4MP by ncsa.
the class DDServerTests method getClient.
protected Client getClient(ClientStore store) {
Client c = (Client) store.create();
String random = getRandom(8);
c.setSecret(getRandom(64));
c.setProxyLimited(true);
c.setHomeUri("https://baz.foo.edu/" + random + "/home");
c.setErrorUri("https://baz.foo.edu/home/" + random + "/error");
c.setProxyLimited(false);
c.setEmail("bob@" + random + ".foo.bar");
c.setName("Test client " + random);
return c;
}
use of edu.uiuc.ncsa.security.delegation.storage.Client 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 edu.uiuc.ncsa.security.delegation.storage.Client in project OA4MP by ncsa.
the class TransactionStoreTest method testServiceTransaction.
@Test
public void testServiceTransaction() throws Exception {
OA4MPServiceTransaction OA4MPServiceTransaction = (OA4MPServiceTransaction) getStore().create();
OA4MPServiceTransaction.setCallback(URI.create("http://callback"));
// set lifetime to 10 hours (stored in ms!)
OA4MPServiceTransaction.setLifetime(10 * 60 * 60 * 1000);
OA4MPServiceTransaction.setUsername("FakeUserName");
String mpUN = "myproxy username /with weird $$#@ in=it/#" + System.nanoTime();
OA4MPServiceTransaction.setMyproxyUsername(mpUN);
Client client = getTSProvider().getClientStore().create();
client.setIdentifier(new BasicIdentifier(URI.create("test:client:1d/" + System.currentTimeMillis())));
OA4MPServiceTransaction.setAuthorizationGrant(newAG());
OA4MPServiceTransaction.setAuthGrantValid(false);
client.setName("service test name #" + System.nanoTime());
getStore().save(OA4MPServiceTransaction);
assert getStore().containsKey(OA4MPServiceTransaction.getIdentifier());
assert OA4MPServiceTransaction.equals(getStore().get(OA4MPServiceTransaction.getIdentifier()));
assert OA4MPServiceTransaction.equals(getStore().get(OA4MPServiceTransaction.getAuthorizationGrant()));
// now emulate doing oauth type transactions with it.
// First leg sets the verifier and user
String r = getRandomString(12);
OA4MPServiceTransaction.setVerifier(newVerifier());
getStore().save(OA4MPServiceTransaction);
assert OA4MPServiceTransaction.equals(getStore().get(OA4MPServiceTransaction.getVerifier()));
// next leg creates the access tokens and invalidates the temp credentials
OA4MPServiceTransaction.setAccessToken(newAT());
OA4MPServiceTransaction.setAuthGrantValid(false);
OA4MPServiceTransaction.setAccessTokenValid(true);
getStore().save(OA4MPServiceTransaction);
assert OA4MPServiceTransaction.equals(getStore().get(OA4MPServiceTransaction.getIdentifier()));
assert OA4MPServiceTransaction.equals(getStore().get(OA4MPServiceTransaction.getAccessToken()));
OA4MPServiceTransaction.setAccessTokenValid(false);
getStore().save(OA4MPServiceTransaction);
assert OA4MPServiceTransaction.equals(getStore().get(OA4MPServiceTransaction.getIdentifier()));
// and we're done
getStore().remove(OA4MPServiceTransaction.getIdentifier());
assert !getStore().containsKey(OA4MPServiceTransaction.getIdentifier());
}
use of edu.uiuc.ncsa.security.delegation.storage.Client in project OA4MP by ncsa.
the class CAStoreTest method testApprovalCycle.
@Test
public void testApprovalCycle() throws Exception {
assert !getApprovalStore().isApproved(BasicIdentifier.newID("foo:bar:baz://" + getRandomString(32)));
Client client = getClientStore().create();
Identifier identifier = client.getIdentifier();
client.setHomeUri("urn:test:/home/uri/" + getRandomString(32));
client.setSecret(getRandomString(256));
client.setName("Test client" + getRandomString(32));
client.setEmail(getRandomString(32) + "@email.foo.edu");
client.setErrorUri("uri:test:/uh/oh/uri/" + getRandomString(32));
getClientStore().save(client);
ClientApproval ca = getApprovalStore().create();
ca.setApprover("test-approver");
ca.setApproved(false);
ca.setApprovalTimestamp(new Date());
ca.setIdentifier(identifier);
getApprovalStore().save(ca);
assert !getApprovalStore().get(client.getIdentifier()).isApproved();
assert !getApprovalStore().isApproved(identifier);
ca.setApproved(true);
getApprovalStore().save(ca);
// Regression test to be sure that identifiers are never changed.
assert identifier.equals(ca.getIdentifier());
assert identifier.equals(client.getIdentifier());
assert getApprovalStore().get(client.getIdentifier()).isApproved();
assert getApprovalStore().isApproved(identifier);
getApprovalStore().remove(client.getIdentifier());
getClientStore().remove(client.getIdentifier());
}
use of edu.uiuc.ncsa.security.delegation.storage.Client in project OA4MP by ncsa.
the class CAStoreTest method testApprovalStore.
@Test
public void testApprovalStore() throws Exception {
// put one in, get it back, make sure it matches.
Client client = getClientStore().create();
client.setHomeUri("urn:test:/home/uri/" + getRandomString(32));
client.setSecret(getRandomString(256));
client.setName("Test client" + getRandomString(32));
client.setEmail(getRandomString(32) + "@email.foo.edu");
client.setErrorUri("uri:test:/uh/oh/uri/" + getRandomString(32));
getClientStore().save(client);
ClientApproval ca = getApprovalStore().create();
ca.setApprover("test-approver");
ca.setApproved(true);
ca.setApprovalTimestamp(new Date());
ca.setIdentifier(client.getIdentifier());
getApprovalStore().save(ca);
ClientApproval ca1 = getApprovalStore().get(ca.getIdentifier());
assert ca.equals(ca1);
getApprovalStore().remove(ca.getIdentifier());
}
Aggregations