Search in sources :

Example 16 with ClientApproval

use of edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval in project OA4MP by ncsa.

the class DDServerTests method setupClients.

protected CC setupClients(CMTestStoreProvider tp2) throws Exception {
    AdminClient adminClient = getAdminClient(tp2.getAdminClientStore());
    ClientApproval clientApproval = tp2.getClientApprovalStore().create();
    clientApproval.setIdentifier(adminClient.getIdentifier());
    clientApproval.setApproved(true);
    clientApproval.setApprover("junit");
    tp2.getClientApprovalStore().save(clientApproval);
    OA2Client client = getOa2Client(tp2.getClientStore());
    PermissionList permissions = tp2.getPermissionStore().get(adminClient.getIdentifier(), client.getIdentifier());
    if (permissions.isEmpty()) {
        Permission p = tp2.getPermissionStore().create();
        p.setAdminID(adminClient.getIdentifier());
        p.setClientID(client.getIdentifier());
        p.setRead(true);
        p.setWrite(true);
        p.setDelete(true);
        p.setApprove(true);
        p.setCreate(true);
        tp2.getPermissionStore().save(p);
    }
    CC cc = new CC();
    cc.adminClient = adminClient;
    cc.client = client;
    return cc;
}
Also used : ClientApproval(edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval) PermissionList(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.PermissionList) Permission(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.Permission) AdminClient(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient)

Example 17 with ClientApproval

use of edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval 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 18 with ClientApproval

use of edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval 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)

Example 19 with ClientApproval

use of edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval in project OA4MP by ncsa.

the class NewCAStoreTest method testApprovalCycle.

public void testApprovalCycle(ClientStore clientStore, ClientApprovalStore caStore) throws Exception {
    assert !caStore.isApproved(BasicIdentifier.newID("foo:bar:baz://" + getRandomString(32)));
    Client client = (Client) clientStore.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));
    clientStore.save(client);
    ClientApproval ca = (ClientApproval) caStore.create();
    ca.setApprover("test-approver");
    ca.setApproved(false);
    ca.setApprovalTimestamp(new Date());
    ca.setIdentifier(identifier);
    caStore.save(ca);
    assert !((ClientApproval) caStore.get(client.getIdentifier())).isApproved();
    assert !caStore.isApproved(identifier);
    ca.setApproved(true);
    caStore.save(ca);
    // Regression test to be sure that identifiers are never changed.
    assert identifier.equals(ca.getIdentifier());
    assert identifier.equals(client.getIdentifier());
    assert ((ClientApproval) caStore.get(client.getIdentifier())).isApproved();
    assert caStore.isApproved(identifier);
    caStore.remove(client.getIdentifier());
    clientStore.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)

Example 20 with ClientApproval

use of edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval in project OA4MP by ncsa.

the class NewCAStoreTest method testPermissions.

public void testPermissions() throws Exception {
    File storeDirectory = File.createTempFile("fs-store", "-tmp");
    File indexDirectory = File.createTempFile("fs-index", "-tmp");
    storeDirectory.setWritable(false);
    indexDirectory.setWritable(false);
    assert !storeDirectory.canWrite();
    FSClientApprovalStore x = null;
    final ClientApprovalProvider caProvider = new ClientApprovalProvider();
    try {
        // Make sure that if someone creates a bad one, it blows up in the constructor.
        x = new FSClientApprovalStore(null, null, null, null) {

            @Override
            public Object put(Object key, Object value) {
                return null;
            }
        };
        assert false : "Could make a new object without being properly configured";
    } catch (MyConfigurationException xx) {
        assert true;
    }
    x = new DSFSClientApprovalStore(storeDirectory, indexDirectory, caProvider, new ClientApproverConverter(caProvider));
    try {
        // should bomb here.
        x.create();
        assert false;
    } catch (FilePermissionsException xx) {
        assert true;
    }
    // so make a new entry and then have retrieving it fail.
    storeDirectory.setWritable(true);
    indexDirectory.setWritable(true);
    ClientApproval ca = (ClientApproval) x.create();
    // fail for store directory un readable
    storeDirectory.setReadable(false);
    try {
        x.get(ca.getIdentifier());
        assert false;
    } catch (FilePermissionsException xx) {
        assert true;
    }
}
Also used : MyConfigurationException(edu.uiuc.ncsa.security.core.exceptions.MyConfigurationException) DSFSClientApprovalStore(edu.uiuc.ncsa.myproxy.oa4mp.server.storage.filestore.DSFSClientApprovalStore) FSClientApprovalStore(edu.uiuc.ncsa.security.delegation.server.storage.impl.FSClientApprovalStore) ClientApproval(edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval) FilePermissionsException(edu.uiuc.ncsa.security.core.exceptions.FilePermissionsException) DSFSClientApprovalStore(edu.uiuc.ncsa.myproxy.oa4mp.server.storage.filestore.DSFSClientApprovalStore) ClientApproverConverter(edu.uiuc.ncsa.myproxy.oa4mp.server.util.ClientApproverConverter) ClientApprovalProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.ClientApprovalProvider) File(java.io.File)

Aggregations

ClientApproval (edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval)26 Client (edu.uiuc.ncsa.security.delegation.storage.Client)6 Date (java.util.Date)5 ClientApprovalProvider (edu.uiuc.ncsa.myproxy.oa4mp.server.ClientApprovalProvider)3 ClientApproverConverter (edu.uiuc.ncsa.myproxy.oa4mp.server.util.ClientApproverConverter)3 Identifier (edu.uiuc.ncsa.security.core.Identifier)3 BasicIdentifier (edu.uiuc.ncsa.security.core.util.BasicIdentifier)3 BaseClient (edu.uiuc.ncsa.security.delegation.storage.BaseClient)3 OA2Client (edu.uiuc.ncsa.security.oauth_2_0.OA2Client)3 LinkedList (java.util.LinkedList)3 TypeClient (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypeClient)2 DSFSClientApprovalStore (edu.uiuc.ncsa.myproxy.oa4mp.server.storage.filestore.DSFSClientApprovalStore)2 FilePermissionsException (edu.uiuc.ncsa.security.core.exceptions.FilePermissionsException)2 GeneralException (edu.uiuc.ncsa.security.core.exceptions.GeneralException)2 MyConfigurationException (edu.uiuc.ncsa.security.core.exceptions.MyConfigurationException)2 ClientApprovalStore (edu.uiuc.ncsa.security.delegation.server.storage.ClientApprovalStore)2 FSClientApprovalStore (edu.uiuc.ncsa.security.delegation.server.storage.impl.FSClientApprovalStore)2 OA2ClientApprovalKeys (edu.uiuc.ncsa.security.oauth_2_0.OA2ClientApprovalKeys)2 File (java.io.File)2 Set (java.util.Set)2