use of org.apache.jackrabbit.oak.spi.xml.PropInfo in project jackrabbit-oak by apache.
the class AccessControlImporterBaseTest method testStartAceChildInfoInvalidPrivilege.
@Test(expected = AccessControlException.class)
public void testStartAceChildInfoInvalidPrivilege() throws Exception {
init();
importer.start(aclTree);
PropInfo invalidPrivInfo = new PropInfo(REP_PRIVILEGES, PropertyType.NAME, createTextValues("jcr:invalidPrivilege"), PropInfo.MultipleStatus.MULTIPLE);
importer.startChildInfo(aceInfo, ImmutableList.of(invalidPrivInfo));
}
use of org.apache.jackrabbit.oak.spi.xml.PropInfo in project jackrabbit-oak by apache.
the class AccessControlImporterBesteffortTest method testImportWithUnknownPrincipal.
@Test
public void testImportWithUnknownPrincipal() throws Exception {
init();
importer.start(aclTree);
PropInfo privs = new PropInfo(REP_PRIVILEGES, PropertyType.NAME, createTextValues(PrivilegeConstants.JCR_READ));
importer.startChildInfo(aceInfo, ImmutableList.of(unknownPrincipalInfo, privs));
importer.endChildInfo();
importer.end(aclTree);
Tree aceTree = aclTree.getChildren().iterator().next();
assertEquals(unknownPrincipalInfo.getValue(PropertyType.STRING).getString(), TreeUtil.getString(aceTree, REP_PRINCIPAL_NAME));
}
use of org.apache.jackrabbit.oak.spi.xml.PropInfo in project jackrabbit-oak by apache.
the class AccessControlImporterBaseTest method before.
@Override
public void before() throws Exception {
super.before();
Tree t = root.getTree(PathUtils.ROOT_PATH).addChild("testNode");
t.setProperty(JcrConstants.JCR_PRIMARYTYPE, NodeTypeConstants.NT_OAK_UNSTRUCTURED, Type.NAME);
AccessControlManager acMgr = getAccessControlManager(root);
JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, t.getPath());
acl.addAccessControlEntry(EveryonePrincipal.getInstance(), privilegesFromNames(PrivilegeConstants.JCR_READ));
acMgr.setPolicy(t.getPath(), acl);
root.commit();
accessControlledTree = root.getTree("/testNode");
aclTree = accessControlledTree.getChild(REP_POLICY);
importer = new AccessControlImporter();
principalName = getTestUser().getPrincipal().getName();
principalInfo = new PropInfo(REP_PRINCIPAL_NAME, PropertyType.STRING, createTextValue(principalName));
privInfo = new PropInfo(REP_PRIVILEGES, PropertyType.NAME, createTextValues(PrivilegeConstants.JCR_READ, PrivilegeConstants.JCR_ADD_CHILD_NODES));
}
use of org.apache.jackrabbit.oak.spi.xml.PropInfo in project jackrabbit-oak by apache.
the class AccessControlImporter method startChildInfo.
@Override
public void startChildInfo(@Nonnull NodeInfo childInfo, @Nonnull List<PropInfo> propInfos) throws RepositoryException {
checkInitialized();
String ntName = childInfo.getPrimaryTypeName();
if (NT_REP_GRANT_ACE.equals(ntName) || NT_REP_DENY_ACE.equals(ntName)) {
if (entry != null) {
throw new ConstraintViolationException("Invalid child node sequence: ACEs may not be nested.");
}
entry = new MutableEntry(NT_REP_GRANT_ACE.equals(ntName));
for (PropInfo prop : propInfos) {
String name = prop.getName();
if (REP_PRINCIPAL_NAME.equals(name)) {
entry.setPrincipal(prop.getTextValue());
} else if (REP_PRIVILEGES.equals(name)) {
entry.setPrivilegeNames(prop.getTextValues());
} else {
entry.addRestriction(prop);
}
}
childStatus = CHILD_STATUS_ACE;
} else if (NT_REP_RESTRICTIONS.equals(ntName)) {
if (entry == null) {
throw new ConstraintViolationException("Invalid child node sequence: Restriction must be associated with an ACE");
}
entry.addRestrictions(propInfos);
childStatus = CHILD_STATUS_RESTRICTION;
} else {
throw new ConstraintViolationException("Invalid child node with type " + ntName);
}
}
use of org.apache.jackrabbit.oak.spi.xml.PropInfo in project jackrabbit-oak by apache.
the class SysViewImportHandler method processNode.
private void processNode(ImportState state, boolean start, boolean end) throws SAXException {
if (!start && !end) {
return;
}
String id = state.uuid;
NodeInfo node = new NodeInfo(state.nodeName, state.nodeTypeName, state.mixinNames, id);
// call Importer
try {
if (start) {
importer.startNode(node, state.props);
// dispose temporary property values
for (PropInfo pi : state.props) {
pi.dispose();
}
}
if (end) {
importer.endNode(node);
}
} catch (RepositoryException re) {
throw new SAXException(re);
}
}
Aggregations