Search in sources :

Example 16 with Client

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;
}
Also used : AdminClient(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient) Client(edu.uiuc.ncsa.security.delegation.storage.Client)

Example 17 with Client

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();
}
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 18 with Client

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());
}
Also used : OA4MPServiceTransaction(edu.uiuc.ncsa.myproxy.oa4mp.server.OA4MPServiceTransaction) BasicIdentifier(edu.uiuc.ncsa.security.core.util.BasicIdentifier) Client(edu.uiuc.ncsa.security.delegation.storage.Client) Test(org.junit.Test)

Example 19 with Client

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());
}
Also used : BasicIdentifier(edu.uiuc.ncsa.security.core.util.BasicIdentifier) Identifier(edu.uiuc.ncsa.security.core.Identifier) ClientApproval(edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval) Client(edu.uiuc.ncsa.security.delegation.storage.Client) Date(java.util.Date) Test(org.junit.Test)

Example 20 with Client

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());
}
Also used : ClientApproval(edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval) Client(edu.uiuc.ncsa.security.delegation.storage.Client) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Client (edu.uiuc.ncsa.security.delegation.storage.Client)26 BasicIdentifier (edu.uiuc.ncsa.security.core.util.BasicIdentifier)8 Test (org.junit.Test)7 ClientApproval (edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval)6 Date (java.util.Date)6 Identifier (edu.uiuc.ncsa.security.core.Identifier)5 OA4MPIdentifierProvider (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.transactions.OA4MPIdentifierProvider)3 OA2ClientMemoryStore (edu.uiuc.ncsa.myproxy.oa4mp.oauth2.storage.OA2ClientMemoryStore)2 OA4MPServiceTransaction (edu.uiuc.ncsa.myproxy.oa4mp.server.OA4MPServiceTransaction)2 UnknownClientException (edu.uiuc.ncsa.security.core.exceptions.UnknownClientException)2 ClientProvider (edu.uiuc.ncsa.security.delegation.storage.ClientProvider)2 ClientConverter (edu.uiuc.ncsa.security.delegation.storage.impl.ClientConverter)2 OA2Client (edu.uiuc.ncsa.security.oauth_2_0.OA2Client)2 OA2ClientConverter (edu.uiuc.ncsa.security.oauth_2_0.OA2ClientConverter)2 OA2ClientProvider (edu.uiuc.ncsa.security.oauth_2_0.OA2ClientProvider)2 JSONObject (net.sf.json.JSONObject)2 OA4MPServiceProvider (edu.uiuc.ncsa.myproxy.oa4mp.client.OA4MPServiceProvider)1 AssetProvider (edu.uiuc.ncsa.myproxy.oa4mp.client.storage.AssetProvider)1 AdminClient (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient)1 MultiDSClientStoreProvider (edu.uiuc.ncsa.myproxy.oa4mp.server.storage.MultiDSClientStoreProvider)1