From 69aa81016fe20e901a3be02bb6772c9185c0b9ef Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Mon, 2 May 2022 17:16:15 +0200 Subject: chore(matching): re-oreder process steps in GUI releated matching --- .../specific/modules/auth/eidas/v2/Constants.java | 7 +++++ .../v2/tasks/GenerateAustrianResidenceGuiTask.java | 26 +++++++++++++++-- .../v2/tasks/GenerateOtherLoginMethodGuiTask.java | 24 ++++++++-------- .../ReceiveAustrianResidenceGuiResponseTask.java | 33 ++++++++++++++-------- .../auth/eidas/v2/utils/MatchingTaskUtils.java | 19 ++++++++++++- .../resources/eIDAS.Authentication.process.xml | 6 ++-- .../messages/eidas_connector_message.properties | 3 +- 7 files changed, 87 insertions(+), 31 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/Constants.java b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/Constants.java index fbc211f5..0b5d086d 100644 --- a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/Constants.java +++ b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/Constants.java @@ -320,6 +320,7 @@ public class Constants { // UI options + public static final String HTML_FORM_CREATE_NEW_ERNP_ENTRY = "createNewErnpEntry"; public static final String HTML_FORM_ADVANCED_MATCHING_FAILED = "advancedMatchingFailed"; public static final String HTML_FORM_ADVANCED_MATCHING_FAILED_REASON = HTML_FORM_ADVANCED_MATCHING_FAILED + "Reason"; @@ -347,6 +348,12 @@ public class Constants { public static final String TRANSITION_TO_GENERATE_GUI_QUERY_AUSTRIAN_RESIDENCE_TASK = "TASK_GenerateAustrianResidenceGuiTask"; + /** + * {@link at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.CreateNewErnpEntryTask}. + */ + public static final String TRANSITION_TO_REQUESTING_NEW_ERNP_ENTRY_TASK = "TASK_RequestingNewErnpEntryTask"; + + /** * {@link at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.GenerateMobilePhoneSignatureRequestTask}. */ diff --git a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/GenerateAustrianResidenceGuiTask.java b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/GenerateAustrianResidenceGuiTask.java index 190e28eb..dc57dd78 100644 --- a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/GenerateAustrianResidenceGuiTask.java +++ b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/GenerateAustrianResidenceGuiTask.java @@ -31,10 +31,13 @@ import org.springframework.stereotype.Component; import at.asitplus.eidas.specific.core.MsEidasNodeConstants; import at.asitplus.eidas.specific.core.gui.StaticGuiBuilderConfiguration; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.MatchingTaskUtils; import at.gv.egiz.eaaf.core.api.gui.ISpringMvcGuiFormBuilder; import at.gv.egiz.eaaf.core.api.idp.IConfiguration; import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; +import at.gv.egiz.eaaf.core.impl.gui.AbstractGuiFormBuilderConfiguration; import at.gv.egiz.eaaf.core.impl.idp.controller.tasks.AbstractLocaleAuthServletTask; import lombok.extern.slf4j.Slf4j; @@ -55,8 +58,8 @@ public class GenerateAustrianResidenceGuiTask extends AbstractLocaleAuthServletT private IConfiguration basicConfig; @Override - public void executeWithLocale(ExecutionContext executionContext, HttpServletRequest request, HttpServletResponse response) - throws TaskExecutionException { + public void executeWithLocale(ExecutionContext executionContext, + HttpServletRequest request, HttpServletResponse response) throws TaskExecutionException { try { final StaticGuiBuilderConfiguration config = new StaticGuiBuilderConfiguration( basicConfig, @@ -72,6 +75,25 @@ public class GenerateAustrianResidenceGuiTask extends AbstractLocaleAuthServletT PARAM_FORMWIZARDPOINT, pendingReq.getAuthUrl() + MsEidasNodeConstants.ENDPOINT_RESIDENCY_SEARCH); + + // inject flag to indicate advanced matching error + if (MatchingTaskUtils.getExecutionContextFlag( + executionContext, Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED)) { + config.putCustomParameter(AbstractGuiFormBuilderConfiguration.PARAM_GROUP_UIOPTIONS, + Constants.HTML_FORM_ADVANCED_MATCHING_FAILED, String.valueOf(true)); + + //set detailed error-code + if (executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON) != null) { + config.putCustomParameter(AbstractGuiFormBuilderConfiguration.PARAM_GROUP_UIOPTIONS, + Constants.HTML_FORM_ADVANCED_MATCHING_FAILED_REASON, + executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON).toString()); + } + } + + // reset executionContext parameters + ReceiveOtherLoginMethodGuiResponseTask.ALL_EXECUTIONCONTEXT_PARAMETERS.forEach( + el -> executionContext.remove(el)); + guiBuilder.build(request, response, config, "Query Austrian residency"); } catch (final Exception e) { diff --git a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/GenerateOtherLoginMethodGuiTask.java b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/GenerateOtherLoginMethodGuiTask.java index 11da4281..a90c5929 100644 --- a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/GenerateOtherLoginMethodGuiTask.java +++ b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/GenerateOtherLoginMethodGuiTask.java @@ -23,8 +23,6 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks; -import java.io.Serializable; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -34,6 +32,7 @@ import org.springframework.stereotype.Component; import at.asitplus.eidas.specific.core.MsEidasNodeConstants; import at.asitplus.eidas.specific.core.gui.StaticGuiBuilderConfiguration; import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.MatchingTaskUtils; import at.gv.egiz.eaaf.core.api.gui.ISpringMvcGuiFormBuilder; import at.gv.egiz.eaaf.core.api.idp.IConfiguration; import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; @@ -62,8 +61,8 @@ public class GenerateOtherLoginMethodGuiTask extends AbstractLocaleAuthServletTa private IConfiguration basicConfig; @Override - public void executeWithLocale(ExecutionContext executionContext, HttpServletRequest request, HttpServletResponse response) - throws TaskExecutionException { + public void executeWithLocale(ExecutionContext executionContext, + HttpServletRequest request, HttpServletResponse response) throws TaskExecutionException { try { final StaticGuiBuilderConfiguration config = new StaticGuiBuilderConfiguration( basicConfig, @@ -75,7 +74,8 @@ public class GenerateOtherLoginMethodGuiTask extends AbstractLocaleAuthServletTa resourceLoader); // inject flag to indicate advanced matching error - if (getExecutionContextFlag(executionContext, Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED)) { + if (MatchingTaskUtils.getExecutionContextFlag( + executionContext, Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED)) { config.putCustomParameter(AbstractGuiFormBuilderConfiguration.PARAM_GROUP_UIOPTIONS, Constants.HTML_FORM_ADVANCED_MATCHING_FAILED, String.valueOf(true)); @@ -87,6 +87,13 @@ public class GenerateOtherLoginMethodGuiTask extends AbstractLocaleAuthServletTa } } + // inject request to create a new ERnP entry + config.putCustomParameter(AbstractGuiFormBuilderConfiguration.PARAM_GROUP_UIOPTIONS, + Constants.HTML_FORM_CREATE_NEW_ERNP_ENTRY, + String.valueOf( + MatchingTaskUtils.getExecutionContextFlag( + executionContext,Constants.TRANSITION_TO_REQUESTING_NEW_ERNP_ENTRY_TASK))); + // reset executionContext parameters ReceiveOtherLoginMethodGuiResponseTask.ALL_EXECUTIONCONTEXT_PARAMETERS.forEach( el -> executionContext.remove(el)); @@ -102,11 +109,4 @@ public class GenerateOtherLoginMethodGuiTask extends AbstractLocaleAuthServletTa } } - private boolean getExecutionContextFlag(ExecutionContext executionContext, String key) { - Serializable value = executionContext.get(key); - return value instanceof Boolean && (boolean)value - || value instanceof String && Boolean.parseBoolean((String) value); - - } - } diff --git a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveAustrianResidenceGuiResponseTask.java b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveAustrianResidenceGuiResponseTask.java index 89a3f350..f335bc2a 100644 --- a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveAustrianResidenceGuiResponseTask.java +++ b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveAustrianResidenceGuiResponseTask.java @@ -25,9 +25,11 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks; 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.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON; -import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK; +import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.TRANSITION_TO_GENERATE_GUI_QUERY_AUSTRIAN_RESIDENCE_TASK; +import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.TRANSITION_TO_REQUESTING_NEW_ERNP_ENTRY_TASK; import java.util.Enumeration; +import java.util.Set; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -37,6 +39,8 @@ import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; import org.springframework.stereotype.Component; +import com.google.common.collect.Sets; + import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; import at.asitplus.eidas.specific.modules.auth.eidas.v2.controller.AdresssucheController; import at.asitplus.eidas.specific.modules.auth.eidas.v2.controller.AdresssucheController.AdresssucheOutput; @@ -83,13 +87,19 @@ import lombok.extern.slf4j.Slf4j; @Component("ReceiveAustrianResidenceGuiResponseTask") public class ReceiveAustrianResidenceGuiResponseTask extends AbstractLocaleAuthServletTask { - private static final String MSG_PROP_20 = "module.eidasauth.matching.20"; private static final String MSG_PROP_21 = "module.eidasauth.matching.21"; private static final String MSG_PROP_22 = "module.eidasauth.matching.22"; public static final String HTTP_PARAM_NO_RESIDENCE = "noResidence"; + public static final Set ALL_EXECUTIONCONTEXT_PARAMETERS = Sets.newHashSet( + CONTEXT_FLAG_ADVANCED_MATCHING_FAILED, + CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON, + TRANSITION_TO_REQUESTING_NEW_ERNP_ENTRY_TASK, + TRANSITION_TO_GENERATE_GUI_QUERY_AUSTRIAN_RESIDENCE_TASK); + private final RegisterSearchService registerSearchService; + public ReceiveAustrianResidenceGuiResponseTask(RegisterSearchService registerSearchService) { this.registerSearchService = registerSearchService; @@ -104,21 +114,22 @@ public class ReceiveAustrianResidenceGuiResponseTask extends AbstractLocaleAuthS //return to AuswahlScreen if HTTP_PARAM_NO_RESIDENCE was selected final boolean forwardWithOutMandate = parseFlagFromHttpRequest(request, HTTP_PARAM_NO_RESIDENCE, false); if (forwardWithOutMandate) { - log.debug("User selects 'no residence' button. Switch back to 'other matching' selection ... "); - executionContext.put(TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK, true); - - executionContext.put(CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON, MSG_PROP_20); - executionContext.put(CONTEXT_FLAG_ADVANCED_MATCHING_FAILED, true); + log.debug("User selects 'no residence' button. Switch back to 'insert-into-ERnP' selection ... "); + executionContext.put(TRANSITION_TO_REQUESTING_NEW_ERNP_ENTRY_TASK, true); + executionContext.put(TRANSITION_TO_GENERATE_GUI_QUERY_AUSTRIAN_RESIDENCE_TASK, false); return; + } else { + executionContext.put(TRANSITION_TO_REQUESTING_NEW_ERNP_ENTRY_TASK, false); + } //load search parameters from HTML form AdresssucheOutput input = parseHtmlInput(request); if (validateHtmlInput(input)) { // HTML form should ensure that mandatory fields are set => this should never happen - log.warn("HTML form contains no residence information. Switch back to 'other matching' selection ... "); - executionContext.put(TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK, true); + log.warn("HTML form contains no residence information. Switch back to 'input residence inputs' ... "); + executionContext.put(TRANSITION_TO_GENERATE_GUI_QUERY_AUSTRIAN_RESIDENCE_TASK, true); executionContext.put(CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON, MSG_PROP_21); executionContext.put(CONTEXT_FLAG_ADVANCED_MATCHING_FAILED, true); @@ -136,9 +147,9 @@ public class ReceiveAustrianResidenceGuiResponseTask extends AbstractLocaleAuthS // validate matching response from registers if (residencyResult.getResultCount() != 1) { - log.info("Find {} match by using residence information. Forward user to 'other matching' selection ... ", + log.info("Find {} match by using residence information. Forward user to 'input residence infos' ... ", residencyResult.getResultCount() == 0 ? "no" : "more-than-one"); - executionContext.put(TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK, true); + executionContext.put(TRANSITION_TO_GENERATE_GUI_QUERY_AUSTRIAN_RESIDENCE_TASK, true); executionContext.put(CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON, MSG_PROP_22); executionContext.put(CONTEXT_FLAG_ADVANCED_MATCHING_FAILED, true); diff --git a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/utils/MatchingTaskUtils.java b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/utils/MatchingTaskUtils.java index ad641841..3c9db9ea 100644 --- a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/utils/MatchingTaskUtils.java +++ b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/utils/MatchingTaskUtils.java @@ -1,5 +1,6 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.utils; +import java.io.Serializable; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -20,6 +21,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.ICcSpecificEidProcessingService; import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService.RegisterStatusResults; import at.gv.egiz.eaaf.core.api.IRequest; +import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; import at.gv.egiz.eaaf.core.exceptions.EaafStorageException; import at.gv.egiz.eaaf.core.impl.idp.auth.data.AuthProcessDataWrapper; import eu.eidas.auth.commons.attribute.AttributeDefinition; @@ -67,7 +69,7 @@ public class MatchingTaskUtils { RegisterStatusResults.class); } - + /** * Store intermediate matching result into session. * @@ -123,6 +125,21 @@ public class MatchingTaskUtils { } + + /** + * Evaluate a flag on Execution context. + * + * @param executionContext Current execution context. + * @param key Parameter name + * @return true if the parameter exists and evaluates to true, otherwise false + */ + public static boolean getExecutionContextFlag(ExecutionContext executionContext, String key) { + Serializable value = executionContext.get(key); + return value instanceof Boolean && (boolean)value + || value instanceof String && Boolean.parseBoolean((String) value); + + } + /** * Convert attributes from eIDAS Authn Response into a simple map, to be used from * {@link ICcSpecificEidProcessingService#postProcess(Map)}. diff --git a/modules/authmodule-eIDAS-v2/src/main/resources/eIDAS.Authentication.process.xml b/modules/authmodule-eIDAS-v2/src/main/resources/eIDAS.Authentication.process.xml index d72d6ac7..dfa8622c 100644 --- a/modules/authmodule-eIDAS-v2/src/main/resources/eIDAS.Authentication.process.xml +++ b/modules/authmodule-eIDAS-v2/src/main/resources/eIDAS.Authentication.process.xml @@ -67,9 +67,9 @@ - - + diff --git a/modules/authmodule-eIDAS-v2/src/main/resources/messages/eidas_connector_message.properties b/modules/authmodule-eIDAS-v2/src/main/resources/messages/eidas_connector_message.properties index 3942f30a..bd05fef2 100644 --- a/modules/authmodule-eIDAS-v2/src/main/resources/messages/eidas_connector_message.properties +++ b/modules/authmodule-eIDAS-v2/src/main/resources/messages/eidas_connector_message.properties @@ -22,8 +22,7 @@ module.eidasauth.matching.04=An error occurred while loading your data from offi module.eidasauth.matching.11=Matching failed, because of an ERnP communication error. Reason: {0} module.eidasauth.matching.12=Matching failed, because ERnP response contains historic information which is not supported. - -module.eidasauth.matching.20=Matching be using residence information was canceled. Use another method for matching or create a new Austrian identity. + module.eidasauth.matching.21=Matching be using residence information failed by missing input information. Use another method for matching or create a new Austrian identity. module.eidasauth.matching.22=Can not find an unique match by using residence information. Provide more or other data, use another method for matching, or create a new Austrian identity. module.eidasauth.matching.23=Matching be using Austrian Identity was canceled. Use another method for matching or create a new Austrian identity. -- cgit v1.2.3