diff options
author | Christian Kollmann <christian.kollmann@a-sit.at> | 2021-02-22 14:06:16 +0100 |
---|---|---|
committer | Christian Kollmann <christian.kollmann@a-sit.at> | 2021-02-22 15:03:41 +0100 |
commit | 5eb83e0ca367958c81a7b0ee2cbd047482dd1974 (patch) | |
tree | b21f7f07e85e71b0cd4d292407cb85f07c040ef6 /eidas_modules/authmodule-eIDAS-v2/src/main/java | |
parent | 39b5e38cc5e3c7c555ae10e0ff0f684c9bcc0966 (diff) | |
download | National_eIDAS_Gateway-5eb83e0ca367958c81a7b0ee2cbd047482dd1974.tar.gz National_eIDAS_Gateway-5eb83e0ca367958c81a7b0ee2cbd047482dd1974.tar.bz2 National_eIDAS_Gateway-5eb83e0ca367958c81a7b0ee2cbd047482dd1974.zip |
Move country specific search in registers into common service
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src/main/java')
6 files changed, 74 insertions, 83 deletions
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/CountrySpecificDetailSearchProcessor.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/CountrySpecificDetailSearchProcessor.java index c5b3b231..6e8f7fce 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/CountrySpecificDetailSearchProcessor.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/CountrySpecificDetailSearchProcessor.java @@ -25,27 +25,13 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.handler; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.MergedRegisterSearchResult; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.ernp.IErnpClient; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient; -public abstract class CountrySpecificDetailSearchProcessor { - - protected IErnpClient ernbClient; - protected IZmrClient zmrClient; - - public CountrySpecificDetailSearchProcessor(IErnpClient ernbClient, IZmrClient zmrClient) { - this.ernbClient = ernbClient; - this.zmrClient = zmrClient; - } +public interface CountrySpecificDetailSearchProcessor { /** * Get a friendlyName of this post-processor implementation. - * - * @return */ - public String getName() { - return this.getClass().getName(); - } + String getName(); /** * Check if this postProcessor is sensitive for a specific country. @@ -54,8 +40,8 @@ public abstract class CountrySpecificDetailSearchProcessor { * @param eidData eID data * @return true if this implementation can handle the country, otherwise false */ - public abstract boolean canHandle(String countryCode, SimpleEidasData eidData); + boolean canHandle(String countryCode, SimpleEidasData eidData); - public abstract MergedRegisterSearchResult search(SimpleEidasData eidData); + MergedRegisterSearchResult search(SimpleEidasData eidData); } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/DeSpecificDetailSearchProcessor.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/DeSpecificDetailSearchProcessor.java index 544d5b0c..904c41a1 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/DeSpecificDetailSearchProcessor.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/DeSpecificDetailSearchProcessor.java @@ -25,17 +25,20 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.handler; import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.MergedRegisterSearchResult; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.ernp.IErnpClient; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService; -import java.util.List; +public class DeSpecificDetailSearchProcessor implements CountrySpecificDetailSearchProcessor { -public class DeSpecificDetailSearchProcessor extends CountrySpecificDetailSearchProcessor { + private final RegisterSearchService registerSearchService; - public DeSpecificDetailSearchProcessor(IErnpClient ernbClient, IZmrClient zmrClient) { - super(ernbClient, zmrClient); + public DeSpecificDetailSearchProcessor(RegisterSearchService registerSearchService) { + this.registerSearchService = registerSearchService; + } + + @Override + public String getName() { + return this.getClass().getName(); } @Override @@ -54,12 +57,6 @@ public class DeSpecificDetailSearchProcessor extends CountrySpecificDetailSearch @Override public MergedRegisterSearchResult search(SimpleEidasData eidData) { - List<RegisterResult> resultsZmr = - zmrClient.searchDeSpecific(eidData.getGivenName(), eidData.getFamilyName(), eidData.getDateOfBirth(), - eidData.getPlaceOfBirth(), eidData.getBirthName()); - List<RegisterResult> resultsErnb = - ernbClient.searchDeSpecific(eidData.getGivenName(), eidData.getFamilyName(), eidData.getDateOfBirth(), - eidData.getPlaceOfBirth(), eidData.getBirthName()); - return new MergedRegisterSearchResult(resultsZmr, resultsErnb); + return registerSearchService.searchDeSpecific(eidData); } } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ItSpecificDetailSearchProcessor.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ItSpecificDetailSearchProcessor.java index 370a111c..7e74a85c 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ItSpecificDetailSearchProcessor.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ItSpecificDetailSearchProcessor.java @@ -25,17 +25,20 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.handler; import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.MergedRegisterSearchResult; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.ernp.IErnpClient; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService; -import java.util.List; +public class ItSpecificDetailSearchProcessor implements CountrySpecificDetailSearchProcessor { -public class ItSpecificDetailSearchProcessor extends CountrySpecificDetailSearchProcessor { + private final RegisterSearchService registerSearchService; - public ItSpecificDetailSearchProcessor(IErnpClient ernbClient, IZmrClient zmrClient) { - super(ernbClient, zmrClient); + public ItSpecificDetailSearchProcessor(RegisterSearchService registerSearchService) { + this.registerSearchService = registerSearchService; + } + + @Override + public String getName() { + return this.getClass().getName(); } @Override @@ -51,8 +54,6 @@ public class ItSpecificDetailSearchProcessor extends CountrySpecificDetailSearch @Override public MergedRegisterSearchResult search(SimpleEidasData eidData) { - List<RegisterResult> resultsZmr = zmrClient.searchItSpecific(eidData.getTaxNumber()); - List<RegisterResult> resultsErnb = ernbClient.searchItSpecific(eidData.getTaxNumber()); - return new MergedRegisterSearchResult(resultsZmr, resultsErnb); + return registerSearchService.searchItSpecific(eidData); } } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/RegisterSearchService.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/RegisterSearchService.java index 75374872..a3062d0d 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/RegisterSearchService.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/RegisterSearchService.java @@ -1,6 +1,7 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.service; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.MergedRegisterSearchResult; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; import at.asitplus.eidas.specific.modules.auth.eidas.v2.ernp.IErnpClient; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.WorkflowException; @@ -10,6 +11,8 @@ import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import java.util.List; + @Slf4j @Service("registerSearchService") public class RegisterSearchService { @@ -22,7 +25,6 @@ public class RegisterSearchService { this.ernpClient = ernpClient; } - /** * Automatic process to fix the register entries. * @@ -44,14 +46,50 @@ public class RegisterSearchService { throw new WorkflowException("countrySpecificDetailSearchResult.getResultCount() != 1"); } if (specificDetailSearchResult.getResultsZmr().size() == 1) { - this.zmrClient.update(specificDetailSearchResult.getResultsZmr().get(0), eidData); + zmrClient.update(specificDetailSearchResult.getResultsZmr().get(0), eidData); } if (specificDetailSearchResult.getResultsErnp().size() == 1) { - this.ernpClient.update(specificDetailSearchResult.getResultsErnp().get(0), eidData); + ernpClient.update(specificDetailSearchResult.getResultsErnp().get(0), eidData); } return specificDetailSearchResult.getBpk(); } catch (WorkflowException e) { throw new TaskExecutionException(pendingReq, "Step7a failed.", e); } } + + public MergedRegisterSearchResult searchWithMds(SimpleEidasData eidData) { + List<RegisterResult> resultsZmr = + zmrClient.searchWithMds(eidData.getGivenName(), eidData.getFamilyName(), eidData.getDateOfBirth()); + List<RegisterResult> resultsErnp = + ernpClient.searchWithMds(eidData.getGivenName(), eidData.getFamilyName(), eidData.getDateOfBirth()); + return new MergedRegisterSearchResult(resultsZmr, resultsErnp); + } + + public MergedRegisterSearchResult searchWithPersonIdentifier(SimpleEidasData eidData) { + List<RegisterResult> resultsZmr = zmrClient.searchWithPersonIdentifier(eidData.getPseudonym()); + List<RegisterResult> resultsErnp = ernpClient.searchWithPersonIdentifier(eidData.getPseudonym()); + return new MergedRegisterSearchResult(resultsZmr, resultsErnp); + } + + public MergedRegisterSearchResult searchItSpecific(SimpleEidasData eidData) { + List<RegisterResult> resultsZmr = zmrClient.searchItSpecific(eidData.getTaxNumber()); + List<RegisterResult> resultsErnb = ernpClient.searchItSpecific(eidData.getTaxNumber()); + return new MergedRegisterSearchResult(resultsZmr, resultsErnb); + } + + public MergedRegisterSearchResult searchDeSpecific(SimpleEidasData eidData) { + List<RegisterResult> resultsZmr = + zmrClient.searchDeSpecific(eidData.getGivenName(), eidData.getFamilyName(), eidData.getDateOfBirth(), + eidData.getPlaceOfBirth(), eidData.getBirthName()); + List<RegisterResult> resultsErnb = + ernpClient.searchDeSpecific(eidData.getGivenName(), eidData.getFamilyName(), eidData.getDateOfBirth(), + eidData.getPlaceOfBirth(), eidData.getBirthName()); + return new MergedRegisterSearchResult(resultsZmr, resultsErnb); + } + + public MergedRegisterSearchResult searchWithBpkZp(String bpkzp) { + List<RegisterResult> resultsZmr = zmrClient.searchWithBpkZp(bpkzp); + List<RegisterResult> resultsErnp = ernpClient.searchWithBpkZp(bpkzp); + return new MergedRegisterSearchResult(resultsZmr, resultsErnp); + } } 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 7f4526ad..4fdf3cd2 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 @@ -24,15 +24,12 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.MergedRegisterSearchResult; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.ernp.IErnpClient; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasAttributeException; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.ManualFixNecessaryException; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.WorkflowException; import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.CountrySpecificDetailSearchProcessor; import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient; import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; import at.gv.egiz.eaaf.core.exceptions.EaafStorageException; import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; @@ -70,24 +67,17 @@ import static at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasRespon public class InitialSearchTask extends AbstractAuthServletTask { private final List<CountrySpecificDetailSearchProcessor> handlers; - private final IErnpClient ernpClient; - private final IZmrClient zmrClient; private final RegisterSearchService registerSearchService; /** * Constructor. - * @param handlers List of countrySpecificSearchProcessors - * @param registerSearchService - * @param ernpClient Ernp client - * @param zmrClient ZMR client + * + * @param handlers List of countrySpecificSearchProcessors + * @param registerSearchService Service for register search access */ public InitialSearchTask(List<CountrySpecificDetailSearchProcessor> handlers, - RegisterSearchService registerSearchService, - IErnpClient ernpClient, - IZmrClient zmrClient) { + RegisterSearchService registerSearchService) { this.registerSearchService = registerSearchService; - this.ernpClient = ernpClient; - this.zmrClient = zmrClient; this.handlers = handlers; log.info("Init with {} country specific detail search services", handlers.size()); } @@ -112,7 +102,7 @@ public class InitialSearchTask extends AbstractAuthServletTask { throws TaskExecutionException { log.trace("Starting step2RegisterSearchWithPersonIdentifier"); String personIdentifier = eidData.getPseudonym(); - MergedRegisterSearchResult result = searchWithPersonIdentifier(personIdentifier); + MergedRegisterSearchResult result = registerSearchService.searchWithPersonIdentifier(eidData); //store data in session try { authProcessData.setGenericDataToSession(DATA_INITIAL_REGISTER_RESULT, result); @@ -201,7 +191,7 @@ public class InitialSearchTask extends AbstractAuthServletTask { private String step8RegisterSearchWithMds(ExecutionContext executionContext, SimpleEidasData eidData) { log.trace("Starting step8RegisterSearchWithMds"); - MergedRegisterSearchResult mdsSearchResult = searchWithMds(eidData); + MergedRegisterSearchResult mdsSearchResult = registerSearchService.searchWithMds(eidData); if (mdsSearchResult.getResultCount() == 0) { executionContext.put(TRANSITION_TO_CREATE_NEW_ERNB_ENTRY_TASK, true); } else { @@ -213,21 +203,6 @@ public class InitialSearchTask extends AbstractAuthServletTask { } @NotNull - private MergedRegisterSearchResult searchWithMds(SimpleEidasData eidData) { - List<RegisterResult> resultsZmr = - zmrClient.searchWithMds(eidData.getGivenName(), eidData.getFamilyName(), eidData.getDateOfBirth()); - List<RegisterResult> resultsErnp = - ernpClient.searchWithMds(eidData.getGivenName(), eidData.getFamilyName(), eidData.getDateOfBirth()); - return new MergedRegisterSearchResult(resultsZmr, resultsErnp); - } - - private MergedRegisterSearchResult searchWithPersonIdentifier(String personIdentifier) { - List<RegisterResult> resultsZmr = zmrClient.searchWithPersonIdentifier(personIdentifier); - List<RegisterResult> resultsErnp = ernpClient.searchWithPersonIdentifier(personIdentifier); - return new MergedRegisterSearchResult(resultsZmr, resultsErnp); - } - - @NotNull private SimpleEidasData convertEidasAttrToSimpleData(AuthProcessDataWrapper authProcessData) throws EidasAttributeException { final ILightResponse eidasResponse = authProcessData diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTask.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTask.java index 74af7be4..09f2d54c 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTask.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTask.java @@ -25,7 +25,6 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks; import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.MergedRegisterSearchResult; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleMobileSignatureData; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.InvalidUserInputException; @@ -208,7 +207,7 @@ public class ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTask extends } String bpkzp = simpleMobileSignatureData.getBpk(); - MergedRegisterSearchResult result = searchWithBpkZp(bpkzp); + MergedRegisterSearchResult result = registerSearchService.searchWithBpkZp(bpkzp); if (result.getResultCount() == 0) { //go to step 16 executionContext.put(Constants.TRANSITION_TO_GENERATE_GUI_QUERY_AUSTRIAN_RESIDENCE_TASK, true); @@ -368,9 +367,4 @@ public class ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTask extends } - private MergedRegisterSearchResult searchWithBpkZp(String bpkzp) { - List<RegisterResult> resultsZmr = zmrClient.searchWithBpkZp(bpkzp); - List<RegisterResult> resultsErnp = ernpClient.searchWithBpkZp(bpkzp); - return new MergedRegisterSearchResult(resultsZmr, resultsErnp); - } } |