@Test public void testCheckPermissionForUserOnDefaultResource() { underTest.checkPermissionForUserOnResource(AuthorizationResourceAction.DESCRIBE_IMAGE_CATALOG, USER_CRN, DEFAULT_RESOURCE_CRN); verify(defaultResourceChecker).isDefault(DEFAULT_RESOURCE_CRN); verify(defaultResourceChecker).isAllowedAction(AuthorizationResourceAction.DESCRIBE_IMAGE_CATALOG); verifyZeroInteractions(umsResourceAuthorizationService); }
public void checkPermissionForUserOnResource(Map<String, AuthorizationResourceAction> resourcesWithActions, String userCrn) { Set<String> removableDefaultResourceCrns = Sets.newHashSet(); for (Map.Entry<String, AuthorizationResourceAction> resourceAndAction : resourcesWithActions.entrySet()) { String resourceCrn = resourceAndAction.getKey(); AuthorizationResourceAction action = resourceAndAction.getValue(); DefaultResourceChecker defaultResourceChecker = defaultResourceCheckerMap.get(umsRightProvider.getResourceType(action)); if (defaultResourceChecker != null && defaultResourceChecker.isDefault(resourceCrn)) { throwAccessDeniedIfActionNotAllowed(action, List.of(resourceCrn), defaultResourceChecker); removableDefaultResourceCrns.add(resourceCrn); } } removableDefaultResourceCrns.stream().forEach(resourceCrn -> resourcesWithActions.remove(resourceCrn)); if (!resourcesWithActions.isEmpty()) { umsResourceAuthorizationService.checkIfUserHasAtLeastOneRight(userCrn, resourcesWithActions); } }
CommonPermissionCheckingUtils { public void checkPermissionForUserOnResource(Map<String, AuthorizationResourceAction> resourcesWithActions, String userCrn) { Set<String> removableDefaultResourceCrns = Sets.newHashSet(); for (Map.Entry<String, AuthorizationResourceAction> resourceAndAction : resourcesWithActions.entrySet()) { String resourceCrn = resourceAndAction.getKey(); AuthorizationResourceAction action = resourceAndAction.getValue(); DefaultResourceChecker defaultResourceChecker = defaultResourceCheckerMap.get(umsRightProvider.getResourceType(action)); if (defaultResourceChecker != null && defaultResourceChecker.isDefault(resourceCrn)) { throwAccessDeniedIfActionNotAllowed(action, List.of(resourceCrn), defaultResourceChecker); removableDefaultResourceCrns.add(resourceCrn); } } removableDefaultResourceCrns.stream().forEach(resourceCrn -> resourcesWithActions.remove(resourceCrn)); if (!resourcesWithActions.isEmpty()) { umsResourceAuthorizationService.checkIfUserHasAtLeastOneRight(userCrn, resourcesWithActions); } } }
CommonPermissionCheckingUtils { public void checkPermissionForUserOnResource(Map<String, AuthorizationResourceAction> resourcesWithActions, String userCrn) { Set<String> removableDefaultResourceCrns = Sets.newHashSet(); for (Map.Entry<String, AuthorizationResourceAction> resourceAndAction : resourcesWithActions.entrySet()) { String resourceCrn = resourceAndAction.getKey(); AuthorizationResourceAction action = resourceAndAction.getValue(); DefaultResourceChecker defaultResourceChecker = defaultResourceCheckerMap.get(umsRightProvider.getResourceType(action)); if (defaultResourceChecker != null && defaultResourceChecker.isDefault(resourceCrn)) { throwAccessDeniedIfActionNotAllowed(action, List.of(resourceCrn), defaultResourceChecker); removableDefaultResourceCrns.add(resourceCrn); } } removableDefaultResourceCrns.stream().forEach(resourceCrn -> resourcesWithActions.remove(resourceCrn)); if (!resourcesWithActions.isEmpty()) { umsResourceAuthorizationService.checkIfUserHasAtLeastOneRight(userCrn, resourcesWithActions); } }  }
CommonPermissionCheckingUtils { public void checkPermissionForUserOnResource(Map<String, AuthorizationResourceAction> resourcesWithActions, String userCrn) { Set<String> removableDefaultResourceCrns = Sets.newHashSet(); for (Map.Entry<String, AuthorizationResourceAction> resourceAndAction : resourcesWithActions.entrySet()) { String resourceCrn = resourceAndAction.getKey(); AuthorizationResourceAction action = resourceAndAction.getValue(); DefaultResourceChecker defaultResourceChecker = defaultResourceCheckerMap.get(umsRightProvider.getResourceType(action)); if (defaultResourceChecker != null && defaultResourceChecker.isDefault(resourceCrn)) { throwAccessDeniedIfActionNotAllowed(action, List.of(resourceCrn), defaultResourceChecker); removableDefaultResourceCrns.add(resourceCrn); } } removableDefaultResourceCrns.stream().forEach(resourceCrn -> resourcesWithActions.remove(resourceCrn)); if (!resourcesWithActions.isEmpty()) { umsResourceAuthorizationService.checkIfUserHasAtLeastOneRight(userCrn, resourcesWithActions); } }  @PostConstruct void init(); boolean legacyAuthorizationNeeded(); ResourceBasedCrnProvider getResourceBasedCrnProvider(AuthorizationResourceAction action); void checkPermissionForUser(AuthorizationResourceAction action, String userCrn); void checkPermissionForUserOnResource(Map<String, AuthorizationResourceAction> resourcesWithActions, String userCrn); void checkPermissionForUserOnResource(AuthorizationResourceAction action, String userCrn, String resourceCrn); void checkPermissionForUserOnResources(AuthorizationResourceAction action,
            String userCrn, Collection<String> resourceCrns); Map<String, Boolean> getPermissionsForUserOnResources(AuthorizationResourceAction action,
            String userCrn, List<String> resourceCrns); Object proceed(ProceedingJoinPoint proceedingJoinPoint, MethodSignature methodSignature, long startTime); boolean isAuthorizationDisabled(ProceedingJoinPoint proceedingJoinPoint); boolean isInternalOnly(ProceedingJoinPoint proceedingJoinPoint); T getParameter(ProceedingJoinPoint proceedingJoinPoint, MethodSignature methodSignature, Class annotation, Class<T> target); }
