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);
}
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);
}
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());
}
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);
}
}
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());
}
}
}
Aggregations