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;
}
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;
}
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";
}
}
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;
}
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());
}
Aggregations