use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class AuthorizablePropertiesImpl method getAuthorizableProperty.
/**
* Returns the valid authorizable property identified by the specified
* property location or {@code null} if that property does not exist or
* isn't a authorizable property because it is protected or outside of the
* scope of the {@code authorizableTree}.
*
* @param authorizableTree The tree of the target authorizable.
* @param propertyLocation Location to be tested.
* @param verifyAncestor If true the property is tested to be a descendant
* of the node of this authorizable; otherwise it is expected that this
* test has been executed by the caller.
* @return a valid authorizable property or {@code null} if no such property
* exists or fi the property is protected or not defined by the rep:authorizable
* node type or one of it's sub-node types.
* @throws RepositoryException If an error occurs.
*/
@CheckForNull
private PropertyState getAuthorizableProperty(@Nonnull Tree authorizableTree, @Nonnull TreeLocation propertyLocation, boolean verifyAncestor) throws RepositoryException {
PropertyState property = propertyLocation.getProperty();
if (property == null) {
return null;
}
String authorizablePath = authorizableTree.getPath();
if (verifyAncestor && !Text.isDescendant(authorizablePath, propertyLocation.getPath())) {
log.debug("Attempt to access property outside of authorizable scope.");
return null;
}
Tree parent = propertyLocation.getParent().getTree();
if (parent == null) {
log.debug("Unable to determine definition of authorizable property at " + propertyLocation.getPath());
return null;
}
ReadOnlyNodeTypeManager nodeTypeManager = authorizable.getUserManager().getNodeTypeManager();
PropertyDefinition def = nodeTypeManager.getDefinition(parent, property, true);
if (def.isProtected() || (authorizablePath.equals(parent.getPath()) && !def.getDeclaringNodeType().isNodeType(UserConstants.NT_REP_AUTHORIZABLE))) {
return null;
}
return property;
}
use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class AuthorizablePropertiesImpl method setProperty.
/**
* @see org.apache.jackrabbit.api.security.user.Authorizable#setProperty(String, javax.jcr.Value[])
*/
@Override
public void setProperty(@Nonnull String relPath, @Nullable Value[] values) throws RepositoryException {
if (values == null) {
removeProperty(relPath);
} else {
String oakPath = getOakPath(relPath);
String name = Text.getName(oakPath);
PropertyState propertyState = PropertyStates.createProperty(name, Arrays.asList(values));
String intermediate = (oakPath.equals(name)) ? null : Text.getRelativeParent(oakPath, 1);
Tree parent = getOrCreateTargetTree(intermediate);
checkProtectedProperty(parent, propertyState);
parent.setProperty(propertyState);
}
}
use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class AuthorizablePropertiesImpl method getNames.
//---------------------------------------------< AuthorizableProperties >---
@Nonnull
@Override
public Iterator<String> getNames(@Nonnull String relPath) throws RepositoryException {
String oakPath = getOakPath(relPath);
Tree tree = getTree();
TreeLocation location = getLocation(tree, oakPath);
Tree parent = location.getTree();
if (parent != null && Text.isDescendantOrEqual(tree.getPath(), parent.getPath())) {
List<String> l = new ArrayList<String>();
for (PropertyState property : parent.getProperties()) {
String propName = property.getName();
if (isAuthorizableProperty(tree, location.getChild(propName), false)) {
l.add(namePathMapper.getJcrName(propName));
}
}
return l.iterator();
} else {
throw new RepositoryException("Relative path " + relPath + " refers to non-existing tree or tree outside of scope of authorizable.");
}
}
use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class AuthorizablePropertiesImpl method setProperty.
/**
* @see org.apache.jackrabbit.api.security.user.Authorizable#setProperty(String, javax.jcr.Value)
*/
@Override
public void setProperty(@Nonnull String relPath, @Nullable Value value) throws RepositoryException {
if (value == null) {
removeProperty(relPath);
} else {
String oakPath = getOakPath(relPath);
String name = Text.getName(oakPath);
PropertyState propertyState = PropertyStates.createProperty(name, value);
String intermediate = (oakPath.equals(name)) ? null : Text.getRelativeParent(oakPath, 1);
Tree parent = getOrCreateTargetTree(intermediate);
checkProtectedProperty(parent, propertyState);
parent.setProperty(propertyState);
}
}
use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class RestrictionProviderImpl method validateRestrictions.
@Override
public void validateRestrictions(String oakPath, @Nonnull Tree aceTree) throws AccessControlException {
super.validateRestrictions(oakPath, aceTree);
Tree restrictionsTree = getRestrictionsTree(aceTree);
PropertyState glob = restrictionsTree.getProperty(REP_GLOB);
if (glob != null) {
GlobPattern.validate(glob.getValue(Type.STRING));
}
}
Aggregations