Search in sources :

Example 36 with Restriction

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

the class ACETest method testGetRestrictionsForMultiValued.

/**
 * @since OAK 1.0: support for multi-value restrictions
 */
@Test
public void testGetRestrictionsForMultiValued() throws Exception {
    // multivalued restriction
    Restriction nameRestr = createRestriction(AccessControlConstants.REP_NT_NAMES, nameValues);
    ACE ace = createEntry(nameRestr);
    Value[] vs = ace.getRestrictions(AccessControlConstants.REP_NT_NAMES);
    assertEquals(2, vs.length);
    assertArrayEquals(nameValues, vs);
}
Also used : Restriction(org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction) Value(javax.jcr.Value) Test(org.junit.Test)

Example 37 with Restriction

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

the class EntryTest 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(ImmutableSet.of(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) ACE(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ACE) Value(javax.jcr.Value) Test(org.junit.Test)

Example 38 with Restriction

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

the class EntryTest 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(ImmutableSet.of(nameRestr));
    assertNull(ace.getRestrictions(AccessControlConstants.REP_GLOB));
}
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 39 with Restriction

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

the class EntryTest method testGetRestrictionsForMultiValued.

/**
 * @since OAK 1.0: support for multi-value restrictions
 */
@Test
public void testGetRestrictionsForMultiValued() throws Exception {
    // multivalued restriction
    Restriction nameRestr = createRestriction(AccessControlConstants.REP_NT_NAMES, nameValues);
    ACE ace = createEntry(ImmutableSet.of(nameRestr));
    Value[] vs = ace.getRestrictions(AccessControlConstants.REP_NT_NAMES);
    assertEquals(2, vs.length);
    assertArrayEquals(nameValues, vs);
}
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