use of org.apache.jackrabbit.api.security.authorization.PrivilegeCollection in project jackrabbit by apache.
the class AbstractACLTemplateTest method testRemoveInvalidEntry.
public void testRemoveInvalidEntry() throws RepositoryException {
JackrabbitAccessControlList pt = createEmptyTemplate(getTestPath());
try {
pt.removeAccessControlEntry(new JackrabbitAccessControlEntry() {
public boolean isAllow() {
return false;
}
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() {
try {
return privilegesFromName(Privilege.JCR_READ);
} catch (Exception e) {
return new Privilege[0];
}
}
});
fail("Passing an unknown ACE should fail");
} catch (AccessControlException e) {
// success
}
}
use of org.apache.jackrabbit.api.security.authorization.PrivilegeCollection 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 org.apache.jackrabbit.api.security.authorization.PrivilegeCollection in project jackrabbit by apache.
the class AbstractEntryTest method testGetPrivilegeCollection.
public void testGetPrivilegeCollection() throws RepositoryException, NotExecutableException {
JackrabbitAccessControlEntry entry = createEntry(new String[] { Privilege.JCR_READ, Privilege.JCR_WRITE }, true);
PrivilegeCollection pc = entry.getPrivilegeCollection();
assertArrayEquals(entry.getPrivileges(), pc.getPrivileges());
assertTrue(pc.includes(Privilege.JCR_READ));
assertTrue(pc.includes(Privilege.JCR_WRITE));
assertTrue(pc.includes(Privilege.JCR_READ, Privilege.JCR_WRITE));
assertTrue(pc.includes(Privilege.JCR_READ, Privilege.JCR_MODIFY_PROPERTIES, Privilege.JCR_REMOVE_CHILD_NODES));
assertFalse(pc.includes(Privilege.JCR_READ, Privilege.JCR_LIFECYCLE_MANAGEMENT));
assertFalse(pc.includes(Privilege.JCR_VERSION_MANAGEMENT));
assertFalse(pc.includes(Privilege.JCR_ALL));
}
Aggregations