use of org.apache.jackrabbit.oak.spi.security.privilege.ImmutablePrivilegeDefinition in project jackrabbit-oak by apache.
the class PrivilegeDefinitionWriter method getBuiltInDefinitions.
private static Collection<PrivilegeDefinition> getBuiltInDefinitions() {
Map<String, PrivilegeDefinition> definitions = new LinkedHashMap<String, PrivilegeDefinition>();
for (String privilegeName : NON_AGGREGATE_PRIVILEGES) {
PrivilegeDefinition def = new ImmutablePrivilegeDefinition(privilegeName, false, null);
definitions.put(privilegeName, def);
}
for (String privilegeName : AGGREGATE_PRIVILEGES.keySet()) {
PrivilegeDefinition def = new ImmutablePrivilegeDefinition(privilegeName, false, asList(AGGREGATE_PRIVILEGES.get(privilegeName)));
definitions.put(privilegeName, def);
}
PrivilegeDefinition all = new ImmutablePrivilegeDefinition(JCR_ALL, false, definitions.keySet());
definitions.put(JCR_ALL, all);
return definitions.values();
}
use of org.apache.jackrabbit.oak.spi.security.privilege.ImmutablePrivilegeDefinition in project jackrabbit-oak by apache.
the class PrivilegeDefinitionWriterTest method testNameCollision.
@Test
public void testNameCollision() {
try {
PrivilegeDefinitionWriter writer = new PrivilegeDefinitionWriter(root);
writer.writeDefinition(new ImmutablePrivilegeDefinition(JCR_READ, true, null));
fail("name collision");
} catch (RepositoryException e) {
// success
}
}
use of org.apache.jackrabbit.oak.spi.security.privilege.ImmutablePrivilegeDefinition in project jackrabbit-oak by apache.
the class PrivilegeDefinitionWriterTest method testMissingPrivilegeRoot.
@Test
public void testMissingPrivilegeRoot() throws Exception {
ContentRepository repo = new Oak().with(new OpenSecurityProvider()).createContentRepository();
Root tmpRoot = repo.login(null, null).getLatestRoot();
try {
PrivilegeDefinitionWriter writer = new PrivilegeDefinitionWriter(tmpRoot);
writer.writeDefinition(new ImmutablePrivilegeDefinition("newName", true, null));
fail("missing privilege root");
} catch (RepositoryException e) {
// success
} finally {
tmpRoot.getContentSession().close();
}
}
use of org.apache.jackrabbit.oak.spi.security.privilege.ImmutablePrivilegeDefinition in project jackrabbit-oak by apache.
the class PrivilegeDefinitionWriterTest method testWriteDefinition.
@Test
public void testWriteDefinition() throws Exception {
PrivilegeDefinitionWriter writer = new PrivilegeDefinitionWriter(root);
writer.writeDefinition(new ImmutablePrivilegeDefinition("tmp", true, asList(JCR_READ_ACCESS_CONTROL, JCR_MODIFY_ACCESS_CONTROL)));
Tree privRoot = root.getTree(PRIVILEGES_PATH);
assertTrue(privRoot.hasChild("tmp"));
Tree tmpTree = privRoot.getChild("tmp");
assertTrue(TreeUtil.getBoolean(tmpTree, REP_IS_ABSTRACT));
assertArrayEquals(new String[] { JCR_READ_ACCESS_CONTROL, JCR_MODIFY_ACCESS_CONTROL }, Iterables.toArray(TreeUtil.getStrings(tmpTree, REP_AGGREGATES), String.class));
}
use of org.apache.jackrabbit.oak.spi.security.privilege.ImmutablePrivilegeDefinition in project jackrabbit-oak by apache.
the class PrivilegeDefinitionWriterTest method testCommitFails.
@Test(expected = RepositoryException.class)
public void testCommitFails() throws Exception {
Root r = Mockito.spy(root);
doThrow(new CommitFailedException(CommitFailedException.OAK, 1, "msg")).when(r).commit();
PrivilegeDefinitionWriter writer = new PrivilegeDefinitionWriter(r);
writer.writeDefinition(new ImmutablePrivilegeDefinition("tmp", true, asList(JCR_READ_ACCESS_CONTROL, JCR_MODIFY_ACCESS_CONTROL)));
}
Aggregations