Search in sources :

Example 1 with CheckResourceRightV4SingleResponse

use of com.sequenceiq.authorization.info.model.CheckResourceRightV4SingleResponse in project cloudbreak by hortonworks.

the class UtilAuthorizationService method generateResponse.

private CheckResourceRightsV4Response generateResponse(Multimap<ImmutablePair<String, RightV4>, AuthorizationProto.RightCheck> resourceRightsChecks, Map<AuthorizationProto.RightCheck, Boolean> rightCheckResultMap) {
    CheckResourceRightsV4Response response = new CheckResourceRightsV4Response(Lists.newArrayList());
    Map<ImmutablePair<String, RightV4>, Boolean> rightCheckResults = new HashMap<>();
    for (ImmutablePair<String, RightV4> resourceRight : resourceRightsChecks.keys()) {
        Collection<AuthorizationProto.RightCheck> rightChecks = resourceRightsChecks.get(resourceRight);
        Boolean hasRight = hasRight(rightCheckResultMap, rightChecks);
        rightCheckResults.put(resourceRight, hasRight);
    }
    rightCheckResults.forEach((rightCheck, result) -> {
        if (getResourceRightSingleResponse(response, rightCheck.getLeft()).isEmpty()) {
            response.getResponses().add(new CheckResourceRightV4SingleResponse(rightCheck.getLeft(), Lists.newArrayList()));
        }
        CheckRightV4SingleResponse singleResponse = new CheckRightV4SingleResponse(rightCheck.getRight(), result);
        getResourceRightSingleResponse(response, rightCheck.getLeft()).get().getRights().add(singleResponse);
    });
    return response;
}
Also used : RightV4(com.sequenceiq.authorization.info.model.RightV4) CheckRightV4SingleResponse(com.sequenceiq.authorization.info.model.CheckRightV4SingleResponse) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) HashMap(java.util.HashMap) CheckResourceRightsV4Response(com.sequenceiq.authorization.info.model.CheckResourceRightsV4Response) CheckResourceRightV4SingleResponse(com.sequenceiq.authorization.info.model.CheckResourceRightV4SingleResponse)

Aggregations

CheckResourceRightV4SingleResponse (com.sequenceiq.authorization.info.model.CheckResourceRightV4SingleResponse)1 CheckResourceRightsV4Response (com.sequenceiq.authorization.info.model.CheckResourceRightsV4Response)1 CheckRightV4SingleResponse (com.sequenceiq.authorization.info.model.CheckRightV4SingleResponse)1 RightV4 (com.sequenceiq.authorization.info.model.RightV4)1 HashMap (java.util.HashMap)1 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)1