use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class AccessControlManagerImpl method getPrincipal.
@Nonnull
private Principal getPrincipal(@Nonnull Tree aceTree) {
String principalName = checkNotNull(TreeUtil.getString(aceTree, REP_PRINCIPAL_NAME));
Principal principal = principalManager.getPrincipal(principalName);
if (principal == null) {
log.debug("Unknown principal " + principalName);
principal = new PrincipalImpl(principalName);
}
return principal;
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class AdminPrincipalsBaseTest method before.
@Override
public void before() throws Exception {
super.before();
NodeUtil rootNode = new NodeUtil(root.getTree("/"), NamePathMapper.DEFAULT);
rootNode.addChild("testNode", JcrConstants.NT_UNSTRUCTURED);
administrativePrincipal = getUserManager(root).createGroup(new PrincipalImpl(ADMINISTRATORS_PRINCIPAL_NAME)).getPrincipal();
root.commit();
AccessControlManager acMgr = getAccessControlManager(root);
AccessControlPolicyIterator itr = acMgr.getApplicablePolicies("/testNode");
while (itr.hasNext() && acl == null) {
AccessControlPolicy policy = itr.nextAccessControlPolicy();
if (policy instanceof AccessControlList) {
acl = (AccessControlList) policy;
}
}
if (acl == null) {
throw new RepositoryException("No applicable policy found.");
}
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class ACLTest method testInternalPrincipal.
@Test
public void testInternalPrincipal() throws RepositoryException {
Principal internal = new PrincipalImpl("unknown");
acl.addAccessControlEntry(internal, privilegesFromNames(JCR_READ));
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class ACLTest method testAddEntriesWithCustomPrincipal.
@Test
public void testAddEntriesWithCustomPrincipal() throws Exception {
Principal oakPrincipal = new PrincipalImpl("anonymous");
Principal principal = new Principal() {
@Override
public String getName() {
return "anonymous";
}
};
assertTrue(acl.addAccessControlEntry(oakPrincipal, privilegesFromNames(JCR_READ)));
assertTrue(acl.addAccessControlEntry(principal, privilegesFromNames(JCR_READ_ACCESS_CONTROL)));
assertEquals(1, acl.getAccessControlEntries().length);
assertTrue(acl.addEntry(principal, privilegesFromNames(JCR_READ), false));
assertEquals(2, acl.getAccessControlEntries().length);
assertArrayEquals(privilegesFromNames(JCR_READ_ACCESS_CONTROL), acl.getAccessControlEntries()[0].getPrivileges());
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class ACLTest method testEmptyPrincipal.
@Test
public void testEmptyPrincipal() throws Exception {
try {
acl.addAccessControlEntry(new PrincipalImpl(""), privilegesFromNames(JCR_READ));
fail("Adding an ACE with empty-named principal should fail");
} catch (AccessControlException e) {
// success
}
}
Aggregations