use of com.sequenceiq.authorization.service.defaults.CrnsByCategory in project cloudbreak by hortonworks.
the class DefaultImageCheckerTest method shouldReturnDefaultCrnsWithLegacy.
@Test
public void shouldReturnDefaultCrnsWithLegacy() {
CrnsByCategory result = underTest.getDefaultResourceCrns(List.of(DEFAULT_CRN, OTHER_CRN));
assertEquals(List.of(DEFAULT_CRN), result.getDefaultResourceCrns());
assertEquals(List.of(OTHER_CRN), result.getNotDefaultResourceCrns());
}
use of com.sequenceiq.authorization.service.defaults.CrnsByCategory in project cloudbreak by hortonworks.
the class CommonPermissionCheckingUtils method getPermissionsForUserOnResources.
public Map<String, Boolean> getPermissionsForUserOnResources(AuthorizationResourceAction action, String userCrn, List<String> resourceCrns) {
DefaultResourceChecker defaultResourceChecker = defaultResourceCheckerMap.get(umsRightProvider.getResourceType(action));
if (defaultResourceChecker == null) {
return umsResourceAuthorizationService.getRightOfUserOnResources(userCrn, action, resourceCrns);
} else {
CrnsByCategory crnsByCategory = defaultResourceChecker.getDefaultResourceCrns(resourceCrns);
Map<String, Boolean> result = new HashMap<>();
if (!crnsByCategory.getDefaultResourceCrns().isEmpty()) {
result.putAll(crnsByCategory.getDefaultResourceCrns().stream().collect(toMap(Function.identity(), s -> defaultResourceChecker.isAllowedAction(action))));
}
if (!crnsByCategory.getNotDefaultResourceCrns().isEmpty()) {
result.putAll(umsResourceAuthorizationService.getRightOfUserOnResources(userCrn, action, crnsByCategory.getNotDefaultResourceCrns()));
}
return result;
}
}
Aggregations