aboutsummaryrefslogtreecommitdiff
path: root/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveAustrianResidenceGuiResponseTask.java
diff options
context:
space:
mode:
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveAustrianResidenceGuiResponseTask.java')
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveAustrianResidenceGuiResponseTask.java80
1 files changed, 37 insertions, 43 deletions
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveAustrianResidenceGuiResponseTask.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveAustrianResidenceGuiResponseTask.java
index 83fdf771..acf469d3 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveAustrianResidenceGuiResponseTask.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveAustrianResidenceGuiResponseTask.java
@@ -35,7 +35,6 @@ import org.springframework.stereotype.Component;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.MatchedPersonResult;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.InvalidUserInputException;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.ManualFixNecessaryException;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.WorkflowException;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService;
@@ -50,6 +49,9 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED;
+import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK;
+
/**
* Task receives the response of {@link GenerateAustrianResidenceGuiTask} and handles it.
@@ -61,13 +63,14 @@ import lombok.extern.slf4j.Slf4j;
* </ul>
* Output:
* <ul>
- * <li>{@link Constants#DATA_RESULT_MATCHING_BPK} if one register result found</li>
+ * <li>{@link Constants#DATA_PERSON_MATCH_RESULT} if one register result found</li>
* </ul>
* Transitions:
* <ul>
* <li>{@link CreateNewErnpEntryTask} if no results from search with residency data in registers</li>
* <li>{@link CreateIdentityLinkTask} if one exact match between initial register search (with MDS) and results
* from search with residency data in registers exists</li>
+ * <li>{@link GenerateOtherLoginMethodGuiTask} if a user input error has happened</li>
* </ul>
*
* @author amarsalek
@@ -102,89 +105,80 @@ public class ReceiveAustrianResidenceGuiResponseTask extends AbstractAuthServlet
public void execute(ExecutionContext executionContext, HttpServletRequest request, HttpServletResponse response)
throws TaskExecutionException {
log.trace("Starting ReceiveAustrianResidenceGuiResponseTask");
-
- UserInput input = parseHtmlInput(request);
+
+ UserInput input = parseHtmlInput(request);
if (!input.isFormerResidenceAvailable()) {
moveToNextTask(executionContext);
return;
-
+
}
-
- //TODO: Here, we need an error handling an can not stop full process if form input was invalid
- //TODO: check minimum form elements
- /*TODO: maybe we can switch to custom controller and use WebMVC form-binding feature.
- * Binding element can be add as attribute to this request
- */
+
if (input.getStreet().isEmpty() || input.getCity().isEmpty() || input.getZipcode().isEmpty()) {
// HTML form should ensure that mandatory fields are set => this should never happen
- throw new TaskExecutionException(pendingReq, "Invalid user input",
- new InvalidUserInputException("module.eidasauth.matching.06"));
-
+ executionContext.put(CONTEXT_FLAG_ADVANCED_MATCHING_FAILED, true);
+ executionContext.put(TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK, true);
+ return;
+
}
-
-
-
+
try {
SimpleEidasData eidasData = MatchingTaskUtils.getInitialEidasData(pendingReq);
RegisterStatusResults initialSearchResult = MatchingTaskUtils.getIntermediateMatchingResult(pendingReq);
-
- RegisterStatusResults residencyResult =
- registerSearchService.searchWithResidence(initialSearchResult.getOperationStatus(),
+
+ RegisterStatusResults residencyResult =
+ registerSearchService.searchWithResidence(initialSearchResult.getOperationStatus(),
eidasData, input.zipcode, input.city, input.street);
if (residencyResult.getResultCount() == 0) {
//TODO: her we should add a GUI step of result is zero to inform user an forward process by click
moveToNextTask(executionContext);
-
+
} else if (residencyResult.getResultCount() == 1) {
compareSearchResultWithInitialData(executionContext, residencyResult, eidasData);
-
+
} else {
- /*TODO: align with form generation task and to better error handling in case of more-than-one result.
+ /*TODO: align with form generation task and to better error handling in case of more-than-one result.
* Maybe the user has to provide more information.
*/
throw new TaskExecutionException(pendingReq,
"Manual Fix necessary", new ManualFixNecessaryException(eidasData));
-
+
}
-
+
} catch (EaafStorageException e) {
log.error("Search with residency data failed", e);
throw new TaskExecutionException(pendingReq, "Search with residency data failed", e);
-
+
}
}
- private void compareSearchResultWithInitialData(ExecutionContext executionContext,
+ private void compareSearchResultWithInitialData(ExecutionContext executionContext,
RegisterStatusResults residencyResult, SimpleEidasData eidasData)
throws TaskExecutionException, EaafStorageException {
- try {
- /*TODO: check 'equalsRegisterData' because this method maybe this method evaluate to an invalid result.
- * See TODO in methods body
- */
+ try {
if (eidasData.equalsRegisterData(residencyResult.getResult())) {
// update register information
registerSearchService.step7aKittProcess(residencyResult, eidasData);
-
+
// store search result to re-used in CreateIdentityLink step, because there we need bPK and MDS
- MatchingTaskUtils.storeFinalMatchingResult(pendingReq,
+ MatchingTaskUtils.storeFinalMatchingResult(pendingReq,
MatchedPersonResult.generateFormMatchingResult(
residencyResult.getResult(), eidasData.getCitizenCountryCode()));
-
+
} else {
moveToNextTask(executionContext);
-
+
}
-
+
} catch (WorkflowException e) {
throw new TaskExecutionException(pendingReq, "Search failed", new ManualFixNecessaryException(eidasData));
-
+
}
}
private void moveToNextTask(ExecutionContext executionContext) {
// Later on, this should transition to Step 20
executionContext.put(Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_TASK, true);
-
+
}
private @NotNull UserInput parseHtmlInput(HttpServletRequest request) {
@@ -195,20 +189,20 @@ public class ReceiveAustrianResidenceGuiResponseTask extends AbstractAuthServlet
String escaped = StringEscapeUtils.escapeHtml(request.getParameter(paramName));
if (PARAM_FORMER_RESIDENCE_AVAILABLE.equalsIgnoreCase(paramName)) {
result.setFormerResidenceAvailable(Boolean.parseBoolean(escaped));
-
+
} else if (PARAM_STREET.equalsIgnoreCase(paramName)) {
result.setStreet(escaped);
-
+
} else if (PARAM_CITY.equalsIgnoreCase(paramName)) {
result.setCity(escaped);
-
+
} else if (PARAM_ZIPCODE.equalsIgnoreCase(paramName)) {
result.setZipcode(escaped);
-
+
}
}
return result;
-
+
}
}