Search in sources :

Example 16 with AdminClient

use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient 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 AdminClient

use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient in project OA4MP by ncsa.

the class DDServerTests method getAdminClient.

protected AdminClient getAdminClient(AdminClientStore store) {
    AdminClient adminClient = (AdminClient) store.create();
    String random = getRandom(8);
    adminClient.setSecret(getRandom(64));
    adminClient.setName("Test admin client " + random);
    adminClient.setEmail("bob@" + random + ".foo.bar");
    adminClient.setVirtualOrganization("VO=" + getRandom(64));
    adminClient.setIssuer("Issuer=" + random);
    store.save(adminClient);
    return adminClient;
}
Also used : AdminClient(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient)

Example 18 with AdminClient

use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient in project OA4MP by ncsa.

the class PermissionServerTest method addClient.

/**
 * Adds a client to the permissions of an admin.
 *
 * @param tp2
 * @throws Exception
 */
public void addClient(CMTestStoreProvider tp2) throws Exception {
    AdminClient adminClient = getAdminClient(tp2.getAdminClientStore());
    OA2Client client = getOa2Client(tp2.getClientStore());
    PermissionServer permissionServer = new PermissionServer(tp2.getCOSE());
    AddClientRequest req = RequestFactory.createRequest(adminClient, new TypePermission(), new ActionAdd(), client, null);
    // AddClientRequest req = new AddClientRequest(adminClient, client);
    AddClientResponse response = (AddClientResponse) permissionServer.process(req);
    PermissionList permissionList = tp2.getPermissionStore().get(adminClient.getIdentifier(), client.getIdentifier());
    try {
        permissionList.canApprove();
        permissionList.canCreate();
        permissionList.canDelete();
        permissionList.canRead();
        permissionList.canWrite();
    } catch (Throwable t) {
        assert false : "failed to have correct permissions";
    }
}
Also used : OA2Client(edu.uiuc.ncsa.security.oauth_2_0.OA2Client) PermissionList(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.PermissionList) TypePermission(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypePermission) ActionAdd(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.actions.ActionAdd) AdminClient(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient)

Example 19 with AdminClient

use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient in project OA4MP by ncsa.

the class PermissionTest method testPermission.

public void testPermission(PermissionsStore pStore, ClientStore clientStore, AdminClientStore acStore) throws Exception {
    AdminClient ac = (AdminClient) acStore.create();
    OA2Client c = (OA2Client) clientStore.create();
    Permission p = (Permission) pStore.create();
    p.setAdminID(ac.getIdentifier());
    p.setClientID(c.getIdentifier());
    pStore.save(p);
    assert pStore.hasEntry(ac.getIdentifier(), c.getIdentifier());
    List<Identifier> adminIds = pStore.getAdmins(c.getIdentifier());
    assert adminIds.contains(ac.getIdentifier());
    List<Identifier> clientIDs = pStore.getClients(ac.getIdentifier());
    assert clientIDs.contains(c.getIdentifier());
    // now to ttest for multiple additions
    pStore.save(p);
    pStore.save(p);
    assert pStore.getAdmins(c.getIdentifier()).size() == 1;
    assert pStore.getClients(ac.getIdentifier()).size() == 1;
    OA2Client c1 = (OA2Client) clientStore.create();
    Permission p1 = (Permission) pStore.create();
    p1.setApprove(false);
    p1.setAdminID(ac.getIdentifier());
    p1.setClientID(c1.getIdentifier());
    pStore.save(p1);
    assert pStore.getAdmins(c1.getIdentifier()).size() == 1;
    assert pStore.getClients(ac.getIdentifier()).size() == 2;
}
Also used : OA2Client(edu.uiuc.ncsa.security.oauth_2_0.OA2Client) Identifier(edu.uiuc.ncsa.security.core.Identifier) Permission(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.Permission) AdminClient(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient)

Example 20 with AdminClient

use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient in project OA4MP by ncsa.

the class PermissionTest method testIDs.

public void testIDs(PermissionsStore pStore, ClientStore clientStore, AdminClientStore acStore) throws Exception {
    AdminClient ac = (AdminClient) acStore.create();
    AdminClient ac2 = (AdminClient) acStore.create();
    OA2Client c = (OA2Client) clientStore.create();
    Permission p = (Permission) pStore.create();
    p.setAdminID(ac.getIdentifier());
    p.setClientID(c.getIdentifier());
    pStore.save(p);
    p.setAdminID(ac2.getIdentifier());
    System.out.println(p);
    pStore.save(p);
    Permission p2 = (Permission) pStore.get(p.getIdentifier());
    assert p2.getAdminID().equals(ac2.getIdentifier());
    assert pStore.hasEntry(ac2.getIdentifier(), c.getIdentifier());
    assert !pStore.hasEntry(ac.getIdentifier(), c.getIdentifier());
}
Also used : OA2Client(edu.uiuc.ncsa.security.oauth_2_0.OA2Client) Permission(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.Permission) AdminClient(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient)

Aggregations

AdminClient (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient)20 Permission (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.Permission)5 Identifier (edu.uiuc.ncsa.security.core.Identifier)4 OA2Client (edu.uiuc.ncsa.security.oauth_2_0.OA2Client)4 TypePermission (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypePermission)3 ColumnMap (edu.uiuc.ncsa.security.storage.sql.internals.ColumnMap)3 JSONObject (net.sf.json.JSONObject)3 AdminClientKeys (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClientKeys)2 PermissionList (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.PermissionList)2 PrintWriter (java.io.PrintWriter)2 LinkedList (java.util.LinkedList)2 OA2SE (edu.uiuc.ncsa.myproxy.oa4mp.oauth2.OA2SE)1 AddClientRequest (edu.uiuc.ncsa.myproxy.oa4mp.oauth2.cm.util.permissions.AddClientRequest)1 PermissionServer (edu.uiuc.ncsa.myproxy.oa4mp.oauth2.cm.util.permissions.PermissionServer)1 ActionAdd (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.actions.ActionAdd)1 ActionList (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.actions.ActionList)1 TypeClient (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypeClient)1 GeneralException (edu.uiuc.ncsa.security.core.exceptions.GeneralException)1 BasicIdentifier (edu.uiuc.ncsa.security.core.util.BasicIdentifier)1 ClientApproval (edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval)1