diff options
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/AlternativeSearchTask.java')
-rw-r--r-- | eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/AlternativeSearchTask.java | 79 |
1 files changed, 39 insertions, 40 deletions
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/AlternativeSearchTask.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/AlternativeSearchTask.java index e0273d10..f021fae9 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/AlternativeSearchTask.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/AlternativeSearchTask.java @@ -62,7 +62,6 @@ import lombok.extern.slf4j.Slf4j; * Output: * <ul> * <li>{@link Constants#DATA_PERSON_MATCH_RESULT} results after second search in registers with MDS</li> - * <li>{@link Constants#DATA_RESULT_MATCHING_BPK} if one register result found</li> * </ul> * Transitions: * <ul> @@ -98,123 +97,123 @@ public class AlternativeSearchTask extends AbstractAuthServletTask { public void execute(ExecutionContext executionContext, HttpServletRequest request, HttpServletResponse response) throws TaskExecutionException { try { - final SimpleEidasData altEidasData = convertEidasAttrToSimpleData(); + final SimpleEidasData altEidasData = convertEidasAttrToSimpleData(); final SimpleEidasData initialEidasData = MatchingTaskUtils.getInitialEidasData(pendingReq); - final RegisterStatusResults intermediateMatchingState = + final RegisterStatusResults intermediateMatchingState = MatchingTaskUtils.getIntermediateMatchingResult(pendingReq); - + //pre-validation of eIDAS data preVerifyAlternativeEidasData(altEidasData, initialEidasData, intermediateMatchingState); - + //perform register search operation based on alterantive eIDAS data - step11RegisterSearchWithPersonIdentifier(executionContext, altEidasData, + step11RegisterSearchWithPersonIdentifier(executionContext, altEidasData, intermediateMatchingState, initialEidasData); - + } catch (WorkflowException e) { throw new TaskExecutionException(pendingReq, "Initial search failed", e); - + } catch (final Exception e) { log.error("Initial search failed", e); throw new TaskExecutionException(pendingReq, "Initial search failed with a generic error", e); - + } } /** * Pre-validation of eIDAS information. - * + * * <p>Check if country-code and MDS (givenName, familyName, dateOfBirth) matches.</p> - * + * * @param altEidasData eIDAS data from alternative authentication * @param initialEidasData eIDAS data from initial authentication * @param intermediateMatchingState Intermediate matching result * @throws WorkflowException In case of a validation error */ - private void preVerifyAlternativeEidasData(SimpleEidasData altEidasData, SimpleEidasData initialEidasData, + private void preVerifyAlternativeEidasData(SimpleEidasData altEidasData, SimpleEidasData initialEidasData, RegisterStatusResults intermediateMatchingState) throws WorkflowException { if (initialEidasData == null) { throw new WorkflowException("step11", "No initial eIDAS authn data", true); - + } - + if (intermediateMatchingState == null) { throw new WorkflowException("step11", "No intermediate matching-state", true); - + } - + if (!Objects.equals(altEidasData.getCitizenCountryCode(), initialEidasData.getCitizenCountryCode())) { throw new WorkflowException("step11", "Country Code of alternative eIDAS authn not matching", true); - + } - + if (!altEidasData.equalsMds(initialEidasData)) { throw new WorkflowException("step11", "MDS of alternative eIDAS authn does not match initial authn", true); - + } } private void step11RegisterSearchWithPersonIdentifier( - ExecutionContext executionContext, SimpleEidasData altEidasData, + ExecutionContext executionContext, SimpleEidasData altEidasData, RegisterStatusResults intermediateMatchingState, SimpleEidasData initialEidasData) throws WorkflowException, EaafStorageException { try { log.trace("Starting step11RegisterSearchWithPersonIdentifier"); RegisterStatusResults altSearchResult = registerSearchService.searchWithPersonIdentifier( intermediateMatchingState.getOperationStatus(), altEidasData); - + int resultCount = altSearchResult.getResultCount(); if (resultCount == 0) { - step12CountrySpecificSearch(executionContext, intermediateMatchingState, initialEidasData, + step12CountrySpecificSearch(executionContext, intermediateMatchingState, initialEidasData, altSearchResult.getOperationStatus(), altEidasData); - + } else if (resultCount == 1) { log.debug("step11RegisterSearchWithPersonIdentifier find single result. Starting KITT operation ... "); RegisterStatusResults matchtedResult = registerSearchService.step7bKittProcess( intermediateMatchingState, initialEidasData, altSearchResult, altEidasData); - + log.debug("KITT operation finished. Finalize matching process ... "); foundMatchFinalizeTask(matchtedResult, altEidasData); - + } else { throw new WorkflowException("step11RegisterSearchWithPersonIdentifier", "More than one entry with unique personal-identifier", true); - + } } catch (WorkflowException e) { log.warn("Workflow error during matching step: {}. Reason: {}", e.getProcessStepName(), e.getErrorReason()); throw e; - + } } private void step12CountrySpecificSearch(ExecutionContext executionContext, - RegisterStatusResults intermediateMatchingState, + RegisterStatusResults intermediateMatchingState, SimpleEidasData initialEidasData, RegisterOperationStatus registerOperationStatus, SimpleEidasData altEidasData) throws EaafStorageException, WorkflowException { - log.trace("Starting 'step12CountrySpecificSearch' ... "); + log.trace("Starting 'step12CountrySpecificSearch' ... "); RegisterStatusResults ccAltSearchResult = registerSearchService.searchWithCountrySpecifics( registerOperationStatus, altEidasData); - + if (ccAltSearchResult.getResultCount() == 0) { log.trace("'step12CountrySpecificSearch' ends with no result. Forward to GUI based matching step ... "); log.debug("Forward to GUI based matching steps ... "); executionContext.put(TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK, true); - - } else if (ccAltSearchResult.getResultCount() == 1) { - log.debug("'step12CountrySpecificSearch' find single result. Starting KITT operation ... "); + + } else if (ccAltSearchResult.getResultCount() == 1) { + log.debug("'step12CountrySpecificSearch' find single result. Starting KITT operation ... "); RegisterStatusResults matchtedResult = registerSearchService.step7bKittProcess( intermediateMatchingState, initialEidasData, ccAltSearchResult, altEidasData); - - log.debug("KITT operation finished. Finalize matching process ... "); + + log.debug("KITT operation finished. Finalize matching process ... "); foundMatchFinalizeTask(matchtedResult, altEidasData); - + } else { throw new WorkflowException("step12CountrySpecificSearch", "More than one entry with unique country-specific information", true); - - } + + } } private void foundMatchFinalizeTask(RegisterStatusResults searchResult, SimpleEidasData eidasData) @@ -222,10 +221,10 @@ public class AlternativeSearchTask extends AbstractAuthServletTask { MatchedPersonResult result = MatchedPersonResult.generateFormMatchingResult( searchResult.getResult(), eidasData.getCitizenCountryCode()); MatchingTaskUtils.storeFinalMatchingResult(pendingReq, result); - + //remove intermediate matching-state MatchingTaskUtils.storeIntermediateMatchingResult(pendingReq, null); - + } @NotNull |