From fb6e40832df5182ae1ebd7555583caed174e8776 Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Tue, 7 Jan 2014 17:25:38 +0100 Subject: oa attr configuration revisited --- .../id/configuration/data/oa/AttributeHelper.java | 61 ++++++++++++++++++++++ .../id/configuration/data/oa/OASTORKConfig.java | 56 +++++++++++++------- .../configuration/struts/action/EditOAAction.java | 2 +- .../validation/oa/OASTORKConfigValidation.java | 17 ------ 4 files changed, 98 insertions(+), 38 deletions(-) create mode 100644 id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/AttributeHelper.java (limited to 'id/ConfigWebTool/src/main/java/at/gv') diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/AttributeHelper.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/AttributeHelper.java new file mode 100644 index 000000000..1590918c6 --- /dev/null +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/AttributeHelper.java @@ -0,0 +1,61 @@ +package at.gv.egovernment.moa.id.configuration.data.oa; + +import at.gv.egovernment.moa.id.commons.db.dao.config.OAStorkAttribute; +import at.gv.egovernment.moa.id.commons.db.dao.config.StorkAttribute; + +public class AttributeHelper { + private boolean isUsed = false; + private String name; + private boolean mandatory; + private boolean readonly; + + public AttributeHelper() { + // TODO Auto-generated constructor stub + } + + public AttributeHelper(OAStorkAttribute attribute) { + isUsed = true; + name = attribute.getAttribute().getName(); + mandatory = attribute.isMandatory(); + readonly = attribute.getAttribute().isMandatory(); + } + + public AttributeHelper(StorkAttribute attribute) { + name = attribute.getName(); + mandatory = false; + readonly = attribute.isMandatory(); + isUsed = readonly; + } + + public boolean isUsed() { + return isUsed; + } + + public void setUsed(boolean used) { + isUsed = used; + } + + public String getName() { + return name; + } + + public void setName(String newname) { + name = newname; + } + + public boolean isMandatory() { + return mandatory; + } + + public void setMandatory(boolean value) { + mandatory = value; + } + + public boolean isReadOnly() { + return readonly; + } + + public void setReadOnly(boolean value) { + // we do not allow setting the readonly field + } +} \ No newline at end of file diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASTORKConfig.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASTORKConfig.java index f6fc4416f..42501b4d1 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASTORKConfig.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASTORKConfig.java @@ -1,20 +1,21 @@ package at.gv.egovernment.moa.id.configuration.data.oa; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import at.gv.egovernment.moa.id.commons.db.ConfigurationDBRead; import at.gv.egovernment.moa.id.commons.db.dao.config.AuthComponentOA; import at.gv.egovernment.moa.id.commons.db.dao.config.OASTORK; +import at.gv.egovernment.moa.id.commons.db.dao.config.OAStorkAttribute; import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; -import at.gv.egovernment.moa.id.commons.db.dao.config.RequestedAttributesType; +import at.gv.egovernment.moa.id.commons.db.dao.config.StorkAttribute; public class OASTORKConfig { private boolean isStorkLogonEnabled = false; private int qaa; - private List attributes; + + private List attributes; public OASTORKConfig() { @@ -40,13 +41,20 @@ public class OASTORKConfig { setQaa(ConfigurationDBRead.getMOAIDConfiguration().getAuthComponentGeneral().getForeignIdentities().getSTORK().getQualityAuthenticationAssuranceLevel()); } - RequestedAttributesType tmp = config.getAttributes(); - if(null == tmp) - // if there is no configuration available for the OA, get the default attributes - tmp = ConfigurationDBRead.getMOAIDConfiguration().getAuthComponentGeneral().getForeignIdentities().getSTORK().getRequestedAttributes(); - attributes = new ArrayList(); - for(String current : tmp.getAttributeValue()) - attributes.add(current); + // prepare attribute helper list + attributes = new ArrayList(); + for(StorkAttribute current : ConfigurationDBRead.getMOAIDConfiguration().getAuthComponentGeneral().getForeignIdentities().getSTORK().getRequestedAttributes()) { + AttributeHelper tmp = null; + + for(OAStorkAttribute sepp : config.getAttributes()) + if(sepp.getAttribute().equals(current)) + tmp = new AttributeHelper(sepp); + + if(null == tmp) + tmp = new AttributeHelper(current); + + attributes.add(tmp); + } } } } @@ -67,19 +75,27 @@ public class OASTORKConfig { this.qaa = qaa; } - public RequestedAttributesType getRequestedAttributesType() { - RequestedAttributesType tmp = new RequestedAttributesType(); - tmp.setAttributeValue(attributes); - return tmp; + public List getAttributes() { + List result = new ArrayList(); + for(AttributeHelper current : getHelperAttributes()) { + if(current.isUsed()) { + OAStorkAttribute tmp = new OAStorkAttribute(); + for(StorkAttribute currentAttribute : ConfigurationDBRead.getMOAIDConfiguration().getAuthComponentGeneral().getForeignIdentities().getSTORK().getRequestedAttributes()) + if(currentAttribute.getName().equals(current.getName())) + tmp.setAttribute(currentAttribute); + tmp.setMandatory(current.isMandatory()); + result.add(tmp); + } + } + + return result; } - public String getAttributes() { - return Arrays.toString(attributes.toArray()).replace("[", "").replace("]", ""); + public List getHelperAttributes() { + return attributes; } - public void setAttributes(String attributes) { - this.attributes = new ArrayList(); - for(String current : attributes.split(",")) - this.attributes.add(current.trim()); + public void setHelperAttributes(List attributes) { + this.attributes = attributes; } } diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditOAAction.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditOAAction.java index 466feba23..59d5f7302 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditOAAction.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditOAAction.java @@ -968,7 +968,7 @@ public class EditOAAction extends ActionSupport implements ServletRequestAware, // transfer the incoming data to the database model stork.setStorkLogonEnabled(storkOA.isStorkLogonEnabled()); stork.setQaa(storkOA.getQaa()); - stork.setAttributes(storkOA.getRequestedAttributesType()); + stork.setAttributes(storkOA.getAttributes()); try { if (newentry) { diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/oa/OASTORKConfigValidation.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/oa/OASTORKConfigValidation.java index 31cf7bcee..71b3857c3 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/oa/OASTORKConfigValidation.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/oa/OASTORKConfigValidation.java @@ -7,8 +7,6 @@ import org.apache.log4j.Logger; import at.gv.egovernment.moa.id.configuration.data.oa.OASTORKConfig; 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 OASTORKConfigValidation { @@ -26,21 +24,6 @@ public class OASTORKConfigValidation { new Object[] {qaa} )); } - // check attributes - String check = oageneral.getAttributes(); - if (MiscUtil.isNotEmpty(check)) { - if (ValidationHelper.containsPotentialCSSCharacter(check, true)) { - log.warn("attributes contains potentail XSS characters: " + check); - errors.add(LanguageHelper.getErrorString("validation.stork.requestedattributes", - new Object[] {ValidationHelper.getPotentialCSSCharacter(true)} )); - } - if(!check.toLowerCase().matches("^[a-z0-9, ]*$")) { - log.warn("attributes do not match the requested format : " + check); - errors.add(LanguageHelper.getErrorString("validation.stork.requestedattributes", - new Object[] {check} )); - } - } - return errors; } } -- cgit v1.2.3