From 1923066ca9db0eacb8c1776b657705ef9b173448 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Thu, 1 Dec 2022 12:10:45 +0100 Subject: feat(matching): add flag 'allowNewErnpEntryByUser' into intermediate matching-result That flag disable a new ERnP entry by user decision --- .../eidas/v2/service/RegisterSearchService.java | 55 +++++++++++++++++----- 1 file changed, 43 insertions(+), 12 deletions(-) (limited to 'modules/authmodule-eIDAS-v2/src/main') diff --git a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/RegisterSearchService.java b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/RegisterSearchService.java index 096c9d5f..ff702595 100644 --- a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/RegisterSearchService.java +++ b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/RegisterSearchService.java @@ -107,7 +107,7 @@ public class RegisterSearchService { resultsZmr.getPersonResult().size(), resultsErnp.getPersonResult().size(), resultsErnp.getZmrPersonResult().size()); - return RegisterStatusResults.fromZmrAndErnp(resultsZmr, resultsErnp); + return RegisterStatusResults.fromZmrAndErnp(operationStatus, resultsZmr, resultsErnp); } catch (final EidasSAuthenticationException e) { throw new WorkflowException("searchWithPersonalIdentifier", e.getMessage(), @@ -139,7 +139,7 @@ public class RegisterSearchService { resultsZmr.getPersonResult().size(), resultsErnp.getPersonResult().size(), resultsErnp.getZmrPersonResult().size()); - return RegisterStatusResults.fromZmrAndErnp(resultsZmr, resultsErnp); + return RegisterStatusResults.fromZmrAndErnp(operationStatus, resultsZmr, resultsErnp); } catch (final EidasSAuthenticationException e) { throw new WorkflowException("searchWithMDSOnly", e.getMessage(), @@ -179,7 +179,7 @@ public class RegisterSearchService { resultsZmr.getPersonResult().size(), resultErnp.getPersonResult().size(), resultErnp.getZmrPersonResult().size()); - return RegisterStatusResults.fromZmrAndErnp(resultsZmr, resultErnp); + return RegisterStatusResults.fromZmrAndErnp(operationStatus, resultsZmr, resultErnp); } else { return RegisterStatusResults.fromEmpty(operationStatus); @@ -216,7 +216,7 @@ public class RegisterSearchService { log.info(LOG_MSG_RESULTS, "seachByResidence", resultsZmr.getPersonResult().size(), 0, 0); - return RegisterStatusResults.fromZmr(resultsZmr); + return RegisterStatusResults.fromZmr(operationStatus, resultsZmr); } catch (final EidasSAuthenticationException e) { throw new WorkflowException("searchWithResidenceInformation", e.getMessage(), @@ -251,7 +251,7 @@ public class RegisterSearchService { ZmrRegisterResult updateZmr = zmrClient .update(registerResult.getOperationStatus().getZmrProcessId(), entryZmr, initialEidasData); log.info(LOG_MSG_KITT, ZMR); - return RegisterStatusResults.fromZmr(updateZmr); + return RegisterStatusResults.fromZmr(registerResult.operationStatus, updateZmr); } else { RegisterResult entryErnp = registerResult.getResultsErnp().get(0); @@ -327,7 +327,7 @@ public class RegisterSearchService { altSearchResult.getOperationStatus().getZmrProcessId(), entryZmr, altEidasData); log.info(LOG_MSG_KITT, ZMR); - return RegisterStatusResults.fromZmr(updateAlt); + return RegisterStatusResults.fromZmr(altSearchResult.getOperationStatus(), updateAlt); } else { RegisterResult entryErnp = altSearchResult.getResultsErnp().get(0); @@ -376,6 +376,27 @@ public class RegisterSearchService { private BigInteger zmrProcessId; + /** + * Flag that indicates if ERnP entries by user decision is allowed. + */ + private final boolean allowErnpEntryByUser; + + + /** + * Build {@link RegisterOperationStatus} based on an existing status 'before' + * and an 'allowErnpEntry' flag of current process. + * + * @param before Status from process-step before + * @param allowErnpEntry does current result allow new ERnP entry by user + * @return + */ + public static RegisterOperationStatus buildFromExisting(@Nonnull RegisterOperationStatus before, + boolean allowErnpEntry) { + return new RegisterOperationStatus(before.getZmrProcessId(), + before.isAllowErnpEntryByUser() && allowErnpEntry); + + } + } @@ -447,12 +468,13 @@ public class RegisterSearchService { } } - static RegisterStatusResults fromZmr(ZmrRegisterResult result) { - return new RegisterStatusResults(new RegisterOperationStatus(result.getProcessId()), + static RegisterStatusResults fromZmr(RegisterOperationStatus status, ZmrRegisterResult result) { + return new RegisterStatusResults(RegisterOperationStatus.buildFromExisting(status, true), result.getPersonResult(), Collections.emptyList()); } - static RegisterStatusResults fromZmrAndErnp(ZmrRegisterResult result, ErnpRegisterResult resultErnp) { + static RegisterStatusResults fromZmrAndErnp(RegisterOperationStatus status, + ZmrRegisterResult result, ErnpRegisterResult resultErnp) { /* * Post-processing of ERnP entries to remove entities that included twice. * In case of KITT on register side that KITTS an ERnP to ZMR entry, @@ -483,16 +505,25 @@ public class RegisterSearchService { } - return new RegisterStatusResults(new RegisterOperationStatus(result.getProcessId()), + return new RegisterStatusResults( + status != null + ? RegisterOperationStatus.buildFromExisting(status, resultErnp.isAllowErnpEntryByUser()) + : new RegisterOperationStatus(result.getProcessId(), resultErnp.isAllowErnpEntryByUser()), zmrCleared, ernpCleared); + } static RegisterStatusResults fromErnp(RegisterOperationStatus status, ErnpRegisterResult updateErnp) { - return new RegisterStatusResults(status, Collections.emptyList(), updateErnp.getPersonResult()); + return new RegisterStatusResults( + RegisterOperationStatus.buildFromExisting(status, updateErnp.isAllowErnpEntryByUser()), + Collections.emptyList(), updateErnp.getPersonResult()); + } static RegisterStatusResults fromEmpty(RegisterOperationStatus status) { - return new RegisterStatusResults(status, Collections.emptyList(), Collections.emptyList()); + return new RegisterStatusResults( + RegisterOperationStatus.buildFromExisting(status, true), + Collections.emptyList(), Collections.emptyList()); } } -- cgit v1.2.3