diff options
Diffstat (limited to 'id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/validation/modul')
7 files changed, 536 insertions, 0 deletions
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..e7775beba --- /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,58 @@ +/* + * 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.ServicesGeneralInformationTask; +import at.gv.egovernment.moa.id.config.webgui.validation.task.impl.ServicesPVPGatewayTask; + +/** + * @author tlenz + * + */ +public class GatewayValidator extends AbstractModuleValidator { + + public GatewayValidator() { + addTaskValidator(new ServicesGeneralInformationTask()); + addTaskValidator(new ServicesPVPGatewayTask()); + } + + + /* (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..5b9312e8e --- /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,57 @@ +/* + * 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.ServicesGeneralInformationTask; +import at.gv.egovernment.moa.id.config.webgui.validation.task.impl.ServicesInterfederationIDPTask; + +/** + * @author tlenz + * + */ +public class InterfederationIDPValidator extends AbstractModuleValidator { + + public InterfederationIDPValidator() { + addTaskValidator(new ServicesGeneralInformationTask()); + addTaskValidator(new ServicesInterfederationIDPTask()); + + } + + /* (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..dbce8ec3a --- /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,71 @@ +/* + * 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.ServicesAuthenticationInformationTask; +import at.gv.egovernment.moa.id.config.webgui.validation.task.impl.ServicesBKUSelectionTask; +import at.gv.egovernment.moa.id.config.webgui.validation.task.impl.ServicesGeneralInformationTask; +import at.gv.egovernment.moa.id.config.webgui.validation.task.impl.ServicesProtocolSAML1Task; +import at.gv.egovernment.moa.id.config.webgui.validation.task.impl.ServicesSSOAuthenticationTask; +import at.gv.egovernment.moa.id.config.webgui.validation.task.impl.ServicesTargetTask; +import at.gv.egovernment.moa.id.config.webgui.validation.task.impl.ServicesbPKDecryptionTask; + +/** + * @author tlenz + * + */ +public class OnlineApplicationValidator extends AbstractModuleValidator { + + /** + * + */ + public OnlineApplicationValidator() { + addTaskValidator(new ServicesGeneralInformationTask()); + addTaskValidator(new ServicesTargetTask()); + addTaskValidator(new ServicesAuthenticationInformationTask()); + addTaskValidator(new ServicesSSOAuthenticationTask()); + addTaskValidator(new ServicesbPKDecryptionTask()); + addTaskValidator(new ServicesProtocolSAML1Task()); + addTaskValidator(new ServicesBKUSelectionTask()); + + } + + /* (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..ad3c15b16 --- /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,61 @@ +/* + * 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.ServicesBKUSelectionTask; +import at.gv.egovernment.moa.id.config.webgui.validation.task.impl.ServicesGeneralInformationTask; +import at.gv.egovernment.moa.id.config.webgui.validation.task.impl.ServicesTargetTask; + +/** + * @author tlenz + * + */ +public class VIDPValidator extends AbstractModuleValidator { + + + public VIDPValidator() { + addTaskValidator(new ServicesGeneralInformationTask()); + addTaskValidator(new ServicesTargetTask()); + addTaskValidator(new ServicesBKUSelectionTask()); + + } + + /* (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"; + } + +} |