Search in sources :

Example 1 with TypeClient

use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypeClient in project OA4MP by ncsa.

the class ClientServerTest method testRemove.

public void testRemove(CMTestStoreProvider tp2) throws Exception {
    CC cc = setupClients(tp2);
    // so approve this
    ClientServer server = new ClientServer(tp2.getCOSE());
    ApproveRequest approveRequest = RequestFactory.createRequest(cc.adminClient, new TypeClient(), new ActionApprove(), cc.client, null);
    server.process(approveRequest);
    assert tp2.getClientApprovalStore().containsKey(cc.client.getIdentifier());
    assert tp2.getClientApprovalStore().get(cc.client.getIdentifier()).isApproved();
    assert !tp2.getPermissionStore().get(cc.adminClient.getIdentifier(), cc.client.getIdentifier()).isEmpty();
    AdminClient ac2 = getAdminClient(tp2.getAdminClientStore());
    PermissionServer permissionServer = new PermissionServer(tp2.getCOSE());
    AddClientRequest addClientRequest = RequestFactory.createRequest(ac2, new TypePermission(), new ActionAdd(), cc.client, null);
    permissionServer.process(addClientRequest);
    assert !tp2.getPermissionStore().get(ac2.getIdentifier(), cc.client.getIdentifier()).isEmpty();
    // ok, so now we have a couple of admin clients with permissions on this client and it is approved. Let's
    // see if everything gets cleaned out.
    RemoveRequest removeRequest = RequestFactory.createRequest(cc.adminClient, new TypeClient(), new ActionRemove(), cc.client, null);
    server.process(removeRequest);
    assert !tp2.getClientStore().containsKey(cc.client.getIdentifier());
    assert !tp2.getClientApprovalStore().containsKey(cc.client.getIdentifier());
    assert tp2.getPermissionStore().get(cc.adminClient.getIdentifier(), cc.client.getIdentifier()).isEmpty();
    assert tp2.getPermissionStore().get(ac2.getIdentifier(), cc.client.getIdentifier()).isEmpty();
}
Also used : PermissionServer(edu.uiuc.ncsa.myproxy.oa4mp.oauth2.cm.util.permissions.PermissionServer) TypeClient(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypeClient) TypePermission(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypePermission) AdminClient(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient) AddClientRequest(edu.uiuc.ncsa.myproxy.oa4mp.oauth2.cm.util.permissions.AddClientRequest)

Example 2 with TypeClient

use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypeClient in project OA4MP by ncsa.

the class ClientServerTest method testApprove.

public void testApprove(CMTestStoreProvider tp2) throws Exception {
    CC cc = setupClients(tp2);
    ApproveRequest req = RequestFactory.createRequest(cc.adminClient, new TypeClient(), new ActionApprove(), cc.client, null);
    ClientServer server = new ClientServer(tp2.getCOSE());
    ClientResponse resp = (ClientResponse) server.process(req);
    ClientApproval approval = tp2.getClientApprovalStore().get(cc.client.getIdentifier());
    assert approval != null : "No approval found";
    assert approval.isApproved();
}
Also used : ClientApproval(edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval) TypeClient(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypeClient)

Example 3 with TypeClient

use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypeClient in project OA4MP by ncsa.

the class ClientServerTest method testUnapprove.

public void testUnapprove(CMTestStoreProvider tp2) throws Exception {
    CC cc = setupClients(tp2);
    // approve it first.
    ApproveRequest req0 = RequestFactory.createRequest(cc.adminClient, new TypeClient(), new ActionApprove(), cc.client, null);
    ClientServer server = new ClientServer(tp2.getCOSE());
    ClientResponse resp0 = (ClientResponse) server.process(req0);
    UnapproveRequest req = RequestFactory.createRequest(cc.adminClient, new TypeClient(), new ActionUnapprove(), cc.client, null);
    ClientResponse resp = (ClientResponse) server.process(req);
    ClientApproval approval = tp2.getClientApprovalStore().get(cc.client.getIdentifier());
    assert approval != null : "No approval found";
    assert !approval.isApproved();
}
Also used : ClientApproval(edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval) TypeClient(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypeClient)

Example 4 with TypeClient

use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypeClient in project OA4MP by ncsa.

the class ClientServerTest method testCreatePublicClient.

