@Test public void testEnsurePermitted_notPermitted() throws Exception { when(contentPermissionChecker.isPermitted(eq("SecurityFacetSupportTest"), eq("test"), eq(READ), any())) .thenReturn(false); try { testSecurityFacetSupport.ensurePermitted(request); fail("AuthorizationException should have been thrown"); } catch (AuthorizationException e) { } verify(contentPermissionChecker).isPermitted(eq("SecurityFacetSupportTest"), eq("test"), eq(READ), any()); }
@Override public void ensurePermitted(final Request request) { checkNotNull(request); String action = action(request); Repository repo = getRepository(); VariableSource variableSource = variableResolverAdapter.fromRequest(request, getRepository()); if (!contentPermissionChecker.isPermitted(repo.getName(), repo.getFormat().getValue(), action, variableSource)) { throw new AuthorizationException(); } }
SecurityFacetSupport extends FacetSupport implements SecurityFacet { @Override public void ensurePermitted(final Request request) { checkNotNull(request); String action = action(request); Repository repo = getRepository(); VariableSource variableSource = variableResolverAdapter.fromRequest(request, getRepository()); if (!contentPermissionChecker.isPermitted(repo.getName(), repo.getFormat().getValue(), action, variableSource)) { throw new AuthorizationException(); } } }
SecurityFacetSupport extends FacetSupport implements SecurityFacet { @Override public void ensurePermitted(final Request request) { checkNotNull(request); String action = action(request); Repository repo = getRepository(); VariableSource variableSource = variableResolverAdapter.fromRequest(request, getRepository()); if (!contentPermissionChecker.isPermitted(repo.getName(), repo.getFormat().getValue(), action, variableSource)) { throw new AuthorizationException(); } } SecurityFacetSupport(final RepositoryFormatSecurityContributor securityContributor,
                              final VariableResolverAdapter variableResolverAdapter,
                              final ContentPermissionChecker contentPermissionChecker); }
SecurityFacetSupport extends FacetSupport implements SecurityFacet { @Override public void ensurePermitted(final Request request) { checkNotNull(request); String action = action(request); Repository repo = getRepository(); VariableSource variableSource = variableResolverAdapter.fromRequest(request, getRepository()); if (!contentPermissionChecker.isPermitted(repo.getName(), repo.getFormat().getValue(), action, variableSource)) { throw new AuthorizationException(); } } SecurityFacetSupport(final RepositoryFormatSecurityContributor securityContributor,
                              final VariableResolverAdapter variableResolverAdapter,
                              final ContentPermissionChecker contentPermissionChecker); @Override void ensurePermitted(final Request request); }
SecurityFacetSupport extends FacetSupport implements SecurityFacet { @Override public void ensurePermitted(final Request request) { checkNotNull(request); String action = action(request); Repository repo = getRepository(); VariableSource variableSource = variableResolverAdapter.fromRequest(request, getRepository()); if (!contentPermissionChecker.isPermitted(repo.getName(), repo.getFormat().getValue(), action, variableSource)) { throw new AuthorizationException(); } } SecurityFacetSupport(final RepositoryFormatSecurityContributor securityContributor,
                              final VariableResolverAdapter variableResolverAdapter,
                              final ContentPermissionChecker contentPermissionChecker); @Override void ensurePermitted(final Request request);  }