Search in sources :

Example 1 with Restriction

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

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

the class EntryTest method testGetRestrictions.

@Test
public void testGetRestrictions() throws Exception {
    Restriction nameRestr = createRestriction(AccessControlConstants.REP_NT_NAMES, nameValues);
    Restriction globRestr = createRestriction(AccessControlConstants.REP_GLOB, globValue);
    Set<Restriction> expected = ImmutableSet.of(nameRestr, globRestr);
    ACE ace = createEntry(expected);
    assertEquals(expected, ace.getRestrictions());
}
Also used : Restriction(org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction) ACE(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ACE) Test(org.junit.Test)

Example 3 with Restriction

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

the class EntryTest method testGetRestrictionForEmpty.

@Test
public void testGetRestrictionForEmpty() throws Exception {
    // empty restrictions
    Value val = createEntry(Collections.<Restriction>emptySet()).getRestriction(AccessControlConstants.REP_GLOB);
    assertNull(val);
}
Also used : Restriction(org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction) Value(javax.jcr.Value) Test(org.junit.Test)

Example 4 with Restriction

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

the class EntryTest method testGetNonExistingRestriction.

@Test
public void testGetNonExistingRestriction() throws Exception {
    // single valued restriction
    Restriction globRestr = createRestriction(AccessControlConstants.REP_GLOB, globValue);
    ACE ace = createEntry(ImmutableSet.of(globRestr));
    assertNull(ace.getRestriction(AccessControlConstants.REP_NT_NAMES));
}
Also used : Restriction(org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction) ACE(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ACE) Test(org.junit.Test)

Example 5 with Restriction

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

the class EntryTest method testGetRestrictionForSingleValued.

@Test
public void testGetRestrictionForSingleValued() throws Exception {
    // single valued restriction
    Restriction globRestr = createRestriction(AccessControlConstants.REP_GLOB, globValue);
    ACE ace = createEntry(ImmutableSet.of(globRestr));
    Value val = ace.getRestriction(AccessControlConstants.REP_GLOB);
    assertNotNull(val);
    assertEquals(globValue, val);
}
Also used : Restriction(org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction) ACE(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ACE) Value(javax.jcr.Value) Test(org.junit.Test)

Aggregations

Restriction (org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction)39 Test (org.junit.Test)33 Value (javax.jcr.Value)12 ACE (org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ACE)12 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)10 AccessControlException (javax.jcr.security.AccessControlException)6 Tree (org.apache.jackrabbit.oak.api.Tree)6 NodeUtil (org.apache.jackrabbit.oak.util.NodeUtil)5 Nonnull (javax.annotation.Nonnull)2 RestrictionImpl (org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionImpl)2 RestrictionPattern (org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionPattern)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 AccessControlEntry (javax.jcr.security.AccessControlEntry)1 AccessControlPolicy (javax.jcr.security.AccessControlPolicy)1 NamedAccessControlPolicy (javax.jcr.security.NamedAccessControlPolicy)1 Privilege (javax.jcr.security.Privilege)1 JackrabbitAccessControlPolicy (org.apache.jackrabbit.api.security.JackrabbitAccessControlPolicy)1 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)1 ImmutableACL (org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ImmutableACL)1