aboutsummaryrefslogtreecommitdiff
path: root/modules/authmodule-eIDAS-v2
diff options
context:
space:
mode:
authorThomas <>2022-03-11 07:09:27 +0100
committerThomas <>2022-03-11 07:09:27 +0100
commit2119f7613a04651d7cc1cb9a8c7ecdc8556d07d9 (patch)
tree0d7ad91571b55e4eb74e7cefdcaaed7584bec599 /modules/authmodule-eIDAS-v2
parentf2df62788d1c47aea5dc16d985fd8b4fd9fa424c (diff)
downloadNational_eIDAS_Gateway-2119f7613a04651d7cc1cb9a8c7ecdc8556d07d9.tar.gz
National_eIDAS_Gateway-2119f7613a04651d7cc1cb9a8c7ecdc8556d07d9.tar.bz2
National_eIDAS_Gateway-2119f7613a04651d7cc1cb9a8c7ecdc8556d07d9.zip
fix(matching): unset all matching releated parameters on executioncontext
Diffstat (limited to 'modules/authmodule-eIDAS-v2')
-rw-r--r--modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/GenerateOtherLoginMethodGuiTask.java7
-rw-r--r--modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveOtherLoginMethodGuiResponseTask.java11
-rw-r--r--modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/GenerateOtherLoginMethodGuiTaskTest.java32
3 files changed, 47 insertions, 3 deletions
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 62e5c57b..f6ca0309 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
@@ -84,10 +84,13 @@ public class GenerateOtherLoginMethodGuiTask extends AbstractAuthServletTask {
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));
+
// store pending request before next step
requestStoreage.storePendingRequest(pendingReq);
diff --git a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveOtherLoginMethodGuiResponseTask.java b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveOtherLoginMethodGuiResponseTask.java
index 075b23c1..184ad499 100644
--- a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveOtherLoginMethodGuiResponseTask.java
+++ b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveOtherLoginMethodGuiResponseTask.java
@@ -24,6 +24,7 @@
package at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks;
import java.util.Enumeration;
+import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -31,6 +32,8 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringEscapeUtils;
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.dao.SelectedLoginMethod;
import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext;
@@ -60,6 +63,14 @@ import lombok.extern.slf4j.Slf4j;
@Component("ReceiveOtherLoginMethodGuiResponseTask")
public class ReceiveOtherLoginMethodGuiResponseTask extends AbstractLocaleAuthServletTask {
+ public static final Set<String> ALL_EXECUTIONCONTEXT_PARAMETERS = Sets.newHashSet(
+ Constants.REQ_SELECTED_LOGIN_METHOD_PARAMETER,
+ Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK,
+ Constants.TRANSITION_TO_GENERATE_EIDAS_LOGIN,
+ Constants.TRANSITION_TO_GENERATE_MOBILE_PHONE_SIGNATURE_REQUEST_TASK,
+ Constants.TRANSITION_TO_GENERATE_GUI_QUERY_AUSTRIAN_RESIDENCE_TASK,
+ Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_TASK);
+
@Override
public void executeWithLocale(ExecutionContext executionContext, HttpServletRequest request,
HttpServletResponse response) {
diff --git a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/GenerateOtherLoginMethodGuiTaskTest.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/GenerateOtherLoginMethodGuiTaskTest.java
index cc092004..1751e95a 100644
--- a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/GenerateOtherLoginMethodGuiTaskTest.java
+++ b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/GenerateOtherLoginMethodGuiTaskTest.java
@@ -2,6 +2,7 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.test.tasks;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.io.UnsupportedEncodingException;
@@ -30,8 +31,10 @@ import com.fasterxml.jackson.databind.json.JsonMapper;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SelectedLoginMethod;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.GenerateOtherLoginMethodGuiTask;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.ReceiveOtherLoginMethodGuiResponseTask;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.test.dummy.DummyOA;
import at.gv.egiz.eaaf.core.api.IRequestStorage;
+import at.gv.egiz.eaaf.core.api.data.EaafConstants;
import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException;
import at.gv.egiz.eaaf.core.impl.idp.module.test.TestRequestImpl;
import at.gv.egiz.eaaf.core.impl.idp.process.ExecutionContextImpl;
@@ -54,7 +57,7 @@ public class GenerateOtherLoginMethodGuiTaskTest {
@Autowired IRequestStorage storage;
- private ExecutionContextImpl executionContext = new ExecutionContextImpl();
+ private ExecutionContextImpl executionContext;
private TestRequestImpl pendingReq;
private MockHttpServletRequest httpReq;
private MockHttpServletResponse httpResp;
@@ -80,12 +83,39 @@ public class GenerateOtherLoginMethodGuiTaskTest {
pendingReq.setPendingReqId(RandomStringUtils.randomAlphanumeric(10));
pendingReq.setSpConfig(new DummyOA());
+ executionContext = new ExecutionContextImpl();
+
LocaleContextHolder.resetLocaleContext();
}
@Test
@SneakyThrows
+ public void unsetExecutionContextParameters() throws TaskExecutionException, UnsupportedEncodingException {
+ httpReq.addHeader("Accept", "application/json");
+ ReceiveOtherLoginMethodGuiResponseTask.ALL_EXECUTIONCONTEXT_PARAMETERS.forEach(
+ el -> executionContext.put(el, RandomStringUtils.randomAlphabetic(5)));
+
+ // execute test
+ task.execute(pendingReq, executionContext);
+
+ //result validation
+ Assert.assertEquals("httpStausCode", 200, httpResp.getStatus());
+ Assert.assertEquals("http ContentType", "application/json;charset=UTF-8", httpResp.getContentType());
+
+ ReceiveOtherLoginMethodGuiResponseTask.ALL_EXECUTIONCONTEXT_PARAMETERS.forEach(
+ el -> assertNull("executionContext parameter: " + el, executionContext.get(el)));
+
+ // remove pendingRequestId because it's added by default
+ executionContext.remove(EaafConstants.PROCESS_ENGINE_PENDINGREQUESTID);
+
+ // in case of 'ReceiveOtherLoginMethodGuiResponseTask.ALL_EXECUTIONCONTEXT_PARAMETERS' does not include all parameters
+ assertTrue("ExecutionContext is not empty", executionContext.keySet().isEmpty());
+
+ }
+
+ @Test
+ @SneakyThrows
public void jsonResponse() throws TaskExecutionException, UnsupportedEncodingException {
String reason = RandomStringUtils.randomAlphabetic(5);
executionContext.put(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED, true);