SelectorManagerImpl extends StateGuardLifecycleSupport implements SelectorManager, EventAware { @Override @Guarded(by = STARTED) public List<SelectorConfiguration> browseActive(final List<String> repositoryNames, final List<String> formats) { AuthorizationManager authorizationManager; User currentUser; try { authorizationManager = securitySystem.getAuthorizationManager(DEFAULT_SOURCE); currentUser = securitySystem.currentUser(); } catch (NoSuchAuthorizationManagerException | UserNotFoundException e) { log.warn("Unable to load active content selectors", e); return Collections.emptyList(); } if (currentUser == null) { return Collections.emptyList(); } List<String> roleIds = currentUser.getRoles().stream().map(RoleIdentifier::getRoleId) .collect(toList()); List<Role> roles = getRoles(roleIds, authorizationManager, new ArrayList<>()); List<String> contentSelectorNames = roles.stream().map(Role::getPrivileges).flatMap(Collection::stream).map(id -> { try { return authorizationManager.getPrivilege(id); } catch (NoSuchPrivilegeException e) { log.debug("Unable to find privilege for id={}, continuing to check privileges", id, e); return null; } }).filter(Objects::nonNull).filter(repositoryFormatOrNameMatcher(repositoryNames, formats)).map(this::getContentSelector).collect(toList()); return browse().stream().filter(selector -> contentSelectorNames.contains(selector.getName())).collect(toList()); } @Inject  SelectorManagerImpl(final SelectorConfigurationStore store,
                             final SecuritySystem securitySystem,
                             final SelectorFactory selectorFactory); @Override @Guarded(by = STARTED) List<SelectorConfiguration> browse(); @Override @Guarded(by = STARTED) List<SelectorConfiguration> browse(final String selectorType); @Override @Guarded(by = STARTED) SelectorConfiguration read(final EntityId entityId); @Override @Guarded(by = STARTED) SelectorConfiguration readByName(final String name); @Override @Guarded(by = STARTED) Optional<SelectorConfiguration> findByName(final String name); @Override @Guarded(by = STARTED) void create(final SelectorConfiguration configuration); @Override void create(
      final String name,
      final String type,
      final String description,
      final Map<String, String> attributes); @Override @Guarded(by = STARTED) void update(final SelectorConfiguration configuration); @Override @Guarded(by = STARTED) void delete(final SelectorConfiguration configuration); @Subscribe @AllowConcurrentEvents void on(final SelectorConfigurationEvent event); @Override @Guarded(by = STARTED) boolean evaluate(final SelectorConfiguration selectorConfiguration, final VariableSource variableSource); @Override void toSql(final SelectorConfiguration selectorConfiguration, final SelectorSqlBuilder sqlBuilder); @Override @Guarded(by = STARTED) List<SelectorConfiguration> browseActive(final List<String> repositoryNames, final List<String> formats); @Override SelectorConfiguration newSelectorConfiguration(); @Override SelectorConfiguration newSelectorConfiguration(
      String name,
      String type,
      String description,
      Map<String, ?> attributes);  }
@Test public void browseActiveReturnsNoContentSelectorsWhenAnonymousAccessDisabled() throws Exception { when(securitySystem.currentUser()).thenReturn(null); List<SelectorConfiguration> selectors = manager.browseActive(asList("anyRepository"), asList("anyFormat")); assertThat(selectors.size(), is(0)); }