KEYCLOAK-2705

This commit is contained in:
Bill Burke 2016-12-06 17:32:41 -05:00
parent a0b54ebedc
commit 68c8bfa0e1
4 changed files with 17 additions and 1 deletions

View file

@ -79,6 +79,18 @@ public interface GroupResource {
@Path("role-mappings") @Path("role-mappings")
public RoleMappingResource roles(); public RoleMappingResource roles();
/**
* Get users
* <p/>
* Returns a list of all users in group.
*
* @return Returns a max size of 100 users
*/
@GET
@NoCache
@Path("/members")
@Produces(MediaType.APPLICATION_JSON)
public List<UserRepresentation> members();
/** /**
* Get users * Get users
* <p/> * <p/>

View file

@ -212,7 +212,7 @@ public class GroupResource {
throw new NotFoundException("Could not find group by id"); throw new NotFoundException("Could not find group by id");
} }
firstResult = firstResult != null ? firstResult : -1; firstResult = firstResult != null ? firstResult : 0;
maxResults = maxResults != null ? maxResults : Constants.DEFAULT_MAX_RESULTS; maxResults = maxResults != null ? maxResults : Constants.DEFAULT_MAX_RESULTS;
List<UserRepresentation> results = new ArrayList<UserRepresentation>(); List<UserRepresentation> results = new ArrayList<UserRepresentation>();

View file

@ -379,6 +379,8 @@ public class UserStorageManager implements UserProvider, OnUserCache {
protected List<UserModel> query(PaginatedQuery pagedQuery, RealmModel realm, int firstResult, int maxResults) { protected List<UserModel> query(PaginatedQuery pagedQuery, RealmModel realm, int firstResult, int maxResults) {
if (maxResults == 0) return Collections.EMPTY_LIST; if (maxResults == 0) return Collections.EMPTY_LIST;
if (firstResult < 0) firstResult = 0;
if (maxResults < 0) maxResults = Integer.MAX_VALUE - 1;
List<UserQueryProvider> storageProviders = getStorageProviders(session, realm, UserQueryProvider.class); List<UserQueryProvider> storageProviders = getStorageProviders(session, realm, UserQueryProvider.class);
// we can skip rest of method if there are no storage providers // we can skip rest of method if there are no storage providers

View file

@ -602,7 +602,9 @@ public class GroupTest extends AbstractGroupTest {
} }
assertEquals(100, group.members(null, null).size()); assertEquals(100, group.members(null, null).size());
assertEquals(100, group.members().size());
assertEquals(105, group.members(0, 105).size()); assertEquals(105, group.members(0, 105).size());
assertEquals(110, group.members(0, 1000).size()); assertEquals(110, group.members(0, 1000).size());
assertEquals(110, group.members(-1, -2).size());
} }
} }