Skip to content

Commit

Permalink
[Minor] allow to leave out locations in remote group mapping model
Browse files Browse the repository at this point in the history
  • Loading branch information
eitch committed Jun 11, 2024
1 parent efd643c commit abe4151
Showing 1 changed file with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,6 @@ public void loadJsonConfig(String realm, String basePath, String configFileS) {

this.groupConfigs = configJ.get(GROUP_CONFIGS).getAsJsonObject();

// validate the configuration
for (String name : this.groupConfigs.keySet()) {
JsonObject config = this.groupConfigs.get(name).getAsJsonObject();
JsonElement locationsJ = config.get(LOCATIONS);
if (locationsJ == null || !locationsJ.isJsonArray() || locationsJ.getAsJsonArray().isEmpty())
throw new IllegalStateException(
format("LDAP Group {0} is missing attribute {1}, or it is not an array or the array is empty",
name, LOCATIONS));
}

this.userGroupOverrides = new HashMap<>();
if (configJ.has(USER_GROUP_OVERRIDES)) {
JsonObject userGroupOverrides = configJ.get(USER_GROUP_OVERRIDES).getAsJsonObject();
Expand Down Expand Up @@ -189,10 +179,12 @@ public Map<String, String> buildProperties(String remoteLocation, Set<String> re
logger.info("No configs for {}", remoteGroup);
continue;
}

JsonObject mappingJ = mappingE.getAsJsonObject();
if (mappingJ.has(ORGANISATION))
mappingJ.get(ORGANISATION).getAsJsonArray().forEach(e -> organisations.add(e.getAsString()));
mappingJ.get(LOCATIONS).getAsJsonArray().forEach(e -> locations.add(e.getAsString()));
if (mappingJ.has(LOCATIONS))
mappingJ.get(LOCATIONS).getAsJsonArray().forEach(e -> locations.add(e.getAsString()));

JsonElement primaryLocationJ = mappingJ.get(PRIMARY_LOCATION);
if (primaryLocationJ != null && !primaryLocationJ.isJsonNull()) {
Expand Down

0 comments on commit abe4151

Please sign in to comment.