diff options
author | Christian Kollmann <christian.kollmann@a-sit.at> | 2021-02-22 13:18:16 +0100 |
---|---|---|
committer | Christian Kollmann <christian.kollmann@a-sit.at> | 2021-02-22 13:19:53 +0100 |
commit | 06b30e1aad923cf5ed034911c5949a294310fe24 (patch) | |
tree | be75fc163db01c0916c3562c50d594866ed04f36 /eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific | |
parent | ebd5a42630e4a204b4839d08c722614a9ad63af6 (diff) | |
download | National_eIDAS_Gateway-06b30e1aad923cf5ed034911c5949a294310fe24.tar.gz National_eIDAS_Gateway-06b30e1aad923cf5ed034911c5949a294310fe24.tar.bz2 National_eIDAS_Gateway-06b30e1aad923cf5ed034911c5949a294310fe24.zip |
Refactor InitialSearchTask: Pass execution context as parameter
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific')
-rw-r--r-- | eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/InitialSearchTask.java | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/InitialSearchTask.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/InitialSearchTask.java index 554c60b6..3ebb2116 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/InitialSearchTask.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/InitialSearchTask.java @@ -59,9 +59,10 @@ import java.util.List; import java.util.Map; /** - * Task that searches ErnP and ZMR before adding person to SZR. + * Task that searches registers (ERnP and ZMR) before adding person to SZR. * * @author amarsalek + * @author ckollmann */ @Slf4j @Component("InitialSearchTask") @@ -70,27 +71,26 @@ public class InitialSearchTask extends AbstractAuthServletTask { private final List<CountrySpecificDetailSearchProcessor> handlers; private final IErnpClient ernpClient; private final IZmrClient zmrClient; - private ExecutionContext executionContext; /** * Constructor. - * @param handlers List of countrySpecificSearchProcessors + * + * @param handlers List of countrySpecificSearchProcessors * @param ernpClient Ernp client - * @param zmrClient ZMR client + * @param zmrClient ZMR client */ public InitialSearchTask(List<CountrySpecificDetailSearchProcessor> handlers, IErnpClient ernpClient, IZmrClient zmrClient) { this.ernpClient = ernpClient; this.zmrClient = zmrClient; this.handlers = handlers; - log.info("# " + handlers.size() + " country specific detail search services are registered"); + log.info("Init with {} country specific detail search services", handlers.size()); } @Override public void execute(ExecutionContext executionContext, HttpServletRequest request, HttpServletResponse response) throws TaskExecutionException { try { - this.executionContext = executionContext; final AuthProcessDataWrapper authProcessData = pendingReq.getSessionData(AuthProcessDataWrapper.class); final ILightResponse eidasResponse = authProcessData .getGenericDataFromSession(Constants.DATA_FULL_EIDAS_RESPONSE, ILightResponse.class); @@ -98,7 +98,7 @@ public class InitialSearchTask extends AbstractAuthServletTask { final SimpleEidasData eidData = convertSimpleMapToSimpleData(convertEidasAttrToSimpleMap( eidasResponse.getAttributes().getAttributeMap())); - String bpK = step2RegisterSearchWithPersonidentifier(eidData, authProcessData); + final String bpK = step2RegisterSearchWithPersonidentifier(executionContext, eidData, authProcessData); authProcessData.setGenericDataToSession(Constants.DATA_RESULT_MATCHING_BPK, bpK); authProcessData.setGenericDataToSession(Constants.DATA_SIMPLE_EIDAS, eidData); } catch (final Exception e) { @@ -107,8 +107,9 @@ public class InitialSearchTask extends AbstractAuthServletTask { } } - private String step2RegisterSearchWithPersonidentifier(SimpleEidasData eidData, - AuthProcessDataWrapper authProcessData) throws TaskExecutionException { + private String step2RegisterSearchWithPersonidentifier( + ExecutionContext executionContext, SimpleEidasData eidData, AuthProcessDataWrapper authProcessData) + throws TaskExecutionException { log.trace("Starting step2RegisterSearchWithPersonidentifier"); String personIdentifier = eidData.getPseudonym(); MergedRegisterSearchResult result = searchInZmrAndErnp(personIdentifier); @@ -116,10 +117,10 @@ public class InitialSearchTask extends AbstractAuthServletTask { try { authProcessData.setGenericDataToSession(Constants.DATA_INITIAL_REGISTER_RESULT, result); } catch (EaafStorageException e) { - throw new TaskExecutionException(pendingReq, "Initial search - Kitt Process necessary.",e); + throw new TaskExecutionException(pendingReq, "Initial search - Kitt Process necessary.", e); } if (result.getResultCount() == 0) { - return step5CheckAndPerformCountrySpecificSearchIfPossible(result, eidData); + return step5CheckAndPerformCountrySpecificSearchIfPossible(executionContext, result, eidData); } else if (result.getResultCount() == 1) { return step3CheckRegisterUpdateNecessary(result, eidData); } @@ -145,42 +146,43 @@ public class InitialSearchTask extends AbstractAuthServletTask { private String step4UpdateRegisterData(MergedRegisterSearchResult result, SimpleEidasData eidData) throws WorkflowException { log.trace("Starting step4UpdateRegisterData"); - log.debug("Update " + result + " with " + eidData); + log.debug("Update {} with {}", result, eidData); //TODO wann rechtlich möglich? return result.getBpk(); } private String step5CheckAndPerformCountrySpecificSearchIfPossible( - MergedRegisterSearchResult result, SimpleEidasData eidData) throws TaskExecutionException { + ExecutionContext executionContext, MergedRegisterSearchResult result, SimpleEidasData eidData) + throws TaskExecutionException { log.trace("Starting step5CheckAndPerformCountrySpecificSearchIfPossible"); String citizenCountry = eidData.getCitizenCountryCode(); CountrySpecificDetailSearchProcessor foundHandler = null; for (final CountrySpecificDetailSearchProcessor el : handlers) { if (el.canHandle(citizenCountry, eidData)) { - log.debug("Found suitable country specific search handler for " + citizenCountry - + " by using: " + el.getName()); + log.debug("Found suitable country specific search handler for {} by using: {}", citizenCountry, el.getName()); foundHandler = el; break; } } if (foundHandler == null) { - return step8RegisterSearchWithMds(eidData); + return step8RegisterSearchWithMds(executionContext, eidData); } else { - return step6CountrySpecificSearch(foundHandler, result, eidData); + return step6CountrySpecificSearch(executionContext, foundHandler, result, eidData); } } - private String step6CountrySpecificSearch(CountrySpecificDetailSearchProcessor countrySpecificDetailSearchProcessor, - MergedRegisterSearchResult initialSearchResult, SimpleEidasData eidData) - throws TaskExecutionException { + private String step6CountrySpecificSearch(ExecutionContext executionContext, + CountrySpecificDetailSearchProcessor countrySpecificDetailSearchProcessor, + MergedRegisterSearchResult initialSearchResult, + SimpleEidasData eidData) throws TaskExecutionException { log.trace("Starting step6CountrySpecificSearch"); MergedRegisterSearchResult countrySpecificDetailSearchResult = countrySpecificDetailSearchProcessor.search(eidData); switch (countrySpecificDetailSearchResult.getResultCount()) { case 0: - return step8RegisterSearchWithMds(eidData); + return step8RegisterSearchWithMds(executionContext, eidData); case 1: return step7aKittProcess(initialSearchResult, countrySpecificDetailSearchResult, eidData); default: @@ -197,7 +199,7 @@ public class InitialSearchTask extends AbstractAuthServletTask { eidData, pendingReq); } - private String step8RegisterSearchWithMds(SimpleEidasData eidData) { + private String step8RegisterSearchWithMds(ExecutionContext executionContext, SimpleEidasData eidData) { log.trace("Starting step8RegisterSearchWithMds"); List<RegisterResult> resultsZmr = zmrClient.searchWithMds(eidData.getGivenName(), eidData.getFamilyName(), eidData.getDateOfBirth()); @@ -272,7 +274,7 @@ public class InitialSearchTask extends AbstractAuthServletTask { final DateTime attribute = EidasResponseUtils.translateDateAttribute(el, attributeMap.get(el).asList()); if (attribute != null) { result.put(el.getFriendlyName(), attribute); - log.trace("Find attr '" + el.getFriendlyName() + "' with value: " + attribute.toString()); + log.trace("Find attr '{}' with value: {}", el.getFriendlyName(), attribute.toString()); } else { log.info("Ignore empty 'DateTime' attribute"); @@ -282,7 +284,7 @@ public class InitialSearchTask extends AbstractAuthServletTask { .translateAddressAttribute(el, attributeMap.get(el).asList()); if (addressAttribute != null) { result.put(el.getFriendlyName(), addressAttribute); - log.trace("Find attr '" + el.getFriendlyName() + "' with value: " + addressAttribute.toString()); + log.trace("Find attr '{}' with value: {}", el.getFriendlyName(), addressAttribute.toString()); } else { log.info("Ignore empty 'PostalAddress' attribute"); @@ -293,7 +295,7 @@ public class InitialSearchTask extends AbstractAuthServletTask { final String stringAttr = natPersonIdObj.get(0); if (StringUtils.isNotEmpty(stringAttr)) { result.put(el.getFriendlyName(), stringAttr); - log.trace("Find attr '" + el.getFriendlyName() + "' with value: " + stringAttr); + log.trace("Find attr '{}' with value: {}", el.getFriendlyName(), stringAttr); } else { log.info("Ignore empty 'String' attribute"); } |