Search in sources :

Example 1 with OA2ClientApprovalKeys

use of edu.uiuc.ncsa.security.oauth_2_0.OA2ClientApprovalKeys in project OA4MP by ncsa.

the class ClientServer method approve.

public ClientResponse approve(ApproveRequest request) {
    canApprove(request);
    Identifier id = request.getClient().getIdentifier();
    ClientApproval approval = null;
    OA2ClientApprovalKeys keys = new OA2ClientApprovalKeys();
    if (getClientApprovalStore().containsKey(id)) {
        approval = (ClientApproval) getClientApprovalStore().get(id);
    } else {
        approval = (ClientApproval) getClientApprovalStore().create();
        // approval ID must be the same as the client's
        approval.setIdentifier(id);
    }
    if (request.getAttributes() != null && request.getAttributes().containsKey(keys.approver())) {
        approval.setApprover(String.valueOf(request.getAttributes().get(keys.approver())));
    } else {
        approval.setApprover(request.getAdminClient().getIdentifierString());
    }
    approval.setApproved(true);
    getClientApprovalStore().save(approval);
    return new ClientResponse();
}
Also used : Identifier(edu.uiuc.ncsa.security.core.Identifier) ClientApproval(edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval) OA2ClientApprovalKeys(edu.uiuc.ncsa.security.oauth_2_0.OA2ClientApprovalKeys)

Example 2 with OA2ClientApprovalKeys

use of edu.uiuc.ncsa.security.oauth_2_0.OA2ClientApprovalKeys in project OA4MP by ncsa.

the class ClientServer method unapprove.

public ClientResponse unapprove(UnapproveRequest request) {
    canApprove(request);
    ClientApproval approval = (ClientApproval) getClientApprovalStore().get(request.getClient().getIdentifier());
    OA2ClientApprovalKeys keys = new OA2ClientApprovalKeys();
    if (request.getAttributes() != null && request.getAttributes().containsKey(keys.approver())) {
        approval.setApprover(String.valueOf(request.getAttributes().get(keys.approver())));
    } else {
        approval.setApprover(request.getAdminClient().getIdentifierString());
    }
    approval.setApproved(false);
    getClientApprovalStore().save(approval);
    return new ClientResponse();
}
Also used : ClientApproval(edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval) OA2ClientApprovalKeys(edu.uiuc.ncsa.security.oauth_2_0.OA2ClientApprovalKeys)

Aggregations

ClientApproval (edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval)2 OA2ClientApprovalKeys (edu.uiuc.ncsa.security.oauth_2_0.OA2ClientApprovalKeys)2 Identifier (edu.uiuc.ncsa.security.core.Identifier)1