aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas <>2022-06-07 13:47:42 +0200
committerThomas <>2022-06-07 13:47:42 +0200
commit9c9463d593014292a4b19fbad2fca779e56e33cf (patch)
tree535f98a42845f2a0f6011c0c224799b47e9051da
parent4c6a80097a041135b96dd1bccac5d3887d63865c (diff)
downloadNational_eIDAS_Gateway-9c9463d593014292a4b19fbad2fca779e56e33cf.tar.gz
National_eIDAS_Gateway-9c9463d593014292a4b19fbad2fca779e56e33cf.tar.bz2
National_eIDAS_Gateway-9c9463d593014292a4b19fbad2fca779e56e33cf.zip
feat(eidas): update proxy-service attribute registry to request releated attributes
-rw-r--r--modules/eidas_proxy-sevice/src/main/java/at/asitplus/eidas/specific/modules/msproxyservice/dto/attributes/AttrMappingElement.java6
-rw-r--r--modules/eidas_proxy-sevice/src/main/java/at/asitplus/eidas/specific/modules/msproxyservice/service/ProxyEidasAttributeRegistry.java27
-rw-r--r--modules/eidas_proxy-sevice/src/test/java/at/asitplus/eidas/specific/modules/msproxyservice/test/services/ProxyEidasAttributeRegistryTest.java13
-rw-r--r--modules/eidas_proxy-sevice/src/test/resources/config/idaAttributeMapping.json6
4 files changed, 42 insertions, 10 deletions
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<String> 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<String> 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<String> getReleadedIdaAttribute(IdaAttribute el, boolean withMandates) {
- return withMandates
- ? Sets.newHashSet(el.getBasic(), el.getWithMandates())
- : Sets.newHashSet(el.getBasic());
-
+ private Set<String> getReleadedIdaAttribute(AttrMappingElement el, boolean withMandates) {
+ if (el.getIdaAttribute() != null) {
+ Set<String> 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) {
diff --git a/modules/eidas_proxy-sevice/src/test/java/at/asitplus/eidas/specific/modules/msproxyservice/test/services/ProxyEidasAttributeRegistryTest.java b/modules/eidas_proxy-sevice/src/test/java/at/asitplus/eidas/specific/modules/msproxyservice/test/services/ProxyEidasAttributeRegistryTest.java
index 6034c92a..d3e787bb 100644
--- a/modules/eidas_proxy-sevice/src/test/java/at/asitplus/eidas/specific/modules/msproxyservice/test/services/ProxyEidasAttributeRegistryTest.java
+++ b/modules/eidas_proxy-sevice/src/test/java/at/asitplus/eidas/specific/modules/msproxyservice/test/services/ProxyEidasAttributeRegistryTest.java
@@ -50,9 +50,18 @@ public class ProxyEidasAttributeRegistryTest {
@Test
public void eidasAttributeMappingMandateOnly() {
checkAttributeMapping("http://eidas.europa.eu/attributes/legalperson/LegalPersonIdentifier", false,
- Collections.emptyList());
+ Arrays.asList(
+ "urn:oid:1.2.40.0.10.2.1.1.149",
+ "urn:oid:2.5.4.42",
+ "urn:oid:1.2.40.0.10.2.1.1.261.20",
+ "urn:oid:1.2.40.0.10.2.1.1.55"));
checkAttributeMapping("http://eidas.europa.eu/attributes/legalperson/LegalPersonIdentifier", true,
- Arrays.asList("urn:oid:1.2.40.0.10.2.1.1.261.100"));
+ Arrays.asList(
+ "urn:oid:1.2.40.0.10.2.1.1.261.100",
+ "urn:oid:1.2.40.0.10.2.1.1.149",
+ "urn:oid:2.5.4.42",
+ "urn:oid:1.2.40.0.10.2.1.1.261.20",
+ "urn:oid:1.2.40.0.10.2.1.1.55"));
}
diff --git a/modules/eidas_proxy-sevice/src/test/resources/config/idaAttributeMapping.json b/modules/eidas_proxy-sevice/src/test/resources/config/idaAttributeMapping.json
index 4f059876..2d375acb 100644
--- a/modules/eidas_proxy-sevice/src/test/resources/config/idaAttributeMapping.json
+++ b/modules/eidas_proxy-sevice/src/test/resources/config/idaAttributeMapping.json
@@ -58,6 +58,12 @@
"idaAttribute": {
"withMandates": "urn:oid:1.2.40.0.10.2.1.1.261.100"
},
+ "addionalRequiredAttributes" : [
+ "urn:oid:1.2.40.0.10.2.1.1.149",
+ "urn:oid:2.5.4.42",
+ "urn:oid:1.2.40.0.10.2.1.1.261.20",
+ "urn:oid:1.2.40.0.10.2.1.1.55"
+ ],
"type": {
"mds": true
}