use of org.apache.jackrabbit.value.StringValue in project jackrabbit-oak by apache.
the class PermissionTest method addEntry.
private void addEntry(String path, boolean grant, String restriction, String... privilegeNames) throws Exception {
AccessControlManager acMgr = getAccessControlManager(root);
JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, path);
if (restriction.length() > 0) {
Map<String, Value> rs = new HashMap<String, Value>();
rs.put("rep:glob", new StringValue(restriction));
acl.addEntry(testPrincipal, AccessControlUtils.privilegesFromNames(acMgr, privilegeNames), grant, rs);
} else {
acl.addEntry(testPrincipal, AccessControlUtils.privilegesFromNames(acMgr, privilegeNames), grant);
}
acMgr.setPolicy(path, acl);
root.commit();
}
use of org.apache.jackrabbit.value.StringValue in project jackrabbit by apache.
the class ImpersonationImpl method updateImpersonatorNames.
private void updateImpersonatorNames(Set<String> principalNames) throws RepositoryException {
NodeImpl userNode = user.getNode();
try {
String[] pNames = principalNames.toArray(new String[principalNames.size()]);
if (pNames.length == 0) {
PropertyImpl prop = userNode.getProperty(P_IMPERSONATORS);
userManager.removeProtectedItem(prop, userNode);
} else {
Value[] values = new Value[pNames.length];
for (int i = 0; i < pNames.length; i++) {
values[i] = new StringValue(pNames[i]);
}
userManager.setProtectedProperty(userNode, P_IMPERSONATORS, values);
}
} catch (RepositoryException e) {
// revert pending changes
userNode.refresh(false);
throw e;
}
}
use of org.apache.jackrabbit.value.StringValue in project jackrabbit-oak by apache.
the class CustomRestrictionProviderTest method addEntry.
private void addEntry(String path, boolean grant, String restriction, String... privilegeNames) throws Exception {
AccessControlManager acMgr = getAccessControlManager(root);
JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, path);
if (restriction.length() > 0) {
Map<String, Value> rs = new HashMap<String, Value>();
rs.put(PropertyRestrictionProvider.RESTRICTION_NAME, new StringValue(restriction));
acl.addEntry(testPrincipal, AccessControlUtils.privilegesFromNames(acMgr, privilegeNames), grant, rs);
} else {
acl.addEntry(testPrincipal, AccessControlUtils.privilegesFromNames(acMgr, privilegeNames), grant);
}
acMgr.setPolicy(path, acl);
root.commit();
}
use of org.apache.jackrabbit.value.StringValue in project jackrabbit-oak by apache.
the class AuthorizablePropertyTest method testSetSpecialPropertiesDirectly.
@Test
public void testSetSpecialPropertiesDirectly() throws NotExecutableException, RepositoryException {
Node n = getNode(user, superuser);
try {
String pName = user.getPrincipal().getName();
n.setProperty(UserConstants.REP_PRINCIPAL_NAME, new StringValue("any-value"));
// should have failed => change value back.
n.setProperty(UserConstants.REP_PRINCIPAL_NAME, new StringValue(pName));
fail("Attempt to change protected property rep:principalName should fail.");
} catch (ConstraintViolationException e) {
// ok.
}
try {
String imperson = "anyimpersonator";
n.setProperty(UserConstants.REP_IMPERSONATORS, new Value[] { new StringValue(imperson) }, PropertyType.STRING);
fail("Attempt to change protected property rep:impersonators should fail.");
} catch (ConstraintViolationException e) {
// ok.
}
}
use of org.apache.jackrabbit.value.StringValue in project jackrabbit by apache.
the class RestrictionTest method addEntry.
private void addEntry(String path, boolean grant, String restriction, String... privilegeNames) throws Exception {
if (restriction.length() > 0) {
Map<String, Value> rs = new HashMap<String, Value>();
rs.put("rep:glob", new StringValue(restriction));
modifyPrivileges(path, testUser.getPrincipal(), AccessControlUtils.privilegesFromNames(acMgr, privilegeNames), grant, rs);
} else {
modifyPrivileges(path, testUser.getPrincipal(), AccessControlUtils.privilegesFromNames(acMgr, privilegeNames), grant, Collections.<String, Value>emptyMap());
}
}
Aggregations