diff options
-rw-r--r-- | eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/RegisterSearchService.java | 60 |
1 files changed, 34 insertions, 26 deletions
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/RegisterSearchService.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/RegisterSearchService.java index fc26b214..cc328b75 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/RegisterSearchService.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/RegisterSearchService.java @@ -13,6 +13,7 @@ import lombok.AllArgsConstructor; import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.ListUtils; import org.jetbrains.annotations.Nullable; import org.springframework.stereotype.Service; @@ -159,27 +160,29 @@ public class RegisterSearchService { * Automatic process to fix the register entries. * Called when the initial eIDAS authn leads to a match in a register. * - * @param specificSearchResult Result of last register search - * @param initialEidasData Received eidas data from initial authn + * @param registerResult Result of last register search + * @param initialEidasData Received eidas data from initial authn * @return */ - public RegisterStatusResults step7aKittProcess(RegisterStatusResults specificSearchResult, + public RegisterStatusResults step7aKittProcess(RegisterStatusResults registerResult, SimpleEidasData initialEidasData) throws WorkflowException { log.trace("Starting step7aKittProcess"); // TODO verify with which data this method gets called - if (specificSearchResult.getResultCount() != 1) { + if (registerResult.getResultCount() != 1) { throw new WorkflowException("step7aKittProcess", "getResultCount() != 1"); } try { - if (specificSearchResult.getResultsZmr().size() == 1) { - final ZmrRegisterResult resultsZmr = zmrClient.update( - specificSearchResult.getOperationStatus().getZmrProcessId(), - specificSearchResult.getResultsZmr().get(0), initialEidasData); - return new RegisterStatusResults(specificSearchResult.getOperationStatus(), - resultsZmr.getPersonResult(), Collections.emptyList()); + if (registerResult.getResultsZmr().size() == 1) { + RegisterResult entryZmr = registerResult.getResultsZmr().get(0); + ZmrRegisterResult updateZmr = zmrClient + .update(registerResult.getOperationStatus().getZmrProcessId(), entryZmr, initialEidasData); + return new RegisterStatusResults(registerResult.getOperationStatus(), + updateZmr.getPersonResult(), Collections.emptyList()); } else { - return new RegisterStatusResults(specificSearchResult.getOperationStatus(), Collections.emptyList(), - Arrays.asList(ernpClient.update(specificSearchResult.getResultsErnp().get(0), initialEidasData))); + RegisterResult entryErnp = registerResult.getResultsErnp().get(0); + RegisterResult updateErnp = ernpClient.update(entryErnp, initialEidasData); + return new RegisterStatusResults(registerResult.getOperationStatus(), Collections.emptyList(), + Collections.singletonList(updateErnp)); } } catch (final EidasSAuthenticationException e) { throw new WorkflowException("kittMatchedIdentitiess", e.getMessage(), @@ -191,30 +194,35 @@ public class RegisterSearchService { * Automatic process to fix the register entries. * Called when the alternative eIDAS authn leads to a match in a register. * - * @param specificSearchResult Result of last register search - * @param initialEidasData Received eidas data from initial authentication - * @param altEidasData Received eidas data from alternative authentication + * @param registerResult Result of last register search + * @param initialEidasData Received eidas data from initial authentication + * @param altEidasData Received eidas data from alternative authentication * @return */ - public RegisterStatusResults step7bKittProcess(RegisterStatusResults specificSearchResult, + public RegisterStatusResults step7bKittProcess(RegisterStatusResults registerResult, SimpleEidasData initialEidasData, SimpleEidasData altEidasData) throws WorkflowException { log.trace("Starting step7bKittProcess"); - // TODO What to do with the initialEidasData? // TODO verify with which data this method gets called - if (specificSearchResult.getResultCount() != 1) { + if (registerResult.getResultCount() != 1) { throw new WorkflowException("step7bKittProcess", "getResultCount() != 1"); } try { - if (specificSearchResult.getResultsZmr().size() == 1) { - final ZmrRegisterResult resultsZmr = zmrClient.update( - specificSearchResult.getOperationStatus().getZmrProcessId(), - specificSearchResult.getResultsZmr().get(0), altEidasData); - return new RegisterStatusResults(specificSearchResult.getOperationStatus(), - resultsZmr.getPersonResult(), Collections.emptyList()); + if (registerResult.getResultsZmr().size() == 1) { + RegisterResult entryZmr = registerResult.getResultsZmr().get(0); + ZmrRegisterResult updateAlt = zmrClient + .update(registerResult.getOperationStatus().getZmrProcessId(), entryZmr, altEidasData); + ZmrRegisterResult updateInitial = zmrClient + .update(registerResult.getOperationStatus().getZmrProcessId(), entryZmr, initialEidasData); + return new RegisterStatusResults(registerResult.getOperationStatus(), + ListUtils.union(updateAlt.getPersonResult(), updateInitial.getPersonResult()), + Collections.emptyList()); } else { - return new RegisterStatusResults(specificSearchResult.getOperationStatus(), Collections.emptyList(), - Arrays.asList(ernpClient.update(specificSearchResult.getResultsErnp().get(0), altEidasData))); + RegisterResult entryErnp = registerResult.getResultsErnp().get(0); + RegisterResult updateAlt = ernpClient.update(entryErnp, altEidasData); + RegisterResult updateInitial = ernpClient.update(entryErnp, initialEidasData); + return new RegisterStatusResults(registerResult.getOperationStatus(), Collections.emptyList(), + Arrays.asList(updateAlt, updateInitial)); } } catch (final EidasSAuthenticationException e) { throw new WorkflowException("kittMatchedIdentitiess", e.getMessage(), |