Search in sources :

Example 31 with Restriction

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

the class ACETest method testGetRestrictionNames.

@Test
public void testGetRestrictionNames() throws Exception {
    // empty restrictions
    String[] restrictionNames = createEntry().getRestrictionNames();
    assertNotNull(restrictionNames);
    assertEquals(0, restrictionNames.length);
    Restriction globRestr = createRestriction(AccessControlConstants.REP_GLOB, globValue);
    Restriction nameRestr = createRestriction(AccessControlConstants.REP_NT_NAMES, nameValues);
    // single restriction
    restrictionNames = createEntry(globRestr).getRestrictionNames();
    assertEquals(1, restrictionNames.length);
    // 2 restrictions
    restrictionNames = createEntry(globRestr, nameRestr).getRestrictionNames();
    assertEquals(2, restrictionNames.length);
}
Also used : Restriction(org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction) Test(org.junit.Test)

Example 32 with Restriction

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

the class ACETest method testGetNonExistingRestrictions.

/**
 * @since OAK 1.0: support for multi-value restrictions
 */
@Test
public void testGetNonExistingRestrictions() throws Exception {
    Restriction nameRestr = createRestriction(AccessControlConstants.REP_NT_NAMES, nameValues);
    ACE ace = createEntry(nameRestr);
    assertNull(ace.getRestrictions(AccessControlConstants.REP_GLOB));
}
Also used : Restriction(org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction) Test(org.junit.Test)

Example 33 with Restriction

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

the class ACETest 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(nameRestr, globRestr);
    assertEquals(expected, ace.getRestrictions());
}
Also used : Restriction(org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction) Test(org.junit.Test)

Example 34 with Restriction

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

the class ACETest method testGetRestrictionsForSingleValue.

/**
 * @since OAK 1.0: support for multi-value restrictions
 */
@Test
public void testGetRestrictionsForSingleValue() throws Exception {
    // single valued restriction
    Restriction globRestr = createRestriction(AccessControlConstants.REP_GLOB, globValue);
    ACE ace = createEntry(globRestr);
    Value[] vs = ace.getRestrictions(AccessControlConstants.REP_GLOB);
    assertNotNull(vs);
    assertArrayEquals(new Value[] { globValue }, vs);
}
Also used : Restriction(org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction) Value(javax.jcr.Value) Test(org.junit.Test)

Example 35 with Restriction

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

the class ACETest method testGetRestrictionForMultiValued2.

/**
 * @since OAK 1.0: support for multi-value restrictions
 */
@Test
public void testGetRestrictionForMultiValued2() throws Exception {
    // single value restriction stored in multi-value property
    Restriction singleNameRestr = createRestriction(AccessControlConstants.REP_NT_NAMES, new Value[] { nameValue });
    ACE ace = createEntry(singleNameRestr);
    Value val = ace.getRestriction(AccessControlConstants.REP_NT_NAMES);
    assertEquals(nameValue, val);
}
Also used : Restriction(org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction) 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