Search in sources :

Example 36 with 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.");
    }
}
Also used : TreeLocation(org.apache.jackrabbit.oak.plugins.tree.TreeLocation) ArrayList(java.util.ArrayList) Tree(org.apache.jackrabbit.oak.api.Tree) RepositoryException(javax.jcr.RepositoryException) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Nonnull(javax.annotation.Nonnull)

Example 37 with PropertyState

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);
    }
}
Also used : Tree(org.apache.jackrabbit.oak.api.Tree) PropertyState(org.apache.jackrabbit.oak.api.PropertyState)

Example 38 with 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));
    }
}
Also used : Tree(org.apache.jackrabbit.oak.api.Tree) PropertyState(org.apache.jackrabbit.oak.api.PropertyState)

Example 39 with PropertyState

use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.

the class PrincipalRestrictionProvider method readRestrictions.

@Nonnull
@Override
public Set<Restriction> readRestrictions(@Nullable String oakPath, @Nonnull Tree aceTree) {
    Set<Restriction> restrictions = new HashSet<Restriction>(base.readRestrictions(oakPath, aceTree));
    String value = (oakPath == null) ? "" : oakPath;
    PropertyState nodePathProp = PropertyStates.createProperty(REP_NODE_PATH, value, Type.PATH);
    restrictions.add(new RestrictionImpl(nodePathProp, true));
    return restrictions;
}
Also used : Restriction(org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction) RestrictionImpl(org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionImpl) HashSet(java.util.HashSet) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Nonnull(javax.annotation.Nonnull)

Example 40 with PropertyState

use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.

the class AbstractCompositeProviderTest method testTreePermissionIsNotGranted.

@Test
public void testTreePermissionIsNotGranted() throws Exception {
    PermissionProvider pp = createPermissionProvider();
    TreePermission parentPermission = TreePermission.EMPTY;
    PropertyState ps = PropertyStates.createProperty("propName", "val");
    for (String path : TP_PATHS) {
        Tree t = readOnlyRoot.getTree(path);
        TreePermission tp = pp.getTreePermission(t, parentPermission);
        assertFalse(tp.isGranted(Permissions.NO_PERMISSION));
        assertFalse(tp.isGranted(Permissions.MODIFY_ACCESS_CONTROL));
        assertFalse(tp.isGranted(Permissions.NO_PERMISSION, ps));
        assertFalse(tp.isGranted(Permissions.MODIFY_ACCESS_CONTROL, ps));
        parentPermission = tp;
    }
}
Also used : PermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider) AggregatedPermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.AggregatedPermissionProvider) Tree(org.apache.jackrabbit.oak.api.Tree) ImmutableTree(org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree) TreePermission(org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Aggregations

PropertyState (org.apache.jackrabbit.oak.api.PropertyState)404 Test (org.junit.Test)189 Tree (org.apache.jackrabbit.oak.api.Tree)138 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)49 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)45 Nonnull (javax.annotation.Nonnull)31 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)29 RemoteTree (org.apache.jackrabbit.oak.remote.RemoteTree)28 RemoteValue (org.apache.jackrabbit.oak.remote.RemoteValue)28 Blob (org.apache.jackrabbit.oak.api.Blob)21 ArrayList (java.util.ArrayList)20 LongPropertyState (org.apache.jackrabbit.oak.plugins.memory.LongPropertyState)17 ChildNodeEntry (org.apache.jackrabbit.oak.spi.state.ChildNodeEntry)16 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)14 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)13 CheckForNull (javax.annotation.CheckForNull)12 RepositoryException (javax.jcr.RepositoryException)10 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)10 Map (java.util.Map)9 Value (javax.jcr.Value)9