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