@Test public void testIsContentPermittedMultipleRepositories_notPermitted() throws Exception { when(selectorManager.evaluate(any(), any())).thenReturn(true); assertThat(impl.isContentPermitted(Sets.newLinkedHashSet(Arrays.asList("repoName", "repoName2")), "repoFormat", BreadActions.READ, config, variableSource), is(false)); verify(securityHelper) .anyPermitted( eq(new RepositoryContentSelectorPermission("selector", "repoFormat", "repoName", Arrays.asList(BreadActions.READ))), eq(new RepositoryContentSelectorPermission("selector", "repoFormat", "repoName2", Arrays.asList(BreadActions.READ)))); }
@VisibleForTesting public boolean isContentPermitted(final String repositoryName, final String repositoryFormat, final String action, final SelectorConfiguration selectorConfiguration, final VariableSource variableSource) { RepositoryContentSelectorPermission perm = new RepositoryContentSelectorPermission( selectorConfiguration.getName(), repositoryFormat, repositoryName, Arrays.asList(action)); try { return securityHelper.anyPermitted(perm) && selectorManager.evaluate(selectorConfiguration, variableSource); } catch (SelectorEvaluationException e) { if (log.isTraceEnabled()) { log.debug(e.getMessage(), e); } else { log.debug(e.getMessage()); } } return false; }
ContentPermissionCheckerImpl extends ComponentSupport implements ContentPermissionChecker { @VisibleForTesting public boolean isContentPermitted(final String repositoryName, final String repositoryFormat, final String action, final SelectorConfiguration selectorConfiguration, final VariableSource variableSource) { RepositoryContentSelectorPermission perm = new RepositoryContentSelectorPermission( selectorConfiguration.getName(), repositoryFormat, repositoryName, Arrays.asList(action)); try { return securityHelper.anyPermitted(perm) && selectorManager.evaluate(selectorConfiguration, variableSource); } catch (SelectorEvaluationException e) { if (log.isTraceEnabled()) { log.debug(e.getMessage(), e); } else { log.debug(e.getMessage()); } } return false; } }
ContentPermissionCheckerImpl extends ComponentSupport implements ContentPermissionChecker { @VisibleForTesting public boolean isContentPermitted(final String repositoryName, final String repositoryFormat, final String action, final SelectorConfiguration selectorConfiguration, final VariableSource variableSource) { RepositoryContentSelectorPermission perm = new RepositoryContentSelectorPermission( selectorConfiguration.getName(), repositoryFormat, repositoryName, Arrays.asList(action)); try { return securityHelper.anyPermitted(perm) && selectorManager.evaluate(selectorConfiguration, variableSource); } catch (SelectorEvaluationException e) { if (log.isTraceEnabled()) { log.debug(e.getMessage(), e); } else { log.debug(e.getMessage()); } } return false; } @Inject  ContentPermissionCheckerImpl(final SecurityHelper securityHelper,
                                      final SelectorManager selectorManager); }
ContentPermissionCheckerImpl extends ComponentSupport implements ContentPermissionChecker { @VisibleForTesting public boolean isContentPermitted(final String repositoryName, final String repositoryFormat, final String action, final SelectorConfiguration selectorConfiguration, final VariableSource variableSource) { RepositoryContentSelectorPermission perm = new RepositoryContentSelectorPermission( selectorConfiguration.getName(), repositoryFormat, repositoryName, Arrays.asList(action)); try { return securityHelper.anyPermitted(perm) && selectorManager.evaluate(selectorConfiguration, variableSource); } catch (SelectorEvaluationException e) { if (log.isTraceEnabled()) { log.debug(e.getMessage(), e); } else { log.debug(e.getMessage()); } } return false; } @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 { @VisibleForTesting public boolean isContentPermitted(final String repositoryName, final String repositoryFormat, final String action, final SelectorConfiguration selectorConfiguration, final VariableSource variableSource) { RepositoryContentSelectorPermission perm = new RepositoryContentSelectorPermission( selectorConfiguration.getName(), repositoryFormat, repositoryName, Arrays.asList(action)); try { return securityHelper.anyPermitted(perm) && selectorManager.evaluate(selectorConfiguration, variableSource); } catch (SelectorEvaluationException e) { if (log.isTraceEnabled()) { log.debug(e.getMessage(), e); } else { log.debug(e.getMessage()); } } return false; } @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);  }