public void testCreatePublicClient(CMTestStoreProvider tp2) throws Exception {
    // only needs an admin client and map.
    CC cc = setupClients(tp2);
    cc.client.setPublicClient(true);
    tp2.getClientStore().save(cc.client);
    OA2ClientConverter converter = getClientConverter(tp2);
    ColumnMap values = new ColumnMap();
    converter.toMap(cc.client, values);
    tp2.getClientStore().remove(cc.client.getIdentifier());
    assert !tp2.getClientStore().containsKey(cc.client.getIdentifier());
    // remove the identifier and create it
    OA2ClientKeys clientKeys = getClientKeys(tp2);
    values.remove(clientKeys.identifier());
    values.remove(clientKeys.creationTS());
    JSONObject json = new JSONObject();
    json.putAll(values);
    CreateRequest req = RequestFactory.createRequest(cc.adminClient, new TypeClient(), new ActionCreate(), null, json);
    ClientServer server = new ClientServer(tp2.getCOSE());
    CreateResponse resp = (CreateResponse) server.process(req);
    OA2Client newClient = resp.getClient();
    assert tp2.getClientStore().containsKey(newClient.getIdentifier());
    // quick and dirty check
    OA2Client oldClient = (OA2Client) cc.client;
    oldClient.setIdentifier(newClient.getIdentifier());
    oldClient.setSecret(newClient.getSecret());
    assert oldClient.equals(newClient);
}
Also used : ColumnMap(edu.uiuc.ncsa.security.storage.sql.internals.ColumnMap) OA2Client(edu.uiuc.ncsa.security.oauth_2_0.OA2Client) JSONObject(net.sf.json.JSONObject) OA2ClientKeys(edu.uiuc.ncsa.security.oauth_2_0.OA2ClientKeys) TypeClient(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypeClient) OA2ClientConverter(edu.uiuc.ncsa.security.oauth_2_0.OA2ClientConverter)

Example 5 with TypeClient

use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypeClient in project OA4MP by ncsa.

the class ClientServerTest method testCreate.

public void testCreate(CMTestStoreProvider tp2) throws Exception {
    // only needs an admin client and map.
    CC cc = setupClients(tp2);
    OA2ClientConverter converter = getClientConverter(tp2);
    ColumnMap values = new ColumnMap();
    converter.toMap(cc.client, values);
    tp2.getClientStore().remove(cc.client.getIdentifier());
    assert !tp2.getClientStore().containsKey(cc.client.getIdentifier());
    // remove the identifier and create it
    OA2ClientKeys clientKeys = getClientKeys(tp2);
    values.remove(clientKeys.identifier());
    values.remove(clientKeys.creationTS());
    JSONObject json = new JSONObject();
    json.putAll(values);
    CreateRequest req = RequestFactory.createRequest(cc.adminClient, new TypeClient(), new ActionCreate(), null, json);
    ClientServer server = new ClientServer(tp2.getCOSE());
    CreateResponse resp = (CreateResponse) server.process(req);
    OA2Client newClient = resp.getClient();
    assert tp2.getClientStore().containsKey(newClient.getIdentifier());
    // quick and dirty check
    OA2Client oldClient = (OA2Client) cc.client;
    oldClient.setIdentifier(newClient.getIdentifier());
    oldClient.setSecret(newClient.getSecret());
    assert oldClient.equals(newClient);
}
Also used : ColumnMap(edu.uiuc.ncsa.security.storage.sql.internals.ColumnMap) OA2Client(edu.uiuc.ncsa.security.oauth_2_0.OA2Client) JSONObject(net.sf.json.JSONObject) OA2ClientKeys(edu.uiuc.ncsa.security.oauth_2_0.OA2ClientKeys) TypeClient(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypeClient) OA2ClientConverter(edu.uiuc.ncsa.security.oauth_2_0.OA2ClientConverter)

Aggregations

TypeClient (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypeClient)5 ClientApproval (edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval)2 OA2Client (edu.uiuc.ncsa.security.oauth_2_0.OA2Client)2 OA2ClientConverter (edu.uiuc.ncsa.security.oauth_2_0.OA2ClientConverter)2 OA2ClientKeys (edu.uiuc.ncsa.security.oauth_2_0.OA2ClientKeys)2 ColumnMap (edu.uiuc.ncsa.security.storage.sql.internals.ColumnMap)2 JSONObject (net.sf.json.JSONObject)2 AddClientRequest (edu.uiuc.ncsa.myproxy.oa4mp.oauth2.cm.util.permissions.AddClientRequest)1 PermissionServer (edu.uiuc.ncsa.myproxy.oa4mp.oauth2.cm.util.permissions.PermissionServer)1 AdminClient (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient)1 TypePermission (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypePermission)1