@Override void checkValidTree(@Nonnull Tree tree) throws RepositoryException { if (!UserUtil.isType(tree, AuthorizableType.USER)) { throw new IllegalArgumentException("Invalid user node: node type rep:User expected."); } }
@Override void checkValidTree(@NotNull Tree tree) { if (!UserUtil.isType(tree, AuthorizableType.GROUP)) { throw new IllegalArgumentException("Invalid group node: node type rep:Group expected."); } }
@Override void checkValidTree(@NotNull Tree tree) { if (!UserUtil.isType(tree, AuthorizableType.GROUP)) { throw new IllegalArgumentException("Invalid group node: node type rep:Group expected."); } }
@Override void checkValidTree(@NotNull Tree tree) throws RepositoryException { if (!UserUtil.isType(tree, AuthorizableType.USER)) { throw new IllegalArgumentException("Invalid user node: node type rep:User expected."); } }
@Override void checkValidTree(@Nonnull Tree tree) throws RepositoryException { if (!UserUtil.isType(tree, AuthorizableType.GROUP)) { throw new IllegalArgumentException("Invalid group node: node type rep:Group expected."); } }
@Override void checkValidTree(@NotNull Tree tree) throws RepositoryException { if (!UserUtil.isType(tree, AuthorizableType.USER)) { throw new IllegalArgumentException("Invalid user node: node type rep:User expected."); } }
@Nullable Tree getByPath(@NotNull String authorizableOakPath, @NotNull AuthorizableType type) { Tree tree = root.getTree(authorizableOakPath); if (UserUtil.isType(tree, type)) { return tree; } else { return null; } }
@Nullable Tree getByPath(@NotNull String authorizableOakPath, @NotNull AuthorizableType type) { Tree tree = root.getTree(authorizableOakPath); if (UserUtil.isType(tree, type)) { return tree; } else { return null; } }
@Nullable private Tree getByContentID(@NotNull String contentId, @NotNull AuthorizableType authorizableType) { Tree tree = identifierManager.getTree(contentId); if (UserUtil.isType(tree, authorizableType)) { return tree; } else { return null; } }
@Nullable private Tree getByContentID(@NotNull String contentId, @NotNull AuthorizableType authorizableType) { Tree tree = identifierManager.getTree(contentId); if (UserUtil.isType(tree, authorizableType)) { return tree; } else { return null; } }
@CheckForNull Tree getByContentID(@Nonnull String contentId, @Nonnull AuthorizableType authorizableType) { Tree tree = identifierManager.getTree(contentId); if (UserUtil.isType(tree, authorizableType)) { return tree; } else { return null; } }
@CheckForNull Tree getByPath(@Nonnull String authorizableOakPath, @Nonnull AuthorizableType type) { Tree tree = root.getTree(authorizableOakPath); if (UserUtil.isType(tree, type)) { return tree; } else { return null; } }
@NotNull @Override public Set<? extends Principal> getPrincipals(@NotNull String userID) { Set<Principal> principals = new HashSet<>(); Tree tree = userProvider.getAuthorizable(userID); if (UserUtil.isType(tree, AuthorizableType.USER)) { Principal userPrincipal = createUserPrincipal(userID, tree); if (userPrincipal != null) { principals.add(userPrincipal); principals.addAll(getGroupMembership(tree)); } } return principals; }
@NotNull @Override public Set<? extends Principal> getPrincipals(@NotNull String userID) { Set<Principal> principals = new HashSet<>(); Tree tree = userProvider.getAuthorizable(userID); if (UserUtil.isType(tree, AuthorizableType.USER)) { Principal userPrincipal = createUserPrincipal(userID, tree); if (userPrincipal != null) { principals.add(userPrincipal); principals.addAll(getGroupMembership(tree)); } } return principals; }
@Nullable public static String getAuthorizableId(@NotNull Tree authorizableTree) { checkNotNull(authorizableTree); if (UserUtil.isType(authorizableTree, AuthorizableType.AUTHORIZABLE)) { PropertyState idProp = authorizableTree.getProperty(UserConstants.REP_AUTHORIZABLE_ID); if (idProp != null) { return idProp.getValue(STRING); } else { return Text.unescapeIllegalJcrChars(authorizableTree.getName()); } } return null; }
@CheckForNull public static String getAuthorizableId(@Nonnull Tree authorizableTree) { checkNotNull(authorizableTree); if (UserUtil.isType(authorizableTree, AuthorizableType.AUTHORIZABLE)) { PropertyState idProp = authorizableTree.getProperty(UserConstants.REP_AUTHORIZABLE_ID); if (idProp != null) { return idProp.getValue(STRING); } else { return Text.unescapeIllegalJcrChars(authorizableTree.getName()); } } return null; }
@Test public void testIsTypeGroupFromTree() { Map<String, Boolean> test = ImmutableMap.of( UserConstants.NT_REP_GROUP, true, UserConstants.NT_REP_USER, false, UserConstants.NT_REP_SYSTEM_USER, false, UserConstants.NT_REP_AUTHORIZABLE, false, JcrConstants.NT_FILE, false ); for (String key : test.keySet()) { assertEquals(test.get(key), UserUtil.isType(createTree(key), AuthorizableType.GROUP)); } }
@Test public void testIsTypeUserFromTree() { Map<String, Boolean> test = ImmutableMap.of( UserConstants.NT_REP_GROUP, false, UserConstants.NT_REP_USER, true, UserConstants.NT_REP_SYSTEM_USER, true, UserConstants.NT_REP_AUTHORIZABLE, false, JcrConstants.NT_FILE, false ); for (String ntName : test.keySet()) { boolean expected = test.get(ntName); assertEquals(ntName, expected, UserUtil.isType(createTree(ntName), AuthorizableType.USER)); } }
@Test public void testIsTypeAuthorizableFromTree() { Map<String, Boolean> test = ImmutableMap.of( UserConstants.NT_REP_GROUP, true, UserConstants.NT_REP_USER, true, UserConstants.NT_REP_SYSTEM_USER, true, UserConstants.NT_REP_AUTHORIZABLE, false, JcrConstants.NT_FILE, false ); for (String ntName : test.keySet()) { boolean expected = test.get(ntName); assertEquals(ntName, expected, UserUtil.isType(createTree(ntName), AuthorizableType.AUTHORIZABLE)); } }