diff options
author | Thomas Lenz <tlenz@iaik.tugraz.at> | 2018-12-14 13:18:23 +0100 |
---|---|---|
committer | Thomas Lenz <tlenz@iaik.tugraz.at> | 2018-12-14 13:18:23 +0100 |
commit | f27dd94733a9c2cf3a6e4f5611fbeff9de199720 (patch) | |
tree | b47c8d4e9067dc1a50438c2d3151497467e1fcf9 /id/server/modules/moa-id-module-eIDAS/src/main/java/at/gv/egovernment/moa/id/protocols/eidas/attributes/builder/eid4u/HomeInstituteAddressAttrBuilder.java | |
parent | da0174d3b037468d243fad688ca1fd91c2049d24 (diff) | |
download | moa-id-spss-f27dd94733a9c2cf3a6e4f5611fbeff9de199720.tar.gz moa-id-spss-f27dd94733a9c2cf3a6e4f5611fbeff9de199720.tar.bz2 moa-id-spss-f27dd94733a9c2cf3a6e4f5611fbeff9de199720.zip |
some more updates and first code for TUG interaction
Diffstat (limited to 'id/server/modules/moa-id-module-eIDAS/src/main/java/at/gv/egovernment/moa/id/protocols/eidas/attributes/builder/eid4u/HomeInstituteAddressAttrBuilder.java')
-rw-r--r-- | id/server/modules/moa-id-module-eIDAS/src/main/java/at/gv/egovernment/moa/id/protocols/eidas/attributes/builder/eid4u/HomeInstituteAddressAttrBuilder.java | 33 |
1 files changed, 28 insertions, 5 deletions
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 b5e240759..73ab6fdda 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 @@ -1,5 +1,7 @@ package at.gv.egovernment.moa.id.protocols.eidas.attributes.builder.eid4u; +import java.io.IOException; + import org.apache.commons.lang3.StringUtils; import at.gv.egiz.eaaf.core.api.idp.IAttributeGenerator; @@ -9,7 +11,12 @@ 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 at.gv.egovernment.moa.logging.Logger; +import at.gv.egovernment.moa.util.Base64Utils; +import eu.eidas.auth.commons.attribute.AttributeValueMarshallingException; +import eu.eidas.auth.commons.protocol.eidas.impl.CurrentAddressAttributeValueMarshaller; import eu.eidas.auth.commons.protocol.eidas.impl.PostalAddress; +import eu.eidas.auth.commons.protocol.eidas.impl.PostalAddressAttributeValue; @eIDASMetadata public class HomeInstituteAddressAttrBuilder implements IeIDASAttribute { @@ -21,12 +28,28 @@ public class HomeInstituteAddressAttrBuilder implements IeIDASAttribute { Object obj= authData.getGenericData(getName(), Object.class); if (obj instanceof PostalAddress) { - return g.buildStringAttribute(Definitions.HOMEINSTITUTIONADDRESS_FRIENDLYNAME, getName(), ((PostalAddress)obj).toString()); - - + try { + return g.buildStringAttribute(Definitions.HOMEINSTITUTIONADDRESS_FRIENDLYNAME, getName(), + new CurrentAddressAttributeValueMarshaller().marshal( + new PostalAddressAttributeValue((PostalAddress) obj))); + + } catch (AttributeValueMarshallingException e) { + Logger.warn("Can NOT build attribute: " + getName(), e); + + } + } else if (obj instanceof String) { - if (StringUtils.isNotEmpty((String)obj)) - return g.buildStringAttribute(Definitions.HOMEINSTITUTIONADDRESS_FRIENDLYNAME, getName(), (String) obj); + if (StringUtils.isNotEmpty((String)obj)) { + try { + return g.buildStringAttribute(Definitions.HOMEINSTITUTIONADDRESS_FRIENDLYNAME, getName(), + Base64Utils.encode(((String) obj).getBytes())); + + } catch (IOException e) { + Logger.warn("Can NOT build attribute: " + getName(), e); + + } + + } } |