aboutsummaryrefslogtreecommitdiff
path: root/modules/authmodule-eIDAS-v2/src/main/java
diff options
context:
space:
mode:
authorThomas <>2022-12-01 08:27:29 +0100
committerThomas <>2022-12-01 08:27:29 +0100
commit0ec26c52a362f5558a9cbb07132c32ac94418ec9 (patch)
tree8f23ca807ee2b7e7c99ca018fe9e4fd1067b5a75 /modules/authmodule-eIDAS-v2/src/main/java
parent709244c42e6dfe339805a1476a70a5690b1ee4dc (diff)
downloadNational_eIDAS_Gateway-0ec26c52a362f5558a9cbb07132c32ac94418ec9.tar.gz
National_eIDAS_Gateway-0ec26c52a362f5558a9cbb07132c32ac94418ec9.tar.bz2
National_eIDAS_Gateway-0ec26c52a362f5558a9cbb07132c32ac94418ec9.zip
fix(matching): change processing order in case of single entity selection and more than one ERnP results
ERnP responses can include more than one results that are a mix of active and in-active persons. Therefore, we have to clear fist and check uniqueness afterwards
Diffstat (limited to 'modules/authmodule-eIDAS-v2/src/main/java')
-rw-r--r--modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/ErnpRestClient.java34
1 files changed, 17 insertions, 17 deletions
diff --git a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/ErnpRestClient.java b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/ErnpRestClient.java
index ce474793..8b34bbef 100644
--- a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/ErnpRestClient.java
+++ b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/ErnpRestClient.java
@@ -398,15 +398,14 @@ public class ErnpRestClient implements IErnpClient {
resp.getPerson(), citizenCountryCode, processStepFiendlyname);
} else {
- return processSearchPersonResponse(
- resp.getPerson(), citizenCountryCode);
+ return new ErnpRegisterResult(processSearchPersonResponse(resp.getPerson(), citizenCountryCode));
}
}
}
@Nonnull
- private ErnpRegisterResult processSearchPersonResponse(
+ private List<ErnpPersonRegisterResult> processSearchPersonResponse(
@Nonnull List<Person> list,
@Nonnull String citizenCountryCode) throws EaafAuthenticationException {
final List<ErnpPersonRegisterResult> ernpResult = list.stream()
@@ -414,31 +413,32 @@ public class ErnpRestClient implements IErnpClient {
.filter(Objects::nonNull)
.collect(Collectors.toList());
log.info("Get #{} ERnP results after post-processing", ernpResult.size());
- return new ErnpRegisterResult(ernpResult);
-
+ return ernpResult;
+
}
@NonNull
private ErnpRegisterResult processSearchPersonResponseSingleResult(
@Nonnull List<Person> persons,
@Nonnull String citizenCountryCode, String processStepFiendlyname) throws EaafAuthenticationException {
- if (persons.size() > 1) {
+
+ // process ERnP response and check state of entities
+ List<ErnpPersonRegisterResult> activePersons = processSearchPersonResponse(persons, citizenCountryCode);
+
+ // check final result
+ if (activePersons.isEmpty()) {
+ log.error("ERnP entry, which was selected by matching, looks already closed. "
+ + "Automated operations on closed entries not supported my matching");
+ throw new WorkflowException(processStepFiendlyname,
+ "ERnP entry, which was selected by matching, is not active any more.", true);
+
+ } else if (activePersons.size() > 1) {
log.error("Find more-than-one ERnP entry with search criteria that has to be unique");
throw new WorkflowException(processStepFiendlyname,
"Find more-than-one ERnP entry with search criteria that has to be unique", true);
} else {
- final ErnpPersonRegisterResult activeResult =
- mapErnpResponseToRegisterResult(persons.get(0), citizenCountryCode);
- if (activeResult == null) {
- log.error("ERnP entry, which was selected by matching, looks already closed. "
- + "Automated operations on closed entries not supported my matching");
- throw new WorkflowException(processStepFiendlyname,
- "ERnP entry, which was selected by matching, is not active any more.", true);
-
- }
-
- return new ErnpRegisterResult(Arrays.asList(activeResult));
+ return new ErnpRegisterResult(activePersons);
}
}