CugAccessControlManager extends AbstractAccessControlManager implements CugConstants, PolicyOwner { @NotNull @Override public Privilege[] getSupportedPrivileges(@Nullable String absPath) throws RepositoryException { if (isSupportedPath(getOakPath(absPath))) { return new Privilege[] {privilegeFromName(PrivilegeConstants.JCR_READ)}; } else { return new Privilege[0]; } } CugAccessControlManager(@NotNull Root root,
                            @NotNull NamePathMapper namePathMapper,
                            @NotNull SecurityProvider securityProvider,
                            @NotNull Set<String> supportedPaths,
                            @NotNull CugExclude cugExclude, RootProvider rootProvider); @NotNull @Override Privilege[] getSupportedPrivileges(@Nullable String absPath); @Override AccessControlPolicy[] getPolicies(String absPath); @Override AccessControlPolicy[] getEffectivePolicies(String absPath); @Override AccessControlPolicyIterator getApplicablePolicies(String absPath); @Override void removePolicy(String absPath, AccessControlPolicy policy); @Override void setPolicy(String absPath, AccessControlPolicy policy); @NotNull @Override JackrabbitAccessControlPolicy[] getApplicablePolicies(@NotNull Principal principal); @NotNull @Override JackrabbitAccessControlPolicy[] getPolicies(@NotNull Principal principal); @NotNull @Override AccessControlPolicy[] getEffectivePolicies(@NotNull Set<Principal> principals); @Override boolean defines(@Nullable String absPath, @NotNull AccessControlPolicy accessControlPolicy);  }
@Test public void testGetSupportedPrivileges() throws Exception { Privilege[] readPrivs = privilegesFromNames(PrivilegeConstants.JCR_READ); Map<String, Privilege[]> pathMap = ImmutableMap.of( SUPPORTED_PATH, readPrivs, SUPPORTED_PATH + "/subtree", readPrivs, UNSUPPORTED_PATH, new Privilege[0], NodeTypeConstants.NODE_TYPES_PATH, new Privilege[0] ); for (String path : pathMap.keySet()) { Privilege[] expected = pathMap.get(path); assertArrayEquals(expected, cugAccessControlManager.getSupportedPrivileges(path)); } }
@Test public void testGetSupportedPrivilegesNullPath() throws Exception { assertArrayEquals(new Privilege[0], cugAccessControlManager.getSupportedPrivileges(null)); }
@Test(expected = PathNotFoundException.class) public void testGetSupportedPrivilegesInvalidPath() throws Exception { cugAccessControlManager.getSupportedPrivileges(INVALID_PATH); }