From 5d11ae1d5062c6770d4af9c573e0e1cdcb86cef2 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Mon, 30 May 2016 13:11:16 +0200 Subject: fix problem with MOA-ID-configuration GUI and SecurityLayer Templates in legacy mode --- .../validation/MOAIDConfigurationValidator.java | 26 ++++++++++++++++++---- .../ServicesAuthenticationInformationTask.java | 19 ++++++++++++++++ .../config/ConfigurationMigrationUtils.java | 9 +++++--- 3 files changed, 47 insertions(+), 7 deletions(-) diff --git a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/MOAIDConfigurationValidator.java b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/MOAIDConfigurationValidator.java index 42ef0e1e6..2bb33a9d7 100644 --- a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/MOAIDConfigurationValidator.java +++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/MOAIDConfigurationValidator.java @@ -22,19 +22,19 @@ */ package at.gv.egovernment.moa.id.config.webgui.validation; +import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.ServiceLoader; import java.util.Map.Entry; +import java.util.ServiceLoader; import java.util.Set; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import at.gv.egiz.components.configuration.api.Configuration; import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants; import at.gv.egovernment.moa.id.commons.config.persistence.MOAIDConfiguration; import at.gv.egovernment.moa.id.commons.utils.KeyValueUtils; @@ -243,10 +243,11 @@ public class MOAIDConfigurationValidator { groupEl.getKey(), MOAIDConfigurationConstants.PREFIX_MOAID)); - //add or update key/value pairs from users with module or task specific information + //add or update key/value pairs from users with module or task specific information + List taskDelete = new ArrayList(); Map toBeAdded = module.postProcessing( KeyValueUtils.removePrefixFromKeys(groupEl.getValue(), groupEl.getKey()), - deleted, + taskDelete, dbconfig); if (toBeAdded != null) { toBeAdded = KeyValueUtils.makeKeysAbsolut(toBeAdded, groupEl.getKey(), MOAIDConfigurationConstants.PREFIX_MOAID); @@ -261,6 +262,23 @@ public class MOAIDConfigurationValidator { } } + //make delete elements absolute + if (!taskDelete.isEmpty()) { + Iterator delInterator = taskDelete.iterator(); + while (delInterator.hasNext()) { + String delKey = delInterator.next(); + if (!delKey.startsWith(MOAIDConfigurationConstants.PREFIX_MOAID)) { + deleted.add(groupEl.getKey() + KeyValueUtils.KEY_DELIMITER + delKey ); + + } else { + deleted.add(delKey); + + } + + } + + } + } private void keyValueClassification(Iterator> config, Map> result) { diff --git a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/impl/ServicesAuthenticationInformationTask.java b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/impl/ServicesAuthenticationInformationTask.java index 8e8feefe0..1819c5c2b 100644 --- a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/impl/ServicesAuthenticationInformationTask.java +++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/impl/ServicesAuthenticationInformationTask.java @@ -89,6 +89,25 @@ public class ServicesAuthenticationInformationTask extends AbstractTaskValidator } + String isLegacyModeActive = input.get(MOAIDConfigurationConstants.SERVICE_AUTH_BKU_TEMPLATE_LEGACY); + if (MiscUtil.isNotEmpty(isLegacyModeActive) && Boolean.parseBoolean(isLegacyModeActive)) { + if (!input.containsKey(MOAIDConfigurationConstants.SERVICE_AUTH_BKU_TEMPLATE_FIRST_VALUE)) + keysToDelete.add(MOAIDConfigurationConstants.SERVICE_AUTH_BKU_TEMPLATE_FIRST_VALUE); + + if (!input.containsKey(MOAIDConfigurationConstants.SERVICE_AUTH_BKU_TEMPLATE_SECOND_VALUE)) + keysToDelete.add(MOAIDConfigurationConstants.SERVICE_AUTH_BKU_TEMPLATE_SECOND_VALUE); + + if (!input.containsKey(MOAIDConfigurationConstants.SERVICE_AUTH_BKU_TEMPLATE_THIRD_VALUE)) + keysToDelete.add(MOAIDConfigurationConstants.SERVICE_AUTH_BKU_TEMPLATE_THIRD_VALUE); + + } else { + keysToDelete.add(MOAIDConfigurationConstants.SERVICE_AUTH_BKU_TEMPLATE_FIRST_VALUE); + keysToDelete.add(MOAIDConfigurationConstants.SERVICE_AUTH_BKU_TEMPLATE_SECOND_VALUE); + keysToDelete.add(MOAIDConfigurationConstants.SERVICE_AUTH_BKU_TEMPLATE_THIRD_VALUE); + + } + + if (newConfigValues.isEmpty()) return null; else diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/ConfigurationMigrationUtils.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/ConfigurationMigrationUtils.java index fb2ef456c..a221d30e4 100644 --- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/ConfigurationMigrationUtils.java +++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/ConfigurationMigrationUtils.java @@ -239,17 +239,20 @@ public class ConfigurationMigrationUtils { if (templates != null) { List templatetype = templates.getTemplate(); if (templatetype != null) { - if (templatetype.size() > 0) { + if (templatetype.size() > 0 && + MiscUtil.isNotEmpty(templatetype.get(0).getURL())) { result.put(MOAIDConfigurationConstants.SERVICE_AUTH_BKU_TEMPLATE_FIRST_VALUE, templatetype.get(0).getURL()); result.put(MOAIDConfigurationConstants.SERVICE_AUTH_BKU_TEMPLATE_LEGACY, Boolean.TRUE.toString()); } else result.put(MOAIDConfigurationConstants.SERVICE_AUTH_BKU_TEMPLATE_LEGACY, Boolean.FALSE.toString()); - if (templatetype.size() > 1) + if (templatetype.size() > 1 && + MiscUtil.isNotEmpty(templatetype.get(1).getURL())) result.put(MOAIDConfigurationConstants.SERVICE_AUTH_BKU_TEMPLATE_SECOND_VALUE, templatetype.get(1).getURL()); - if (templatetype.size() > 2) + if (templatetype.size() > 2 && + MiscUtil.isNotEmpty(templatetype.get(2).getURL())) result.put(MOAIDConfigurationConstants.SERVICE_AUTH_BKU_TEMPLATE_THIRD_VALUE, templatetype.get(2).getURL()); } -- cgit v1.2.3