diff options
author | Thomas <> | 2022-07-01 16:41:00 +0200 |
---|---|---|
committer | Thomas <> | 2022-07-01 16:41:00 +0200 |
commit | e3afbc7442ad3893e7615d50747c03f600eb1a1b (patch) | |
tree | 88a823f7d342317f94f9a89ae3865ef3ace53d40 /modules/authmodule-eIDAS-v2/src | |
parent | f2a32b225c243e2cf8b5b368cc6ac4611ce3a476 (diff) | |
download | National_eIDAS_Gateway-e3afbc7442ad3893e7615d50747c03f600eb1a1b.tar.gz National_eIDAS_Gateway-e3afbc7442ad3893e7615d50747c03f600eb1a1b.tar.bz2 National_eIDAS_Gateway-e3afbc7442ad3893e7615d50747c03f600eb1a1b.zip |
feat(core): update statistic-logger to include matching results
Diffstat (limited to 'modules/authmodule-eIDAS-v2/src')
10 files changed, 61 insertions, 10 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 ce1d2a11..66848fcc 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 @@ -128,7 +128,7 @@ public class Constants { public static final String CONIG_PROPS_EIDAS_COMMON_CLIENT_SSL_TRUSTSTORE_NAME = CONIG_PROPS_EIDAS_COMMON_CLIENT + ".ssl.trustStore.name"; - /** Enable / Disable matching based on address search **/ + /** Enable / Disable matching based on address search. **/ public static final String CONFIG_PROP_MATCHING_BY_ADDRESS = CONIG_PROPS_EIDAS_PREFIX + ".matching.byaddress.enable"; public static final String CONFIG_PROP_MATCHING_BY_ADDRESS_MAX_RESULTS = diff --git a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SelectedLoginMethod.java b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SelectedLoginMethod.java index 993c0924..c8a2da88 100644 --- a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SelectedLoginMethod.java +++ b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SelectedLoginMethod.java @@ -1,5 +1,5 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.dao; public enum SelectedLoginMethod { - EIDAS_LOGIN, MOBILE_PHONE_SIGNATURE_LOGIN, NO_OTHER_LOGIN, ADD_ME_AS_NEW, REQUESTING_NEW_ENTRY + EIDAS_LOGIN, MOBILE_PHONE_SIGNATURE_LOGIN, NO_OTHER_LOGIN, ADD_ME_AS_NEW, REQUESTING_NEW_ENTRY, STOP_MATCHING_PROCESS } diff --git a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/AlternativeSearchTask.java b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/AlternativeSearchTask.java index e8fb5b6b..ccc84f46 100644 --- a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/AlternativeSearchTask.java +++ b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/AlternativeSearchTask.java @@ -36,6 +36,7 @@ import javax.servlet.http.HttpServletResponse; import org.jetbrains.annotations.NotNull; import org.springframework.stereotype.Component; +import at.asitplus.eidas.specific.core.MsEidasNodeConstants.MATCHING_STATES; 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; @@ -243,6 +244,7 @@ public class AlternativeSearchTask extends AbstractAuthServletTask { throws WorkflowException, EaafStorageException { MatchedPersonResult result = MatchedPersonResult.generateFormMatchingResult( searchResult.getResult(), eidasData.getCitizenCountryCode()); + MatchingTaskUtils.setMatchingState(pendingReq, MATCHING_STATES.BY_EIDAS); MatchingTaskUtils.storeFinalMatchingResult(pendingReq, result); //remove intermediate matching-state 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 c7843be5..6680650e 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 @@ -29,6 +29,7 @@ import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import at.asitplus.eidas.specific.core.MsEidasNodeConstants.MATCHING_STATES; 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; @@ -91,7 +92,8 @@ 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 "); + log.info("User successfully registerred into ERnP and matching tasks are finished "); + MatchingTaskUtils.setMatchingState(pendingReq, MATCHING_STATES.BY_NEW_ERNP_ENTRY); MatchingTaskUtils.storeFinalMatchingResult(pendingReq, MatchedPersonResult.generateFormMatchingResult( resp.getPersonResult().get(0), simpleEidasData.getCitizenCountryCode())); diff --git a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/InitialSearchTask.java b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/InitialSearchTask.java index 3a775837..86d279c6 100644 --- a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/InitialSearchTask.java +++ b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/InitialSearchTask.java @@ -34,6 +34,7 @@ import javax.servlet.http.HttpServletResponse; import org.jetbrains.annotations.NotNull; import org.springframework.stereotype.Component; +import at.asitplus.eidas.specific.core.MsEidasNodeConstants.MATCHING_STATES; 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.RegisterResult; @@ -123,7 +124,8 @@ public class InitialSearchTask extends AbstractAuthServletTask { step6CountrySpecificSearch(executionContext, searchResult.getOperationStatus(), eidasData); } else if (resultCount == 1) { - RegisterResult updatedResult = step3CheckRegisterUpdateNecessary(searchResult, eidasData); + RegisterResult updatedResult = step3CheckRegisterUpdateNecessary(searchResult, eidasData); + MatchingTaskUtils.setMatchingState(pendingReq, MATCHING_STATES.BY_PERSONALID); foundMatchFinalizeTask(updatedResult, eidasData); } else { @@ -151,6 +153,7 @@ public class InitialSearchTask extends AbstractAuthServletTask { } else if (searchResult.getResultCount() == 1) { log.trace("'step6CountrySpecificSearch' finds a person. Forward to 'step7aKittProcess' step ... "); RegisterStatusResults updatedResult = registerSearchService.step7aKittProcess(searchResult, eidasData); + MatchingTaskUtils.setMatchingState(pendingReq, MATCHING_STATES.BY_COUNTRY_SPECIFIC); foundMatchFinalizeTask(updatedResult.getResult(), eidasData); } else { 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 f335bc2a..00a7e28d 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 @@ -41,6 +41,7 @@ import org.springframework.stereotype.Component; import com.google.common.collect.Sets; +import at.asitplus.eidas.specific.core.MsEidasNodeConstants.MATCHING_STATES; 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; @@ -185,7 +186,8 @@ public class ReceiveAustrianResidenceGuiResponseTask extends AbstractLocaleAuthS // update register information RegisterStatusResults updateResult = registerSearchService.step7aKittProcess(residencyResult, eidasData); - // store updated result to re-used in CreateIdentityLink step, because there we need bPK and MDS + // store updated result to re-used in CreateIdentityLink step, because there we need bPK and MDS + MatchingTaskUtils.setMatchingState(pendingReq, MATCHING_STATES.BY_ADDRESS); MatchingTaskUtils.storeFinalMatchingResult(pendingReq, MatchedPersonResult.generateFormMatchingResult( updateResult.getResult(), eidasData.getCitizenCountryCode())); @@ -193,6 +195,7 @@ public class ReceiveAustrianResidenceGuiResponseTask extends AbstractLocaleAuthS } else { log.warn("Suspect state FOUND. Matching by residence was neccessary but NO register-update are required!"); // no update required. Data can be used as it is. + MatchingTaskUtils.setMatchingState(pendingReq, MATCHING_STATES.BY_ADDRESS); MatchingTaskUtils.storeFinalMatchingResult(pendingReq, MatchedPersonResult.generateFormMatchingResult( residencyResult.getResult(), eidasData.getCitizenCountryCode())); diff --git a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseTask.java b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseTask.java index b212d133..11ac9549 100644 --- a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseTask.java +++ b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseTask.java @@ -47,6 +47,7 @@ import org.opensaml.saml.saml2.core.StatusCode; import org.opensaml.saml.saml2.metadata.IDPSSODescriptor; import org.springframework.stereotype.Component; +import at.asitplus.eidas.specific.core.MsEidasNodeConstants.MATCHING_STATES; 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.RegisterResult; @@ -204,6 +205,7 @@ public class ReceiveMobilePhoneSignatureResponseTask extends AbstractAuthServlet registerSearchService.step7aKittProcess(registerResult, eidasData); // store search result to re-used in CreateIdentityLink step, because there we need bPK and MDS + MatchingTaskUtils.setMatchingState(pendingReq, MATCHING_STATES.BY_ID_AUSTRIA); MatchingTaskUtils.storeFinalMatchingResult(pendingReq, MatchedPersonResult.generateFormMatchingResult(registerResult.getResult(), eidasData.getCitizenCountryCode())); 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 3fc29c4e..159b5b51 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 @@ -34,8 +34,10 @@ import org.springframework.stereotype.Component; import com.google.common.collect.Sets; +import at.asitplus.eidas.specific.core.MsEidasNodeConstants.MATCHING_STATES; 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.utils.MatchingTaskUtils; import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; import at.gv.egiz.eaaf.core.exceptions.EaafException; import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; @@ -81,8 +83,8 @@ public class ReceiveOtherLoginMethodGuiResponseTask extends AbstractLocaleAuthSe executionContext.put(Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK, false); executionContext.put(Constants.REQ_SELECTED_LOGIN_METHOD_PARAMETER, selection.name()); executionContext.remove(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED); - executionContext.remove(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON); - transitionToNextTask(executionContext, selection); + executionContext.remove(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON); + transitionToNextTask(executionContext, selection, request, response); } catch (TaskExecutionException e) { throw e; @@ -105,9 +107,15 @@ public class ReceiveOtherLoginMethodGuiResponseTask extends AbstractLocaleAuthSe return null; } - private void transitionToNextTask(ExecutionContext executionContext, SelectedLoginMethod selection) - throws TaskExecutionException { + private void transitionToNextTask(ExecutionContext executionContext, SelectedLoginMethod selection, + HttpServletRequest request, HttpServletResponse response) throws TaskExecutionException { switch (selection) { + case STOP_MATCHING_PROCESS: + log.info("Matching process WAS stopped by entity. Stopping auth. process ... "); + MatchingTaskUtils.setMatchingState(pendingReq, MATCHING_STATES.CANCELED_BY_USER); + stopProcessFromUserDecision(executionContext, request, response); + return; + case EIDAS_LOGIN: executionContext.put(Constants.TRANSITION_TO_GENERATE_EIDAS_LOGIN, true); return; 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 c8a1f190..8ecefe49 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 @@ -15,6 +15,8 @@ import org.springframework.lang.NonNull; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import at.asitplus.eidas.specific.core.MsEidasNodeConstants; +import at.asitplus.eidas.specific.core.MsEidasNodeConstants.MATCHING_STATES; 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; @@ -27,7 +29,9 @@ import at.gv.egiz.eaaf.core.impl.idp.auth.data.AuthProcessDataWrapper; import eu.eidas.auth.commons.attribute.AttributeDefinition; import eu.eidas.auth.commons.attribute.AttributeValue; import eu.eidas.auth.commons.protocol.eidas.impl.PostalAddress; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class MatchingTaskUtils { /** @@ -105,7 +109,6 @@ public class MatchingTaskUtils { * @param personInfos Person information after a successful match * @throws EaafStorageException In case of data can not be add into session */ - @Nullable public static void storeFinalMatchingResult(IRequest pendingReq, MatchedPersonResult personInfos) throws EaafStorageException { getAuthProcessDataWrapper(pendingReq).setGenericDataToSession( @@ -114,6 +117,23 @@ public class MatchingTaskUtils { } /** + * Store matching result-state. + * + * @param pendingReq Current pendingRequest + * @param state Operation that results into a person match + */ + public static void setMatchingState(IRequest pendingReq, MATCHING_STATES state) { + try { + pendingReq.setRawDataToTransaction(MsEidasNodeConstants.DATA_MATCHING_STATE, state); + + } catch (EaafStorageException e) { + log.warn("Can NOT set matching-state for statistic logging.", e); + + } + } + + + /** * Get holder for authentication information for the current process. * * @param pendingReq Current pendingRequest diff --git a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveOtherLoginMethodGuiResponseTaskTest.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveOtherLoginMethodGuiResponseTaskTest.java index af7bf0bf..66867fce 100644 --- a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveOtherLoginMethodGuiResponseTaskTest.java +++ b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveOtherLoginMethodGuiResponseTaskTest.java @@ -5,6 +5,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; import org.apache.commons.lang3.RandomStringUtils; import org.junit.Before; @@ -79,6 +80,16 @@ public class ReceiveOtherLoginMethodGuiResponseTaskTest { } @Test + public void withStopMatchingSelection() throws TaskExecutionException { +httpReq.setParameter(Constants.REQ_SELECTED_LOGIN_METHOD_PARAMETER, SelectedLoginMethod.STOP_MATCHING_PROCESS.name()); + + task.execute(pendingReq, executionContext); + + assertTrue("stoppedByUser", pendingReq.isAbortedByUser()); + + } + + @Test public void withMobileSignatureSelection() throws TaskExecutionException { testTransition(SelectedLoginMethod.MOBILE_PHONE_SIGNATURE_LOGIN, Constants.TRANSITION_TO_GENERATE_MOBILE_PHONE_SIGNATURE_REQUEST_TASK); assertEquals("return to selection", false, executionContext.get(Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK)); |