From cbd8e754af9c4898f7834e0c147c3e86b87d6f5f Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Fri, 7 Jun 2019 10:43:43 +0200 Subject: fix problems in configuration tool --- .../task/impl/GeneralMOAIDConfigurationTask.java | 41 +++++++++++++++++++++- .../task/impl/GeneralSTORKConfigurationTask.java | 2 +- 2 files changed, 41 insertions(+), 2 deletions(-) (limited to 'id/moa-id-webgui') diff --git a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/impl/GeneralMOAIDConfigurationTask.java b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/impl/GeneralMOAIDConfigurationTask.java index ca2df5b66..06e53bf53 100644 --- a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/impl/GeneralMOAIDConfigurationTask.java +++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/impl/GeneralMOAIDConfigurationTask.java @@ -726,7 +726,7 @@ public class GeneralMOAIDConfigurationTask extends AbstractTaskValidator impleme //normalize CSV of SZR-GW service URLs String szrgwServiceURLs = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_SERVICES_ELGA_MANDATE_SERVICE_URL, getKeyPrefix())); - List currentSzrgwServiceURLs = KeyValueUtils.getListOfCSVValues(dbconfig.getStringValue(MOAIDConfigurationConstants.GENERAL_AUTH_SERVICES_CENTRAL_EIDASNODE_URL)); + List currentSzrgwServiceURLs = KeyValueUtils.getListOfCSVValues(dbconfig.getStringValue(MOAIDConfigurationConstants.GENERAL_AUTH_SERVICES_ELGA_MANDATE_SERVICE_URL)); if (MiscUtil.isNotEmpty(szrgwServiceURLs)) { String normalizedSzrgwServiceURLs = KeyValueUtils.normalizeCSVValueString(szrgwServiceURLs); if (!normalizedSzrgwServiceURLs .equals(szrgwServiceURLs)) { @@ -755,6 +755,45 @@ public class GeneralMOAIDConfigurationTask extends AbstractTaskValidator impleme keysToDelete.add(service); } } + + + //normalize CSV of SZR-GW service URLs + String eidServiceURLs = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_SERVICES_EID_SYSTEM_SERVICE_URL, getKeyPrefix())); + List currenteidServiceURLs = KeyValueUtils.getListOfCSVValues(dbconfig.getStringValue(MOAIDConfigurationConstants.GENERAL_AUTH_SERVICES_EID_SYSTEM_SERVICE_URL)); + if (MiscUtil.isNotEmpty(eidServiceURLs)) { + String normalizedeidServiceURLs = KeyValueUtils.normalizeCSVValueString(eidServiceURLs); + if (!normalizedeidServiceURLs.equals(eidServiceURLs)) { + newConfigValues.put(MOAIDConfigurationConstants.GENERAL_AUTH_SERVICES_EID_SYSTEM_SERVICE_URL, normalizedeidServiceURLs); + log.debug("Change key: " + MOAIDConfigurationConstants.GENERAL_AUTH_SERVICES_EID_SYSTEM_SERVICE_URL + + " from value: " + input.get(MOAIDConfigurationConstants.GENERAL_AUTH_SERVICES_EID_SYSTEM_SERVICE_URL) + + " to value: " + normalizedeidServiceURLs); + } + + //check if service URLs are removed + for (String el : KeyValueUtils.getListOfCSVValues(eidServiceURLs)) { + if (currenteidServiceURLs.contains(el)) + currenteidServiceURLs.remove(el); + } + + } else if (!currenteidServiceURLs.isEmpty() && MiscUtil.isEmpty(eidServiceURLs)) { + keysToDelete.add(MOAIDConfigurationConstants.GENERAL_AUTH_SERVICES_EID_SYSTEM_SERVICE_URL); + + } + + //update OA configuration + if (!currenteidServiceURLs.isEmpty()) { + String[] servicesOAs = dbconfig.findConfigurationId( + MOAIDConfigurationConstants.PREFIX_MOAID_SERVICES_OA + + ".%." + + MOAIDConfigurationConstants.SERVICE_EXTERNAL_EID_SYSTEM_SERVICE_URL); + for (String service : servicesOAs) { + String spElgaService = dbconfig.getStringValue(service); + if (MiscUtil.isNotEmpty(spElgaService) && + currentSzrgwServiceURLs.contains(spElgaService)) + keysToDelete.add(service); + } + } + } catch (ConfigurationException e) { log.error("Configuration is not accessable!", e); diff --git a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/impl/GeneralSTORKConfigurationTask.java b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/impl/GeneralSTORKConfigurationTask.java index 4567afcba..8556348ba 100644 --- a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/impl/GeneralSTORKConfigurationTask.java +++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/impl/GeneralSTORKConfigurationTask.java @@ -187,7 +187,7 @@ public static final List KEYWHITELIST; // check qaa try { String eIDAS_LOA = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_STORK_QAA, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL)); - if (!MOAIDConstants.ALLOWED_eIDAS_LOA.contains(eIDAS_LOA)) { + if (eIDAS_LOA != null && !MOAIDConstants.ALLOWED_eIDAS_LOA.contains(eIDAS_LOA)) { log.warn("eIDAS LoA is not allowed : " + eIDAS_LOA); errors.add(new ValidationObjectIdentifier( MOAIDConfigurationConstants.GENERAL_AUTH_STORK_QAA, -- cgit v1.2.3