CugAccessControlManager extends AbstractAccessControlManager implements CugConstants, PolicyOwner { @Override public AccessControlPolicyIterator getApplicablePolicies(String absPath) throws RepositoryException { String oakPath = getOakPath(absPath); if (oakPath == null || !isSupportedPath(oakPath)) { return AccessControlPolicyIteratorAdapter.EMPTY; } else { CugPolicy cug = getCugPolicy(oakPath); if (cug == null) { cug = new CugPolicyImpl(oakPath, getNamePathMapper(), principalManager, CugUtil.getImportBehavior(config), cugExclude); return new AccessControlPolicyIteratorAdapter(ImmutableSet.of(cug)); } else { return AccessControlPolicyIteratorAdapter.EMPTY; } } } 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 testGetApplicablePolicies() throws Exception { AccessControlPolicyIterator it = cugAccessControlManager.getApplicablePolicies(SUPPORTED_PATH); assertTrue(it.hasNext()); AccessControlPolicy policy = cugAccessControlManager.getApplicablePolicies(SUPPORTED_PATH).nextAccessControlPolicy(); assertTrue(policy instanceof CugPolicyImpl); }
@Test(expected = PathNotFoundException.class) public void testGetApplicablePoliciesInvalidPath() throws Exception { cugAccessControlManager.getApplicablePolicies(INVALID_PATH); }
@Test public void testGetApplicablePoliciesUnsupportedPath() throws Exception { AccessControlPolicyIterator it = cugAccessControlManager.getApplicablePolicies(UNSUPPORTED_PATH); assertFalse(it.hasNext()); }
@Test public void testGetApplicablePoliciesNullPath() throws Exception { AccessControlPolicyIterator it = cugAccessControlManager.getApplicablePolicies((String) null); assertFalse(it.hasNext()); }
@Test public void testGetApplicablePoliciesByPrincipal() { AccessControlPolicy[] applicable = cugAccessControlManager.getApplicablePolicies(EveryonePrincipal.getInstance()); assertNotNull(applicable); assertEquals(0, applicable.length); }