Loading src/main/java/org/eclipse/openk/portal/auth2/util/JwtHelper.java +2 −2 Original line number Diff line number Diff line Loading @@ -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); } Loading src/main/java/org/eclipse/openk/portal/common/BackendConfig.java +4 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ public class BackendConfig { private String keycloakClient; private String keycloakAdmin; private String keycloakPW; private Integer maxLoadUsers; private static BackendConfig instance; Loading Loading @@ -54,6 +55,9 @@ public class BackendConfig { return keycloakRealm; } public Integer getMaxLoadUsers() { return maxLoadUsers; } public static String getConfigFileName() { return configFileName; Loading src/main/java/org/eclipse/openk/portal/common/UserCacheTimerTask.java +1 −1 Original line number Diff line number Diff line Loading @@ -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) { Loading src/main/java/org/eclipse/openk/portal/controller/BackendController.java +0 −6 Original line number Diff line number Diff line Loading @@ -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(); Loading src/main/resources/_backendConfigCustom.json +2 −1 Original line number Diff line number Diff line Loading @@ -5,5 +5,6 @@ "keycloakRealm": "elogbook", "keycloakClient": "elogbook-backend", "keycloakAdmin": "admin", "keycloakPW": "nimda" "keycloakPW": "nimda", "maxLoadUsers": 1000 } No newline at end of file Loading
src/main/java/org/eclipse/openk/portal/auth2/util/JwtHelper.java +2 −2 Original line number Diff line number Diff line Loading @@ -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); } Loading
src/main/java/org/eclipse/openk/portal/common/BackendConfig.java +4 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ public class BackendConfig { private String keycloakClient; private String keycloakAdmin; private String keycloakPW; private Integer maxLoadUsers; private static BackendConfig instance; Loading Loading @@ -54,6 +55,9 @@ public class BackendConfig { return keycloakRealm; } public Integer getMaxLoadUsers() { return maxLoadUsers; } public static String getConfigFileName() { return configFileName; Loading
src/main/java/org/eclipse/openk/portal/common/UserCacheTimerTask.java +1 −1 Original line number Diff line number Diff line Loading @@ -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) { Loading
src/main/java/org/eclipse/openk/portal/controller/BackendController.java +0 −6 Original line number Diff line number Diff line Loading @@ -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(); Loading
src/main/resources/_backendConfigCustom.json +2 −1 Original line number Diff line number Diff line Loading @@ -5,5 +5,6 @@ "keycloakRealm": "elogbook", "keycloakClient": "elogbook-backend", "keycloakAdmin": "admin", "keycloakPW": "nimda" "keycloakPW": "nimda", "maxLoadUsers": 1000 } No newline at end of file