diff options
author | Florian Reimair <florian.reimair@iaik.tugraz.at> | 2013-12-13 10:01:36 +0100 |
---|---|---|
committer | Florian Reimair <florian.reimair@iaik.tugraz.at> | 2014-01-27 16:34:14 +0100 |
commit | 6f418eaa49c86c26a5d8cb0d9577545167ba850d (patch) | |
tree | c3680c906de2e934159939a8a62349999a1ac013 /id/ConfigWebTool/src/main/java | |
parent | 9786de6a3b5886437d23d9cce06ae76ab440ff51 (diff) | |
download | moa-id-spss-6f418eaa49c86c26a5d8cb0d9577545167ba850d.tar.gz moa-id-spss-6f418eaa49c86c26a5d8cb0d9577545167ba850d.tar.bz2 moa-id-spss-6f418eaa49c86c26a5d8cb0d9577545167ba850d.zip |
peps save is validated
Diffstat (limited to 'id/ConfigWebTool/src/main/java')
2 files changed, 63 insertions, 0 deletions
diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditGeneralConfigAction.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditGeneralConfigAction.java index b4ae27c6a..5dc6f33e7 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditGeneralConfigAction.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditGeneralConfigAction.java @@ -51,6 +51,7 @@ import at.gv.egovernment.moa.id.configuration.data.GeneralMOAIDConfig; import at.gv.egovernment.moa.id.configuration.data.GeneralStorkConfig; import at.gv.egovernment.moa.id.configuration.helper.LanguageHelper; import at.gv.egovernment.moa.id.configuration.validation.moaconfig.MOAConfigValidator; +import at.gv.egovernment.moa.id.configuration.validation.moaconfig.StorkConfigValidator; import at.gv.egovernment.moa.id.util.Random; import at.gv.egovernment.moa.util.MiscUtil; @@ -132,6 +133,8 @@ public class EditGeneralConfigAction extends ActionSupport MOAConfigValidator validator = new MOAConfigValidator(); List<String> errors = validator.validate(moaconfig); + + errors.addAll(new StorkConfigValidator().validate(storkconfig)); if (errors.size() > 0) { log.info("General MOA-ID configuration has some erros."); diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/moaconfig/StorkConfigValidator.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/moaconfig/StorkConfigValidator.java new file mode 100644 index 000000000..91d5ecabd --- /dev/null +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/moaconfig/StorkConfigValidator.java @@ -0,0 +1,60 @@ +package at.gv.egovernment.moa.id.configuration.validation.moaconfig; + +import java.util.ArrayList; +import java.util.List; +import org.apache.log4j.Logger; + +import at.gv.egovernment.moa.id.commons.db.dao.config.CPEPS; +import at.gv.egovernment.moa.id.configuration.data.GeneralStorkConfig; +import at.gv.egovernment.moa.id.configuration.helper.LanguageHelper; +import at.gv.egovernment.moa.id.configuration.validation.ValidationHelper; +import at.gv.egovernment.moa.util.MiscUtil; + +public class StorkConfigValidator { + + private static final Logger log = Logger.getLogger(StorkConfigValidator.class); + + public List<String> validate(GeneralStorkConfig form) { + + List<String> errors = new ArrayList<String>(); + + log.debug("Validate general STORK configuration"); + + // check peps list + for(CPEPS current : form.getCpepslist()) { + // check country code + String check = current.getCountryCode(); + if (MiscUtil.isNotEmpty(check)) { + if (ValidationHelper.containsPotentialCSSCharacter(check, false)) { + log.warn("CPEPS config countrycode contains potentail XSS characters: " + check); + errors.add(LanguageHelper.getErrorString("validation.stork.cpeps.cc", + new Object[] {ValidationHelper.getPotentialCSSCharacter(false)} )); + } + if(!check.toLowerCase().matches("^[a-z][a-z]$")) { + log.warn("CPEPS config countrycode does not comply to ISO 3166-2 : " + check); + errors.add(LanguageHelper.getErrorString("validation.stork.cpeps.cc", + new Object[] {check} )); + } + } else { + log.warn("CPEPS config countrycode is empty : " + check); + errors.add(LanguageHelper.getErrorString("validation.stork.cpeps.empty", + new Object[] {check} )); + } + + // check url + check = current.getURL(); + if (MiscUtil.isNotEmpty(check)) { + if (!ValidationHelper.validateURL(check)) { + log.info("CPEPS config URL is invalid : " + check); + errors.add(LanguageHelper.getErrorString("validation.stork.cpeps.url")); + } + } else { + log.warn("CPEPS config url is empty : " + check); + errors.add(LanguageHelper.getErrorString("validation.stork.cpeps.empty", + new Object[] {check} )); + } + } + + return errors; + } +} |