@Test void vote_noPluginNoMenu() { FilterInvocation filterInvocation = when(mock(FilterInvocation.class).getRequestUrl()).thenReturn("asdasdsaddas").getMock(); assertEquals(ACCESS_DENIED, voter.vote(null, filterInvocation, null)); }
@Override public int vote( Authentication authentication, FilterInvocation filterInvocation, Collection<ConfigAttribute> attributes) { String requestUrl = filterInvocation.getRequestUrl(); Matcher pluginMatcher = PATTERN_PLUGINID.matcher(requestUrl); if (pluginMatcher.matches()) { String pluginId = pluginMatcher.group(1); return userPermissionEvaluator.hasPermission(new PluginIdentity(pluginId), VIEW_PLUGIN) ? ACCESS_GRANTED : ACCESS_DENIED; } Matcher menuMatcher = PATTERN_MENUID.matcher(requestUrl); if (menuMatcher.matches()) { String menuId = menuMatcher.group(1); boolean found = menuReaderService.getMenu().flatMap(it -> it.getPath(menuId)).isPresent(); return found ? ACCESS_GRANTED : ACCESS_DENIED; } return ACCESS_DENIED; }
MolgenisAccessDecisionVoter implements AccessDecisionVoter<FilterInvocation> { @Override public int vote( Authentication authentication, FilterInvocation filterInvocation, Collection<ConfigAttribute> attributes) { String requestUrl = filterInvocation.getRequestUrl(); Matcher pluginMatcher = PATTERN_PLUGINID.matcher(requestUrl); if (pluginMatcher.matches()) { String pluginId = pluginMatcher.group(1); return userPermissionEvaluator.hasPermission(new PluginIdentity(pluginId), VIEW_PLUGIN) ? ACCESS_GRANTED : ACCESS_DENIED; } Matcher menuMatcher = PATTERN_MENUID.matcher(requestUrl); if (menuMatcher.matches()) { String menuId = menuMatcher.group(1); boolean found = menuReaderService.getMenu().flatMap(it -> it.getPath(menuId)).isPresent(); return found ? ACCESS_GRANTED : ACCESS_DENIED; } return ACCESS_DENIED; } }
MolgenisAccessDecisionVoter implements AccessDecisionVoter<FilterInvocation> { @Override public int vote( Authentication authentication, FilterInvocation filterInvocation, Collection<ConfigAttribute> attributes) { String requestUrl = filterInvocation.getRequestUrl(); Matcher pluginMatcher = PATTERN_PLUGINID.matcher(requestUrl); if (pluginMatcher.matches()) { String pluginId = pluginMatcher.group(1); return userPermissionEvaluator.hasPermission(new PluginIdentity(pluginId), VIEW_PLUGIN) ? ACCESS_GRANTED : ACCESS_DENIED; } Matcher menuMatcher = PATTERN_MENUID.matcher(requestUrl); if (menuMatcher.matches()) { String menuId = menuMatcher.group(1); boolean found = menuReaderService.getMenu().flatMap(it -> it.getPath(menuId)).isPresent(); return found ? ACCESS_GRANTED : ACCESS_DENIED; } return ACCESS_DENIED; }  }
MolgenisAccessDecisionVoter implements AccessDecisionVoter<FilterInvocation> { @Override public int vote( Authentication authentication, FilterInvocation filterInvocation, Collection<ConfigAttribute> attributes) { String requestUrl = filterInvocation.getRequestUrl(); Matcher pluginMatcher = PATTERN_PLUGINID.matcher(requestUrl); if (pluginMatcher.matches()) { String pluginId = pluginMatcher.group(1); return userPermissionEvaluator.hasPermission(new PluginIdentity(pluginId), VIEW_PLUGIN) ? ACCESS_GRANTED : ACCESS_DENIED; } Matcher menuMatcher = PATTERN_MENUID.matcher(requestUrl); if (menuMatcher.matches()) { String menuId = menuMatcher.group(1); boolean found = menuReaderService.getMenu().flatMap(it -> it.getPath(menuId)).isPresent(); return found ? ACCESS_GRANTED : ACCESS_DENIED; } return ACCESS_DENIED; }  @Override boolean supports(ConfigAttribute attribute); @Override boolean supports(Class<?> clazz); @Override int vote(
      Authentication authentication,
      FilterInvocation filterInvocation,
      Collection<ConfigAttribute> attributes); }
MolgenisAccessDecisionVoter implements AccessDecisionVoter<FilterInvocation> { @Override public int vote( Authentication authentication, FilterInvocation filterInvocation, Collection<ConfigAttribute> attributes) { String requestUrl = filterInvocation.getRequestUrl(); Matcher pluginMatcher = PATTERN_PLUGINID.matcher(requestUrl); if (pluginMatcher.matches()) { String pluginId = pluginMatcher.group(1); return userPermissionEvaluator.hasPermission(new PluginIdentity(pluginId), VIEW_PLUGIN) ? ACCESS_GRANTED : ACCESS_DENIED; } Matcher menuMatcher = PATTERN_MENUID.matcher(requestUrl); if (menuMatcher.matches()) { String menuId = menuMatcher.group(1); boolean found = menuReaderService.getMenu().flatMap(it -> it.getPath(menuId)).isPresent(); return found ? ACCESS_GRANTED : ACCESS_DENIED; } return ACCESS_DENIED; }  @Override boolean supports(ConfigAttribute attribute); @Override boolean supports(Class<?> clazz); @Override int vote(
      Authentication authentication,
      FilterInvocation filterInvocation,
      Collection<ConfigAttribute> attributes);  }