aboutsummaryrefslogtreecommitdiff
path: root/modules/authmodule-eIDAS-v2
diff options
context:
space:
mode:
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/Constants.java10
-rw-r--r--modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateNewErnpEntryTask.java11
-rw-r--r--modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveOtherLoginMethodGuiResponseTask.java5
-rw-r--r--modules/authmodule-eIDAS-v2/src/main/resources/eIDAS.Authentication.process.xml2
-rw-r--r--modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateNewErnpEntryTaskTest.java63
5 files changed, 85 insertions, 6 deletions
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 faf38b64..0d0d11f8 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
@@ -336,10 +336,20 @@ public class Constants {
/**
* {@link at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.CreateNewErnpEntryTask}.
+ *
+ * <p>In case of an automated decision to create ERnP entry</p>
*/
public static final String TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_TASK = "TASK_CreateNewErnpEntryTask";
/**
+ * {@link at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.CreateNewErnpEntryTask}.
+ *
+ * <p>In case of an user decision to create ERnP entry</p>
+ */
+ public static final String TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_BY_USER_TASK =
+ "TASK_CreateNewErnpEntryByUserTask";
+
+ /**
* {@link at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.GenerateOtherLoginMethodGuiTask}.
*/
public static final String TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK =
diff --git a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateNewErnpEntryTask.java b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateNewErnpEntryTask.java
index 563a66ba..5926adc6 100644
--- a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateNewErnpEntryTask.java
+++ b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateNewErnpEntryTask.java
@@ -23,6 +23,8 @@
package at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks;
+import java.io.Serializable;
+
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -93,7 +95,7 @@ public class CreateNewErnpEntryTask extends AbstractAuthServletTask {
// finish matching process, because new user-entry uniquly matches
log.info("User successfully registerred into ERnP and matching tasks are finished ");
- MatchingTaskUtils.setMatchingState(pendingReq, MatchingStates.BY_NEW_ERNP_ENTRY);
+ MatchingTaskUtils.setMatchingState(pendingReq, selectMatchingStateByContextInfos(executionContext));
MatchingTaskUtils.storeFinalMatchingResult(pendingReq,
MatchedPersonResult.generateFormMatchingResult(
resp.getPersonResult().get(0), simpleEidasData.getCitizenCountryCode()));
@@ -104,4 +106,11 @@ public class CreateNewErnpEntryTask extends AbstractAuthServletTask {
}
}
+ private MatchingStates selectMatchingStateByContextInfos(ExecutionContext executionContext) {
+ Serializable flag = executionContext.get(Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_BY_USER_TASK);
+ return flag != null && (boolean) flag
+ ? MatchingStates.BY_USER_TO_NEW_ERNP_ENTRY : MatchingStates.BY_NEW_ERNP_ENTRY;
+
+ }
+
}
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 5b966ffe..fb4e6e7b 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
@@ -73,7 +73,8 @@ public class ReceiveOtherLoginMethodGuiResponseTask extends AbstractLocaleAuthSe
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);
+ Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_TASK,
+ Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_BY_USER_TASK);
@Override
public void executeWithLocale(ExecutionContext executionContext, HttpServletRequest request,
@@ -146,7 +147,7 @@ public class ReceiveOtherLoginMethodGuiResponseTask extends AbstractLocaleAuthSe
case ADD_ME_AS_NEW:
log.info("User selects insert-into-ERnP option. Starting ERnP operation and complete prozess ... ");
- executionContext.put(Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_TASK, true);
+ executionContext.put(Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_BY_USER_TASK, true);
executionContext.put(Constants.TRANSITION_TO_REQUESTING_NEW_ERNP_ENTRY_TASK, false);
return;
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 e57f9ca6..3a37a82b 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
@@ -47,7 +47,7 @@
from="receiveOtherLoginMethodGuiResponseTask" to="generateAustrianResidenceGuiTask" />
<pd:Transition conditionExpression="ctx['TASK_RequestingNewErnpEntryTask']"
from="receiveOtherLoginMethodGuiResponseTask" to="generateOtherLoginMethodGuiTask" />
- <pd:Transition conditionExpression="ctx['TASK_CreateNewErnpEntryTask']"
+ <pd:Transition conditionExpression="ctx['TASK_CreateNewErnpEntryByUserTask']"
from="receiveOtherLoginMethodGuiResponseTask" to="createNewErnpEntryTask" />
<!-- alternative eIDAS authentication -->
diff --git a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateNewErnpEntryTaskTest.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateNewErnpEntryTaskTest.java
index 6298e250..c3beff33 100644
--- a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateNewErnpEntryTaskTest.java
+++ b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateNewErnpEntryTaskTest.java
@@ -27,6 +27,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
+import at.asitplus.eidas.specific.core.MsEidasNodeConstants;
+import at.asitplus.eidas.specific.core.MsEidasNodeConstants.MatchingStates;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.ErnpRestClient;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.ErnpRestClient.ErnpRegisterResult;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ErnpPersonRegisterResult;
@@ -55,7 +58,7 @@ public class CreateNewErnpEntryTaskTest {
@Mock ErnpRestClient ernpClient;
- final ExecutionContext executionContext = new ExecutionContextImpl();
+ private ExecutionContext executionContext;
private TestRequestImpl pendingReq;
/**
@@ -70,6 +73,8 @@ public class CreateNewErnpEntryTaskTest {
RequestContextHolder.resetRequestAttributes();
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(httpReq, httpResp));
+ executionContext = new ExecutionContextImpl();
+
pendingReq = new TestRequestImpl();
pendingReq.setPendingReqId(RandomStringUtils.randomAlphanumeric(10));
@@ -145,10 +150,64 @@ public class CreateNewErnpEntryTaskTest {
assertEquals("givenyname", input.getGivenName(), result.getGivenName());
assertEquals("dateOfBirth", input.getDateOfBirth(), result.getDateOfBirth());
assertEquals("bpk", bpk, result.getBpk());
- assertEquals("countryCode", input.getCitizenCountryCode(), result.getCountryCode());
+ assertEquals("countryCode", input.getCitizenCountryCode(), result.getCountryCode());
+ assertEquals("matching state", MatchingStates.BY_NEW_ERNP_ENTRY,
+ pendingReq.getRawData(MsEidasNodeConstants.DATA_MATCHING_STATE));
}
+ @Test
+ @SneakyThrows
+ public void insertErnpByAutoselectionSuccess() {
+ String bpk = RandomStringUtils.randomAlphabetic(5);
+ SimpleEidasData input = buildInputData();
+ Mockito.when(ernpClient.add(input))
+ .thenReturn(ernpRegisterResult(Arrays.asList(buildErnpResultEntry(input, bpk))));
+
+ executionContext.put(Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_TASK, true);
+
+ // perform test
+ task.execute(pendingReq, executionContext);
+
+ // validate state
+ MatchedPersonResult result = MatchingTaskUtils.getFinalMatchingResult(pendingReq);
+ assertNotNull("no matching result", result);
+ assertEquals("familyname", input.getFamilyName(), result.getFamilyName());
+ assertEquals("givenyname", input.getGivenName(), result.getGivenName());
+ assertEquals("dateOfBirth", input.getDateOfBirth(), result.getDateOfBirth());
+ assertEquals("bpk", bpk, result.getBpk());
+ assertEquals("countryCode", input.getCitizenCountryCode(), result.getCountryCode());
+ assertEquals("matching state", MatchingStates.BY_NEW_ERNP_ENTRY,
+ pendingReq.getRawData(MsEidasNodeConstants.DATA_MATCHING_STATE));
+
+ }
+
+ @Test
+ @SneakyThrows
+ public void insertErnpByUserSuccess() {
+ String bpk = RandomStringUtils.randomAlphabetic(5);
+ SimpleEidasData input = buildInputData();
+ Mockito.when(ernpClient.add(input))
+ .thenReturn(ernpRegisterResult(Arrays.asList(buildErnpResultEntry(input, bpk))));
+
+ executionContext.put(Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_BY_USER_TASK, true);
+
+ // perform test
+ task.execute(pendingReq, executionContext);
+
+ // validate state
+ MatchedPersonResult result = MatchingTaskUtils.getFinalMatchingResult(pendingReq);
+ assertNotNull("no matching result", result);
+ assertEquals("familyname", input.getFamilyName(), result.getFamilyName());
+ assertEquals("givenyname", input.getGivenName(), result.getGivenName());
+ assertEquals("dateOfBirth", input.getDateOfBirth(), result.getDateOfBirth());
+ assertEquals("bpk", bpk, result.getBpk());
+ assertEquals("countryCode", input.getCitizenCountryCode(), result.getCountryCode());
+ assertEquals("matching state", MatchingStates.BY_USER_TO_NEW_ERNP_ENTRY,
+ pendingReq.getRawData(MsEidasNodeConstants.DATA_MATCHING_STATE));
+
+ }
+
@NotNull
private ErnpRegisterResult ernpRegisterResult(List<RegisterResult> registerResult) {