CommonPermissionCheckingUtils { public void checkPermissionForUserOnResource(Map<String, AuthorizationResourceAction> resourcesWithActions, String userCrn) { Set<String> removableDefaultResourceCrns = Sets.newHashSet(); for (Map.Entry<String, AuthorizationResourceAction> resourceAndAction : resourcesWithActions.entrySet()) { String resourceCrn = resourceAndAction.getKey(); AuthorizationResourceAction action = resourceAndAction.getValue(); DefaultResourceChecker defaultResourceChecker = defaultResourceCheckerMap.get(umsRightProvider.getResourceType(action)); if (defaultResourceChecker != null && defaultResourceChecker.isDefault(resourceCrn)) { throwAccessDeniedIfActionNotAllowed(action, List.of(resourceCrn), defaultResourceChecker); removableDefaultResourceCrns.add(resourceCrn); } } removableDefaultResourceCrns.stream().forEach(resourceCrn -> resourcesWithActions.remove(resourceCrn)); if (!resourcesWithActions.isEmpty()) { umsResourceAuthorizationService.checkIfUserHasAtLeastOneRight(userCrn, resourcesWithActions); } }  @PostConstruct void init(); boolean legacyAuthorizationNeeded(); ResourceBasedCrnProvider getResourceBasedCrnProvider(AuthorizationResourceAction action); void checkPermissionForUser(AuthorizationResourceAction action, String userCrn); void checkPermissionForUserOnResource(Map<String, AuthorizationResourceAction> resourcesWithActions, String userCrn); void checkPermissionForUserOnResource(AuthorizationResourceAction action, String userCrn, String resourceCrn); void checkPermissionForUserOnResources(AuthorizationResourceAction action,
            String userCrn, Collection<String> resourceCrns); Map<String, Boolean> getPermissionsForUserOnResources(AuthorizationResourceAction action,
            String userCrn, List<String> resourceCrns); Object proceed(ProceedingJoinPoint proceedingJoinPoint, MethodSignature methodSignature, long startTime); boolean isAuthorizationDisabled(ProceedingJoinPoint proceedingJoinPoint); boolean isInternalOnly(ProceedingJoinPoint proceedingJoinPoint); T getParameter(ProceedingJoinPoint proceedingJoinPoint, MethodSignature methodSignature, Class annotation, Class<T> target);  }