Search in sources :

Example 1 with RestrictionImpl

use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionImpl 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 2 with RestrictionImpl

use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionImpl in project jackrabbit-oak by apache.

the class CompositeRestrictionProviderTest method testWriteUnsupportedRestrictions.

@Test
public void testWriteUnsupportedRestrictions() throws Exception {
    NodeUtil aceNode = new NodeUtil(root.getTree("/")).addChild("test", NT_REP_GRANT_ACE);
    Restriction invalid = new RestrictionImpl(PropertyStates.createProperty("invalid", vf.createValue(true)), false);
    try {
        provider.writeRestrictions("/test", aceNode.getTree(), ImmutableSet.<Restriction>of(invalid));
        fail("AccessControlException expected");
    } catch (AccessControlException e) {
    // success
    }
}
Also used : Restriction(org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction) AccessControlException(javax.jcr.security.AccessControlException) RestrictionImpl(org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionImpl) NodeUtil(org.apache.jackrabbit.oak.util.NodeUtil) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 3 with RestrictionImpl

use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionImpl in project jackrabbit-oak by apache.

the class AbstractRestrictionProviderTest method testWriteInvalidRestrictions.

@Test
public void testWriteInvalidRestrictions() throws Exception {
    PropertyState ps = PropertyStates.createProperty(REP_GLOB, valueFactory.createValue(false));
    Tree aceTree = getAceTree();
    restrictionProvider.writeRestrictions(testPath, aceTree, ImmutableSet.<Restriction>of(new RestrictionImpl(ps, false)));
    assertTrue(aceTree.hasChild(REP_RESTRICTIONS));
    Tree restr = aceTree.getChild(REP_RESTRICTIONS);
    assertEquals(ps, restr.getProperty(REP_GLOB));
}
Also used : Tree(org.apache.jackrabbit.oak.api.Tree) RestrictionImpl(org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionImpl) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Aggregations

RestrictionImpl (org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionImpl)3 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)2 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)2 Restriction (org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction)2 Test (org.junit.Test)2 HashSet (java.util.HashSet)1 Nonnull (javax.annotation.Nonnull)1 AccessControlException (javax.jcr.security.AccessControlException)1 Tree (org.apache.jackrabbit.oak.api.Tree)1 NodeUtil (org.apache.jackrabbit.oak.util.NodeUtil)1