use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.Permission in project OA4MP by ncsa.
the class PermissionServer method addClient.
/**
* Adds a given client to the list of clients managed by this admin
*
* @param request
* @return
*/
public PermissionResponse addClient(AddClientRequest request) {
// request needs admin and client.
// Check if there is one already -- don't fill up table with redundant permissions.
Permission p = null;
PermissionList pList = getPermissionStore().get(request.getAdminClient().getIdentifier(), request.getClient().getIdentifier());
switch(pList.size()) {
case 0:
p = getPermissionStore().create();
break;
case 1:
p = pList.get(0);
break;
default:
throw new GeneralException("Internal error. Multiple permissiions entries found");
}
p.setAdminID(request.getAdminClient().getIdentifier());
p.setClientID(request.getClient().getIdentifier());
p.setApprove(true);
p.setCreate(true);
p.setDelete(true);
p.setRead(true);
p.setWrite(true);
getPermissionStore().save(p);
return new AddClientResponse();
}
use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.Permission in project OA4MP by ncsa.
the class PermissionServer method removeClient.
/**
* removes a client from management by an admin. This does NOT remove the client!!
*
* @param request
* @return
*/
public PermissionResponse removeClient(RemoveClientRequest request) {
// request needs admin as src, client as target
canWrite(request);
PermissionList permissionList = getPermissionStore().get(request.getAdminClient().getIdentifier(), request.getClient().getIdentifier());
// remove all of these permissions
for (Permission p : permissionList) {
getPermissionStore().remove(p.getIdentifier());
}
return new PermissionResponse();
}
use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.Permission in project OA4MP by ncsa.
the class ClientServer method remove.
/**
* remove the client completely and all references to it.
*
* @param request
* @return
*/
public ClientResponse remove(RemoveRequest request) {
canDelete(request);
Identifier clientID = request.getClient().getIdentifier();
getClientApprovalStore().remove(clientID);
List<Identifier> admins = getPermissionStore().getAdmins(clientID);
// remove all permissions for this client and these admins
for (Identifier adminID : admins) {
PermissionList permissions = getPermissionStore().get(adminID, clientID);
for (Permission p : permissions) {
getPermissionStore().remove(p.getIdentifier());
}
}
getClientStore().remove(clientID);
return new ClientResponse();
}
use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.Permission in project OA4MP by ncsa.
the class PermissionServerTest method testGetAdmins.
public void testGetAdmins(CMTestStoreProvider tp2) throws Exception {
int clientCount = 4;
CC cc = setupClients(tp2);
List<AdminClient> admins = new LinkedList<>();
for (int i = 0; i < clientCount; i++) {
AdminClient ac2 = getAdminClient(tp2.getAdminClientStore());
Permission p = tp2.getPermissionStore().create();
p.setDelete(true);
p.setRead(true);
p.setApprove(true);
p.setCreate(true);
p.setWrite(true);
p.setAdminID(ac2.getIdentifier());
p.setClientID(cc.client.getIdentifier());
tp2.getPermissionStore().save(p);
admins.add(ac2);
}
admins.add(cc.adminClient);
// need this list of identifiers later for checking that the returned result is correct.
List<Identifier> adminIDs = new LinkedList<>();
for (AdminClient ac : admins) {
adminIDs.add(ac.getIdentifier());
}
PermissionServer permissionServer = new PermissionServer(tp2.getCOSE());
// ListAdminsRequest req = new ListAdminsRequest(cc.adminClient, cc.client);
ListAdminsRequest req = (ListAdminsRequest) RequestFactory.createRequest(null, new TypePermission(), new ActionList(), cc.client, null);
ListAdminsResponse resp = (ListAdminsResponse) permissionServer.process(req);
// so add a bunch of admins for a single client and check that they all come back.
List<AdminClient> returnedACs = resp.getAdmins();
assert returnedACs.size() == admins.size();
for (AdminClient x : returnedACs) {
assert adminIDs.contains(x.getIdentifier());
}
}
use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.Permission in project OA4MP by ncsa.
the class PermissionTest method testAttributes.
public void testAttributes(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());
p.setApprove(false);
pStore.save(p);
Permission p2 = (Permission) pStore.get(p.getIdentifier());
assert p2.equals(p);
p.setCreate(false);
pStore.save(p);
p2 = (Permission) pStore.get(p.getIdentifier());
assert p2.equals(p);
p.setRead(false);
pStore.save(p);
p2 = (Permission) pStore.get(p.getIdentifier());
assert p2.equals(p);
p.setDelete(false);
pStore.save(p);
p2 = (Permission) pStore.get(p.getIdentifier());
assert p2.equals(p);
p.setDelete(false);
pStore.save(p);
p2 = (Permission) pStore.get(p.getIdentifier());
assert p2.equals(p);
}
Aggregations