use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction in project jackrabbit-oak by apache.
the class AbstractRestrictionProviderTest method testValidateRestrictionsMissingMandatory.
@Test
public void testValidateRestrictionsMissingMandatory() throws Exception {
Restriction glob = restrictionProvider.createRestriction(testPath, REP_GLOB, globValue);
try {
restrictionProvider.validateRestrictions(testPath, getAceTree(glob));
fail("missing mandatory restriction");
} catch (AccessControlException e) {
// success
}
}
use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction in project jackrabbit-oak by apache.
the class AbstractRestrictionProviderTest method testValidateRestrictionsUnsupportedPath.
@Test
public void testValidateRestrictionsUnsupportedPath() throws Exception {
// empty restrictions => must succeed
restrictionProvider.validateRestrictions(null, getAceTree());
// non-empty restrictions => must fail
try {
Restriction restr = restrictionProvider.createRestriction(testPath, REP_GLOB, globValue);
restrictionProvider.validateRestrictions(null, getAceTree(restr));
fail();
} catch (AccessControlException e) {
// success
}
}
use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction in project jackrabbit-oak by apache.
the class AbstractRestrictionProviderTest method testValidateRestrictionsWrongType.
@Test
public void testValidateRestrictionsWrongType() throws Exception {
Restriction mand = restrictionProvider.createRestriction(testPath, "mandatory", valueFactory.createValue(true));
try {
Tree ace = getAceTree(mand);
new NodeUtil(ace).getChild(REP_RESTRICTIONS).setBoolean(REP_GLOB, true);
restrictionProvider.validateRestrictions(testPath, ace);
fail("wrong type with restriction 'rep:glob");
} catch (AccessControlException e) {
// success
}
}
use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction in project jackrabbit-oak by apache.
the class AbstractRestrictionProviderTest method testValidateRestrictionsUnsupportedRestriction.
@Test
public void testValidateRestrictionsUnsupportedRestriction() throws Exception {
Restriction mand = restrictionProvider.createRestriction(testPath, "mandatory", valueFactory.createValue(true));
try {
Tree ace = getAceTree(mand);
new NodeUtil(ace).getChild(REP_RESTRICTIONS).setString("Unsupported", "value");
restrictionProvider.validateRestrictions(testPath, ace);
fail("wrong type with restriction 'rep:glob");
} catch (AccessControlException e) {
// success
}
}
use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction in project sling by apache.
the class SlingRestrictionProviderImpl method getPattern.
@Nonnull
@Override
public RestrictionPattern getPattern(@Nullable String oakPath, @Nonnull Set<Restriction> restrictions) {
if (oakPath != null && !restrictions.isEmpty()) {
for (Restriction r : restrictions) {
String name = r.getDefinition().getName();
if (SLING_RESOURCE_TYPES.equals(name)) {
ResourceTypePattern resourceTypePattern = new ResourceTypePattern(r.getProperty().getValue(Type.STRINGS), oakPath, false);
LOG.trace("Returning resourceTypePattern={} for rep:slingResourceTypes in getPattern(String,Set<Restriction>)", resourceTypePattern);
return resourceTypePattern;
} else if (SLING_RESOURCE_TYPES_WITH_DESCENDANTS.equals(name)) {
ResourceTypePattern resourceTypePattern = new ResourceTypePattern(r.getProperty().getValue(Type.STRINGS), oakPath, true);
LOG.trace("Returning resourceTypePattern={} for rep:slingResourceTypesWithChildren in getPattern(String,Set<Restriction>)", resourceTypePattern);
return resourceTypePattern;
}
}
}
return RestrictionPattern.EMPTY;
}
Aggregations