diff options
author | Thomas <> | 2022-02-03 15:50:33 +0100 |
---|---|---|
committer | Thomas <> | 2022-02-08 09:35:52 +0100 |
commit | b70915cf52ecb08c881d33e8c65b6256922fc0f4 (patch) | |
tree | c203b5f743269ca6b64818e6d731b4c1a0bedd59 /eidas_modules/authmodule-eIDAS-v2/src/main | |
parent | a3d1b2e9aaad4b00031cfcd76e26940697c876c2 (diff) | |
download | National_eIDAS_Gateway-b70915cf52ecb08c881d33e8c65b6256922fc0f4.tar.gz National_eIDAS_Gateway-b70915cf52ecb08c881d33e8c65b6256922fc0f4.tar.bz2 National_eIDAS_Gateway-b70915cf52ecb08c881d33e8c65b6256922fc0f4.zip |
refactor(ernp): change API of ERnP client to same model as ZMR client
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src/main')
4 files changed, 168 insertions, 44 deletions
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/ErnpRestClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/ErnpRestClient.java new file mode 100644 index 00000000..7763fc9d --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/ErnpRestClient.java @@ -0,0 +1,65 @@ +package at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp; + +import java.util.List; + +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.exception.EidasSAuthenticationException; +import at.gv.bmi.namespace.zmr_su.zmr._20040201.PersonSuchenRequest; +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * Implements an ERnP client that uses REST API for communication. + * + * @author tlenz + * + */ +public class ErnpRestClient implements IErnpClient { + + @AllArgsConstructor + @Getter + public static class ErnpRegisterResult { + private final List<RegisterResult> personResult; + + } + + @Override + public ErnpRegisterResult searchWithPersonIdentifier(String personIdentifier, String citizenCountryCode) + throws EidasSAuthenticationException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ErnpRegisterResult searchWithMds(String givenName, String familyName, String dateOfBirth, + String citizenCountryCode) throws EidasSAuthenticationException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ErnpRegisterResult searchCountrySpecific(PersonSuchenRequest personSearchDao, + String citizenCountryCode) throws EidasSAuthenticationException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ErnpRegisterResult update(RegisterResult registerResult, SimpleEidasData eidData) + throws EidasSAuthenticationException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ErnpRegisterResult searchWithResidenceData(String givenName, String familyName, String dateOfBirth, + String zipcode, String city, String street) { + // TODO Auto-generated method stub + return null; + } + + + + +} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/IErnpClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/IErnpClient.java index 377048d9..4c8bcd3e 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/IErnpClient.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/IErnpClient.java @@ -23,24 +23,80 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp; -import java.util.List; +import javax.annotation.Nonnull; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.ErnpRestClient.ErnpRegisterResult; 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.exception.EidasSAuthenticationException; +import at.gv.bmi.namespace.zmr_su.zmr._20040201.PersonSuchenRequest; public interface IErnpClient { - List<RegisterResult> searchWithPersonIdentifier(String personIdentifier); + /** + * Search person based on eIDAS personal identifier. + * + * @param personIdentifier Full eIDAS personal identifier with prefix + * @param citizenCountryCode CountryCode of the eIDAS proxy-service + * @return Search result but never <code>null</code> + * @throws EidasSAuthenticationException In case of a communication error + */ + @Nonnull + ErnpRegisterResult searchWithPersonIdentifier(@Nonnull String personIdentifier, + @Nonnull String citizenCountryCode) throws EidasSAuthenticationException; - List<RegisterResult> searchWithMds(String givenName, String familyName, String dateOfBirth); + /** + * Search person based on eIDSA MDS information. + * + * @param givenName eIDAS given name + * @param familyName eIDAS principle name + * @param dateOfBirth eIDAS date-of-birth + * @param citizenCountryCode CountryCode of the eIDAS proxy-service + * @return Search result but never <code>null</code> + * @throws EidasSAuthenticationException In case of a communication error + */ + @Nonnull + ErnpRegisterResult searchWithMds(@Nonnull String givenName, @Nonnull String familyName, + @Nonnull String dateOfBirth, @Nonnull String citizenCountryCode) + throws EidasSAuthenticationException; - List<RegisterResult> searchDeSpecific(String givenName, String familyName, String dateOfBirth, - String birthPlace, String birthName); + /** + * Search person based on country-specific natural person set. + * + * @param personSearchDao Specific set of natural person informations. + * @param citizenCountryCode CountryCode of the eIDAS proxy-service + * @return Search result but never <code>null</code> + * @throws EidasSAuthenticationException In case of a communication error + */ + @Nonnull + ErnpRegisterResult searchCountrySpecific(@Nonnull PersonSuchenRequest personSearchDao, + @Nonnull String citizenCountryCode) throws EidasSAuthenticationException; - List<RegisterResult> searchItSpecific(String taxNumber); + /** + * Update ERnP entry to KITT existing ERnP identity with this eIDAS authentication. + * + * @param registerResult Already matched eIDAS identity that should be KITT + * @param eidData eIDAS eID information from current authentication process + * @return Update result but never <code>null</code> + * @throws EidasSAuthenticationException In case of a communication error + */ + @Nonnull + ErnpRegisterResult update(RegisterResult registerResult, SimpleEidasData eidData) + throws EidasSAuthenticationException; - RegisterResult update(RegisterResult registerResult, SimpleEidasData eidData); - - List<RegisterResult> searchWithBpkZp(String bpkzp); + /** + * Search person based on address information. + * + * @param givenName eIDAS given name + * @param familyName eIDAS principle name + * @param dateOfBirth eIDAS date-of-birth + * @param zipcode ZipCode + * @param city City + * @param street Street + * @return Search result but never <code>null</code> + */ + @Nonnull + ErnpRegisterResult searchWithResidenceData(String givenName, String familyName, + String dateOfBirth, String zipcode, String city, String street); } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/DummyErnpClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/DummyErnpClient.java index db10752b..52703232 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/DummyErnpClient.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/DummyErnpClient.java @@ -24,52 +24,53 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.ernp; import java.util.Collections; -import java.util.List; import org.springframework.stereotype.Service; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.ErnpRestClient.ErnpRegisterResult; import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.IErnpClient; 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.exception.EidasSAuthenticationException; +import at.gv.bmi.namespace.zmr_su.zmr._20040201.PersonSuchenRequest; @Service("ErnbClientForeIDAS") public class DummyErnpClient implements IErnpClient { + @Override - public List<RegisterResult> searchWithPersonIdentifier(String personIdentifier) { - return Collections.emptyList(); + public ErnpRegisterResult searchWithPersonIdentifier(String personIdentifier, String citizenCountryCode) + throws EidasSAuthenticationException { + return buildEmptyResult(); } @Override - public List<RegisterResult> searchWithMds(String givenName, String familyName, String dateOfBirth) { - //TODO will I only receive matches where all three values match perfectly? - return Collections.emptyList(); + public ErnpRegisterResult searchWithMds(String givenName, String familyName, String dateOfBirth, + String citizenCountryCode) throws EidasSAuthenticationException { + return buildEmptyResult(); } @Override - public List<RegisterResult> searchDeSpecific(String givenName, String familyName, String dateOfBirth, - String birthPlace, String birthName) { - //TODO - return Collections.emptyList(); + public ErnpRegisterResult searchCountrySpecific(PersonSuchenRequest personSearchDao, + String citizenCountryCode) throws EidasSAuthenticationException { + return buildEmptyResult(); } @Override - public List<RegisterResult> searchItSpecific(String taxNumber) { - //TODO - return Collections.emptyList(); + public ErnpRegisterResult update(RegisterResult registerResult, SimpleEidasData eidData) + throws EidasSAuthenticationException { + return buildEmptyResult(); } @Override - public RegisterResult update(RegisterResult registerResult, SimpleEidasData eidData) { - //TODO - return null; + public ErnpRegisterResult searchWithResidenceData(String givenName, String familyName, String dateOfBirth, + String zipcode, String city, String street) { + return buildEmptyResult(); } - @Override - public List<RegisterResult> searchWithBpkZp(String bpkzp) { - //TODO - return Collections.emptyList(); + private static ErnpRegisterResult buildEmptyResult() { + return new ErnpRegisterResult(Collections.emptyList()); + } - } 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 5f1e96a4..fd9a67a9 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 @@ -11,6 +11,7 @@ import org.springframework.stereotype.Service; import com.google.common.collect.Streams; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.ErnpRestClient.ErnpRegisterResult; import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.IErnpClient; import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.zmr.IZmrClient; import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.zmr.ZmrSoapClient.ZmrRegisterResult; @@ -77,8 +78,8 @@ public class RegisterSearchService { final ZmrRegisterResult resultsZmr = zmrClient.searchWithPersonIdentifier( operationStatus != null ? operationStatus.getZmrProcessId() : null, eidasData.getPseudonym(), eidasData.getCitizenCountryCode()); - final List<RegisterResult> resultsErnp = ernpClient.searchWithPersonIdentifier( - eidasData.getPersonalIdentifier()); + final ErnpRegisterResult resultsErnp = ernpClient.searchWithPersonIdentifier( + eidasData.getPseudonym(), eidasData.getCitizenCountryCode()); return RegisterStatusResults.fromZmrAndErnp(resultsZmr, resultsErnp); @@ -104,9 +105,9 @@ public class RegisterSearchService { zmrClient.searchWithMds(operationStatus.getZmrProcessId(), eidasData.getGivenName(), eidasData.getFamilyName(), eidasData.getDateOfBirth(), eidasData.getCitizenCountryCode()); - final List<RegisterResult> resultsErnp = - ernpClient.searchWithMds(eidasData.getGivenName(), eidasData.getFamilyName(), eidasData - .getDateOfBirth()); + final ErnpRegisterResult resultsErnp = + ernpClient.searchWithMds(eidasData.getGivenName(), + eidasData.getFamilyName(), eidasData.getDateOfBirth(), eidasData.getCitizenCountryCode()); return RegisterStatusResults.fromZmrAndErnp(resultsZmr, resultsErnp); @@ -141,7 +142,8 @@ public class RegisterSearchService { } else { // TODO: add search procesfor for ERnP searching - return RegisterStatusResults.fromErnp(operationStatus, Collections.emptyList()); + return RegisterStatusResults.fromErnp(operationStatus, + new ErnpRegisterResult(Collections.emptyList())); } @@ -193,8 +195,8 @@ public class RegisterSearchService { return RegisterStatusResults.fromZmr(updateZmr); } else { RegisterResult entryErnp = registerResult.getResultsErnp().get(0); - RegisterResult updateErnp = ernpClient.update(entryErnp, initialEidasData); - return RegisterStatusResults.fromErnp(registerResult.operationStatus, Collections.singletonList(updateErnp)); + ErnpRegisterResult updateErnp = ernpClient.update(entryErnp, initialEidasData); + return RegisterStatusResults.fromErnp(registerResult.operationStatus, updateErnp); } } catch (final EidasSAuthenticationException e) { throw new WorkflowException("kittMatchedIdentitiess", e.getMessage(), @@ -263,9 +265,9 @@ public class RegisterSearchService { ernpClient.update(entryErnp, initialEidasData); // update ZMR entry by using eIDAS information from alternative authentication - RegisterResult updateAlt = ernpClient.update(entryErnp, altEidasData); + ErnpRegisterResult updateAlt = ernpClient.update(entryErnp, altEidasData); - return RegisterStatusResults.fromErnp(altSearchResult.operationStatus, Collections.singletonList(updateAlt)); + return RegisterStatusResults.fromErnp(altSearchResult.operationStatus, updateAlt); } } catch (final EidasSAuthenticationException e) { throw new WorkflowException("kittMatchedIdentitiess", e.getMessage(), @@ -373,13 +375,13 @@ public class RegisterSearchService { result.getPersonResult(), Collections.emptyList()); } - static RegisterStatusResults fromZmrAndErnp(ZmrRegisterResult result, List<RegisterResult> resultsErnp) { + static RegisterStatusResults fromZmrAndErnp(ZmrRegisterResult result, ErnpRegisterResult resultErnp) { return new RegisterStatusResults(new RegisterOperationStatus(result.getProcessId()), - result.getPersonResult(), resultsErnp); + result.getPersonResult(), resultErnp.getPersonResult()); } - static RegisterStatusResults fromErnp(RegisterOperationStatus status, List<RegisterResult> resultsErnp) { - return new RegisterStatusResults(status, Collections.emptyList(), resultsErnp); + static RegisterStatusResults fromErnp(RegisterOperationStatus status, ErnpRegisterResult updateErnp) { + return new RegisterStatusResults(status, Collections.emptyList(), updateErnp.getPersonResult()); } } |