@NotNull @Override public Restriction createRestriction(@Nullable String oakPath, @NotNull String oakName, @NotNull Value... values) throws RepositoryException { return base.createRestriction(oakPath, oakName, values); }
@Nonnull @Override public Restriction createRestriction(@Nullable String oakPath, @Nonnull String oakName, @Nonnull Value value) throws RepositoryException { return getProvider(oakPath, oakName).createRestriction(oakPath, oakName, value); }
@Nonnull @Override public Restriction createRestriction(@Nullable String oakPath, @Nonnull String oakName, @Nonnull Value... values) throws RepositoryException { return getProvider(oakPath, oakName).createRestriction(oakPath, oakName, values); }
@NotNull @Override public Restriction createRestriction(@Nullable String oakPath, @NotNull String oakName, @NotNull Value value) throws RepositoryException { return getProvider().createRestriction(oakPath, oakName, value); }
@Nonnull @Override public Restriction createRestriction(@Nullable String oakPath, @Nonnull String oakName, @Nonnull Value value) throws RepositoryException { return getProvider().createRestriction(oakPath, oakName, value); }
@NotNull @Override public Restriction createRestriction(@Nullable String oakPath, @NotNull String oakName, @NotNull Value... values) throws RepositoryException { return getProvider().createRestriction(oakPath, oakName, values); }
@NotNull @Override public Restriction createRestriction(@Nullable String oakPath, @NotNull String oakName, @NotNull Value value) throws RepositoryException { return getProvider(oakPath, oakName).createRestriction(oakPath, oakName, value); }
@NotNull @Override public Restriction createRestriction(@Nullable String oakPath, @NotNull String oakName, @NotNull Value value) throws RepositoryException { return getProvider().createRestriction(oakPath, oakName, value); }
@NotNull @Override public Restriction createRestriction(@Nullable String oakPath, @NotNull String oakName, @NotNull Value... values) throws RepositoryException { return getProvider(oakPath, oakName).createRestriction(oakPath, oakName, values); }
@Nonnull @Override public Restriction createRestriction(@Nullable String oakPath, @Nonnull String oakName, @Nonnull Value... values) throws RepositoryException { return getProvider().createRestriction(oakPath, oakName, values); }
@NotNull @Override public Restriction createRestriction(@Nullable String oakPath, @NotNull String oakName, @NotNull Value... values) throws RepositoryException { return getProvider().createRestriction(oakPath, oakName, values); }
@NotNull @Override public Restriction createRestriction(@Nullable String oakPath, @NotNull String oakName, @NotNull Value value) throws RepositoryException { if (REP_NODE_PATH.equals(oakName) && PropertyType.PATH == value.getType()) { return new RestrictionImpl(PropertyStates.createProperty(oakName, value), true); } else { return base.createRestriction(oakPath, oakName, value); } }
@NotNull @Override public Restriction createRestriction(@Nullable String oakPath, @NotNull String oakName, @NotNull Value value) throws RepositoryException { if (REP_NODE_PATH.equals(oakName) && PropertyType.PATH == value.getType()) { return new RestrictionImpl(PropertyStates.createProperty(oakName, value), true); } else { return base.createRestriction(oakPath, oakName, value); } }
@Test(expected = AccessControlException.class) public void testCreateRestrictionMvValues() throws RepositoryException { Value v = Mockito.mock(Value.class); RestrictionProvider.EMPTY.createRestriction(null, "name", v, v); }
@Test(expected = AccessControlException.class) public void testCreateRestrictionSingleValue() throws RepositoryException { Value v = Mockito.mock(Value.class); RestrictionProvider.EMPTY.createRestriction(null, "name", v); }
@Test public void testCreateRestriction() throws Exception { Map<String, Value> valid = ImmutableMap.of( NAME_BOOLEAN, vf.createValue(true), NAME_LONGS, vf.createValue(10), REP_GLOB, vf.createValue("*") ); for (String name : valid.keySet()) { provider.createRestriction("/testPath", name, valid.get(name)); } }
@Test public void testMvCreateRestriction() throws RepositoryException { Map<String, Value[]> valid = ImmutableMap.of( NAME_LONGS, new Value[] {vf.createValue(100)}, REP_PREFIXES, new Value[] {vf.createValue("prefix"), vf.createValue("prefix2")} ); for (String name : valid.keySet()) { provider.createRestriction("/testPath", name, valid.get(name)); } }
@Test public void testWriteRestrictions() throws Exception { NodeUtil aceNode = new NodeUtil(root.getTree("/")).addChild("test", NT_REP_GRANT_ACE); Set<Restriction> restrictions = ImmutableSet.of( provider.createRestriction("/test","boolean", vf.createValue(true)), provider.createRestriction("/test", "longs"), provider.createRestriction("/test", REP_GLOB, vf.createValue("*")), provider.createRestriction("/test", REP_NT_NAMES, vf.createValue("nt:base", PropertyType.NAME), vf.createValue("nt:version", PropertyType.NAME))); provider.writeRestrictions("/test", aceNode.getTree(), restrictions); }
private RestrictionPattern buildGlobPattern(@NotNull String path, @NotNull String glob) throws Exception { RestrictionProvider rp = getConfig(AuthorizationConfiguration.class).getRestrictionProvider(); Restriction restriction = rp.createRestriction(path, AccessControlConstants.REP_GLOB, getValueFactory(root).createValue(glob)); return rp.getPattern(path, ImmutableSet.of(restriction)); }
@Test public void testCreateRestrictionWithInvalidPath() throws Exception { try { provider.createRestriction(null, REP_GLOB, vf.createValue("*")); fail("rep:glob not supported at 'null' path"); } catch (AccessControlException e) { // success } }