@Test public void testIsPermittedMultipleRepositories_viewNotPermittedContentNotPermitted() throws Exception { when(securityHelper .anyPermitted( eq(new RepositoryViewPermission("repoFormat", "repoName", Arrays.asList(BreadActions.READ))), eq(new RepositoryViewPermission("repoFormat", "repoName2", Arrays.asList(BreadActions.READ))))) .thenReturn(false); when(selectorManager.browse()).thenReturn(Arrays.asList(config)); when(selectorManager.evaluate(any(), any())).thenReturn(false); assertThat(impl.isPermitted(Sets.newHashSet("repoName", "repoName2"), "repoFormat", BreadActions.READ, variableSource), is(false)); }
@Override public boolean isPermitted(final String repositoryName, final String repositoryFormat, final String action, final VariableSource variableSource) { if (isViewPermitted(repositoryName, repositoryFormat, action)) { return true; } return selectorManager.browse().stream() .anyMatch(config -> isContentPermitted(repositoryName, repositoryFormat, action, config, variableSource)); }
ContentPermissionCheckerImpl extends ComponentSupport implements ContentPermissionChecker { @Override public boolean isPermitted(final String repositoryName, final String repositoryFormat, final String action, final VariableSource variableSource) { if (isViewPermitted(repositoryName, repositoryFormat, action)) { return true; } return selectorManager.browse().stream() .anyMatch(config -> isContentPermitted(repositoryName, repositoryFormat, action, config, variableSource)); } }
ContentPermissionCheckerImpl extends ComponentSupport implements ContentPermissionChecker { @Override public boolean isPermitted(final String repositoryName, final String repositoryFormat, final String action, final VariableSource variableSource) { if (isViewPermitted(repositoryName, repositoryFormat, action)) { return true; } return selectorManager.browse().stream() .anyMatch(config -> isContentPermitted(repositoryName, repositoryFormat, action, config, variableSource)); } @Inject  ContentPermissionCheckerImpl(final SecurityHelper securityHelper,
                                      final SelectorManager selectorManager); }
ContentPermissionCheckerImpl extends ComponentSupport implements ContentPermissionChecker { @Override public boolean isPermitted(final String repositoryName, final String repositoryFormat, final String action, final VariableSource variableSource) { if (isViewPermitted(repositoryName, repositoryFormat, action)) { return true; } return selectorManager.browse().stream() .anyMatch(config -> isContentPermitted(repositoryName, repositoryFormat, action, config, variableSource)); } @Inject  ContentPermissionCheckerImpl(final SecurityHelper securityHelper,
                                      final SelectorManager selectorManager); @VisibleForTesting boolean isViewPermitted(final String repositoryName, final String repositoryFormat, final String action); @VisibleForTesting boolean isViewPermitted(final Set<String> repositoryNames, final String repositoryFormat, final String action); @VisibleForTesting boolean isContentPermitted(final String repositoryName,
                                    final String repositoryFormat,
                                    final String action,
                                    final SelectorConfiguration selectorConfiguration,
                                    final VariableSource variableSource); @VisibleForTesting boolean isContentPermitted(final Set<String> repositoryNames,
                                    final String repositoryFormat,
                                    final String action,
                                    final SelectorConfiguration selectorConfiguration,
                                    final VariableSource variableSource); @Override boolean isPermitted(final String repositoryName,
                             final String repositoryFormat,
                             final String action,
                             final VariableSource variableSource); @Override boolean isPermittedJexlOnly(final String repositoryName,
                                     final String repositoryFormat,
                                     final String action,
                                     final VariableSource variableSource); @Override boolean isPermitted(final Set<String> repositoryNames,
                             final String repositoryFormat,
                             final String action,
                             final VariableSource variableSource); }
ContentPermissionCheckerImpl extends ComponentSupport implements ContentPermissionChecker { @Override public boolean isPermitted(final String repositoryName, final String repositoryFormat, final String action, final VariableSource variableSource) { if (isViewPermitted(repositoryName, repositoryFormat, action)) { return true; } return selectorManager.browse().stream() .anyMatch(config -> isContentPermitted(repositoryName, repositoryFormat, action, config, variableSource)); } @Inject  ContentPermissionCheckerImpl(final SecurityHelper securityHelper,
                                      final SelectorManager selectorManager); @VisibleForTesting boolean isViewPermitted(final String repositoryName, final String repositoryFormat, final String action); @VisibleForTesting boolean isViewPermitted(final Set<String> repositoryNames, final String repositoryFormat, final String action); @VisibleForTesting boolean isContentPermitted(final String repositoryName,
                                    final String repositoryFormat,
                                    final String action,
                                    final SelectorConfiguration selectorConfiguration,
                                    final VariableSource variableSource); @VisibleForTesting boolean isContentPermitted(final Set<String> repositoryNames,
                                    final String repositoryFormat,
                                    final String action,
                                    final SelectorConfiguration selectorConfiguration,
                                    final VariableSource variableSource); @Override boolean isPermitted(final String repositoryName,
                             final String repositoryFormat,
                             final String action,
                             final VariableSource variableSource); @Override boolean isPermittedJexlOnly(final String repositoryName,
                                     final String repositoryFormat,
                                     final String action,
                                     final VariableSource variableSource); @Override boolean isPermitted(final Set<String> repositoryNames,
                             final String repositoryFormat,
                             final String action,
                             final VariableSource variableSource);  }