Search in sources :

Example 1 with Permission

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();
}
Also used : GeneralException(edu.uiuc.ncsa.security.core.exceptions.GeneralException) PermissionList(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.PermissionList) Permission(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.Permission)

Example 2 with Permission

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();
}
Also used : PermissionList(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.PermissionList) Permission(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.Permission)

Example 3 with Permission

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();
}
Also used : Identifier(edu.uiuc.ncsa.security.core.Identifier) PermissionList(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.PermissionList) TypePermission(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypePermission) Permission(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.Permission)

Example 4 with Permission

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());
    }
}
Also used : LinkedList(java.util.LinkedList) Identifier(edu.uiuc.ncsa.security.core.Identifier) TypePermission(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypePermission) TypePermission(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypePermission) Permission(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.Permission) ActionList(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.actions.ActionList) AdminClient(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient)

Example 5 with Permission

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);
}
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

Permission (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.Permission)12 AdminClient (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient)5 PermissionList (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.PermissionList)4 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 ActionList (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.actions.ActionList)2 LinkedList (java.util.LinkedList)2 GeneralException (edu.uiuc.ncsa.security.core.exceptions.GeneralException)1 ClientApproval (edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval)1