From 0ec26c52a362f5558a9cbb07132c32ac94418ec9 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Thu, 1 Dec 2022 08:27:29 +0100 Subject: 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 --- .../auth/eidas/v2/clients/ernp/ErnpRestClient.java | 34 +++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'modules/authmodule-eIDAS-v2/src/main/java') 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 processSearchPersonResponse( @Nonnull List list, @Nonnull String citizenCountryCode) throws EaafAuthenticationException { final List 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 persons, @Nonnull String citizenCountryCode, String processStepFiendlyname) throws EaafAuthenticationException { - if (persons.size() > 1) { + + // process ERnP response and check state of entities + List 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); } } -- cgit v1.2.3