use of org.apache.jackrabbit.api.security.user.QueryBuilder in project jackrabbit-oak by apache.
the class PrincipalProviderImpl method findAuthorizables.
private Iterator<Authorizable> findAuthorizables(@Nullable final String nameHint, final int searchType) throws RepositoryException {
Query userQuery = new Query() {
@Override
public <T> void build(QueryBuilder<T> builder) {
builder.setCondition(builder.like('@' + UserConstants.REP_PRINCIPAL_NAME, buildSearchPattern(nameHint)));
builder.setSelector(AuthorizableType.getType(searchType).getAuthorizableClass());
}
};
return userManager.findAuthorizables(userQuery);
}
use of org.apache.jackrabbit.api.security.user.QueryBuilder in project jackrabbit-oak by apache.
the class UserQueryManagerTest method testQueryNoScope.
@Test
public void testQueryNoScope() throws Exception {
Group g = createGroup(null, EveryonePrincipal.getInstance());
g.setProperty(propertyName, v);
user.setProperty(propertyName, v);
root.commit();
Query q = new Query() {
@Override
public <T> void build(QueryBuilder<T> builder) {
builder.setCondition(builder.eq(propertyName, v));
}
};
Iterator<Authorizable> result = queryMgr.findAuthorizables(q);
assertResultContainsAuthorizables(result, user, g);
}
use of org.apache.jackrabbit.api.security.user.QueryBuilder in project jackrabbit-oak by apache.
the class UserQueryManagerTest method testQueryNameMatchesWithUnderscorePrincipalName.
@Test
public void testQueryNameMatchesWithUnderscorePrincipalName() throws Exception {
Group g = createGroup("g", new PrincipalImpl("group_with_underscore"));
root.commit();
Query q = new Query() {
@Override
public <T> void build(QueryBuilder<T> builder) {
builder.setCondition(builder.nameMatches("group_with_underscore"));
}
};
Iterator<Authorizable> result = queryMgr.findAuthorizables(q);
assertResultContainsAuthorizables(result, g);
}
use of org.apache.jackrabbit.api.security.user.QueryBuilder in project jackrabbit-oak by apache.
the class UserQueryManagerTest method testQueryScopeEveryoneFiltersEveryone.
@Test
public void testQueryScopeEveryoneFiltersEveryone() throws Exception {
Group g = createGroup(null, EveryonePrincipal.getInstance());
g.setProperty(propertyName, v);
user.setProperty(propertyName, v);
root.commit();
Query q = new Query() {
@Override
public <T> void build(QueryBuilder<T> builder) {
builder.setCondition(builder.eq(propertyName, v));
builder.setScope(EveryonePrincipal.NAME, false);
}
};
Iterator<Authorizable> result = queryMgr.findAuthorizables(q);
assertResultContainsAuthorizables(result, user);
}
use of org.apache.jackrabbit.api.security.user.QueryBuilder in project jackrabbit-oak by apache.
the class UserQueryManagerTest method testQueryScopeDeclaredMember.
@Test
public void testQueryScopeDeclaredMember() throws Exception {
Group g = createGroup("g1", null);
g.addMember(user);
user.setProperty(propertyName, v);
root.commit();
Query q = new Query() {
@Override
public <T> void build(QueryBuilder<T> builder) {
builder.setCondition(builder.eq(propertyName, v));
builder.setScope("g1", false);
}
};
Iterator<Authorizable> result = queryMgr.findAuthorizables(q);
assertResultContainsAuthorizables(result, user);
}
Aggregations