Commit 5d55eb95 authored by Frank Dietrich's avatar Frank Dietrich
Browse files

fixed Problem with limited count of 100 when getting all users.

parent 31032bdb
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -38,8 +38,8 @@ public class JwtHelper {
    return getJwtTokenFromJson(token);
  }

  public static List<KeyCloakUser> getUsers(JwtToken jwtToken) throws PortalInternalServerError {
    String users = sendGet(BackendConfig.getInstance().getAuthServerUrl() + "auth/admin/realms/" + BackendConfig.getInstance().getKeycloakRealm() + "/users",
  public static List<KeyCloakUser> getUsers(JwtToken jwtToken, int maxUsers) throws PortalInternalServerError {
    String users = sendGet(BackendConfig.getInstance().getAuthServerUrl() + "auth/admin/realms/" + BackendConfig.getInstance().getKeycloakRealm() + "/users?max="+maxUsers,
        MediaType.APPLICATION_JSON, jwtToken.getAccessToken());
    return getUserListFromJson(users);
  }
+4 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ public class BackendConfig {
    private String keycloakClient;
    private String keycloakAdmin;
    private String keycloakPW;
    private Integer maxLoadUsers;

    private static BackendConfig instance;

@@ -54,6 +55,9 @@ public class BackendConfig {
        return keycloakRealm;
    }

    public Integer getMaxLoadUsers() {
        return maxLoadUsers;
    }

    public static String getConfigFileName() {
        return configFileName;
+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ public class UserCacheTimerTask extends TimerTask {
  }

  private List<KeyCloakUser> getKeyCloakUsersFromToken(JwtToken token) throws PortalInternalServerError {
    List<KeyCloakUser> allUsers = JwtHelper.getUsers(token);
    List<KeyCloakUser> allUsers = JwtHelper.getUsers(token, BackendConfig.getInstance().getMaxLoadUsers());
    List<KeyCloakUser> allUsersWithRoles = new ArrayList<>();

    for (KeyCloakUser user : allUsers) {
+0 −6
Original line number Diff line number Diff line
@@ -22,12 +22,6 @@ public class BackendController {
    private static final Logger LOGGER = Logger.getLogger(BackendController.class.getName());
    private final InputDataValuator inputDataValuator = new InputDataValuator();

    public List<KeyCloakUser> getUsers() throws PortalInternalServerError {
        JwtToken token = JwtHelper.login(BackendConfig.getInstance().getKeycloakAdmin(),
            BackendConfig.getInstance().getKeycloakPW());
        return JwtHelper.getUsers(token);
    }

    public List<KeyCloakUser> getUsersForRole(String roleToCheck) {
        List<KeyCloakUser> usersWithRole = new ArrayList<>();
        List<KeyCloakUser> keyCloakUsers = UserCache.getInstance().getKeyCloakUsers();
+2 −1
Original line number Diff line number Diff line
@@ -5,5 +5,6 @@
  "keycloakRealm": "elogbook",
  "keycloakClient": "elogbook-backend",
  "keycloakAdmin": "admin",
  "keycloakPW": "nimda"
  "keycloakPW": "nimda",
  "maxLoadUsers": 1000
}
 No newline at end of file
Loading