From 9c9463d593014292a4b19fbad2fca779e56e33cf Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Tue, 7 Jun 2022 13:47:42 +0200 Subject: feat(eidas): update proxy-service attribute registry to request releated attributes --- .../dto/attributes/AttrMappingElement.java | 6 +++++ .../service/ProxyEidasAttributeRegistry.java | 27 +++++++++++++++------- 2 files changed, 25 insertions(+), 8 deletions(-) (limited to 'modules/eidas_proxy-sevice/src/main/java/at/asitplus/eidas/specific') diff --git a/modules/eidas_proxy-sevice/src/main/java/at/asitplus/eidas/specific/modules/msproxyservice/dto/attributes/AttrMappingElement.java b/modules/eidas_proxy-sevice/src/main/java/at/asitplus/eidas/specific/modules/msproxyservice/dto/attributes/AttrMappingElement.java index d6ed1147..cf106bad 100644 --- a/modules/eidas_proxy-sevice/src/main/java/at/asitplus/eidas/specific/modules/msproxyservice/dto/attributes/AttrMappingElement.java +++ b/modules/eidas_proxy-sevice/src/main/java/at/asitplus/eidas/specific/modules/msproxyservice/dto/attributes/AttrMappingElement.java @@ -1,6 +1,8 @@ package at.asitplus.eidas.specific.modules.msproxyservice.dto.attributes; +import java.util.List; + import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -28,6 +30,10 @@ public class AttrMappingElement { @JsonProperty("idaAttribute") private IdaAttribute idaAttribute; + + @JsonProperty("addionalRequiredAttributes") + private List addionalRequiredAttributes; + /** * attribute characteristics. */ diff --git a/modules/eidas_proxy-sevice/src/main/java/at/asitplus/eidas/specific/modules/msproxyservice/service/ProxyEidasAttributeRegistry.java b/modules/eidas_proxy-sevice/src/main/java/at/asitplus/eidas/specific/modules/msproxyservice/service/ProxyEidasAttributeRegistry.java index ea561c1d..b9e0c488 100644 --- a/modules/eidas_proxy-sevice/src/main/java/at/asitplus/eidas/specific/modules/msproxyservice/service/ProxyEidasAttributeRegistry.java +++ b/modules/eidas_proxy-sevice/src/main/java/at/asitplus/eidas/specific/modules/msproxyservice/service/ProxyEidasAttributeRegistry.java @@ -26,7 +26,6 @@ import com.google.common.collect.Sets; import at.asitplus.eidas.specific.modules.core.eidas.service.EidasAttributeRegistry; import at.asitplus.eidas.specific.modules.msproxyservice.MsProxyServiceConstants; import at.asitplus.eidas.specific.modules.msproxyservice.dto.attributes.AttrMappingElement; -import at.asitplus.eidas.specific.modules.msproxyservice.dto.attributes.IdaAttribute; import at.gv.egiz.eaaf.core.api.idp.IConfiguration; import at.gv.egiz.eaaf.core.exceptions.EaafConfigurationException; import at.gv.egiz.eaaf.core.impl.utils.FileUtils; @@ -71,7 +70,7 @@ public class ProxyEidasAttributeRegistry { public Stream getAlwaysRequestedAttributes(boolean withMandates) { return attributeConfiguration.stream() .filter(el -> ATTR_CONFIG_ALL.equals(el.getEidasAttributeName())) - .map(el -> getReleadedIdaAttribute(el.getIdaAttribute(), withMandates)) + .map(el -> getReleadedIdaAttribute(el, withMandates)) .flatMap(Collection::stream) .filter(Objects::nonNull); @@ -89,7 +88,7 @@ public class ProxyEidasAttributeRegistry { return attributeConfiguration.stream() .filter(el -> el.getEidasAttributeName().equals(eidasAttributeName)) .findFirst() - .map(el -> getReleadedIdaAttribute(el.getIdaAttribute(), withMandates)) + .map(el -> getReleadedIdaAttribute(el, withMandates)) .orElse(Collections.emptySet()) .stream() .filter(Objects::nonNull) @@ -136,11 +135,23 @@ public class ProxyEidasAttributeRegistry { } } - private Set getReleadedIdaAttribute(IdaAttribute el, boolean withMandates) { - return withMandates - ? Sets.newHashSet(el.getBasic(), el.getWithMandates()) - : Sets.newHashSet(el.getBasic()); - + private Set getReleadedIdaAttribute(AttrMappingElement el, boolean withMandates) { + if (el.getIdaAttribute() != null) { + Set directMapping = withMandates + ? Sets.newHashSet(el.getIdaAttribute().getBasic(), el.getIdaAttribute().getWithMandates()) + : Sets.newHashSet(el.getIdaAttribute().getBasic()); + + if (el.getAddionalRequiredAttributes() != null) { + el.getAddionalRequiredAttributes().forEach( + attr -> directMapping.add(attr)); + + } + return directMapping; + + } else { + return Collections.emptySet(); + + } } private boolean checkEidasAttributeName(AttrMappingElement el) { -- cgit v1.2.3