Search in sources :

Example 6 with RestrictionDefinition

use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionDefinition in project sling by apache.

the class SlingRestrictionProviderImpl method supportedRestrictions.

private static Map<String, RestrictionDefinition> supportedRestrictions() {
    RestrictionDefinition slingResourceTypes = new RestrictionDefinitionImpl(SLING_RESOURCE_TYPES, Type.STRINGS, false);
    RestrictionDefinition slingResourceTypesWithChildren = new RestrictionDefinitionImpl(SLING_RESOURCE_TYPES_WITH_DESCENDANTS, Type.STRINGS, false);
    Map<String, RestrictionDefinition> supportedRestrictions = new HashMap<String, RestrictionDefinition>();
    supportedRestrictions.put(slingResourceTypes.getName(), slingResourceTypes);
    supportedRestrictions.put(slingResourceTypesWithChildren.getName(), slingResourceTypesWithChildren);
    return Collections.unmodifiableMap(supportedRestrictions);
}
Also used : HashMap(java.util.HashMap) RestrictionDefinitionImpl(org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionDefinitionImpl) RestrictionDefinition(org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionDefinition)

Example 7 with RestrictionDefinition

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

the class RestrictionProviderImpl method supportedRestrictions.

private static Map<String, RestrictionDefinition> supportedRestrictions() {
    RestrictionDefinition glob = new RestrictionDefinitionImpl(REP_GLOB, Type.STRING, false);
    RestrictionDefinition nts = new RestrictionDefinitionImpl(REP_NT_NAMES, Type.NAMES, false);
    RestrictionDefinition pfxs = new RestrictionDefinitionImpl(REP_PREFIXES, Type.STRINGS, false);
    RestrictionDefinition names = new RestrictionDefinitionImpl(REP_ITEM_NAMES, Type.NAMES, false);
    return ImmutableMap.of(glob.getName(), glob, nts.getName(), nts, pfxs.getName(), pfxs, names.getName(), names);
}
Also used : RestrictionDefinitionImpl(org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionDefinitionImpl) RestrictionDefinition(org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionDefinition)

Example 8 with RestrictionDefinition

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

the class ACLTest method testGetRestrictionNames.

@Test
public void testGetRestrictionNames() throws RepositoryException {
    AbstractAccessControlList acl = createEmptyACL();
    String[] restrNames = acl.getRestrictionNames();
    assertNotNull(restrNames);
    List<String> names = Lists.newArrayList(restrNames);
    for (RestrictionDefinition def : getRestrictionProvider().getSupportedRestrictions(TEST_PATH)) {
        assertTrue(names.remove(getNamePathMapper().getJcrName(def.getName())));
    }
    assertTrue(names.isEmpty());
}
Also used : AbstractAccessControlList(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList) RestrictionDefinition(org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionDefinition) Test(org.junit.Test)

Example 9 with RestrictionDefinition

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

the class ACLTest method testGetRestrictionType.

@Test
public void testGetRestrictionType() throws RepositoryException {
    AbstractAccessControlList acl = createEmptyACL();
    for (RestrictionDefinition def : getRestrictionProvider().getSupportedRestrictions(TEST_PATH)) {
        int reqType = acl.getRestrictionType(getNamePathMapper().getJcrName(def.getName()));
        assertTrue(reqType > PropertyType.UNDEFINED);
        assertEquals(def.getRequiredType().tag(), reqType);
    }
}
Also used : AbstractAccessControlList(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList) RestrictionDefinition(org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionDefinition) Test(org.junit.Test)

Example 10 with RestrictionDefinition

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

the class RestrictionProviderImplTest method testGetSupportedDefinitions.

@Test
public void testGetSupportedDefinitions() {
    assertTrue(provider.getSupportedRestrictions(null).isEmpty());
    Set<RestrictionDefinition> defs = provider.getSupportedRestrictions("/testPath");
    assertNotNull(defs);
    assertEquals(4, defs.size());
    for (RestrictionDefinition def : defs) {
        if (REP_GLOB.equals(def.getName())) {
            assertEquals(Type.STRING, def.getRequiredType());
            assertFalse(def.isMandatory());
        } else if (REP_NT_NAMES.equals(def.getName())) {
            assertEquals(Type.NAMES, def.getRequiredType());
            assertFalse(def.isMandatory());
        } else if (REP_PREFIXES.equals(def.getName())) {
            assertEquals(Type.STRINGS, def.getRequiredType());
            assertFalse(def.isMandatory());
        } else if (REP_ITEM_NAMES.equals(def.getName())) {
            assertEquals(Type.NAMES, def.getRequiredType());
            assertFalse(def.isMandatory());
        } else {
            fail("unexpected restriction " + def.getName());
        }
    }
}
Also used : RestrictionDefinition(org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionDefinition) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Aggregations

RestrictionDefinition (org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionDefinition)11 RestrictionDefinitionImpl (org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionDefinitionImpl)5 Test (org.junit.Test)5 HashMap (java.util.HashMap)2 Nonnull (javax.annotation.Nonnull)2 AbstractAccessControlList (org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList)2 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Nullable (javax.annotation.Nullable)1 AccessControlException (javax.jcr.security.AccessControlException)1 Privilege (javax.jcr.security.Privilege)1 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)1 Tree (org.apache.jackrabbit.oak.api.Tree)1 ValueFactoryImpl (org.apache.jackrabbit.oak.plugins.value.jcr.ValueFactoryImpl)1 ACE (org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ACE)1 AbstractRestrictionProvider (org.apache.jackrabbit.oak.spi.security.authorization.restriction.AbstractRestrictionProvider)1 Restriction (org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction)1 Before (org.junit.Before)1