@NotNull @Override public Set<Restriction> readRestrictions(@Nullable String oakPath, @NotNull Tree aceTree) { Set<Restriction> restrictions = Sets.newHashSet(); for (RestrictionProvider rp : providers) { restrictions.addAll(rp.readRestrictions(oakPath, aceTree)); } return restrictions; }
@Nonnull @Override public Set<Restriction> readRestrictions(@Nullable String oakPath, @Nonnull Tree aceTree) { Set<Restriction> restrictions = Sets.newHashSet(); for (RestrictionProvider rp : providers) { restrictions.addAll(rp.readRestrictions(oakPath, aceTree)); } return restrictions; }
@NotNull @Override public Set<Restriction> readRestrictions(@Nullable String oakPath, @NotNull Tree aceTree) { return getProvider().readRestrictions(oakPath, aceTree); }
@Nonnull @Override public Set<Restriction> readRestrictions(@Nullable String oakPath, @Nonnull Tree aceTree) { return getProvider().readRestrictions(oakPath, aceTree); }
@NotNull @Override public Set<Restriction> readRestrictions(@Nullable String oakPath, @NotNull Tree aceTree) { return getProvider().readRestrictions(oakPath, aceTree); }
@NotNull @Override public Set<Restriction> readRestrictions(@Nullable String oakPath, @NotNull Tree aceTree) { Set<Restriction> restrictions = new HashSet<>(base.readRestrictions(oakPath, aceTree)); String value = (oakPath == null) ? "" : oakPath; PropertyState nodePathProp = PropertyStates.createProperty(REP_NODE_PATH, value, Type.PATH); restrictions.add(new RestrictionImpl(nodePathProp, true)); return restrictions; }
@NotNull @Override public Set<Restriction> readRestrictions(@Nullable String oakPath, @NotNull Tree aceTree) { Set<Restriction> restrictions = new HashSet<>(base.readRestrictions(oakPath, aceTree)); String value = (oakPath == null) ? "" : oakPath; PropertyState nodePathProp = PropertyStates.createProperty(REP_NODE_PATH, value, Type.PATH); restrictions.add(new RestrictionImpl(nodePathProp, true)); return restrictions; }
@Nonnull @Override public Set<Restriction> readRestrictions(@Nullable String oakPath, @Nonnull Tree aceTree) { Set<Restriction> restrictions = new HashSet<Restriction>(base.readRestrictions(oakPath, aceTree)); String value = (oakPath == null) ? "" : oakPath; PropertyState nodePathProp = PropertyStates.createProperty(REP_NODE_PATH, value, Type.PATH); restrictions.add(new RestrictionImpl(nodePathProp, true)); return restrictions; }
@NotNull private ACE createACE(@Nullable String oakPath, @NotNull Tree aceTree, @NotNull RestrictionProvider restrictionProvider) throws RepositoryException { boolean isAllow = NT_REP_GRANT_ACE.equals(TreeUtil.getPrimaryTypeName(aceTree)); Set<Restriction> restrictions = restrictionProvider.readRestrictions(oakPath, aceTree); Iterable<String> privNames = checkNotNull(TreeUtil.getStrings(aceTree, REP_PRIVILEGES)); return new Entry(getPrincipal(aceTree), bitsProvider.getBits(privNames), isAllow, restrictions, getNamePathMapper()); }
@Nonnull private ACE createACE(@Nullable String oakPath, @Nonnull Tree aceTree, @Nonnull RestrictionProvider restrictionProvider) throws RepositoryException { boolean isAllow = NT_REP_GRANT_ACE.equals(TreeUtil.getPrimaryTypeName(aceTree)); Set<Restriction> restrictions = restrictionProvider.readRestrictions(oakPath, aceTree); Iterable<String> privNames = checkNotNull(TreeUtil.getStrings(aceTree, REP_PRIVILEGES)); return new Entry(getPrincipal(aceTree), bitsProvider.getBits(privNames), isAllow, restrictions, getNamePathMapper()); }
@NotNull private ACE createACE(@Nullable String oakPath, @NotNull Tree aceTree, @NotNull RestrictionProvider restrictionProvider) throws RepositoryException { boolean isAllow = NT_REP_GRANT_ACE.equals(TreeUtil.getPrimaryTypeName(aceTree)); Set<Restriction> restrictions = restrictionProvider.readRestrictions(oakPath, aceTree); Iterable<String> privNames = checkNotNull(TreeUtil.getStrings(aceTree, REP_PRIVILEGES)); return new Entry(getPrincipal(aceTree), bitsProvider.getBits(privNames), isAllow, restrictions, getNamePathMapper()); }
@Test public void testReadRestrictions() { assertTrue(RestrictionProvider.EMPTY.readRestrictions(null, Mockito.mock(Tree.class)).isEmpty()); assertTrue(RestrictionProvider.EMPTY.readRestrictions("/any/path", Mockito.mock(Tree.class)).isEmpty()); }
boolean isAllow = isGrantACE.apply(ace); PrivilegeBits privilegeBits = bitsProvider.getBits(ace.getNames(REP_PRIVILEGES)); Set<Restriction> restrictions = restrictionProvider.readRestrictions(Strings.emptyToNull(accessControlledPath), treeProvider.createReadOnlyTree(ace));
boolean isAllow = isGrantACE.apply(ace); PrivilegeBits privilegeBits = bitsProvider.getBits(ace.getNames(REP_PRIVILEGES)); Set<Restriction> restrictions = restrictionProvider.readRestrictions(Strings.emptyToNull(accessControlledPath), treeProvider.createReadOnlyTree(ace));
boolean isAllow = isGrantACE.apply(ace); PrivilegeBits privilegeBits = bitsProvider.getBits(ace.getNames(REP_PRIVILEGES)); Set<Restriction> restrictions = restrictionProvider.readRestrictions(Strings.emptyToNull(accessControlledPath), treeProvider.createReadOnlyTree(ace));
private Entry(String path, Tree aceTree) { principalName = aceTree.getProperty(REP_PRINCIPAL_NAME).getValue(Type.STRING); privilegeBits = privilegeBitsProvider.getBits(aceTree.getProperty(REP_PRIVILEGES).getValue(Type.NAMES)); restrictions = restrictionProvider.readRestrictions(path, aceTree); }
private Entry(String path, Tree aceTree) { principalName = aceTree.getProperty(REP_PRINCIPAL_NAME).getValue(Type.STRING); privilegeBits = privilegeBitsProvider.getBits(aceTree.getProperty(REP_PRIVILEGES).getValue(Type.NAMES)); restrictions = restrictionProvider.readRestrictions(path, aceTree); }
private Entry(String path, Tree aceTree) { principalName = aceTree.getProperty(REP_PRINCIPAL_NAME).getValue(Type.STRING); privilegeBits = privilegeBitsProvider.getBits(aceTree.getProperty(REP_PRIVILEGES).getValue(Type.NAMES)); restrictions = restrictionProvider.readRestrictions(path, aceTree); }
@Test public void testReadRestrictions() { Tree aceTree = getAceTree(NT_PREFIXES_RESTRICTION, MANDATORY_BOOLEAN_RESTRICTION, UNKNOWN_RESTRICTION); Set<Restriction> restrictions = provider.readRestrictions("/test", aceTree); assertEquals(2, restrictions.size()); for (Restriction r : restrictions) { String name = r.getDefinition().getName(); if (!supported.contains(name)) { fail("read unsupported restriction"); } } }
@Test public void testReadRestrictions() throws Exception { NodeUtil aceNode = new NodeUtil(root.getTree("/")).addChild("test", NT_REP_GRANT_ACE); aceNode.setBoolean("boolean", true); aceNode.setValues("longs", new Value[] {vf.createValue(10), vf.createValue(290)}); aceNode.setString(REP_GLOB, "*"); aceNode.setNames(REP_NT_NAMES); // empty array aceNode.setString("invalid", "val"); aceNode.setStrings("invalid2", "val1", "val2", "val3"); Set<Restriction> restrictions = provider.readRestrictions("/test", aceNode.getTree()); assertEquals(4, restrictions.size()); for (Restriction r : restrictions) { String name = r.getDefinition().getName(); if (!supported.contains(name)) { fail("read unsupported restriction"); } } }