@Test public void testGetPermissionForUserOnMixedResources() { List<String> resourceCrns = List.of(DEFAULT_RESOURCE_CRN, RESOURCE_CRN); when(umsResourceAuthorizationService.getRightOfUserOnResources(anyString(), any(), any())).thenReturn(Map.of(RESOURCE_CRN, true)); Map<String, Boolean> result = underTest.getPermissionsForUserOnResources(AuthorizationResourceAction.DESCRIBE_IMAGE_CATALOG, USER_CRN, resourceCrns); assertEquals(Map.of(DEFAULT_RESOURCE_CRN, true, RESOURCE_CRN, true), result); verify(defaultResourceChecker).getDefaultResourceCrns(resourceCrns); verify(defaultResourceChecker).isAllowedAction(AuthorizationResourceAction.DESCRIBE_IMAGE_CATALOG); verify(umsResourceAuthorizationService).getRightOfUserOnResources(USER_CRN, AuthorizationResourceAction.DESCRIBE_IMAGE_CATALOG, List.of(RESOURCE_CRN)); }
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; } }
CommonPermissionCheckingUtils { 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; } } }
CommonPermissionCheckingUtils { 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; } }  }
CommonPermissionCheckingUtils { 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; } }  @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 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; } }  @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);  }