From 79aeebd55d548326a3892465c441c77589e0e37d Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Fri, 4 Jul 2014 14:48:19 +0200 Subject: refactored logging statements --- .../moa/id/configuration/struts/action/EditGeneralConfigAction.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'id/ConfigWebTool/src/main/java/at/gv/egovernment') 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 0a308a354..ad465e0d8 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 @@ -555,10 +555,10 @@ public class EditGeneralConfigAction extends BasicAction { } try{ - log.error("CPEPS LIST: " + storkconfig.getCpepslist().size() ); - log.error("CPEPS 1:" + storkconfig.getCpepslist().get(0).getCountryCode() +storkconfig.getCpepslist().get(0).getURL()); + log.info("CPEPS LIST: " + storkconfig.getCpepslist().size() ); + log.trace("CPEPS 1:" + storkconfig.getCpepslist().get(0).getCountryCode() +storkconfig.getCpepslist().get(0).getURL()); } catch (Exception ex) { - ex.printStackTrace(); + log.info("CPEPS LIST is null"); } } } -- cgit v1.2.3 From 35993eab38db2aa67137d674baa31031266c2b2e Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Fri, 4 Jul 2014 14:41:55 +0200 Subject: fix: overwrite single config instead of deleting old one --- .../struts/action/EditGeneralConfigAction.java | 73 ++++------------------ 1 file changed, 12 insertions(+), 61 deletions(-) (limited to 'id/ConfigWebTool/src/main/java/at/gv/egovernment') 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 ad465e0d8..ec261335d 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 @@ -237,20 +237,8 @@ public class EditGeneralConfigAction extends BasicAction { } catch (Exception ex) { ex.printStackTrace(); } - - MOAIDConfiguration oldconfig = ConfigurationDBRead.getMOAIDConfiguration(); - AuthComponentGeneral oldauth = null; - if (oldconfig != null) { - oldauth = oldconfig.getAuthComponentGeneral(); - } - -// MOAIDConfiguration dbconfig = ConfigurationDBRead.getMOAIDConfiguration(); -// if (dbconfig == null) { -// dbconfig = new MOAIDConfiguration(); -// isnewconfig = true; -// } - MOAIDConfiguration dbconfig = new MOAIDConfiguration(); + MOAIDConfiguration dbconfig = ConfigurationDBRead.getMOAIDConfiguration(); AuthComponentGeneral dbauth = dbconfig.getAuthComponentGeneral(); if (dbauth == null) { @@ -486,23 +474,6 @@ public class EditGeneralConfigAction extends BasicAction { dbchainingmodes.setSystemDefaultMode( ChainingModeType.fromValue(moaconfig.getDefaultchainigmode())); - if (oldconfig != null) { - ChainingModes oldchainigmodes = oldconfig.getChainingModes(); - if (oldchainigmodes != null) { - List oldtrustanchor = oldchainigmodes.getTrustAnchor(); - if (oldtrustanchor != null) { - List trustanchor = new ArrayList(); - for (TrustAnchor oldel : oldtrustanchor) { - TrustAnchor TAel = new TrustAnchor(); - TAel.setX509IssuerName(oldel.getX509IssuerName()); - TAel.setX509SerialNumber(oldel.getX509SerialNumber()); - TAel.setMode(oldel.getMode()); - trustanchor.add(TAel); - } - dbchainingmodes.setTrustAnchor(trustanchor); - } - } - } IdentityLinkSigners idlsigners = dbauth.getIdentityLinkSigners(); if (idlsigners == null) { @@ -525,31 +496,28 @@ public class EditGeneralConfigAction extends BasicAction { forcon.setURL(moaconfig.getSzrgwURL()); } - //TODO: Set STORK Config!!! - if (oldauth != null) { - ForeignIdentities oldforeign = oldauth.getForeignIdentities(); - if (oldforeign != null) { - STORK oldstork = oldforeign.getSTORK(); - if (oldstork == null) - oldstork = new STORK(); + ForeignIdentities foreign = dbauth.getForeignIdentities(); + if (foreign != null) { + STORK stork = foreign.getSTORK(); + if (stork == null) + stork = new STORK(); try { log.error("QAAAA " + storkconfig.getDefaultQaa()); - oldstork.setQualityAuthenticationAssuranceLevel(storkconfig.getDefaultQaa()); + stork.setQualityAuthenticationAssuranceLevel(storkconfig.getDefaultQaa()); if (storkconfig.getAttributes() != null) - oldstork.setAttributes(storkconfig.getAttributes()); + stork.setAttributes(storkconfig.getAttributes()); else - oldstork.setAttributes((List) (new ArrayList())); + stork.setAttributes((List) (new ArrayList())); if (storkconfig.getCpepslist() != null) - oldstork.setCPEPS(storkconfig.getCpepslist()); + stork.setCPEPS(storkconfig.getCpepslist()); else - oldstork.setCPEPS((List) (new ArrayList())); + stork.setCPEPS((List) (new ArrayList())); - dbforeign.setSTORK(oldstork); } catch (Exception e) { e.printStackTrace(); } @@ -561,7 +529,6 @@ public class EditGeneralConfigAction extends BasicAction { log.info("CPEPS LIST is null"); } } - } if (MiscUtil.isNotEmpty(moaconfig.getMandateURL())) { OnlineMandates dbmandate = dbauth.getOnlineMandates(); @@ -604,7 +571,7 @@ public class EditGeneralConfigAction extends BasicAction { } moaauth.setTrustProfileID(moaconfig.getMoaspssAuthTrustProfile()); - moaauth.setVerifyTransformsInfoProfileID(moaconfig.getAuthTransformList()); + moaauth.getVerifyTransformsInfoProfileID().set(0, moaconfig.getAuthTransformList().get(0)); SecurityLayer seclayertrans = dbauth.getSecurityLayer(); if (seclayertrans == null) { @@ -621,19 +588,6 @@ public class EditGeneralConfigAction extends BasicAction { elem.setTransformation(moatrans.get(key)); trans.add(elem); } - } else { - if (oldauth != null) { - SecurityLayer oldsectrans = oldauth.getSecurityLayer(); - if (oldsectrans != null) { - List oldtranslist = oldsectrans.getTransformsInfo(); - for (TransformsInfoType oldel : oldtranslist) { - TransformsInfoType elem = new TransformsInfoType(); - elem.setFilename(oldel.getFilename()); - elem.setTransformation(oldel.getTransformation()); - trans.add(elem); - } - } - } } if (trans.size() > 0) seclayertrans.setTransformsInfo(trans); @@ -660,9 +614,6 @@ public class EditGeneralConfigAction extends BasicAction { ConfigurationDBUtils.save(dbconfig); - if (oldconfig != null) - ConfigurationDBUtils.delete(oldconfig); - } catch (MOADatabaseException e) { log.warn("MOAID Configuration can not be stored in Database", e); return LanguageHelper.getErrorString("error.db.oa.store", request); -- cgit v1.2.3 From 27c5460e2138fbb7de64214a7538b98effb5a7a6 Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Fri, 4 Jul 2014 14:44:26 +0200 Subject: fix: CPEPS list is now edited in place instead of clean and refill --- .../id/configuration/validation/moaconfig/StorkConfigValidator.java | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'id/ConfigWebTool/src/main/java/at/gv/egovernment') 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 index 8bc916e5a..4a5676fd6 100644 --- 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 @@ -28,6 +28,10 @@ public class StorkConfigValidator { if (form.getCpepslist() != null) { for(CPEPS current : form.getCpepslist()) { + // if an existing record got deleted + if(null == current) + continue; + // check country code String check = current.getCountryCode(); if (MiscUtil.isNotEmpty(check)) { -- cgit v1.2.3 From b2c1ca665aaaa3246671ef2ec933e29b8ff87b25 Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Fri, 4 Jul 2014 16:09:36 +0200 Subject: made country code readonly --- .../struts/action/EditGeneralConfigAction.java | 15 ++++++++-- .../validation/moaconfig/StorkConfigValidator.java | 34 ++++++++++++---------- 2 files changed, 31 insertions(+), 18 deletions(-) (limited to 'id/ConfigWebTool/src/main/java/at/gv/egovernment') 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 ec261335d..ef0672e99 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 @@ -512,9 +512,20 @@ public class EditGeneralConfigAction extends BasicAction { else stork.setAttributes((List) (new ArrayList())); - if (storkconfig.getCpepslist() != null) + if (storkconfig.getCpepslist() != null) { + + // make CountryCode "readonly" + for(CPEPS newone : storkconfig.getCpepslist()) { + for(CPEPS current : stork.getCPEPS()) { + if(current.getHjid().equals(newone.getHjid())) { + newone.setCountryCode(current.getCountryCode()); + break; + } + } + } + stork.setCPEPS(storkconfig.getCpepslist()); - + } else stork.setCPEPS((List) (new ArrayList())); 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 index 4a5676fd6..5ec3af519 100644 --- 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 @@ -32,27 +32,29 @@ public class StorkConfigValidator { if(null == current) continue; - // 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)}, request )); - } - if(!check.toLowerCase().matches("^[a-z][a-z]$")) { - log.warn("CPEPS config countrycode does not comply to ISO 3166-2 : " + check); + if(null == current.getHjid()) { + // 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[] {check}, request )); + new Object[] {ValidationHelper.getPotentialCSSCharacter(false)}, request )); + } + 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}, request )); + } + } else { + log.warn("CPEPS config countrycode is empty : " + check); + errors.add(LanguageHelper.getErrorString("validation.stork.cpeps.empty", + new Object[] {check}, request )); } - } else { - log.warn("CPEPS config countrycode is empty : " + check); - errors.add(LanguageHelper.getErrorString("validation.stork.cpeps.empty", - new Object[] {check}, request )); } // check url - check = current.getURL(); + String check = current.getURL(); if (MiscUtil.isNotEmpty(check)) { if (!ValidationHelper.validateURL(check)) { log.info("CPEPS config URL is invalid : " + check); -- cgit v1.2.3 From bab51d46c3d57ac1fe32f184d5fd8acef53ad618 Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Mon, 7 Jul 2014 09:11:42 +0200 Subject: check for peps country code uniqueness --- .../id/configuration/data/GeneralStorkConfig.java | 20 ++++++++++ .../struts/action/EditGeneralConfigAction.java | 13 +------ .../validation/moaconfig/StorkConfigValidator.java | 45 +++++++++++++--------- 3 files changed, 47 insertions(+), 31 deletions(-) (limited to 'id/ConfigWebTool/src/main/java/at/gv/egovernment') diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/GeneralStorkConfig.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/GeneralStorkConfig.java index 9e5ba684c..b1e268fef 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/GeneralStorkConfig.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/GeneralStorkConfig.java @@ -25,12 +25,14 @@ package at.gv.egovernment.moa.id.configuration.data; import java.util.ArrayList; import java.util.List; +import at.gv.egovernment.moa.id.commons.db.ConfigurationDBRead; import at.gv.egovernment.moa.id.commons.db.dao.config.AuthComponentGeneral; import at.gv.egovernment.moa.id.commons.db.dao.config.CPEPS; import at.gv.egovernment.moa.id.commons.db.dao.config.ForeignIdentities; import at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration; import at.gv.egovernment.moa.id.commons.db.dao.config.STORK; import at.gv.egovernment.moa.id.commons.db.dao.config.StorkAttribute; + import org.apache.log4j.Logger; public class GeneralStorkConfig { @@ -88,6 +90,24 @@ public class GeneralStorkConfig { } public List getCpepslist() { + if (null == cpepslist) + return null; + + MOAIDConfiguration dbconfig = ConfigurationDBRead.getMOAIDConfiguration(); + + List cpepss = dbconfig.getAuthComponentGeneral().getForeignIdentities().getSTORK().getCPEPS(); + + // make CountryCode "readonly" + for (CPEPS newone : cpepslist) { + for (CPEPS current : cpepss) { + if (null != newone) + if (current.getHjid().equals(newone.getHjid())) { + newone.setCountryCode(current.getCountryCode()); + break; + } + } + } + return cpepslist; } 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 ef0672e99..0f1673c3a 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 @@ -512,20 +512,9 @@ public class EditGeneralConfigAction extends BasicAction { else stork.setAttributes((List) (new ArrayList())); - if (storkconfig.getCpepslist() != null) { - - // make CountryCode "readonly" - for(CPEPS newone : storkconfig.getCpepslist()) { - for(CPEPS current : stork.getCPEPS()) { - if(current.getHjid().equals(newone.getHjid())) { - newone.setCountryCode(current.getCountryCode()); - break; - } - } - } + if (storkconfig.getCpepslist() != null) stork.setCPEPS(storkconfig.getCpepslist()); - } else stork.setCPEPS((List) (new ArrayList())); 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 index 5ec3af519..f7d61653d 100644 --- 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 @@ -32,29 +32,27 @@ public class StorkConfigValidator { if(null == current) continue; - if(null == current.getHjid()) { - // 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); + // 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)}, request )); + } + 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[] {ValidationHelper.getPotentialCSSCharacter(false)}, request )); - } - 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}, request )); - } - } else { - log.warn("CPEPS config countrycode is empty : " + check); - errors.add(LanguageHelper.getErrorString("validation.stork.cpeps.empty", - new Object[] {check}, request )); + new Object[] {check}, request )); } + } else { + log.warn("CPEPS config countrycode is empty : " + check); + errors.add(LanguageHelper.getErrorString("validation.stork.cpeps.empty", + new Object[] {check}, request )); } - + // check url - String check = current.getURL(); + check = current.getURL(); if (MiscUtil.isNotEmpty(check)) { if (!ValidationHelper.validateURL(check)) { log.info("CPEPS config URL is invalid : " + check); @@ -66,6 +64,15 @@ public class StorkConfigValidator { new Object[] {check}, request )); } } + + // ensure uniqueness of country code + for (CPEPS one : form.getCpepslist()) + for (CPEPS another : form.getCpepslist()) + if (null != one && null != another) + if (!one.equals(another) && one.getCountryCode().equals(another.getCountryCode())) { + errors.add(LanguageHelper.getErrorString("validation.stork.cpeps.duplicate", request)); + break; + } } // check qaa -- cgit v1.2.3