use of javax.jcr.security.AccessControlException in project jackrabbit by apache.
the class AccessControlPolicyTest method testSetIllegalPolicy.
public void testSetIllegalPolicy() throws RepositoryException, AccessDeniedException, NotExecutableException {
checkCanModifyAc(path);
try {
acMgr.setPolicy(path, new AccessControlPolicy() {
});
fail("SetPolicy with an unknown policy should throw AccessControlException.");
} catch (AccessControlException e) {
// success.
}
}
use of javax.jcr.security.AccessControlException in project jackrabbit by apache.
the class AbstractACLTemplateTest method testAddInvalidEntry.
public void testAddInvalidEntry() throws RepositoryException, NotExecutableException {
Principal unknownPrincipal;
if (!principalMgr.hasPrincipal("an unknown principal")) {
unknownPrincipal = new TestPrincipal("an unknown principal");
} else {
throw new NotExecutableException();
}
JackrabbitAccessControlList pt = createEmptyTemplate(getTestPath());
try {
pt.addAccessControlEntry(unknownPrincipal, privilegesFromName(Privilege.JCR_READ));
fail("Adding an ACE with an unknown principal should fail");
} catch (AccessControlException e) {
// success
}
}
use of javax.jcr.security.AccessControlException in project jackrabbit by apache.
the class AbstractACLTemplateTest method testRemoveInvalidEntry2.
public void testRemoveInvalidEntry2() throws RepositoryException {
JackrabbitAccessControlList pt = createEmptyTemplate(getTestPath());
try {
pt.removeAccessControlEntry(new JackrabbitAccessControlEntry() {
public boolean isAllow() {
return false;
}
public int getPrivilegeBits() {
return 0;
}
public String[] getRestrictionNames() {
return new String[0];
}
public Value getRestriction(String restrictionName) {
return null;
}
public Value[] getRestrictions(String restrictionName) throws RepositoryException {
return null;
}
@Override
public PrivilegeCollection getPrivilegeCollection() throws RepositoryException {
throw new UnsupportedRepositoryOperationException();
}
public Principal getPrincipal() {
return testPrincipal;
}
public Privilege[] getPrivileges() {
return new Privilege[0];
}
});
fail("Passing a ACE with invalid privileges should fail");
} catch (AccessControlException e) {
// success
}
}
use of javax.jcr.security.AccessControlException in project jackrabbit by apache.
the class AbstractACLTemplateTest method testRemoveNonExisting.
public void testRemoveNonExisting() throws RepositoryException {
JackrabbitAccessControlList pt = createEmptyTemplate(getTestPath());
try {
pt.removeAccessControlEntry(new AccessControlEntry() {
public Principal getPrincipal() {
return testPrincipal;
}
public Privilege[] getPrivileges() {
return new Privilege[0];
}
});
fail("Attemt to remove a non-existing, custom ACE must throw AccessControlException.");
} catch (AccessControlException e) {
// success
}
}
use of javax.jcr.security.AccessControlException in project jackrabbit by apache.
the class AbstractEntryTest method testInvalidPrivilege.
public void testInvalidPrivilege() throws RepositoryException, NotExecutableException {
Privilege invalidPriv = new Privilege() {
public String getName() {
return "";
}
public boolean isAbstract() {
return false;
}
public boolean isAggregate() {
return false;
}
public Privilege[] getDeclaredAggregatePrivileges() {
return new Privilege[0];
}
public Privilege[] getAggregatePrivileges() {
return new Privilege[0];
}
};
try {
Privilege[] privs = new Privilege[] { invalidPriv, privilegesFromName(Privilege.JCR_READ)[0] };
createEntry(testPrincipal, privs, true);
fail("Principal must not be null");
} catch (AccessControlException e) {
// success
}
}
Aggregations