use of javax.jcr.security.AccessControlException in project jackrabbit-oak by apache.
the class ACLTest method testMandatoryRestrictions.
@Test
public void testMandatoryRestrictions() throws Exception {
RestrictionProvider rp = new TestRestrictionProvider("mandatory", Type.NAME, true);
JackrabbitAccessControlList acl = createACL(TEST_PATH, new ArrayList(), namePathMapper, rp);
try {
acl.addEntry(testPrincipal, testPrivileges, false, Collections.<String, Value>emptyMap());
fail("Mandatory restriction must be enforced.");
} catch (AccessControlException e) {
// mandatory restriction missing -> success
}
}
use of javax.jcr.security.AccessControlException in project jackrabbit-oak by apache.
the class ACLTest method testUnsupportedRestrictions2.
@Test
public void testUnsupportedRestrictions2() throws Exception {
RestrictionProvider rp = new TestRestrictionProvider("restr", Type.NAME, false);
JackrabbitAccessControlList acl = createACL(TEST_PATH, new ArrayList(), namePathMapper, rp);
try {
acl.addEntry(testPrincipal, testPrivileges, false, Collections.<String, Value>singletonMap("unsupported", getValueFactory().createValue("value")));
fail("Unsupported restriction must be detected.");
} catch (AccessControlException e) {
// mandatory restriction missing -> success
}
}
use of javax.jcr.security.AccessControlException in project jackrabbit-oak by apache.
the class AccessControlManagerImplTest method testRemoveInvalidPolicy.
@Test
public void testRemoveInvalidPolicy() throws Exception {
ACL acl = setupPolicy(testPath);
try {
acMgr.removePolicy(testPath, new TestACL(testPath, getRestrictionProvider(), getNamePathMapper()));
fail("Invalid policy -> removal must fail");
} catch (AccessControlException e) {
// success
}
ACL repoAcl = setupPolicy(null);
try {
acMgr.removePolicy(testPath, repoAcl);
fail("Setting invalid policy must fail");
} catch (AccessControlException e) {
// success
}
try {
acMgr.removePolicy(null, acl);
fail("Setting invalid policy must fail");
} catch (AccessControlException e) {
// success
}
}
use of javax.jcr.security.AccessControlException in project jackrabbit-oak by apache.
the class AccessControlManagerImplTest method testSetPolicyAcContent.
@Test
public void testSetPolicyAcContent() throws Exception {
for (String acPath : getAcContentPaths()) {
try {
AccessControlPolicy acl = createPolicy(acPath);
acMgr.setPolicy(acPath, acl);
fail("Setting access control policy to access control content should fail");
} catch (AccessControlException e) {
// success
}
}
}
use of javax.jcr.security.AccessControlException in project jackrabbit-oak by apache.
the class AccessControlManagerImplTest method testGetApplicablePoliciesInvalidPrincipal.
@Test
public void testGetApplicablePoliciesInvalidPrincipal() throws Exception {
Principal unknown = getPrincipalManager(root).getPrincipal("unknown");
int i = 0;
while (unknown != null) {
unknown = getPrincipalManager(root).getPrincipal("unknown" + i);
}
unknown = new InvalidTestPrincipal("unknown" + i);
try {
acMgr.getApplicablePolicies(unknown);
fail("Unknown principal should be detected.");
} catch (AccessControlException e) {
// success
}
}
Aggregations