use of org.apache.jackrabbit.oak.spi.security.user.AuthorizableType in project jackrabbit-oak by apache.
the class ResultRowToAuthorizable method getAuthorizable.
//------------------------------------------------------------< private >---
@CheckForNull
private Authorizable getAuthorizable(@CheckForNull ResultRow row) {
Authorizable authorizable = null;
if (row != null) {
String resultPath = row.getValue(QueryImpl.JCR_PATH).getValue(Type.STRING);
try {
Tree tree = root.getTree(resultPath);
AuthorizableType type = UserUtil.getType(tree);
while (tree.exists() && !tree.isRoot() && type == null) {
tree = tree.getParent();
type = UserUtil.getType(tree);
}
if (tree.exists() && (targetType == null || targetType == type)) {
authorizable = userManager.getAuthorizable(tree);
}
} catch (RepositoryException e) {
log.debug("Failed to access authorizable " + resultPath);
}
}
return authorizable;
}
use of org.apache.jackrabbit.oak.spi.security.user.AuthorizableType in project jackrabbit-oak by apache.
the class QueryUtilTest method testGetSearchRootUserPathParentOfGroup.
@Test
public void testGetSearchRootUserPathParentOfGroup() {
ConfigurationParameters params = ConfigurationParameters.of(UserConstants.PARAM_USER_PATH, "/configured/users", UserConstants.PARAM_GROUP_PATH, "/configured/users/groups");
Map<AuthorizableType, String> paths = ImmutableMap.of(AuthorizableType.USER, "/configured/users", AuthorizableType.GROUP, "/configured/users/groups", AuthorizableType.AUTHORIZABLE, "/configured/users");
assertSearchRoot(paths, params);
}
use of org.apache.jackrabbit.oak.spi.security.user.AuthorizableType in project jackrabbit-oak by apache.
the class QueryUtilTest method assertSearchRoot.
private static void assertSearchRoot(@Nonnull Map<AuthorizableType, String> mapping, @Nonnull ConfigurationParameters params) {
for (AuthorizableType type : mapping.keySet()) {
String expected = QueryConstants.SEARCH_ROOT_PATH + mapping.get(type);
assertEquals(expected, QueryUtil.getSearchRoot(type, params));
}
}
use of org.apache.jackrabbit.oak.spi.security.user.AuthorizableType in project jackrabbit-oak by apache.
the class QueryUtilTest method testGetSearchRootNoCommonAncestor.
@Test
public void testGetSearchRootNoCommonAncestor() {
ConfigurationParameters params = ConfigurationParameters.of(UserConstants.PARAM_USER_PATH, "/users", UserConstants.PARAM_GROUP_PATH, "/groups");
Map<AuthorizableType, String> paths = ImmutableMap.of(AuthorizableType.USER, "/users", AuthorizableType.GROUP, "/groups", AuthorizableType.AUTHORIZABLE, "/");
assertSearchRoot(paths, params);
}
use of org.apache.jackrabbit.oak.spi.security.user.AuthorizableType in project jackrabbit-oak by apache.
the class UserUtilTest method testGetTypeFromTree.
@Test
public void testGetTypeFromTree() {
Map<String, AuthorizableType> test = ImmutableMap.of(UserConstants.NT_REP_GROUP, AuthorizableType.GROUP, UserConstants.NT_REP_USER, AuthorizableType.USER, UserConstants.NT_REP_SYSTEM_USER, AuthorizableType.USER);
for (String ntName : test.keySet()) {
AuthorizableType expected = test.get(ntName);
assertEquals(ntName, expected, UserUtil.getType(createTree(ntName)));
}
}
Aggregations