aboutsummaryrefslogtreecommitdiff
path: root/id/moa-id-webgui/src/main/java/at/gv/egovernment
diff options
context:
space:
mode:
Diffstat (limited to 'id/moa-id-webgui/src/main/java/at/gv/egovernment')
-rw-r--r--id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/MOAIDConfigurationModul.java244
-rw-r--r--id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/MOAIDSpringResourceProvider.java65
-rw-r--r--id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/exception/ConfigurationModulValidationException.java53
-rw-r--r--id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/exception/ConfigurationTaskValidationException.java54
-rw-r--r--id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/exception/ConfigurationValidationException.java49
-rw-r--r--id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/exception/ValidationObjectIdentifier.java66
-rw-r--r--id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/helper/LanguageHelper.java81
-rw-r--r--id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/MOAIDConfigurationValidator.java302
-rw-r--r--id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul/AbstractModuleValidator.java148
-rw-r--r--id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul/IModuleValidator.java79
-rw-r--r--id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul/impl/GatewayValidator.java65
-rw-r--r--id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul/impl/GeneralConfigurationValidator.java62
-rw-r--r--id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul/impl/InterfederationIDPValidator.java50
-rw-r--r--id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul/impl/OnlineApplicationValidator.java65
-rw-r--r--id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul/impl/VIDPValidator.java65
-rw-r--r--id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/AbstractTaskValidator.java106
-rw-r--r--id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/IDynamicLoadableTaskValidator.java39
-rw-r--r--id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/ITaskValidator.java79
-rw-r--r--id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/impl/GeneralMOAIDConfigurationTask.java578
-rw-r--r--id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/impl/GeneralOpenIDConfigurationTask.java95
-rw-r--r--id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/impl/GeneralPVP2XConfigurationTask.java236
-rw-r--r--id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/impl/GeneralSTORKConfigurationTask.java612
-rw-r--r--id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/impl/ServicesGeneralInformationTask.java111
-rw-r--r--id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/utils/CompanyNumberValidator.java78
-rw-r--r--id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/utils/IdentificationNumberValidator.java29
25 files changed, 3411 insertions, 0 deletions
diff --git a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/MOAIDConfigurationModul.java b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/MOAIDConfigurationModul.java
new file mode 100644
index 000000000..72e2321e9
--- /dev/null
+++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/MOAIDConfigurationModul.java
@@ -0,0 +1,244 @@
+/*
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+package at.gv.egovernment.moa.id.config.webgui;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import at.gv.egiz.components.configuration.api.Configuration;
+import at.gv.egiz.components.configuration.api.ConfigurationException;
+import at.gv.egiz.components.configuration.file.PropertiesBasedConfiguration;
+import at.gv.egiz.components.configuration.meta.api.ConfigurationModul;
+import at.gv.egiz.components.configuration.meta.api.ConfigurationStorageException;
+import at.gv.egiz.components.configuration.meta.api.MetadataConfiguration;
+import at.gv.egiz.components.configuration.meta.api.SchemaEntry;
+import at.gv.egiz.components.configuration.meta.api.impl.BaseMetadataConfiguration;
+import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants;
+import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationValidationException;
+import at.gv.egovernment.moa.id.config.webgui.validation.MOAIDConfigurationValidator;
+
+/**
+ * @author tlenz
+ *
+ */
+@Service
+public class MOAIDConfigurationModul implements ConfigurationModul{
+
+ private static final String MODULE_NAME = "MOAIDConfigurationModul";
+
+ private static Configuration config;
+ private static Configuration meta;
+ private static MetadataConfiguration metadata = null;
+
+ private List<SchemaEntry> schemaList = new ArrayList<SchemaEntry>();
+ private static final Logger logger = LoggerFactory.getLogger(MOAIDConfigurationModul.class);
+
+ static {
+ logger.info("Loading class {}", MOAIDConfigurationModul.class.getName());
+ try {
+ meta = new PropertiesBasedConfiguration(MOAIDConfigurationModul.class.getResourceAsStream("/gui/meta.properties"));
+
+ } catch (IOException | ConfigurationException e) {
+ logger.error("Failed to build internal datasets in MOAIDConfiguration modul!");
+
+ }
+ }
+
+ @Autowired
+ public void setDatabaseConfiguration(Configuration dbconfig) {
+ config = dbconfig;
+ }
+
+ /**
+ *
+ */
+ public MOAIDConfigurationModul() {
+ loadType("general", "/gui/types/general.json");
+
+// loadType("oa", "/gui/types/oa.json");
+
+ //TODO: load correct types
+// loadType("vidp", "/gui/types/oa.json");
+// loadType("iidp", "/gui/types/oa.json");
+// loadType("gateway", "/gui/types/oa.json");
+
+
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egiz.components.configuration.meta.api.ConfigurationModul#getSchemas()
+ */
+ @Override
+ public List<SchemaEntry> getSchemas() {
+ return schemaList;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egiz.components.configuration.meta.api.ConfigurationModul#getName()
+ */
+ @Override
+ public String getName() {
+ return MODULE_NAME;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egiz.components.configuration.meta.api.ConfigurationModul#getPrefix()
+ */
+ @Override
+ public String getPrefix() {
+ return MOAIDConfigurationConstants.PREFIX_MOAID;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egiz.components.configuration.meta.api.ConfigurationModul#getConfigurationAccess()
+ */
+ @Override
+ public Configuration getConfigurationAccess() {
+ return config;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egiz.components.configuration.meta.api.ConfigurationModul#getMetadataConfiguration()
+ */
+ @Override
+ public MetadataConfiguration getMetadataConfiguration() {
+ if (metadata == null) {
+ metadata = new BaseMetadataConfiguration(config, meta);
+
+ }
+ return metadata;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egiz.components.configuration.meta.api.ConfigurationModul#buildArrayIdentifier(java.lang.String, int, java.util.Map)
+ */
+ @Override
+ public String buildArrayIdentifier(String arrayId, int refCounter,
+ Map<String, String> properties) throws ConfigurationException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egiz.components.configuration.meta.api.ConfigurationModul#storeChanges(java.util.Map, java.util.Map, java.util.List)
+ */
+ @Override
+ public void storeChanges(Map<String, String> changed,
+ Map<String, String> added, List<String> deleted)
+ throws ConfigurationStorageException {
+
+ logger.debug("Start configuration saving process ...");
+ MOAIDConfigurationValidator configValidator = new MOAIDConfigurationValidator();
+ int numOfGroups = configValidator.preProcess(changed, added, deleted);
+
+ if (configValidator.getPreProcessedConfigurationData() != null &&
+ numOfGroups > 0) {
+ logger.trace("Validate {} groups of key/value pairs", numOfGroups);
+ try {
+ configValidator.validate();
+
+ } catch (ConfigurationValidationException e) {
+ logger.warn("Validation of MOA-ID configuration FAILED.");
+
+ //TODO: update ConfigurationStorageException to add specific information of validation errors
+ throw new ConfigurationStorageException(
+ "Configuration validation finds " + e.getValidationErrors().size() + " errors!",
+ e, false, false);
+ }
+
+ try {
+ logger.trace("PreProcess configuration before saving.");
+ Map<String, String> configToStore = configValidator.postProcessing(deleted);
+
+ //store all keys
+ logger.debug("Store {} key/value pairs to configuration", configToStore.size());
+ Iterator<Entry<String, String>> storageInterator = configToStore.entrySet().iterator();
+ while (storageInterator.hasNext()) {
+ Entry<String, String> el = storageInterator.next();
+ try {
+ config.setStringValue(el.getKey(), el.getValue());
+ logger.trace("Store key: " + el.getKey() + " with value: "
+ + el.getValue());
+
+ } catch (ConfigurationException e) {
+ logger.error("Store key: " + el.getKey() + " with value: "
+ + el.getValue() + " FAILED.", e);
+
+ }
+ }
+
+ //delete all unused keys
+ logger.debug("Delete {} keys pairs from configuration", deleted.size());
+ Iterator<String> deleteInterator = deleted.iterator();
+ while (deleteInterator.hasNext()) {
+ String el = deleteInterator.next();
+ try {
+ config.deleteIds(el);
+ logger.trace("Delete key {}", el);
+
+ } catch (ConfigurationException e) {
+ logger.error("Delete key: " + el + " FAILED.", e);
+
+ }
+ }
+
+ } catch (Exception e) {
+ logger.warn("Configuration post-processing FAILED.", e);
+ throw new ConfigurationStorageException("Configuration can not be stored.", e);
+
+ }
+
+
+ } else {
+ logger.info("Configuration saving process finished: No key/value pairs found.");
+
+ }
+ }
+
+ private void loadType(String name, String resource) {
+ InputStream is = null;
+ try {
+ SchemaEntry entry = new SchemaEntry();
+ is = MOAIDConfigurationModul.class.getResourceAsStream(resource);
+ entry.jsonSchema = IOUtils.toString(is);
+ entry.typeName = name;
+ schemaList.add(entry);
+ } catch (IOException e) {
+ logger.error("Failed to load Type OA!", e);
+ } finally {
+ IOUtils.closeQuietly(is);
+ }
+ }
+
+}
diff --git a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/MOAIDSpringResourceProvider.java b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/MOAIDSpringResourceProvider.java
new file mode 100644
index 000000000..61e1a1192
--- /dev/null
+++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/MOAIDSpringResourceProvider.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+package at.gv.egovernment.moa.id.config.webgui;
+
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+
+import at.gv.egiz.components.spring.api.SpringResourceProvider;
+
+/**
+ * @author tlenz
+ *
+ */
+public class MOAIDSpringResourceProvider implements SpringResourceProvider {
+
+ private static final String SYSTEM_PROP_CONFIG = "moa.id.webconfig";
+
+ /* (non-Javadoc)
+ * @see at.gv.egiz.components.spring.api.SpringResourceProvider#getResourcesToLoad()
+ */
+ @Override
+ public Resource[] getResourcesToLoad() {
+ ClassPathResource webguicontextconfig = new ClassPathResource("/moaid.webgui.beans.xml", MOAIDSpringResourceProvider.class);
+ ClassPathResource databasecontextconfig = new ClassPathResource("/configuration.beans.xml", MOAIDSpringResourceProvider.class);
+ return new Resource[] {webguicontextconfig, databasecontextconfig};
+
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egiz.components.spring.api.SpringResourceProvider#getPackagesToScan()
+ */
+ @Override
+ public String[] getPackagesToScan() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egiz.components.spring.api.SpringResourceProvider#getName()
+ */
+ @Override
+ public String getName() {
+ return "MOAIDConfiguration_SpringResourceDefinition";
+ }
+
+}
diff --git a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/exception/ConfigurationModulValidationException.java b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/exception/ConfigurationModulValidationException.java
new file mode 100644
index 000000000..b2103da54
--- /dev/null
+++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/exception/ConfigurationModulValidationException.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+package at.gv.egovernment.moa.id.config.webgui.exception;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author tlenz
+ *
+ */
+public class ConfigurationModulValidationException extends
+ ConfigurationValidationException {
+
+ /**
+ * @param errors
+ */
+ public ConfigurationModulValidationException(
+ List<ValidationObjectIdentifier> errors) {
+ super(errors);
+ }
+
+ /**
+ * @param validationObjectIdentifier
+ */
+ public ConfigurationModulValidationException(
+ ValidationObjectIdentifier validationObjectIdentifier) {
+ super(Arrays.asList(validationObjectIdentifier));
+ }
+
+ private static final long serialVersionUID = 2961444276927305856L;
+
+}
diff --git a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/exception/ConfigurationTaskValidationException.java b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/exception/ConfigurationTaskValidationException.java
new file mode 100644
index 000000000..6ce2ccbb6
--- /dev/null
+++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/exception/ConfigurationTaskValidationException.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+package at.gv.egovernment.moa.id.config.webgui.exception;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author tlenz
+ *
+ */
+public class ConfigurationTaskValidationException extends
+ ConfigurationModulValidationException {
+
+ /**
+ * @param errors
+ */
+ public ConfigurationTaskValidationException(
+ List<ValidationObjectIdentifier> errors) {
+ super(errors);
+ }
+
+ /**
+ * @param validationObjectIdentifier
+ */
+ public ConfigurationTaskValidationException(
+ ValidationObjectIdentifier validationObjectIdentifier) {
+ super(Arrays.asList(validationObjectIdentifier));
+
+ }
+
+ private static final long serialVersionUID = -8983804572579884044L;
+
+}
diff --git a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/exception/ConfigurationValidationException.java b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/exception/ConfigurationValidationException.java
new file mode 100644
index 000000000..859f2e45e
--- /dev/null
+++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/exception/ConfigurationValidationException.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+package at.gv.egovernment.moa.id.config.webgui.exception;
+
+import java.util.List;
+
+/**
+ * @author tlenz
+ *
+ */
+public class ConfigurationValidationException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ List<ValidationObjectIdentifier> errors = null;
+
+ /**
+ *
+ */
+ public ConfigurationValidationException(List<ValidationObjectIdentifier> errors) {
+ this.errors = errors;
+ }
+
+ public List<ValidationObjectIdentifier> getValidationErrors() {
+ return this.errors;
+
+ }
+
+}
diff --git a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/exception/ValidationObjectIdentifier.java b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/exception/ValidationObjectIdentifier.java
new file mode 100644
index 000000000..0a6112ebb
--- /dev/null
+++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/exception/ValidationObjectIdentifier.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+package at.gv.egovernment.moa.id.config.webgui.exception;
+
+/**
+ * @author tlenz
+ *
+ */
+public class ValidationObjectIdentifier {
+ private String key;
+ private String friendlyName;
+ private String message;
+
+ /**
+ * Create a validation error object identifier
+ *
+ * @param key configuration key
+ * @param friendlyName friendly name in configuration GUI
+ * @param message error message
+ */
+ public ValidationObjectIdentifier(String key, String friendlyName, String message) {
+ this.key = key;
+ this.friendlyName = friendlyName;
+ this.message = message;
+ }
+
+
+ /**
+ * @return the configuration key
+ */
+ public String getKey() {
+ return key;
+ }
+ /**
+ * @return the friendly name, which is used in the GUI
+ */
+ public String getFriendlyName() {
+ return friendlyName;
+ }
+ /**
+ * @return the error message
+ */
+ public String getMessage() {
+ return message;
+ }
+}
diff --git a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/helper/LanguageHelper.java b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/helper/LanguageHelper.java
new file mode 100644
index 000000000..122626ae8
--- /dev/null
+++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/helper/LanguageHelper.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ *******************************************************************************/
+package at.gv.egovernment.moa.id.config.webgui.helper;
+
+import java.text.MessageFormat;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+
+public class LanguageHelper {
+
+
+ private static String errorLanguage(String code, Locale locale) {
+ return ResourceBundle.getBundle("applicationResources", locale).getString(code);
+
+ }
+
+ private static String guiLanguage(String code, Locale locale) {
+ return ResourceBundle.getBundle("applicationResources", locale).getString(code);
+
+ }
+
+ public static String getGUIString(String code) {
+ return guiLanguage(code, getLangFromConfig());
+ }
+
+
+ public static String getErrorString(String code) {
+ return errorLanguage(code, getLangFromConfig());
+ }
+
+ public static String getGUIString(String code, String parameter) {
+ return MessageFormat.format(getGUIString(code), parameter);
+ }
+
+ public static String getErrorString(String code, Object[] parameter) {
+
+ return MessageFormat.format(getGUIString(code), parameter);
+ }
+
+
+ private static Locale getLangFromConfig() {
+
+ Locale defaultLanguage = Locale.forLanguageTag("de");
+
+// try {
+// ConfigurationProvider configurationProvider = ConfigurationProvider.getInstance();
+// defaultLanguage = Locale.forLanguageTag(configurationProvider.getDefaultLanguage());
+//
+// } catch (ConfigurationException e) {
+// log.error("Configuration exception while getting ConfigurationProvider instance", e);
+// }
+
+
+ return defaultLanguage;
+
+
+
+ }
+}
+
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
new file mode 100644
index 000000000..a1cafe702
--- /dev/null
+++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/MOAIDConfigurationValidator.java
@@ -0,0 +1,302 @@
+/*
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+package at.gv.egovernment.moa.id.config.webgui.validation;
+
+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.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.utils.KeyValueUtils;
+import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationModulValidationException;
+import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationValidationException;
+import at.gv.egovernment.moa.id.config.webgui.validation.modul.IModuleValidator;
+import at.gv.egovernment.moa.id.config.webgui.validation.task.IDynamicLoadableTaskValidator;
+
+/**
+ * @author tlenz
+ *
+ */
+public class MOAIDConfigurationValidator {
+ private static final Logger logger = LoggerFactory.getLogger(MOAIDConfigurationValidator.class);
+ private static Configuration dbconfig;
+
+ private static ServiceLoader<IModuleValidator> moduleLoader =
+ ServiceLoader.load(IModuleValidator.class);
+ private static Map<String, IModuleValidator> moduleValidator = null;
+
+ private static ServiceLoader<IDynamicLoadableTaskValidator> taskLoader =
+ ServiceLoader.load(IDynamicLoadableTaskValidator.class);
+
+ private Map<String, Map<String,String>> data = null;
+ private boolean isDataValidated = false;
+
+ @Autowired
+ public void setDatabaseConfiguration(Configuration config) {
+ dbconfig = config;
+
+ }
+
+ /**
+ *
+ */
+ public MOAIDConfigurationValidator() {
+ //load modules
+ if (moduleValidator == null ) {
+ moduleValidator = new HashMap<String, IModuleValidator>();
+ Iterator<IModuleValidator> moduleLoaderInterator = moduleLoader.iterator();
+ while (moduleLoaderInterator.hasNext()) {
+ IModuleValidator modul = moduleLoaderInterator.next();
+ logger.info("Load validation module for key: {}", modul.getKeyPrefix());
+ moduleValidator.put(modul.getKeyPrefix(), modul);
+
+ }
+
+ //load tasks
+ Iterator<IDynamicLoadableTaskValidator> taskLoaderInterator = taskLoader.iterator();
+ while (taskLoaderInterator.hasNext()) {
+ IDynamicLoadableTaskValidator task = taskLoaderInterator.next();
+ List<String> modulesToInject = task.getModulValidatorPrefix();
+ for (String el : modulesToInject) {
+ if (moduleValidator.containsKey(el)) {
+ moduleValidator.get(el).addTaskValidator(task);
+ logger.info("Task " + task.getName()
+ + " is injected to module with prefix " + el);
+
+ } else {
+ logger.warn("Task " + task.getName()
+ + " could NOT injected: No module with prefix " + el);
+
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Get the internal key/value configuration data set
+ *
+ * @return full configuration block of key/value pairs {Map<String, String>} sorted by MOA-ID configuration groups or null if preprocessing was done
+ */
+ public Map<String, Map<String,String>> getPreProcessedConfigurationData() {
+ return data;
+ }
+
+ /**
+ * PreProcess MOA-ID key/value configuration before validation and sort the keys into MOA-ID configuration groups
+ *
+ * @param changed all changed key/value pairs
+ * @param added all added key/value pairs
+ * @param deleted all deleted key/value pairs
+ * @return Number of MOA-ID configuration groups which was found
+ */
+ public int preProcess(Map<String, String> changed,
+ Map<String, String> added, List<String> deleted) {
+ data = new HashMap<String, Map<String, String>>();
+
+ //classify changed key/value pairs
+ keyValueClassification(changed.entrySet().iterator(), data);
+
+ //classify new key/value pairs
+ keyValueClassification(added.entrySet().iterator(), data);
+
+ return data.size();
+ }
+
+ /**
+ * Validate MOA-ID key/value configuration before saving
+ *
+ * @throws ConfigurationValidationException
+ */
+
+ public void validate() throws ConfigurationValidationException {
+ logger.trace("Starting MOA-ID configuration validation process ...");
+
+ Iterator<Entry<String, Map<String, String>>> groupInterator = data.entrySet().iterator();
+ while (groupInterator.hasNext()) {
+ Entry<String, Map<String, String>> groupEl = groupInterator.next();
+
+ try {
+ if (groupEl.getKey().startsWith(MOAIDConfigurationConstants.PREFIX_MOAID_SERVICES)) {
+ String moduleID = KeyValueUtils.getParentKey(groupEl.getKey());
+ if (moduleValidator.containsKey(moduleID)) {
+ logger.trace("Starting validation process of keyGroup: " + groupEl.getKey()
+ + " with module: " + moduleValidator.get(moduleID).getName());
+ moduleValidator.get(moduleID)
+ .validate(KeyValueUtils.removePrefixFromKeys(groupEl.getValue(), groupEl.getKey()));
+
+ } else
+ logger.info("No ModulValidator for keygroup {} found.", moduleID);
+
+ } else if (moduleValidator.containsKey(groupEl.getKey())) {
+ logger.trace("Starting validation process of keyGroup: " + groupEl.getKey()
+ + " with module: " + moduleValidator.get(groupEl.getKey()).getName());
+ moduleValidator.get(groupEl.getKey())
+ .validate(KeyValueUtils.removePrefixFromKeys(groupEl.getValue(), groupEl.getKey()));
+
+ } else {
+ logger.info("No ModulValidator for keygroup {} found.", groupEl.getKey());
+
+ }
+
+ } catch (ConfigurationModulValidationException e) {
+ logger.warn("Validation of keyGroup: " + groupEl.getKey()
+ + " FAILED with " + e.getValidationErrors().size() + " errors");
+ throw e;
+
+ }
+
+ }
+ isDataValidated = true;
+ }
+
+ /**
+ * Post-process the validated configuration to generate storeable key/value pairs
+ * @param deleted
+ *
+ * @return {Map<String, String>} of key/value pairs which could be stored into configuration
+ */
+
+ public Map<String, String> postProcessing(List<String> deleted) {
+ if (!isDataValidated)
+ logger.warn("Post-Processing non validated key/value pairs!");
+
+ Map<String, String> configToStore = new HashMap<String, String>();
+
+ Iterator<Entry<String, Map<String, String>>> groupInterator = data.entrySet().iterator();
+ while (groupInterator.hasNext()) {
+ Entry<String, Map<String, String>> groupEl = groupInterator.next();
+
+ try {
+ if (groupEl.getKey().startsWith(MOAIDConfigurationConstants.PREFIX_MOAID_SERVICES)) {
+ String moduleID = KeyValueUtils.getParentKey(groupEl.getKey());
+ if (moduleValidator.containsKey(moduleID)) {
+ logger.trace("Start postProcessing of keyGroup: " + groupEl.getKey()
+ + " with module: " + moduleValidator.get(moduleID).getName());
+ postProcessing(groupEl, moduleValidator.get(moduleID), configToStore, deleted);
+
+ } else
+ logger.info("No Module for keygroup {} found.", moduleID);
+
+ } else if (moduleValidator.containsKey(groupEl.getKey())) {
+ logger.trace("Start postProcessing of keyGroup: " + groupEl.getKey()
+ + " with module: " + moduleValidator.get(groupEl.getKey()).getName());
+ postProcessing(groupEl, moduleValidator.get(groupEl.getKey()), configToStore, deleted);
+
+ } else {
+ logger.info("No ModulValidator for keygroup {} found.", groupEl.getKey());
+
+ }
+
+ } catch (Exception e) {
+ logger.error("Post-Processing for keygroup: " + groupEl.getKey() + " FAILED!", e);
+
+ }
+
+ }
+ return configToStore;
+ }
+
+ private void postProcessing(Entry<String, Map<String, String>> groupEl,
+ IModuleValidator module, Map<String, String> configToStore, List<String> deleted ) {
+
+ //add all key/value pairs from user configuration GUI
+ configToStore.putAll(KeyValueUtils.makeKeysAbsolut(
+ groupEl.getValue(),
+ groupEl.getKey(),
+ MOAIDConfigurationConstants.PREFIX_MOAID));
+
+ //add or update key/value pairs from users with module or task specific information
+ Map<String, String> toBeAdded = module.postProcessing(
+ KeyValueUtils.removePrefixFromKeys(groupEl.getValue(), groupEl.getKey()),
+ deleted,
+ dbconfig);
+ if (toBeAdded != null) {
+ toBeAdded = KeyValueUtils.makeKeysAbsolut(toBeAdded, groupEl.getKey(), MOAIDConfigurationConstants.PREFIX_MOAID);
+ for (Entry<String, String> el : toBeAdded.entrySet()) {
+ if (configToStore.containsKey(el.getKey())) {
+ logger.info("Overwrite key: " + el.getKey()
+ + " userValue:" + configToStore.get(el.getKey())
+ + " postProcessing: " + toBeAdded.get(el.getKey()));
+
+ }
+ configToStore.put(el.getKey(), el.getValue());
+ }
+ }
+
+ }
+
+ private void keyValueClassification(Iterator<Entry<String, String>> config, Map<String, Map<String,String>> result) {
+ Set<String> validationModuleKeys = moduleValidator.keySet();
+
+ while(config.hasNext()) {
+ Entry<String, String> el = config.next();
+ logger.trace("Preprocess configuration element with key: "
+ + el.getKey() + " value: " + el.getValue());
+
+ //search configuration module
+ IModuleValidator selectedModul = null;
+ for (String key : validationModuleKeys) {
+ if (el.getKey().startsWith(key)) {
+ selectedModul = moduleValidator.get(key);
+ }
+ }
+
+ //group key/value pair to configuration modules
+ if (selectedModul != null) {
+ String groupkey = null;
+ if (selectedModul.getKeyPrefix().startsWith(MOAIDConfigurationConstants.PREFIX_MOAID_SERVICES)) {
+ String oaIndex = KeyValueUtils.getFirstChildAfterPrefix(el.getKey(), selectedModul.getKeyPrefix());
+ groupkey = selectedModul + "." + oaIndex;
+
+ } else
+ groupkey = selectedModul.getKeyPrefix();
+
+ if (!result.containsKey(groupkey)) {
+ result.put(groupkey, new HashMap<String, String>());
+
+ }
+ Map<String, String> resultElement = result.get(groupkey);
+ logger.trace("Put key/value pair to keyGroup: "
+ + groupkey + "with friendlyName: " + selectedModul.getName());
+ resultElement.put(el.getKey(), el.getValue());
+
+ } else {
+ logger.warn("Configuration Key {} is not part of a loaded MOA-ID configuration validation-module!", el.getKey());
+
+ }
+
+ }
+ }
+
+
+}
diff --git a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul/AbstractModuleValidator.java b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul/AbstractModuleValidator.java
new file mode 100644
index 000000000..076f5c75e
--- /dev/null
+++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul/AbstractModuleValidator.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+package at.gv.egovernment.moa.id.config.webgui.validation.modul;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import at.gv.egiz.components.configuration.api.Configuration;
+import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationModulValidationException;
+import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationTaskValidationException;
+import at.gv.egovernment.moa.id.config.webgui.exception.ValidationObjectIdentifier;
+import at.gv.egovernment.moa.id.config.webgui.validation.task.IDynamicLoadableTaskValidator;
+import at.gv.egovernment.moa.id.config.webgui.validation.task.ITaskValidator;
+
+/**
+ * @author tlenz
+ *
+ */
+public abstract class AbstractModuleValidator implements IModuleValidator {
+ private static final Logger logger = LoggerFactory.getLogger(AbstractModuleValidator.class);
+ protected List<ITaskValidator>taskValidator = new ArrayList<ITaskValidator>();
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.modul.IModuleValidator#validate(java.util.Map)
+ */
+ @Override
+ public void validate(Map<String, String> input)
+ throws ConfigurationModulValidationException {
+ List<ValidationObjectIdentifier> errors = new ArrayList<ValidationObjectIdentifier>();
+
+// //perform whitelist checks
+// List<Pattern> allowedPatterns = new ArrayList<Pattern>();
+// for (ITaskValidator task : taskValidator)
+// allowedPatterns.addAll(task.getAllAllowedPatterns());
+//
+// for (String el : input.keySet()) {
+// boolean valid = false;
+//
+// for (Pattern pat : allowedPatterns) {
+// if (pat.matcher(el).matches()) {
+// valid = true;
+// break;
+// }
+// }
+//
+// if (!valid) {
+// logger.warn("Task-Validator for keyPrefix: "
+// + getKeyPrefix() + " found a non-whitelisted key: " + el);
+// throw new ConfigurationModulValidationException(
+// new ValidationObjectIdentifier(el, "unkown", "This key is not allowed!"));
+//
+// }
+// }
+
+ for (ITaskValidator task : taskValidator) {
+ try {
+ task.validate(input);
+
+ } catch (ConfigurationTaskValidationException e) {
+ logger.debug("Task " + task.getName()
+ + " found " + e.getValidationErrors().size()
+ + " errors in configuration");
+ errors.addAll(e.getValidationErrors());
+ }
+ }
+
+ if (!errors.isEmpty())
+ throw new ConfigurationModulValidationException(errors);
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.modul.IModuleValidator#validate(java.util.Map)
+ */
+ public Map<String, String> postProcessing(Map<String, String> input,
+ List<String> keysToDelete, Configuration dbconfig) {
+ Map<String, String> added = new HashMap<String, String>();
+
+ for (ITaskValidator task : taskValidator) {
+ try {
+ Map<String, String> taskResult = task.postProcessing(input, keysToDelete, dbconfig);
+ if (taskResult != null)
+ added.putAll(taskResult);
+
+ } catch (Exception e) {
+ logger.warn("Post processing of task: " + task.getName()
+ + " FAILED!", e);
+
+ }
+ }
+ if (added.isEmpty())
+ return null;
+ else
+ return added;
+
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.modul.IModuleValidator#getKeyPrefix()
+ */
+ @Override
+ abstract public String getKeyPrefix();
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.modul.IModuleValidator#getName()
+ */
+ @Override
+ abstract public String getName();
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.modul.IModuleValidator#addTaskValidator(at.gv.egovernment.moa.id.config.webgui.validation.task.IDynamicTaskValidator)
+ */
+ @Override
+ public void addTaskValidator(IDynamicLoadableTaskValidator validator) {
+ taskValidator.add(validator);
+
+ }
+
+ protected void addTaskValidator(ITaskValidator validator) {
+ taskValidator.add(validator);
+ }
+
+}
diff --git a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul/IModuleValidator.java b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul/IModuleValidator.java
new file mode 100644
index 000000000..3ee665a87
--- /dev/null
+++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul/IModuleValidator.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+package at.gv.egovernment.moa.id.config.webgui.validation.modul;
+
+import java.util.List;
+import java.util.Map;
+
+import at.gv.egiz.components.configuration.api.Configuration;
+import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationModulValidationException;
+import at.gv.egovernment.moa.id.config.webgui.validation.task.IDynamicLoadableTaskValidator;
+
+/**
+ * @author tlenz
+ *
+ */
+public interface IModuleValidator {
+
+ /**
+ * Validate a specific key/value configuration
+ *
+ * @param input key/value configuration pairs without prefix
+ * @throws ConfigurationModulValidationException
+ */
+ public void validate(Map<String, String> input) throws ConfigurationModulValidationException;
+
+ /**
+ * Get module specific additional key/value pairs which must be added
+ *
+ * @param input Set of key/value pairs
+ * @param keysToDelete List<String> of keys which should be deleted
+ * @param dbconfig {Configuration} to access the current used configuration
+ * @return {Map<String, String>} of key/value pairs which had to be added to configuration or null
+ */
+ public Map<String, String> postProcessing(Map<String, String> input,
+ List<String> keysToDelete, Configuration dbconfig);
+
+
+ /**
+ * Key prefix for which this validation module is sensitive
+ *
+ * @return
+ */
+ public String getKeyPrefix();
+
+ /**
+ * Friendly name of the validation module
+ *
+ * @return
+ */
+ public String getName();
+
+
+ /**
+ *
+ *
+ * @param validator
+ */
+ public void addTaskValidator(IDynamicLoadableTaskValidator validator);
+}
diff --git a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul/impl/GatewayValidator.java b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul/impl/GatewayValidator.java
new file mode 100644
index 000000000..22281c973
--- /dev/null
+++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul/impl/GatewayValidator.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+package at.gv.egovernment.moa.id.config.webgui.validation.modul.impl;
+
+import java.util.Map;
+
+import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants;
+import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationModulValidationException;
+import at.gv.egovernment.moa.id.config.webgui.validation.modul.AbstractModuleValidator;
+import at.gv.egovernment.moa.id.config.webgui.validation.modul.IModuleValidator;
+
+/**
+ * @author tlenz
+ *
+ */
+public class GatewayValidator extends AbstractModuleValidator {
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.IModuleValidator#validate(java.util.Map)
+ */
+ @Override
+ public void validate(Map<String, String> input)
+ throws ConfigurationModulValidationException {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.IModuleValidator#getKeyPrefix()
+ */
+ @Override
+ public String getKeyPrefix() {
+ return MOAIDConfigurationConstants.PREFIX_MOAID_SERVICES_GATEWAY;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.IModuleValidator#getName()
+ */
+ @Override
+ public String getName() {
+ return "MOA-ID STORK<->PVP Gateway Configuration";
+ }
+
+}
diff --git a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul/impl/GeneralConfigurationValidator.java b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul/impl/GeneralConfigurationValidator.java
new file mode 100644
index 000000000..01114d235
--- /dev/null
+++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul/impl/GeneralConfigurationValidator.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+package at.gv.egovernment.moa.id.config.webgui.validation.modul.impl;
+
+import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants;
+import at.gv.egovernment.moa.id.config.webgui.validation.modul.AbstractModuleValidator;
+import at.gv.egovernment.moa.id.config.webgui.validation.task.impl.GeneralMOAIDConfigurationTask;
+import at.gv.egovernment.moa.id.config.webgui.validation.task.impl.GeneralOpenIDConfigurationTask;
+import at.gv.egovernment.moa.id.config.webgui.validation.task.impl.GeneralPVP2XConfigurationTask;
+
+/**
+ * @author tlenz
+ *
+ */
+public class GeneralConfigurationValidator extends AbstractModuleValidator {
+
+
+ public GeneralConfigurationValidator() {
+ //add default task to this module
+ addTaskValidator(new GeneralMOAIDConfigurationTask());
+ addTaskValidator(new GeneralPVP2XConfigurationTask());
+ addTaskValidator(new GeneralOpenIDConfigurationTask());
+
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.IModuleValidator#getKeyPrefix()
+ */
+ @Override
+ public String getKeyPrefix() {
+ return MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.IModuleValidator#getName()
+ */
+ @Override
+ public String getName() {
+ return "General MOA-ID Configuration";
+ }
+
+}
diff --git a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul/impl/InterfederationIDPValidator.java b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul/impl/InterfederationIDPValidator.java
new file mode 100644
index 000000000..2e9288415
--- /dev/null
+++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul/impl/InterfederationIDPValidator.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+package at.gv.egovernment.moa.id.config.webgui.validation.modul.impl;
+
+import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants;
+import at.gv.egovernment.moa.id.config.webgui.validation.modul.AbstractModuleValidator;
+
+/**
+ * @author tlenz
+ *
+ */
+public class InterfederationIDPValidator extends AbstractModuleValidator {
+
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.IModuleValidator#getKeyPrefix()
+ */
+ @Override
+ public String getKeyPrefix() {
+ return MOAIDConfigurationConstants.PREFIX_MOAID_SERVICES_IIDP;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.IModuleValidator#getName()
+ */
+ @Override
+ public String getName() {
+ return "MOA-ID Interfederation IDP Configuration";
+ }
+}
diff --git a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul/impl/OnlineApplicationValidator.java b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul/impl/OnlineApplicationValidator.java
new file mode 100644
index 000000000..a71d425f2
--- /dev/null
+++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul/impl/OnlineApplicationValidator.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+package at.gv.egovernment.moa.id.config.webgui.validation.modul.impl;
+
+import java.util.Map;
+
+import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants;
+import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationModulValidationException;
+import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationValidationException;
+import at.gv.egovernment.moa.id.config.webgui.validation.modul.AbstractModuleValidator;
+import at.gv.egovernment.moa.id.config.webgui.validation.modul.IModuleValidator;
+
+/**
+ * @author tlenz
+ *
+ */
+public class OnlineApplicationValidator extends AbstractModuleValidator {
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.IModuleValidator#validate(java.util.Map)
+ */
+ @Override
+ public void validate(Map<String, String> input)
+ throws ConfigurationModulValidationException {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.IModuleValidator#getKeyPrefix()
+ */
+ @Override
+ public String getKeyPrefix() {
+ return MOAIDConfigurationConstants.PREFIX_MOAID_SERVICES_OA;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.IModuleValidator#getName()
+ */
+ @Override
+ public String getName() {
+ return "MOA-ID Online-Application Configuration";
+ }
+
+}
diff --git a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul/impl/VIDPValidator.java b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul/impl/VIDPValidator.java
new file mode 100644
index 000000000..17dc66550
--- /dev/null
+++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul/impl/VIDPValidator.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+package at.gv.egovernment.moa.id.config.webgui.validation.modul.impl;
+
+import java.util.Map;
+
+import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants;
+import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationModulValidationException;
+import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationValidationException;
+import at.gv.egovernment.moa.id.config.webgui.validation.modul.AbstractModuleValidator;
+import at.gv.egovernment.moa.id.config.webgui.validation.modul.IModuleValidator;
+
+/**
+ * @author tlenz
+ *
+ */
+public class VIDPValidator extends AbstractModuleValidator {
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.IModuleValidator#validate(java.util.Map)
+ */
+ @Override
+ public void validate(Map<String, String> input)
+ throws ConfigurationModulValidationException {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.IModuleValidator#getKeyPrefix()
+ */
+ @Override
+ public String getKeyPrefix() {
+ return MOAIDConfigurationConstants.PREFIX_MOAID_SERVICES_VIDP;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.IModuleValidator#getName()
+ */
+ @Override
+ public String getName() {
+ return "MOA-ID V-IDP Configuration";
+ }
+
+}
diff --git a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/AbstractTaskValidator.java b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/AbstractTaskValidator.java
new file mode 100644
index 000000000..394bc4da7
--- /dev/null
+++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/AbstractTaskValidator.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+package at.gv.egovernment.moa.id.config.webgui.validation.task;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import at.gv.egiz.components.configuration.api.Configuration;
+import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationTaskValidationException;
+import at.gv.egovernment.moa.id.config.webgui.exception.ValidationObjectIdentifier;
+
+/**
+ * @author tlenz
+ *
+ */
+public abstract class AbstractTaskValidator implements ITaskValidator {
+ private static final Logger logger = LoggerFactory.getLogger(AbstractTaskValidator.class);
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.ITaskValidator#validate(java.util.Map)
+ */
+ @Override
+ public void validate(Map<String, String> input)
+ throws ConfigurationTaskValidationException {
+
+ //start task specific validation
+ tastValidate(input);
+
+ }
+
+ /**
+ * Validate a specific set of key/value pairs without whitelist checks
+ *
+ * @param input Key/Value pairs of a module for validation
+ * @throws ConfigurationModulValidationException
+ */
+ abstract protected void tastValidate(Map<String, String> input)
+ throws ConfigurationTaskValidationException;
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.ITaskValidator#postProcessing(java.util.Map, java.util.List, at.gv.egiz.components.configuration.api.Configuration)
+ */
+ @Override
+ abstract public Map<String, String> postProcessing(Map<String, String> input,
+ List<String> keysToDelete, Configuration dbconfig);
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.ITaskValidator#getKeyPrefix()
+ */
+ @Override
+ abstract public String getKeyPrefix();
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.ITaskValidator#getName()
+ */
+ @Override
+ abstract public String getName();
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.ITaskValidator#getAllAllowedKeys()
+ */
+ @Override
+ abstract public List<Pattern> getAllAllowedPatterns();
+
+ protected List<Pattern> generatePatternsFromKeys(List<String> keys) {
+ List<Pattern> patterns = new ArrayList<Pattern>();
+ for (String key : keys) {
+ if (key != null) {
+ String patternKey;
+ if (key.contains(".")) {
+ patternKey = key.replaceAll("\\.", "\\\\.");
+ } else
+ patternKey = key;
+
+ patterns.add(Pattern.compile(patternKey));
+ } else
+ logger.info("Found NULL key in whitelist of task: " + getName());
+ }
+ return patterns;
+ }
+}
diff --git a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/IDynamicLoadableTaskValidator.java b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/IDynamicLoadableTaskValidator.java
new file mode 100644
index 000000000..b1a38ab67
--- /dev/null
+++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/IDynamicLoadableTaskValidator.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+package at.gv.egovernment.moa.id.config.webgui.validation.task;
+
+import java.util.List;
+
+/**
+ * @author tlenz
+ *
+ */
+public interface IDynamicLoadableTaskValidator extends ITaskValidator {
+
+ /**
+ * Get a list of {IModuleValidator} prefixes in which this task should be added
+ *
+ * @return List of prefix keys
+ */
+ public List<String> getModulValidatorPrefix();
+}
diff --git a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/ITaskValidator.java b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/ITaskValidator.java
new file mode 100644
index 000000000..f91440d3a
--- /dev/null
+++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/ITaskValidator.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+package at.gv.egovernment.moa.id.config.webgui.validation.task;
+
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import at.gv.egiz.components.configuration.api.Configuration;
+import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationTaskValidationException;
+
+/**
+ * @author tlenz
+ *
+ */
+public interface ITaskValidator {
+
+ /**
+ * Validate a specific set of key/value pairs (whitelist checks are included)
+ *
+ * @param input Key/Value pairs of a module for validation
+ * @throws ConfigurationModulValidationException
+ */
+ public void validate(Map<String, String> input) throws ConfigurationTaskValidationException;
+
+ /**
+ * Get task specific key/value pairs which must be added
+ * The return keys must be full qualified according to the MOA-ID key namespace definition
+ *
+ * @param input Set of key/value pairs
+ * @param keysToDelete List<String> of keys which should be deleted
+ * @param dbconfig {Configuration} to access the current used configuration
+ * @return {Map<String, String>} of key/value pairs which had to be added to configuration or null
+ */
+ public Map<String, String> postProcessing(Map<String, String> input,
+ List<String> keysToDelete, Configuration dbconfig);
+
+ /**
+ * Get a key prefix for with this validation task is sensitive
+ *
+ * @return keyPrefix {String} or null if no prefix is defined
+ */
+ public String getKeyPrefix();
+
+ /**
+ * Get the friendly name of this validation task
+ *
+ * @return friendlyName {String}
+ */
+ public String getName();
+
+ /**
+ * Get a list of keys which are white listed for this task
+ *
+ * @return {List<Pattern>} of keys which are allowed
+ */
+ public List<Pattern> getAllAllowedPatterns();
+
+}
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
new file mode 100644
index 000000000..e4646bc04
--- /dev/null
+++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/impl/GeneralMOAIDConfigurationTask.java
@@ -0,0 +1,578 @@
+/*
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+package at.gv.egovernment.moa.id.config.webgui.validation.task.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import at.gv.egiz.components.configuration.api.Configuration;
+import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants;
+import at.gv.egovernment.moa.id.commons.utils.KeyValueUtils;
+import at.gv.egovernment.moa.id.commons.validation.ValidationHelper;
+import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationTaskValidationException;
+import at.gv.egovernment.moa.id.config.webgui.exception.ValidationObjectIdentifier;
+import at.gv.egovernment.moa.id.config.webgui.helper.LanguageHelper;
+import at.gv.egovernment.moa.id.config.webgui.validation.task.AbstractTaskValidator;
+import at.gv.egovernment.moa.id.config.webgui.validation.task.ITaskValidator;
+import at.gv.egovernment.moa.util.MiscUtil;
+
+/**
+ * @author tlenz
+ *
+ */
+public class GeneralMOAIDConfigurationTask extends AbstractTaskValidator implements ITaskValidator {
+
+ private static final Logger log = LoggerFactory.getLogger(GeneralMOAIDConfigurationTask.class);
+ public static final List<String> KEYWHITELIST;
+
+ static {
+ ArrayList<String> temp = new ArrayList<String>();
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PUBLICURLPREFIX, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_DEFAULTS_BKU_HANDY, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_DEFAULTS_BKU_LOCAL, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_DEFAULTS_BKU_ONLINE, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_DEFAULTS_TEMPLATES_HANDY, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_DEFAULTS_TEMPLATES_LOCAL, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_DEFAULTS_TEMPLATES_ONLINE, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_AUTHBLOCK_TRANSFORMATION_BASE64, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_AUTHBLOCK_TRANSFORMATION_BASE64, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_AUTHBLOCK_TRANSFORMATION_NAME, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_CERTSTORE_URL, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_MOASP_AUTHBLOCK_TRANSFORM, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_MOASP_TRUSTPROFILE_AUTHBLOCK_PROD, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_MOASP_TRUSTPROFILE_AUTHBLOCK_TEST, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_MOASP_TRUSTPROFILE_IDL_PROD, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_MOASP_TRUSTPROFILE_IDL_TEST, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_MOASP_URL, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_REVOCATIONCHECKING, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_SERVICES_OVS_URL, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_SERVICES_SZRGW_URL, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_SSO_AUTHBLOCK_TEXT, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_SSO_SERVICENAME, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_SSO_TARGET, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_TIMEOUS_SSO_CREATE, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_TIMEOUS_SSO_UPDATE, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_TIMEOUTS_TRANSACTION, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_TRUSTSTORE_URL, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_SAML1_ENABLED, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_SAML1_LEGACY, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_SAML1_SOURCEID, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+
+ KEYWHITELIST = Collections.unmodifiableList(temp);
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.ITaskValidator#validate(java.util.Map)
+ */
+ @Override
+ protected void tastValidate(Map<String, String> input)
+ throws ConfigurationTaskValidationException {
+ List<ValidationObjectIdentifier> errors = new ArrayList<ValidationObjectIdentifier>();
+
+ //check all keys against key whitelist
+
+
+ String check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_SAML1_SOURCEID, getKeyPrefix()));
+ if (MiscUtil.isNotEmpty(check)) {
+ if (ValidationHelper.containsPotentialCSSCharacter(check, false)) {
+ log.warn("SAML1 SourceID contains potentail XSS characters: " + check);
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_PROTOCOLS_SAML1_SOURCEID,
+ "SAML1 - SourceID",
+ LanguageHelper.getErrorString("validation.general.SAML1SourceID",
+ new Object[] {ValidationHelper.getPotentialCSSCharacter(false)})));
+ }
+ }
+
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PUBLICURLPREFIX, getKeyPrefix()));
+ if (MiscUtil.isNotEmpty(check)) {
+ if (!ValidationHelper.validateURL(check)) {
+ log.info("Public URL Prefix is not valid");
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_PUBLICURLPREFIX,
+ "Public URL Prefix",
+ LanguageHelper.getErrorString("validation.general.publicURLprefix.valid")));
+ }
+ } else {
+ log.info("PublicURL Prefix is empty.");
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_PUBLICURLPREFIX,
+ "Public URL Prefix",
+ LanguageHelper.getErrorString("validation.general.publicURLprefix.empty")));
+ }
+
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_TIMEOUTS_TRANSACTION, getKeyPrefix()));
+ if (MiscUtil.isNotEmpty(check)) {
+ if (!ValidationHelper.validateNumber(check)) {
+ log.warn("Assertion Timeout is no number " + check);
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_TIMEOUTS_TRANSACTION,
+ "Timeout - Transaction",
+ LanguageHelper.getErrorString("validation.general.timeouts.assertion.valid",
+ new Object[] {ValidationHelper.getNotValidOAIdentifierCharacters()}) ));
+ }
+ }
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_TIMEOUS_SSO_CREATE, getKeyPrefix()));
+ if (MiscUtil.isNotEmpty(check)) {
+ if (!ValidationHelper.validateNumber(check)) {
+ log.warn("MOASessionCreated Timeout is no number " + check);
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_TIMEOUS_SSO_CREATE,
+ "Timeout - SSO created",
+ LanguageHelper.getErrorString("validation.general.timeouts.moasessioncreated.valid",
+ new Object[] {ValidationHelper.getNotValidOAIdentifierCharacters()}) ));
+ }
+ }
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_TIMEOUS_SSO_UPDATE, getKeyPrefix()));
+ if (MiscUtil.isNotEmpty(check)) {
+ if (!ValidationHelper.validateNumber(check)) {
+ log.warn("MOASessionUpdated Timeout is no number " + check);
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_TIMEOUS_SSO_UPDATE,
+ "Timeout - SSO updated",
+ LanguageHelper.getErrorString("validation.general.timeouts.moasessionupdated.valid",
+ new Object[] {ValidationHelper.getNotValidOAIdentifierCharacters()}) ));
+ }
+ }
+
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_CERTSTORE_URL, getKeyPrefix()));
+ if (MiscUtil.isNotEmpty(check)) {
+ if (ValidationHelper.isValidOAIdentifier(check)) {
+ log.warn("CertStoreDirectory contains potentail XSS characters: " + check);
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_CERTSTORE_URL,
+ "Certificate - CertStore Directory",
+ LanguageHelper.getErrorString("validation.general.certStoreDirectory.valid",
+ new Object[] {ValidationHelper.getNotValidOAIdentifierCharacters()}) ));
+ }
+ } else {
+ log.info("CertStoreDirectory is empty.");
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_CERTSTORE_URL,
+ "Certificate - CertStore Directory",
+ LanguageHelper.getErrorString("validation.general.certStoreDirectory.empty")));
+ }
+
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_DEFAULTS_BKU_HANDY, getKeyPrefix()));
+ if (MiscUtil.isNotEmpty(check)) {
+ if (!ValidationHelper.validateURL(check)) {
+ log.info("Not valid Handy-BKU URL");
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_DEFAULTS_BKU_HANDY,
+ "Default BKUs - Handy",
+ LanguageHelper.getErrorString("validation.general.bku.handy.valid")));
+ }
+ } else {
+ log.info("Empty Handy-BKU URL");
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_DEFAULTS_BKU_HANDY,
+ "Default BKUs - Handy",
+ LanguageHelper.getErrorString("validation.general.bku.handy.empty")));
+ }
+
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_DEFAULTS_BKU_LOCAL, getKeyPrefix()));
+ if (MiscUtil.isNotEmpty(check)) {
+ if (!ValidationHelper.validateURL(check)) {
+ log.info("Not valid Online-BKU URL");
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_DEFAULTS_BKU_LOCAL,
+ "Default BKUs - Local",
+ LanguageHelper.getErrorString("validation.general.bku.local.valid")));
+ }
+ } else {
+ log.info("Empty Online-BKU URL");
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_DEFAULTS_BKU_LOCAL,
+ "Default BKUs - Local",
+ LanguageHelper.getErrorString("validation.general.bku.local.empty")));
+
+ }
+
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_DEFAULTS_BKU_ONLINE, getKeyPrefix()));
+ if (MiscUtil.isNotEmpty(check)) {
+ if (!ValidationHelper.validateURL(check)) {
+ log.info("Not valid Online-BKU URL");
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_DEFAULTS_BKU_ONLINE,
+ "Default BKUs - Online",
+ LanguageHelper.getErrorString("validation.general.bku.online.valid")));
+ }
+ } else {
+ log.info("Empty Online-BKU URL");
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_DEFAULTS_BKU_ONLINE,
+ "Default BKUs - Online",
+ LanguageHelper.getErrorString("validation.general.bku.online.empty")));
+
+ }
+
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_SERVICES_OVS_URL, getKeyPrefix()));
+ if (MiscUtil.isNotEmpty(check)) {
+ if (!ValidationHelper.validateURL(check)) {
+ log.info("Not valid Online-Mandate Service URL");
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_SERVICES_OVS_URL,
+ "Services - OVS",
+ LanguageHelper.getErrorString("validation.general.mandateservice.valid")));
+ }
+ }
+
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_MOASP_AUTHBLOCK_TRANSFORM, getKeyPrefix()));
+ if (MiscUtil.isEmpty(check)) {
+ log.info("Empty MoaspssAuthTransformation");
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_MOASP_AUTHBLOCK_TRANSFORM,
+ "MOA-SP - AuthBlocktransformation",
+ LanguageHelper.getErrorString("validation.general.moasp.auth.transformation.empty")));
+ } else {
+ if (ValidationHelper.containsPotentialCSSCharacter(check, false)) {
+ log.info("IdentityLinkSigners is not valid: " + check);
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_MOASP_AUTHBLOCK_TRANSFORM,
+ "MOA-SP - AuthBlocktransformationx",
+ LanguageHelper.getErrorString("validation.general.moasp.auth.transformation.valid",
+ new Object[] {ValidationHelper.getPotentialCSSCharacter(false)} )));
+
+ }
+ }
+
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_MOASP_TRUSTPROFILE_AUTHBLOCK_PROD, getKeyPrefix()));
+ if (MiscUtil.isEmpty(check)) {
+ log.info("Empty MOA-SP/SS Authblock TrustProfile");
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_MOASP_TRUSTPROFILE_AUTHBLOCK_PROD,
+ "MOA-SP - TrustProfile AuthBlock",
+ LanguageHelper.getErrorString("validation.general.moasp.auth.trustprofile.empty")));
+ } else {
+ if (ValidationHelper.containsPotentialCSSCharacter(check, false)) {
+ log.info("Authblock TrustProfile is not valid: " +check);
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_MOASP_TRUSTPROFILE_AUTHBLOCK_PROD,
+ "MOA-SP - TrustProfile AuthBlock",
+ LanguageHelper.getErrorString("validation.general.moasp.auth.trustprofile.valid",
+ new Object[] {ValidationHelper.getPotentialCSSCharacter(false)}) ));
+ }
+ }
+
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_MOASP_TRUSTPROFILE_IDL_PROD, getKeyPrefix()));
+ if (MiscUtil.isEmpty(check)) {
+ log.info("Empty MOA-SP/SS IdentityLink TrustProfile");
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_MOASP_TRUSTPROFILE_IDL_PROD,
+ "MOA-SP - TrustProfile IdL",
+ LanguageHelper.getErrorString("validation.general.moasp.idl.trustprofile.empty")));
+ } else {
+ if (ValidationHelper.containsPotentialCSSCharacter(check, false)) {
+ log.info("IdentityLink TrustProfile is not valid: " +check);
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_MOASP_TRUSTPROFILE_IDL_PROD,
+ "MOA-SP - TrustProfile IdL",
+ LanguageHelper.getErrorString("validation.general.moasp.idl.trustprofile.valid",
+ new Object[] {ValidationHelper.getPotentialCSSCharacter(false)}) ));
+ }
+ }
+
+
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_DEFAULTS_TEMPLATES_HANDY, getKeyPrefix()));
+ if (MiscUtil.isEmpty(check)) {
+ log.info("Empty SLRequestTemplate Handy-BKU");
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_DEFAULTS_TEMPLATES_HANDY,
+ "Default SL-Templates - Handy",
+ LanguageHelper.getErrorString("validation.general.slrequest.handy.empty")));
+ } else {
+ if (ValidationHelper.isNotValidIdentityLinkSigner(check)) {
+ log.info("SLRequestTemplate Handy-BKU is not valid");
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_DEFAULTS_TEMPLATES_HANDY,
+ "Default SL-Templates - ",
+ LanguageHelper.getErrorString("validation.general.slrequest.handy.valid")));
+ }
+ }
+
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_DEFAULTS_TEMPLATES_LOCAL, getKeyPrefix()));
+ if (MiscUtil.isEmpty(check)) {
+ log.info("Empty SLRequestTemplate local BKU");
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_DEFAULTS_TEMPLATES_LOCAL,
+ "Default SL-Templates - Local",
+ LanguageHelper.getErrorString("validation.general.slrequest.local.empty")));
+ } else {
+ if (ValidationHelper.isNotValidIdentityLinkSigner(check)) {
+ log.info("SLRequestTemplate local BKU is not valid");
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_DEFAULTS_TEMPLATES_LOCAL,
+ "Default SL-Templates - Local",
+ LanguageHelper.getErrorString("validation.general.slrequest.local.valid")));
+ }
+ }
+
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_DEFAULTS_TEMPLATES_ONLINE, getKeyPrefix()));
+ if (MiscUtil.isEmpty(check)) {
+ log.info("Empty SLRequestTemplate Online-BKU");
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_DEFAULTS_TEMPLATES_ONLINE,
+ "Default SL-Templates - Online ",
+ LanguageHelper.getErrorString("validation.general.slrequest.online.empty")));
+ } else {
+ if (ValidationHelper.isNotValidIdentityLinkSigner(check)) {
+ log.info("SLRequestTemplate Online-BKU is not valid");
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_DEFAULTS_TEMPLATES_ONLINE,
+ "Default SL-Templates - Online",
+ LanguageHelper.getErrorString("validation.general.slrequest.online.valid")));
+ }
+ }
+
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_SSO_SERVICENAME, getKeyPrefix()));
+ if (MiscUtil.isNotEmpty(check)) {
+ if (ValidationHelper.containsPotentialCSSCharacter(check, false)) {
+ log.info("SSO friendlyname is not valid: " + check);
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_SSO_SERVICENAME,
+ "SSO - Servicename",
+ LanguageHelper.getErrorString("validation.general.sso.friendlyname.valid",
+ new Object[] {ValidationHelper.getPotentialCSSCharacter(false)}) ));
+ }
+ }
+
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_SSO_AUTHBLOCK_TEXT, getKeyPrefix()));
+ if (MiscUtil.isNotEmpty(check)) {
+ if (ValidationHelper.containsPotentialCSSCharacter(check, true)) {
+ log.info("SSO SpecialText is not valid: " + check);
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_SSO_AUTHBLOCK_TEXT,
+ "SSO - AuthBlocktext",
+ LanguageHelper.getErrorString("validation.general.sso.specialauthtext.valid",
+ new Object[] {ValidationHelper.getPotentialCSSCharacter(true)} )));
+ }
+ }
+
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_SSO_TARGET, getKeyPrefix()));
+ if (MiscUtil.isEmpty(check)) {
+ log.info("Empty SSO Target");
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_SSO_TARGET,
+ "SSO - Target",
+ LanguageHelper.getErrorString("validation.general.sso.target.empty")));
+
+ } else {
+
+ //TODO: maybe store full bPK target (incl. prefix)
+ if (!ValidationHelper.isValidAdminTarget(check)) {
+
+ if (ValidationHelper.containsPotentialCSSCharacter(check, false)) {
+ log.warn("IdentificationNumber contains potentail XSS characters: " + check);
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_SSO_TARGET,
+ "SSO - Target",
+ LanguageHelper.getErrorString("validation.general.sso.target.valid",
+ new Object[] {ValidationHelper.getPotentialCSSCharacter(false)}) ));
+ }
+
+ String num = check.replaceAll(" ", "");
+
+ boolean isSSOTargetValid = false;
+ for (String allowedPrefix : MOAIDConfigurationConstants.ALLOWED_WBPK_PREFIXES) {
+ if (num.startsWith(allowedPrefix)) {
+ isSSOTargetValid = true;
+ break;
+ }
+ }
+
+ if (!isSSOTargetValid) {
+ log.info("Not valid SSO Target");
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_SSO_TARGET,
+ "SSO - Target",
+ LanguageHelper.getErrorString("validation.general.sso.target.valid")));
+ }
+
+ }
+ }
+
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_SERVICES_SZRGW_URL, getKeyPrefix()));
+ if (MiscUtil.isNotEmpty(check)) {
+ if (!ValidationHelper.validateURL(check)) {
+ log.info("SZRGW URL is not valid");
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_SERVICES_SZRGW_URL,
+ "Services - SZR-GW URL",
+ LanguageHelper.getErrorString("validation.general.szrgw.url.valid")));
+ }
+ }
+
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_TRUSTSTORE_URL, getKeyPrefix()));
+ if (MiscUtil.isEmpty(check)) {
+ log.info("Empty TrustCACerts Directory");
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_TRUSTSTORE_URL,
+ "Certificate - TrustStore Directory",
+ LanguageHelper.getErrorString("validation.general.trustedcacerts.empty")));
+
+ } else {
+ if (ValidationHelper.isNotValidIdentityLinkSigner(check)) {
+ log.info("Not valid TrustCACerts Directory");
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_TRUSTSTORE_URL,
+ "Certificate - TrustStore Directory",
+ LanguageHelper.getErrorString("validation.general.trustedcacerts.valid",
+ new Object[] {ValidationHelper.getNotValidOAIdentifierCharacters()}) ));
+ }
+ }
+
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_AUTHBLOCK_TRANSFORMATION_BASE64, getKeyPrefix()));
+ if (MiscUtil.isEmpty(check)) {
+ log.info("AuthBlock Transformation file is empty");
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_AUTHBLOCK_TRANSFORMATION_BASE64,
+ "AuthBlock - Transformation",
+ LanguageHelper.getErrorString("validation.general.slrequest.file.empty")));
+
+ }
+
+ if (!errors.isEmpty())
+ throw new ConfigurationTaskValidationException(errors);
+
+
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.ITaskValidator#postProcessing(java.util.Map, java.util.List, at.gv.egiz.components.configuration.api.Configuration)
+ */
+ @Override
+ public Map<String, String> postProcessing(Map<String, String> input,
+ List<String> keysToDelete, Configuration dbconfig) {
+
+ Map<String, String> newConfigValues = new HashMap<String, String>();
+
+ String pubURLPrefix = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PUBLICURLPREFIX, getKeyPrefix()));
+ if(pubURLPrefix.endsWith("/")) {
+ int length = pubURLPrefix.length();
+ pubURLPrefix = pubURLPrefix.substring(0, length-1);
+ newConfigValues.put(MOAIDConfigurationConstants.GENERAL_PUBLICURLPREFIX, pubURLPrefix);
+ log.debug("Change key: " + MOAIDConfigurationConstants.GENERAL_PUBLICURLPREFIX
+ + " from value: " + input.get(MOAIDConfigurationConstants.GENERAL_PUBLICURLPREFIX)
+ + " to value: " + pubURLPrefix);
+ }
+
+ String ssoTarget = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_SSO_TARGET, getKeyPrefix()));
+ if (MiscUtil.isNotEmpty(ssoTarget)) {
+ String newTarget = null;
+ if (!ValidationHelper.isValidAdminTarget(ssoTarget)) {
+ String num = ssoTarget.replaceAll(" ", "");
+ String pre = null;
+ if (!num.startsWith(MOAIDConfigurationConstants.PREFIX_WPBK)) {
+ //add wbPK prefix
+ if (num.startsWith(MOAIDConfigurationConstants.IDENIFICATIONTYPE_FN)) {
+ num = num.substring(MOAIDConfigurationConstants.IDENIFICATIONTYPE_FN.length());
+
+ num = at.gv.egovernment.moa.util.StringUtils.deleteLeadingZeros(num);
+ pre = MOAIDConfigurationConstants.IDENIFICATIONTYPE_FN;
+ }
+
+ if (num.startsWith(MOAIDConfigurationConstants.IDENIFICATIONTYPE_ZVR)) {
+ num = num.substring(MOAIDConfigurationConstants.IDENIFICATIONTYPE_ZVR.length());
+ pre = MOAIDConfigurationConstants.IDENIFICATIONTYPE_ZVR;
+ }
+
+ if (num.startsWith(MOAIDConfigurationConstants.IDENIFICATIONTYPE_ERSB)){
+ num = num.substring(MOAIDConfigurationConstants.IDENIFICATIONTYPE_ERSB.length());
+ pre = MOAIDConfigurationConstants.IDENIFICATIONTYPE_ERSB;
+ }
+
+ newTarget = MOAIDConfigurationConstants.PREFIX_WPBK + pre + "+" + num;
+
+ } else {
+ //wbPK prefix is already added
+ newTarget = num;
+
+ }
+
+ newConfigValues.put(MOAIDConfigurationConstants.GENERAL_AUTH_SSO_TARGET
+ , newTarget);
+ log.debug("Change key: " + MOAIDConfigurationConstants.GENERAL_AUTH_SSO_TARGET
+ + " from value: " + input.get(MOAIDConfigurationConstants.GENERAL_AUTH_SSO_TARGET)
+ + " to value: " + newTarget);
+
+ } else {
+ //TODO: maybe store full bPK target (incl. prefix)
+ newConfigValues.put(MOAIDConfigurationConstants.GENERAL_AUTH_SSO_TARGET
+ , ssoTarget);
+ log.debug("Change key: " + MOAIDConfigurationConstants.GENERAL_AUTH_SSO_TARGET
+ + " from value: " + input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_SSO_TARGET, getKeyPrefix()))
+ + " to value: " + ssoTarget);
+
+ }
+ }
+
+ //TODO: add AuthBlock transformation filename
+ String authBlockTransformation = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_AUTHBLOCK_TRANSFORMATION_BASE64, getKeyPrefix()));
+ String[] splittet = authBlockTransformation.split(",");
+ if (splittet.length > 1) {
+ newConfigValues.put(MOAIDConfigurationConstants.GENERAL_AUTH_AUTHBLOCK_TRANSFORMATION_BASE64,
+ splittet[1]);
+ log.debug("Extract AuthBlock Transformation from GUI upload and add it to key: {}", MOAIDConfigurationConstants.GENERAL_AUTH_AUTHBLOCK_TRANSFORMATION_BASE64);
+
+ }
+
+ if (newConfigValues.isEmpty())
+ return null;
+ else
+ return newConfigValues;
+
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.ITaskValidator#getKeyPrefix()
+ */
+ @Override
+ public String getKeyPrefix() {
+ return MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.ITaskValidator#getName()
+ */
+ @Override
+ public String getName() {
+ return "General MOA-ID Configuration Task";
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.AbstractTaskValidator#getAllAllowedKeys()
+ */
+ @Override
+ public List<Pattern> getAllAllowedPatterns() {
+ return generatePatternsFromKeys(KEYWHITELIST);
+ }
+}
diff --git a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/impl/GeneralOpenIDConfigurationTask.java b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/impl/GeneralOpenIDConfigurationTask.java
new file mode 100644
index 000000000..95f6c8349
--- /dev/null
+++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/impl/GeneralOpenIDConfigurationTask.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+package at.gv.egovernment.moa.id.config.webgui.validation.task.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import at.gv.egiz.components.configuration.api.Configuration;
+import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants;
+import at.gv.egovernment.moa.id.commons.utils.KeyValueUtils;
+import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationTaskValidationException;
+import at.gv.egovernment.moa.id.config.webgui.validation.task.AbstractTaskValidator;
+
+/**
+ * @author tlenz
+ *
+ */
+public class GeneralOpenIDConfigurationTask extends AbstractTaskValidator {
+
+ private static final List<String> KEYWHITELIST;
+
+ static {
+ ArrayList<String> temp = new ArrayList<String>();
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_OPENID_ENABLED, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_OPENID_LEGACY, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+
+ KEYWHITELIST = Collections.unmodifiableList(temp);
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.AbstractTaskValidator#tastValidate(java.util.Map)
+ */
+ @Override
+ protected void tastValidate(Map<String, String> input)
+ throws ConfigurationTaskValidationException {
+
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.AbstractTaskValidator#postProcessing(java.util.Map, java.util.List, at.gv.egiz.components.configuration.api.Configuration)
+ */
+ @Override
+ public Map<String, String> postProcessing(Map<String, String> input,
+ List<String> keysToDelete, Configuration dbconfig) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.AbstractTaskValidator#getKeyPrefix()
+ */
+ @Override
+ public String getKeyPrefix() {
+ return MOAIDConfigurationConstants.GENERAL_PROTOCOLS_OPENID;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.AbstractTaskValidator#getName()
+ */
+ @Override
+ public String getName() {
+ return "General OpenID Configuration Task";
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.AbstractTaskValidator#getAllAllowedKeys()
+ */
+ @Override
+ public List<Pattern> getAllAllowedPatterns() {
+ return generatePatternsFromKeys(KEYWHITELIST);
+ }
+
+}
diff --git a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/impl/GeneralPVP2XConfigurationTask.java b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/impl/GeneralPVP2XConfigurationTask.java
new file mode 100644
index 000000000..46dce77a0
--- /dev/null
+++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/impl/GeneralPVP2XConfigurationTask.java
@@ -0,0 +1,236 @@
+/*
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+package at.gv.egovernment.moa.id.config.webgui.validation.task.impl;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import at.gv.egiz.components.configuration.api.Configuration;
+import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants;
+import at.gv.egovernment.moa.id.commons.utils.KeyValueUtils;
+import at.gv.egovernment.moa.id.commons.validation.ValidationHelper;
+import at.gv.egovernment.moa.id.config.webgui.exception.ValidationObjectIdentifier;
+import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationTaskValidationException;
+import at.gv.egovernment.moa.id.config.webgui.helper.LanguageHelper;
+import at.gv.egovernment.moa.id.config.webgui.validation.task.AbstractTaskValidator;
+import at.gv.egovernment.moa.id.config.webgui.validation.task.ITaskValidator;
+import at.gv.egovernment.moa.util.MiscUtil;
+
+/**
+ * @author tlenz
+ *
+ */
+public class GeneralPVP2XConfigurationTask extends AbstractTaskValidator implements ITaskValidator {
+ private static final Logger logger = LoggerFactory.getLogger(GeneralPVP2XConfigurationTask.class);
+
+ private static final List<String> KEYWHITELIST;
+
+ static {
+ ArrayList<String> temp = new ArrayList<String>();
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_ENABLED, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_LEGACY, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT_COMPANY, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT_FAMLIYNAME, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT_GIVENNAME, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT_MAIL, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT_PHONE, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT_TYPE, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_ORG_FULLNAME, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_ORG_SHORTNAME, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_ORG_URL, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_SERVICENAMME, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+
+ KEYWHITELIST = Collections.unmodifiableList(temp);
+ }
+
+ public static final List<String> AllowedTypes= Arrays.asList(
+ "technical",
+ "support",
+ "administrative",
+ "billing",
+ "other");
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.ITaskValidator#validate(java.util.Map)
+ */
+ @Override
+ protected void tastValidate(Map<String, String> input)
+ throws ConfigurationTaskValidationException {
+
+ List<ValidationObjectIdentifier> errors = new ArrayList<ValidationObjectIdentifier>();
+
+ String check =
+ input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_SERVICENAMME, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ if (MiscUtil.isNotEmpty(check)) {
+ if (ValidationHelper.containsPotentialCSSCharacter(check, false)) {
+ logger.info("PVP2 IssuerName is not valid: " + check);
+ errors.add(new ValidationObjectIdentifier(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_SERVICENAMME,
+ "Service Name",
+ LanguageHelper.getErrorString("validation.general.protocol.pvp2.issuername.valid",
+ new Object[] {ValidationHelper.getPotentialCSSCharacter(false)})));
+ }
+ }
+
+ check =
+ input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_ORG_FULLNAME, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ if (MiscUtil.isNotEmpty(check)) {
+ if (ValidationHelper.containsPotentialCSSCharacter(check, false)) {
+ logger.info("PVP2 organisation display name is not valid: " + check);
+ errors.add(new ValidationObjectIdentifier(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_ORG_FULLNAME,
+ "Organisation - Full name",
+ LanguageHelper.getErrorString("validation.general.protocol.pvp2.org.displayname.valid",
+ new Object[] {ValidationHelper.getPotentialCSSCharacter(false)})));
+ }
+ }
+
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_ORG_SHORTNAME, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ if (MiscUtil.isNotEmpty(check)) {
+ if (ValidationHelper.containsPotentialCSSCharacter(check, false)) {
+ logger.info("PVP2 organisation name is not valid: " + check);
+ errors.add(new ValidationObjectIdentifier(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_ORG_SHORTNAME,
+ "Organisation - Short name",
+ LanguageHelper.getErrorString("validation.general.protocol.pvp2.org.name.valid",
+ new Object[] {ValidationHelper.getPotentialCSSCharacter(false)})));
+ }
+ }
+
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_ORG_URL, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ if (MiscUtil.isNotEmpty(check)) {
+ if (!ValidationHelper.validateURL(check)) {
+ logger.info("PVP2 organisation URL is not valid");
+ errors.add(new ValidationObjectIdentifier(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_ORG_URL,
+ "Organisation - URL",
+ LanguageHelper.getErrorString("validation.general.protocol.pvp2.org.url.valid")));
+ }
+ }
+
+
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT_COMPANY, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ if (MiscUtil.isNotEmpty(check)) {
+ if (ValidationHelper.containsPotentialCSSCharacter(check, false)) {
+ logger.info("PVP2 Contact: Company is not valid: " + check);
+ errors.add(new ValidationObjectIdentifier(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT_COMPANY,
+ "Contact - Company",
+ LanguageHelper.getErrorString("validation.general.protocol.pvp2.contact.company.valid",
+ new Object[] {ValidationHelper.getPotentialCSSCharacter(false)})));
+ }
+ }
+
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT_GIVENNAME, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ if (MiscUtil.isNotEmpty(check)) {
+ if (ValidationHelper.containsPotentialCSSCharacter(check, false)) {
+ logger.info("PVP2 Contact: GivenName is not valid: " + check);
+ errors.add(new ValidationObjectIdentifier(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT_GIVENNAME,
+ "Contact - GivenName",
+ LanguageHelper.getErrorString("validation.general.protocol.pvp2.contact.givenname.valid",
+ new Object[] {ValidationHelper.getPotentialCSSCharacter(false)})));
+ }
+ }
+
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT_FAMLIYNAME, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ if (MiscUtil.isNotEmpty(check)) {
+ if (ValidationHelper.containsPotentialCSSCharacter(check, false)) {
+ logger.info("PVP2 Contact: SureName is not valid: " + check);
+ errors.add(new ValidationObjectIdentifier(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT_FAMLIYNAME,
+ "Contact - FamilyName",
+ LanguageHelper.getErrorString("validation.general.protocol.pvp2.contact.surename.valid",
+ new Object[] {ValidationHelper.getPotentialCSSCharacter(false)})));
+ }
+ }
+
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT_TYPE, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ if (MiscUtil.isNotEmpty(check)) {
+ if (!AllowedTypes.contains(check)) {
+ errors.add(new ValidationObjectIdentifier(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT_TYPE,
+ "Contact - Type",
+ LanguageHelper.getErrorString("validation.general.protocol.pvp2.contact.type.valid")));
+ }
+ }
+
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT_MAIL, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ if (MiscUtil.isNotEmpty(check)) {
+ if (!ValidationHelper.isEmailAddressFormat(check)) {
+ errors.add(new ValidationObjectIdentifier(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT_MAIL,
+ "Contact - Mail",
+ LanguageHelper.getErrorString("validation.general.protocol.pvp2.contact.mail.valid")));
+ }
+ }
+
+ check = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT_PHONE, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ if (MiscUtil.isNotEmpty(check)) {
+ if (!ValidationHelper.validatePhoneNumber(check)) {
+ errors.add(new ValidationObjectIdentifier(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT_PHONE,
+ "Contact - Phone",
+ LanguageHelper.getErrorString("validation.general.protocol.pvp2.contact.phone.valid")));
+ }
+ }
+
+ if (!errors.isEmpty())
+ throw new ConfigurationTaskValidationException(errors);
+
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.ITaskValidator#postProcessing(java.util.Map, java.util.List, at.gv.egiz.components.configuration.api.Configuration)
+ */
+ @Override
+ public Map<String, String> postProcessing(Map<String, String> input,
+ List<String> keysToDelete, Configuration dbconfig) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.ITaskValidator#getKeyPrefix()
+ */
+ @Override
+ public String getKeyPrefix() {
+ return MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X;
+
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.ITaskValidator#getName()
+ */
+ @Override
+ public String getName() {
+ return "General PVP2X Configuration Task";
+
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.AbstractTaskValidator#getAllAllowedKeys()
+ */
+ @Override
+ public List<Pattern> getAllAllowedPatterns() {
+ return generatePatternsFromKeys(KEYWHITELIST);
+ }
+
+}
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
new file mode 100644
index 000000000..a12c8f0cd
--- /dev/null
+++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/impl/GeneralSTORKConfigurationTask.java
@@ -0,0 +1,612 @@
+/*
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+package at.gv.egovernment.moa.id.config.webgui.validation.task.impl;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import org.apache.commons.collections4.map.HashedMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import at.gv.egiz.components.configuration.api.Configuration;
+import at.gv.egiz.components.configuration.api.ConfigurationException;
+import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants;
+import at.gv.egovernment.moa.id.commons.utils.KeyValueUtils;
+import at.gv.egovernment.moa.id.commons.validation.ValidationHelper;
+import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationTaskValidationException;
+import at.gv.egovernment.moa.id.config.webgui.exception.ValidationObjectIdentifier;
+import at.gv.egovernment.moa.id.config.webgui.helper.LanguageHelper;
+import at.gv.egovernment.moa.id.config.webgui.validation.task.AbstractTaskValidator;
+import at.gv.egovernment.moa.id.config.webgui.validation.task.IDynamicLoadableTaskValidator;
+import at.gv.egovernment.moa.util.MiscUtil;
+
+/**
+ * @author tlenz
+ *
+ */
+public class GeneralSTORKConfigurationTask extends AbstractTaskValidator implements
+ IDynamicLoadableTaskValidator {
+ private static final Logger log = LoggerFactory.getLogger(GeneralSTORKConfigurationTask.class);
+
+public static final List<String> KEYWHITELIST;
+
+ static {
+ ArrayList<String> temp = new ArrayList<String>();
+ temp.add(
+ KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_STORK_ATTRIBUTES_LIST, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL)
+ + ".\\S?." + MOAIDConfigurationConstants.GENERAL_AUTH_STORK_ATTRIBUTES_LIST_MANDATORY);
+
+ temp.add(
+ KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_STORK_ATTRIBUTES_LIST, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL)
+ + ".\\S?." + MOAIDConfigurationConstants.GENERAL_AUTH_STORK_ATTRIBUTES_LIST_NAME);
+
+ temp.add(
+ KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL)
+ + ".\\S?." + MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST_SUPPORT_XMLDSIG);
+
+ temp.add(
+ KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL)
+ + ".\\S?." + MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST_COUNTRY);
+
+ temp.add(
+ KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL)
+ + ".\\S?." + MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST_URL);
+
+ temp.add(
+ KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_STORK_QAA, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+
+
+ KEYWHITELIST = Collections.unmodifiableList(temp);
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.ITaskValidator#validate(java.util.Map)
+ */
+ @Override
+ public void tastValidate(Map<String, String> input)
+ throws ConfigurationTaskValidationException {
+ List<ValidationObjectIdentifier> errors = new ArrayList<ValidationObjectIdentifier>();
+ Map<String, String> validatedCPeps = new HashedMap<String, String>();
+ List<String> validatedAttributes = new ArrayList<String>();
+
+ //validate C-PEPS entries
+ Map<String, String> cPepsList = KeyValueUtils.getSubSetWithPrefix(input,
+ KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ if (!cPepsList.isEmpty()) {
+ Iterator<String> cPepsKeys = cPepsList.keySet().iterator();
+ while (cPepsKeys.hasNext()) {
+ String cpepsKey = cPepsKeys.next();
+ String index = KeyValueUtils.getParentKey(cpepsKey);
+
+ if (cpepsKey.endsWith(MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST_COUNTRY)) {
+ String cc = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL)
+ + "." + cpepsKey);
+ String url = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL)
+ + "." + index + "."
+ + MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST_URL);
+
+ log.trace("Extract C-PEPS for country: " + cc + " with URL:" + url);
+ if (!validatedCPeps.containsKey(cc)) {
+ if (MiscUtil.isNotEmpty(cc)) {
+ if (ValidationHelper.containsPotentialCSSCharacter(cc, false)) {
+ log.warn("CPEPS config countrycode contains potentail XSS characters: " + cc);
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST
+ + "." + cpepsKey,
+ "STORK - CPEPS Country",
+ LanguageHelper.getErrorString("validation.stork.cpeps.cc",
+ new Object[] {ValidationHelper.getPotentialCSSCharacter(false)})));
+ }
+ if(!cc.toLowerCase().matches("^[a-z][a-z]$")) {
+ log.warn("CPEPS config countrycode does not comply to ISO 3166-2 : " + cc);
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST
+ + "." + cpepsKey,
+ "STORK - CPEPS Country",
+ LanguageHelper.getErrorString("validation.stork.cpeps.cc",
+ new Object[] {cc})));
+ }
+ } else {
+ log.warn("CPEPS config countrycode is empty : " + cc);
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST
+ + "." + cpepsKey,
+ "STORK - CPEPS Country",
+ LanguageHelper.getErrorString("validation.stork.cpeps.empty",
+ new Object[] {cc})));
+ }
+
+ // check url
+ if (MiscUtil.isNotEmpty(url)) {
+ if (!ValidationHelper.validateURL(url)) {
+ log.info("CPEPS config URL is invalid : " + url);
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST
+ + "." + index + "."
+ + MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST_URL,
+ "STORK - CPEPS URL",
+ LanguageHelper.getErrorString("validation.stork.cpeps.url")));
+ }
+ } else {
+ log.warn("CPEPS config url is empty : " + url);
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST
+ + "." + index + "."
+ + MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST_URL,
+ "STORK - CPEPS URL",
+ LanguageHelper.getErrorString("validation.stork.cpeps.empty",
+ new Object[] {url})));
+
+ }
+ validatedCPeps.put(cc, url);
+
+ } else {
+ log.warn("Duplicated C-PEPS country with countryCode: " + cc + " found.");
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST
+ + "." + cpepsKey,
+ "STORK - CPEPS Country",
+ LanguageHelper.getErrorString("validation.stork.cpeps.duplicate")));
+
+ }
+ }
+ }
+ }
+
+
+ // check qaa
+ try {
+ int qaa = Integer.valueOf(input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_STORK_QAA, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL)));
+ if(1 > qaa && 4 < qaa) {
+ log.warn("QAA is out of range : " + qaa);
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_STORK_QAA,
+ "STORK - QAA Level",
+ LanguageHelper.getErrorString("validation.stork.qaa.outofrange",
+ new Object[] {qaa})));
+ }
+ } catch (Exception e) {
+ log.warn("STORK QAA can not parsed : " + input.get(MOAIDConfigurationConstants.GENERAL_AUTH_STORK_QAA));
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_STORK_QAA,
+ "STORK - QAA Level",
+ LanguageHelper.getErrorString("validation.stork.qaa.outofrange",
+ new Object[] {input.get(MOAIDConfigurationConstants.GENERAL_AUTH_STORK_QAA)})));
+
+ }
+
+
+ // check attributes
+ Map<String, String> attributeList = KeyValueUtils.getSubSetWithPrefix(input,
+ KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_STORK_ATTRIBUTES_LIST, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ if (!attributeList.isEmpty()) {
+ for(String key : attributeList.keySet()) {
+ if (key.endsWith(MOAIDConfigurationConstants.GENERAL_AUTH_STORK_ATTRIBUTES_LIST_NAME)) {
+ String value = attributeList.get(key);
+ if (!validatedAttributes.contains(value)) {
+ if (ValidationHelper.containsPotentialCSSCharacter(value, true)) {
+ log.warn("default attributes contains potentail XSS characters: " + value);
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_STORK_QAA,
+ "STORK - Attributes",
+ LanguageHelper.getErrorString("validation.stork.requestedattributes",
+ new Object[] {ValidationHelper.getPotentialCSSCharacter(true)})));
+ }
+ if(!value.toLowerCase().matches("^[a-z0-9]*$")) {
+ log.warn("default attributes do not match the requested format : " + value);
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_STORK_QAA,
+ "STORK - Attributes",
+ LanguageHelper.getErrorString("validation.stork.requestedattributes",
+ new Object[] {value})));
+ }
+ validatedAttributes.add(value);
+
+ } else {
+ log.warn("Duplicated STORK attribute: " + value + " found.");
+ errors.add(new ValidationObjectIdentifier(
+ MOAIDConfigurationConstants.GENERAL_AUTH_STORK_ATTRIBUTES_LIST
+ + "." + key,
+ "STORK - Attributes",
+ LanguageHelper.getErrorString("validation.stork.requestedattributes")));
+
+ }
+ }
+ }
+
+ }
+
+
+ if (!errors.isEmpty())
+ throw new ConfigurationTaskValidationException(errors);
+
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.ITaskValidator#postProcessing(java.util.Map, java.util.List, at.gv.egiz.components.configuration.api.Configuration)
+ */
+ @Override
+ public Map<String, String> postProcessing(Map<String, String> input,
+ List<String> keysToDelete, Configuration dbconfig) {
+ List<String> currentCEPSCountries = new ArrayList<String>();
+ List<String> currentAttributeNames = new ArrayList<String>();
+
+ List<String> cPESCountriesToAdd = new ArrayList<String>();
+ List<String> attributeNamesToAdd = new ArrayList<String>();
+ List<String> cPESCountriesToDelete = new ArrayList<String>();
+ List<String> attributeNamesToDelete = new ArrayList<String>();
+
+ Map<String, String> newConfigValues = new HashMap<String, String>();
+
+ try {
+ //load current configuration
+ String[] currentCPEPSKeys = dbconfig.findConfigurationId(
+ MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST
+ + ".%."
+ + MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST_COUNTRY);
+ if (currentCPEPSKeys != null) {
+ for (String el : currentCPEPSKeys) {
+ String cc = dbconfig.getStringValue(el);
+ if (MiscUtil.isNotEmpty(cc))
+ currentCEPSCountries.add(cc);
+
+ else {
+ //if empty, mark do delete
+ String keyToDelete = KeyValueUtils.getParentKey(el) + ".*";
+ log.trace("Mark C-PEPS key: {} for deleting.", keyToDelete);
+ keysToDelete.add(keyToDelete);
+ }
+ }
+ cPESCountriesToDelete.addAll(currentCEPSCountries);
+ }
+
+ String[] currentAttributeKeys = dbconfig.findConfigurationId(
+ MOAIDConfigurationConstants.GENERAL_AUTH_STORK_ATTRIBUTES_LIST
+ + ".%."
+ + MOAIDConfigurationConstants.GENERAL_AUTH_STORK_ATTRIBUTES_LIST_NAME);
+ if (currentAttributeKeys != null) {
+ for (String el : currentAttributeKeys) {
+ String cc = dbconfig.getStringValue(el);
+ if (MiscUtil.isNotEmpty(cc))
+ currentAttributeNames.add(cc);
+
+ else {
+ //if empty, mark do delete
+ String keyToDelete = KeyValueUtils.getParentKey(el) + ".*";
+ log.trace("Mark empty STORK attribute key: {} for deleting.", keyToDelete);
+ keysToDelete.add(keyToDelete);
+
+ }
+ }
+ attributeNamesToDelete.addAll(currentAttributeNames);
+ }
+
+ //parse new configuration
+ Map<String, String> cPepsList = KeyValueUtils.getSubSetWithPrefix(input,
+ KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ if (!cPepsList.isEmpty()) {
+ Iterator<String> cPepsKeys = cPepsList.keySet().iterator();
+ while (cPepsKeys.hasNext()) {
+ String cpepsKey = cPepsKeys.next();
+
+ if (cpepsKey.endsWith(MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST_COUNTRY)) {
+ String cc = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL)
+ + "." + cpepsKey);
+
+ //check new configuration against current configuration
+ if (currentCEPSCountries.contains(cc)) {
+ log.trace("C-PEPS for country {} is already in configuration", cc);
+ cPESCountriesToDelete.remove(cc);
+
+ } else {
+ if (MiscUtil.isNotEmpty(cc)) {
+ log.trace("C-PEPS for country {} must be added to Service configurations", cc);
+ cPESCountriesToAdd.add(cc);
+
+ }
+ }
+ }
+ }
+ }
+
+ Map<String, String> attributeList = KeyValueUtils.getSubSetWithPrefix(input,
+ KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_STORK_ATTRIBUTES_LIST, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL));
+ if (!attributeList.isEmpty()) {
+ Iterator<String> attributeKeys = attributeList.keySet().iterator();
+ while (attributeKeys.hasNext()) {
+ String attributeKey = attributeKeys.next();
+
+ if (attributeKey.endsWith(MOAIDConfigurationConstants.GENERAL_AUTH_STORK_ATTRIBUTES_LIST_NAME)) {
+ String attributeName = input.get(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_AUTH_STORK_ATTRIBUTES_LIST, MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL)
+ + "." + attributeKey);
+
+ //check new configuration against current configuration
+ if (currentAttributeNames.contains(attributeName)) {
+ log.trace("STORK Attribute {} is already in configuration", attributeName);
+ attributeNamesToDelete.remove(attributeName);
+
+ } else {
+ if (MiscUtil.isNotEmpty(attributeName)) {
+ log.trace("STORK Attribute {} must be added to Service configurations", attributeName);
+ attributeNamesToAdd.add(attributeName);
+
+ } }
+ }
+ }
+ }
+
+ //add new key/value pairs to online Applications
+ if (!cPESCountriesToAdd.isEmpty() || !attributeNamesToAdd.isEmpty()) {
+ String[] currentOAServices = dbconfig.findConfigurationId(
+ MOAIDConfigurationConstants.PREFIX_MOAID_SERVICES_OA
+ + ".%."
+ + MOAIDConfigurationConstants.SERVICE_UNIQUEIDENTIFIER);
+
+ for(String el : currentOAServices) {
+ String oaKey = KeyValueUtils.getParentKey(el);
+ String[] oaCPEPSList = dbconfig.findConfigurationId(
+ oaKey + "." + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_COUNTRIES_LIST
+ + ".%."
+ + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_COUNTRIES_LIST_COUNTRYCODE);
+
+ int nextListCounter = KeyValueUtils.findNextFreeListCounter(oaCPEPSList, oaKey + "." + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_COUNTRIES_LIST);
+
+ //get all C-PEPS countries from OA
+ List<String> actuallyAddedOACPEPS = new ArrayList<String>();
+ for (String oaCPEPS : oaCPEPSList) {
+ String oaCC = dbconfig.getStringValue(oaCPEPS);
+ if (MiscUtil.isNotEmpty(oaCC) && !actuallyAddedOACPEPS.contains(oaCC))
+ actuallyAddedOACPEPS.add(oaCC);
+
+ }
+
+ for (String cc : cPESCountriesToAdd) {
+ if (!actuallyAddedOACPEPS.contains(cc)) {
+ log.debug("Add key: "
+ + oaKey
+ + "." + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_COUNTRIES_LIST
+ + "." + String.valueOf(nextListCounter)
+ + "." + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_COUNTRIES_LIST_COUNTRYCODE
+ + " and value: " + cc + " to configuration.");
+ newConfigValues.put(oaKey
+ + "." + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_COUNTRIES_LIST
+ + "." + String.valueOf(nextListCounter)
+ + "." + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_COUNTRIES_LIST_COUNTRYCODE
+ , cc);
+
+ log.debug("Add key: "
+ + oaKey
+ + "." + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_COUNTRIES_LIST
+ + "." + String.valueOf(nextListCounter)
+ + "." + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_COUNTRIES_LIST_ENABLED
+ + " and value: true" + " to configuration.");
+ newConfigValues.put(oaKey
+ + "." + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_COUNTRIES_LIST
+ + "." + String.valueOf(nextListCounter)
+ + "." + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_COUNTRIES_LIST_ENABLED
+ , String.valueOf(true));
+
+ nextListCounter++;
+
+ } else {
+ log.info("Configuration is maybe inconsistend! New C-PEPS country: "
+ + cc + " is already added on Service: " + oaKey);
+
+ }
+ }
+
+ String[] oaAttributeList = dbconfig.findConfigurationId(
+ oaKey + "." + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_ATTRIBUTES_LIST
+ + ".%."
+ + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_ATTRIBUTES_LIST_NAME);
+
+ int nextAttributeListCounter = KeyValueUtils.findNextFreeListCounter(oaAttributeList, oaKey + "." + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_ATTRIBUTES_LIST);
+
+ //get all STORK attributes from OA
+ List<String> actuallyAddedOAAttributes = new ArrayList<String>();
+ for (String oaAttr : oaAttributeList) {
+ String oaAttrName = dbconfig.getStringValue(oaAttr);
+ if (MiscUtil.isNotEmpty(oaAttrName) && !actuallyAddedOAAttributes.contains(oaAttrName))
+ actuallyAddedOAAttributes.add(oaAttrName);
+
+ }
+
+ for (String attrName : attributeNamesToAdd) {
+ if (!actuallyAddedOAAttributes.contains(attrName)) {
+ log.debug("Add key: "
+ + oaKey
+ + "." + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_ATTRIBUTES_LIST
+ + "." + String.valueOf(nextAttributeListCounter)
+ + "." + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_ATTRIBUTES_LIST_NAME
+ + " and value: " + attrName + " to configuration.");
+ newConfigValues.put(oaKey
+ + "." + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_ATTRIBUTES_LIST
+ + "." + String.valueOf(nextAttributeListCounter)
+ + "." + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_ATTRIBUTES_LIST_NAME
+ , attrName);
+
+ log.debug("Add key: "
+ + oaKey
+ + "." + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_ATTRIBUTES_LIST
+ + "." + String.valueOf(nextAttributeListCounter)
+ + "." + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_ATTRIBUTES_LIST_REQUESTED
+ + " and value: true" + " to configuration.");
+ newConfigValues.put(oaKey
+ + "." + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_ATTRIBUTES_LIST
+ + "." + String.valueOf(nextAttributeListCounter)
+ + "." + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_ATTRIBUTES_LIST_REQUESTED
+ , String.valueOf(true));
+
+ log.debug("Add key: "
+ + oaKey
+ + "." + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_ATTRIBUTES_LIST
+ + "." + String.valueOf(nextAttributeListCounter)
+ + "." + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_ATTRIBUTES_LIST_MANDATORY
+ + " and value: false" + " to configuration.");
+ newConfigValues.put(oaKey
+ + "." + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_ATTRIBUTES_LIST
+ + "." + String.valueOf(nextAttributeListCounter)
+ + "." + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_ATTRIBUTES_LIST_MANDATORY
+ , String.valueOf(false));
+
+ } else {
+ log.info("Configuration is maybe inconsistend! New STORK attribute: "
+ + attrName + " is already added on Service: " + oaKey);
+
+ }
+ }
+ }
+ }
+
+ //delete unused key/value pairs from online applications
+ if (!cPESCountriesToDelete.isEmpty()) {
+ for (String el : cPESCountriesToDelete) {
+ //mark general config to delete
+ String[] generalCPEPS = dbconfig.findConfigurationId(
+ MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST
+ + ".%."
+ + MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST_COUNTRY);
+
+ for (String ccKey : generalCPEPS) {
+ String storedCC = dbconfig.getStringValue(ccKey);
+ if (el.equals(storedCC)) {
+ //delete C-PEPS
+ String keyToDelete = KeyValueUtils.getParentKey(ccKey) + ".*";
+ log.debug("Mark key: " + keyToDelete + " for deleting.");
+ keysToDelete.add(keyToDelete);
+
+ }
+ }
+
+ //mark service key to delete
+ String[] servicesOAs = dbconfig.findConfigurationId(
+ MOAIDConfigurationConstants.PREFIX_MOAID_SERVICES_OA
+ + ".%."
+ + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_COUNTRIES_LIST
+ + ".%."
+ + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_COUNTRIES_LIST_COUNTRYCODE);
+
+ for (String ccKey : servicesOAs) {
+ String storedCC = dbconfig.getStringValue(ccKey);
+ if (el.equals(storedCC)) {
+ //delete C-PEPS
+ String keyToDelete = KeyValueUtils.getParentKey(ccKey) + ".*";
+ log.debug("Mark key: " + keyToDelete + " for deleting.");
+ keysToDelete.add(keyToDelete);
+
+ }
+ }
+ }
+ }
+ if (!attributeNamesToDelete.isEmpty()) {
+ for (String el : attributeNamesToDelete) {
+ //mark general config to delete
+ String[] generalAttributes = dbconfig.findConfigurationId(
+ MOAIDConfigurationConstants.GENERAL_AUTH_STORK_ATTRIBUTES_LIST
+ + ".%."
+ + MOAIDConfigurationConstants.GENERAL_AUTH_STORK_ATTRIBUTES_LIST_NAME);
+
+ for (String attrKey : generalAttributes) {
+ String storedAttr = dbconfig.getStringValue(attrKey);
+ if (el.equals(storedAttr)) {
+ //delete C-PEPS
+ String keyToDelete = KeyValueUtils.getParentKey(attrKey) + ".*";
+ log.debug("Mark key: " + keyToDelete + " for deleting.");
+ keysToDelete.add(keyToDelete);
+
+ }
+ }
+
+
+ //mark service key to delete
+ String[] servicesOAs = dbconfig.findConfigurationId(
+ MOAIDConfigurationConstants.PREFIX_MOAID_SERVICES_OA
+ + ".%."
+ + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_ATTRIBUTES_LIST
+ + ".%."
+ + MOAIDConfigurationConstants.SERVICE_AUTH_STORK_ATTRIBUTES_LIST_NAME);
+
+ for (String attrKey : servicesOAs) {
+ String storedAttr = dbconfig.getStringValue(attrKey);
+ if (el.equals(storedAttr)) {
+ //delete C-PEPS
+ String keyToDelete = KeyValueUtils.getParentKey(attrKey) + ".*";
+ log.debug("Mark key: " + keyToDelete + " for deleting.");
+ keysToDelete.add(keyToDelete);
+
+ }
+ }
+ }
+ }
+
+ } catch (ConfigurationException e) {
+ log.error("Configuration is not accessable!", e);
+
+ }
+
+ if (newConfigValues.isEmpty())
+ return null;
+ else
+ return newConfigValues;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.ITaskValidator#getKeyPrefix()
+ */
+ @Override
+ public String getKeyPrefix() {
+ return MOAIDConfigurationConstants.GENERAL_AUTH_STORK;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.ITaskValidator#getName()
+ */
+ @Override
+ public String getName() {
+ return "General STORK Configuration Task";
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.IDynamicLoadableTaskValidator#getModulValidatorPrefix()
+ */
+ @Override
+ public List<String> getModulValidatorPrefix() {
+ return Arrays.asList(MOAIDConfigurationConstants.PREFIX_MOAID_GENERAL);
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.AbstractTaskValidator#getAllAllowedKeys()
+ */
+ @Override
+ public List<Pattern> getAllAllowedPatterns() {
+ return generatePatternsFromKeys(KEYWHITELIST);
+ }
+
+}
diff --git a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/impl/ServicesGeneralInformationTask.java b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/impl/ServicesGeneralInformationTask.java
new file mode 100644
index 000000000..f27cb9ce7
--- /dev/null
+++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/task/impl/ServicesGeneralInformationTask.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+package at.gv.egovernment.moa.id.config.webgui.validation.task.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import at.gv.egiz.components.configuration.api.Configuration;
+import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants;
+import at.gv.egovernment.moa.id.commons.utils.KeyValueUtils;
+import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationTaskValidationException;
+import at.gv.egovernment.moa.id.config.webgui.validation.task.AbstractTaskValidator;
+import at.gv.egovernment.moa.id.config.webgui.validation.task.ITaskValidator;
+
+/**
+ * @author tlenz
+ *
+ */
+public class ServicesGeneralInformationTask extends AbstractTaskValidator implements ITaskValidator {
+
+ private static final List<String> KEYWHITELIST;
+
+ static {
+ ArrayList<String> temp = new ArrayList<String>();
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_OPENID_ENABLED, MOAIDConfigurationConstants.PREFIX_GENERAL));
+ temp.add(KeyValueUtils.removePrefixFromKey(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_OPENID_LEGACY, MOAIDConfigurationConstants.PREFIX_GENERAL));
+
+ KEYWHITELIST = Collections.unmodifiableList(temp);
+ }
+
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.ITaskValidator#validate(java.util.Map)
+ */
+ @Override
+ public void validate(Map<String, String> input)
+ throws ConfigurationTaskValidationException {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.ITaskValidator#getKeyPrefix()
+ */
+ @Override
+ public String getKeyPrefix() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.ITaskValidator#getName()
+ */
+ @Override
+ public String getName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.ITaskValidator#postProcessing(java.util.Map, java.util.List, at.gv.egiz.components.configuration.api.Configuration)
+ */
+ @Override
+ public Map<String, String> postProcessing(Map<String, String> input,
+ List<String> keysToDelete, Configuration dbconfig) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.AbstractTaskValidator#tastValidate(java.util.Map)
+ */
+ @Override
+ protected void tastValidate(Map<String, String> input)
+ throws ConfigurationTaskValidationException {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.webgui.validation.task.AbstractTaskValidator#getAllAllowedKeys()
+ */
+ @Override
+ public List<Pattern> getAllAllowedPatterns() {
+ return generatePatternsFromKeys(KEYWHITELIST);
+ }
+
+}
diff --git a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/utils/CompanyNumberValidator.java b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/utils/CompanyNumberValidator.java
new file mode 100644
index 000000000..b9eb76857
--- /dev/null
+++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/utils/CompanyNumberValidator.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ *******************************************************************************/
+package at.gv.egovernment.moa.id.config.webgui.validation.utils;
+
+import org.apache.commons.lang.StringUtils;
+
+import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants;
+
+public class CompanyNumberValidator implements IdentificationNumberValidator {
+
+ public boolean validate(String commercialRegisterNumber) {
+
+ String normalizedNumber = commercialRegisterNumber.replaceAll(" ", "");
+ if(normalizedNumber.startsWith(MOAIDConfigurationConstants.IDENIFICATIONTYPE_FN))
+ normalizedNumber = normalizedNumber.substring(2);
+
+ return checkCommercialRegisterNumber(normalizedNumber);
+ }
+
+ private boolean checkCommercialRegisterNumber(String commercialRegisterNumber) {
+ if (commercialRegisterNumber == null) {
+ return false;
+ }
+ commercialRegisterNumber = StringUtils.leftPad(commercialRegisterNumber, 7,
+ '0');
+ if (!commercialRegisterNumber.matches("\\d{6}[abdfghikmpstvwxzy]")) {
+ return false;
+ }
+ String digits = commercialRegisterNumber.substring(0,
+ commercialRegisterNumber.length() - 1);
+ char checkDigit = commercialRegisterNumber.charAt(commercialRegisterNumber
+ .length() - 1);
+ boolean result = calcCheckDigitFromCommercialRegisterNumber(digits) == checkDigit;
+ return result;
+ }
+
+ public static char calcCheckDigitFromCommercialRegisterNumber(
+ String commercialRegisterDigits) {
+ final int[] WEIGHT = { 6, 4, 14, 15, 10, 1 };
+ final char[] CHECKDIGIT = { 'a', 'b', 'd', 'f', 'g', 'h', 'i', 'k', 'm',
+ 'p', 's', 't', 'v', 'w', 'x', 'y', 'z' };
+ if (commercialRegisterDigits == null) {
+ throw new NullPointerException("Commercial register number missing.");
+ }
+ commercialRegisterDigits = StringUtils.leftPad(commercialRegisterDigits, 6,
+ '0');
+ if (!commercialRegisterDigits.matches("\\d{6}")) {
+ throw new IllegalArgumentException(
+ "Invalid commercial register number provided.");
+ }
+ int sum = 0;
+ for (int i = 0; i < commercialRegisterDigits.length(); i++) {
+ int value = commercialRegisterDigits.charAt(i) - '0';
+ sum += WEIGHT[i] * value;
+ }
+ return CHECKDIGIT[sum % 17];
+ }
+}
diff --git a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/utils/IdentificationNumberValidator.java b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/utils/IdentificationNumberValidator.java
new file mode 100644
index 000000000..1ecbd3f82
--- /dev/null
+++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/utils/IdentificationNumberValidator.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ *******************************************************************************/
+package at.gv.egovernment.moa.id.config.webgui.validation.utils;
+
+public interface IdentificationNumberValidator {
+
+ boolean validate(String idNumber);
+
+}