From 99ad40ac333c737165e3d7110642048da27a1c41 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Wed, 3 Oct 2018 12:28:20 +0200 Subject: update eID4U attribute builder in MOA-ID to support complexe attributes --- .../builder/eid4u/HomeInstituteAddressAttrBuilder.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'id/server/modules/moa-id-module-eIDAS/src/main/java/at/gv/egovernment/moa/id/protocols/eidas/attributes/builder/eid4u/HomeInstituteAddressAttrBuilder.java') diff --git a/id/server/modules/moa-id-module-eIDAS/src/main/java/at/gv/egovernment/moa/id/protocols/eidas/attributes/builder/eid4u/HomeInstituteAddressAttrBuilder.java b/id/server/modules/moa-id-module-eIDAS/src/main/java/at/gv/egovernment/moa/id/protocols/eidas/attributes/builder/eid4u/HomeInstituteAddressAttrBuilder.java index f6fe1d668..b5e240759 100644 --- a/id/server/modules/moa-id-module-eIDAS/src/main/java/at/gv/egovernment/moa/id/protocols/eidas/attributes/builder/eid4u/HomeInstituteAddressAttrBuilder.java +++ b/id/server/modules/moa-id-module-eIDAS/src/main/java/at/gv/egovernment/moa/id/protocols/eidas/attributes/builder/eid4u/HomeInstituteAddressAttrBuilder.java @@ -9,6 +9,7 @@ import at.gv.egiz.eaaf.core.exceptions.AttributeBuilderException; import at.gv.egiz.eid4u.api.attributes.Definitions; import at.gv.egovernment.moa.id.protocols.eidas.attributes.builder.IeIDASAttribute; import at.gv.egovernment.moa.id.protocols.eidas.attributes.builder.eIDASMetadata; +import eu.eidas.auth.commons.protocol.eidas.impl.PostalAddress; @eIDASMetadata public class HomeInstituteAddressAttrBuilder implements IeIDASAttribute { @@ -17,14 +18,19 @@ public class HomeInstituteAddressAttrBuilder implements IeIDASAttribute { public ATT build(ISPConfiguration oaParam, IAuthData authData, IAttributeGenerator g) throws AttributeBuilderException { - //TODO: need update for complex attributes + Object obj= authData.getGenericData(getName(), Object.class); - String idType= authData.getGenericData(getName(), String.class); - if (StringUtils.isNotEmpty(idType)) - return g.buildStringAttribute(Definitions.HOMEINSTITUTIONADDRESS_FRIENDLYNAME, getName(), idType); + if (obj instanceof PostalAddress) { + return g.buildStringAttribute(Definitions.HOMEINSTITUTIONADDRESS_FRIENDLYNAME, getName(), ((PostalAddress)obj).toString()); + + + } else if (obj instanceof String) { + if (StringUtils.isNotEmpty((String)obj)) + return g.buildStringAttribute(Definitions.HOMEINSTITUTIONADDRESS_FRIENDLYNAME, getName(), (String) obj); - else - throw new AttributeBuilderException("Attribute '" + getName() + "' is not available"); + } + + throw new AttributeBuilderException("Attribute '" + getName() + "' is not available"); } -- cgit v1.2.3