use of org.apache.jackrabbit.oak.spi.security.user.AuthorizableType in project jackrabbit-oak by apache.
the class UserValidator method childNodeDeleted.
@Override
public Validator childNodeDeleted(String name, NodeState before) throws CommitFailedException {
Tree tree = parentBefore.getChild(name);
AuthorizableType type = UserUtil.getType(tree);
if (type == AuthorizableType.USER || type == AuthorizableType.GROUP) {
if (isAdminUser(tree)) {
String msg = "The admin user cannot be removed.";
throw constraintViolation(27, msg);
}
return null;
} else {
return newValidator(tree, null, provider);
}
}
use of org.apache.jackrabbit.oak.spi.security.user.AuthorizableType in project jackrabbit-oak by apache.
the class QueryUtilTest method testGetSearchRoot.
@Test
public void testGetSearchRoot() {
ConfigurationParameters params = ConfigurationParameters.of(UserConstants.PARAM_USER_PATH, "/configured/user/path", UserConstants.PARAM_GROUP_PATH, "/configured/group/path");
Map<AuthorizableType, String> paths = ImmutableMap.of(AuthorizableType.USER, "/configured/user/path", AuthorizableType.GROUP, "/configured/group/path", AuthorizableType.AUTHORIZABLE, "/configured");
assertSearchRoot(paths, params);
}
use of org.apache.jackrabbit.oak.spi.security.user.AuthorizableType in project jackrabbit-oak by apache.
the class UserQueryManagerTest method testFindWithRelPathMultipleSelectorNames.
@Test
public void testFindWithRelPathMultipleSelectorNames() throws Exception {
user.setProperty(propertyName, v);
Group g = createGroup("g", null);
g.setProperty("rel/path/to/" + propertyName, v);
root.commit();
for (AuthorizableType type : new AuthorizableType[] { AuthorizableType.AUTHORIZABLE, AuthorizableType.GROUP }) {
Iterator<Authorizable> result = queryMgr.findAuthorizables("rel/path/to/" + propertyName, v.getString(), AuthorizableType.AUTHORIZABLE, false);
assertResultContainsAuthorizables(result, g);
}
}
use of org.apache.jackrabbit.oak.spi.security.user.AuthorizableType in project jackrabbit-oak by apache.
the class QueryUtilTest method testGetSearchRootGroupPathParentOfUser.
@Test
public void testGetSearchRootGroupPathParentOfUser() {
ConfigurationParameters params = ConfigurationParameters.of(UserConstants.PARAM_USER_PATH, "/configured/groups/users", UserConstants.PARAM_GROUP_PATH, "/configured/groups");
Map<AuthorizableType, String> paths = ImmutableMap.of(AuthorizableType.USER, "/configured/groups/users", AuthorizableType.GROUP, "/configured/groups", AuthorizableType.AUTHORIZABLE, "/configured/groups");
assertSearchRoot(paths, params);
}
use of org.apache.jackrabbit.oak.spi.security.user.AuthorizableType in project jackrabbit-oak by apache.
the class UserPrincipalProvider method findPrincipals.
@Nonnull
@Override
public Iterator<? extends Principal> findPrincipals(final String nameHint, final int searchType) {
try {
AuthorizableType type = AuthorizableType.getType(searchType);
StringBuilder statement = new StringBuilder().append(QueryUtil.getSearchRoot(type, config.getParameters())).append("//element(*,").append(QueryUtil.getNodeTypeName(type)).append(')').append("[jcr:like(@rep:principalName,'").append(buildSearchPattern(nameHint)).append("')]");
Result result = root.getQueryEngine().executeQuery(statement.toString(), javax.jcr.query.Query.XPATH, NO_BINDINGS, namePathMapper.getSessionLocalMappings());
Iterator<Principal> principals = Iterators.filter(Iterators.transform(result.getRows().iterator(), new ResultRowToPrincipal()), Predicates.notNull());
if (matchesEveryone(nameHint, searchType)) {
principals = Iterators.concat(principals, Iterators.singletonIterator(EveryonePrincipal.getInstance()));
return Iterators.filter(principals, new EveryonePredicate());
} else {
return principals;
}
} catch (ParseException e) {
log.debug(e.getMessage());
return Iterators.emptyIterator();
}
}
Aggregations