From 87a347c359ec7ee2a39bfcace1975f60c4eb9375 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Mon, 7 Feb 2022 07:55:13 +0100 Subject: feature(ernp): port search and update steps from ZMR client to ERnP client because we need the same functionality on different API --- .../auth/eidas/v2/clients/ernp/ErnpRestClient.java | 308 +++++++++++++++++++-- .../exception/ErnpRestCommunicationException.java | 4 +- .../eidas/v2/service/RegisterSearchService.java | 24 +- .../auth/eidas/v2/tasks/InitialSearchTask.java | 5 +- 4 files changed, 310 insertions(+), 31 deletions(-) (limited to 'eidas_modules/authmodule-eIDAS-v2') 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 index 605f1d0f..2eaece1d 100644 --- 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 @@ -5,9 +5,13 @@ import java.text.MessageFormat; import java.time.LocalDate; import java.time.OffsetDateTime; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.Objects; +import java.util.Optional; +import java.util.Set; import java.util.stream.Collectors; import javax.annotation.Nonnull; @@ -16,7 +20,6 @@ import javax.annotation.PostConstruct; import org.apache.commons.lang3.StringUtils; import org.apache.http.client.HttpClient; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.client.ClientHttpRequestFactory; import org.springframework.http.client.ClientHttpResponse; @@ -25,6 +28,7 @@ import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.lang.NonNull; import org.springframework.lang.Nullable; +import org.springframework.util.Assert; import org.springframework.web.client.ResponseErrorHandler; import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestTemplate; @@ -36,8 +40,11 @@ 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.ernp.api.DefaultApi; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ernp.invoker.ApiClient; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ernp.model.AendernResponse; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ernp.model.Eidas; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ernp.model.PartialDate; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ernp.model.Person; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ernp.model.PersonAendern; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ernp.model.PersonSuchen; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ernp.model.SuchEidas; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ernp.model.Suchdaten; @@ -48,6 +55,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasSAuthenti import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.ErnpRestCommunicationException; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.WorkflowException; import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.VersionHolder; +import at.gv.bmi.namespace.zmr_su.base._20040201_.ServiceFault; import at.gv.bmi.namespace.zmr_su.zmr._20040201.PersonSuchenRequest; import at.gv.egiz.eaaf.core.api.idp.IConfiguration; import at.gv.egiz.eaaf.core.exceptions.EaafAuthenticationException; @@ -81,7 +89,7 @@ public class ErnpRestClient implements IErnpClient { private static final String LOGMSG_ERNP_RESP_PROCESS = "Proces ERnP response during '{}' operation failes with msg: {}"; - private static final String LOGMSG_ERNP_SOAP_ERROR = + private static final String LOGMSG_ERNP_REST_ERROR = "ERnP anwser for transaction: {0} with code: {1} and message: {2}"; private static final String PROCESS_SEARCH_PERSONAL_IDENTIFIER = @@ -95,6 +103,10 @@ public class ErnpRestClient implements IErnpClient { private static final String FRIENDLYNAME_HTTP_CLIENT = "ERnP Client"; + // HTTP header-names from ERnP response + private static final String ERNP_RESPONSE_HEADER_SERVER_ID = "Server-Request-Id"; + + @Autowired IConfiguration basicConfig; @Autowired @@ -109,11 +121,9 @@ public class ErnpRestClient implements IErnpClient { @Override public ErnpRegisterResult searchWithPersonIdentifier(String personIdentifier, String citizenCountryCode) throws EidasSAuthenticationException { - try { - // build generic request metadata - final GenericRequestParams generic = buildGenericRequestParameters("step1"); + final GenericRequestParams generic = buildGenericRequestParameters("stepId"); // build search request final SuchEidas eidasInfos = new SuchEidas(); @@ -153,19 +163,242 @@ public class ErnpRestClient implements IErnpClient { @Override public ErnpRegisterResult searchWithMds(String givenName, String familyName, String dateOfBirth, String citizenCountryCode) throws EidasSAuthenticationException { - return new ErnpRegisterResult(Collections.emptyList()); + try { + // build generic request metadata + final GenericRequestParams generic = buildGenericRequestParameters("stepMDS"); + + // build search request + final Suchdaten searchInfos = new Suchdaten(); + searchInfos.setFamilienname(familyName); + searchInfos.setVorname(givenName); + searchInfos.setGeburtsdatum(buildErnpBirthday(dateOfBirth)); + + final PersonSuchen personSuchen = new PersonSuchen(); + personSuchen.setSuchoptionen(generateSearchParameters()); + personSuchen.setBegruendung(PROCESS_SEARCH_MDS_ONLY); + personSuchen.setSuchdaten(searchInfos); + + // request ERnP + log.trace("Requesting ERnP for '{}' operation", PROCESS_SEARCH_MDS_ONLY); + final SuchenResponse resp = ernpClient.suchen(generic.getClientBehkz(), generic.clientName, + generic.getClientRequestTime(), generic.getClientRequestId(), personSuchen); + + // parse ZMR response + return processErnpResponse(resp, citizenCountryCode, false, PROCESS_SEARCH_MDS_ONLY); + + } catch (RestClientException e) { + log.warn(LOGMSG_ERNP_ERROR, PROCESS_SEARCH_MDS_ONLY, e.getMessage()); + throw new EidasSAuthenticationException(ERROR_MATCHING_11, new Object[] { e.getMessage() }, e); + + } catch (final EidasSAuthenticationException e) { + throw e; + + } catch (final Exception e) { + log.warn(LOGMSG_ERNP_RESP_PROCESS, PROCESS_SEARCH_MDS_ONLY, e.getMessage()); + throw new EidasSAuthenticationException(ERROR_MATCHING_99, new Object[] { e.getMessage() }, e); + } } @Override public ErnpRegisterResult searchCountrySpecific(PersonSuchenRequest personSearchDao, String citizenCountryCode) throws EidasSAuthenticationException { - return new ErnpRegisterResult(Collections.emptyList()); + try { + // build generic request metadata + final GenericRequestParams generic = buildGenericRequestParameters("stepCC"); + + // build search request + final PersonSuchen personSuchen = new PersonSuchen(); + personSuchen.setSuchoptionen(generateSearchParameters()); + personSuchen.setBegruendung(PROCESS_SEARCH_COUNTRY_SPECIFIC); + personSuchen.setSuchdaten(mapCountrySpecificSearchData(personSearchDao)); + + // request ERnP + log.trace("Requesting ERnP for '{}' operation", PROCESS_SEARCH_COUNTRY_SPECIFIC); + final SuchenResponse resp = ernpClient.suchen(generic.getClientBehkz(), generic.clientName, + generic.getClientRequestTime(), generic.getClientRequestId(), personSuchen); + + // parse ZMR response + return processErnpResponse(resp, citizenCountryCode, false, PROCESS_SEARCH_COUNTRY_SPECIFIC); + + } catch (RestClientException e) { + log.warn(LOGMSG_ERNP_ERROR, PROCESS_SEARCH_COUNTRY_SPECIFIC, e.getMessage()); + throw new EidasSAuthenticationException(ERROR_MATCHING_11, new Object[] { e.getMessage() }, e); + + } catch (final EidasSAuthenticationException e) { + throw e; + + } catch (final Exception e) { + log.warn(LOGMSG_ERNP_RESP_PROCESS, PROCESS_SEARCH_COUNTRY_SPECIFIC, e.getMessage()); + throw new EidasSAuthenticationException(ERROR_MATCHING_99, new Object[] { e.getMessage() }, e); + + } } @Override public ErnpRegisterResult update(RegisterResult registerResult, SimpleEidasData eidData) throws EidasSAuthenticationException { - return new ErnpRegisterResult(Collections.emptyList()); + try { + //search person with register result, because update needs information from search response + Person ernpPersonToKitt = searchPersonForUpdate(registerResult); + + // select elements that have to be updated + Collection eidasDocumentToAdd = + selectEidasDocumentsToAdd(ernpPersonToKitt, eidData); + + if (eidasDocumentToAdd.isEmpty()) { + log.info("Find no eIDAS document for update during: {}. Looks strange but nothing todo", + PROCESS_KITT_GENERAL); + return new ErnpRegisterResult(Arrays.asList(registerResult)); + + } else { + log.info("Find #{} eIDAS documents for update during: {}", eidasDocumentToAdd.size(), PROCESS_KITT_GENERAL); + + // update entry based on selected update info's and results from search response + return updatePersonInErnp(ernpPersonToKitt, eidasDocumentToAdd, eidData.getCitizenCountryCode()); + + } + + } catch (RestClientException e) { + log.warn(LOGMSG_ERNP_ERROR, PROCESS_SEARCH_COUNTRY_SPECIFIC, e.getMessage()); + throw new EidasSAuthenticationException(ERROR_MATCHING_11, new Object[] { e.getMessage() }, e); + + } catch (final EidasSAuthenticationException e) { + throw e; + + } catch (final Exception e) { + log.warn(LOGMSG_ERNP_RESP_PROCESS, PROCESS_SEARCH_COUNTRY_SPECIFIC, e.getMessage()); + throw new EidasSAuthenticationException(ERROR_MATCHING_99, new Object[] { e.getMessage() }, e); + + } + } + + private ErnpRegisterResult updatePersonInErnp(Person ernpPersonToKitt, + Collection eidasDocumentToAdd, String citizenCountryCode) + throws ServiceFault { + // build generic request metadata + final GenericRequestParams generic = buildGenericRequestParameters("stepKittUpdate"); + + // build update request + PersonAendern ernpReq = new PersonAendern(); + ernpReq.setBegruendung(PROCESS_KITT_IDENITIES_UPDATE); + + // set reference elements for person update + ernpReq.setEntityId(ernpPersonToKitt.getEntityId()); + ernpReq.setVersion(ernpPersonToKitt.getVersion()); + + // add new eIDAS attributes + eidasDocumentToAdd.stream().forEach(el -> ernpReq.getAnlegen().addEidasItem(el)); + + // TODO: should we update MDS also in that step? + + + // request ZMR + log.trace("Requesting ERnP for '{}' operation", PROCESS_KITT_IDENITIES_UPDATE); + AendernResponse ernpResp = ernpClient.aendern(generic.getClientBehkz(), generic.clientName, + generic.getClientRequestTime(), generic.getClientRequestId(), ernpReq); + log.trace("Receive response from ERnP for '{}' operation", PROCESS_KITT_IDENITIES_UPDATE); + + return new ErnpRegisterResult(Arrays.asList( + mapErnpResponseToRegisterResult(ernpResp.getPerson(), citizenCountryCode))); + + } + + private Collection selectEidasDocumentsToAdd( + Person ernpPersonToKitt, SimpleEidasData eidData) { + + //TODO: maybe we should re-factor SimpleEidasData to a generic data-model to facilitate arbitrary eIDAS attributes + Set result = new HashSet<>(); + addEidasDocumentIfNotAvailable(result, ernpPersonToKitt, eidData.getCitizenCountryCode(), + Constants.eIDAS_ATTRURN_PERSONALIDENTIFIER, eidData.getPseudonym(), true); + addEidasDocumentIfNotAvailable(result, ernpPersonToKitt, eidData.getCitizenCountryCode(), + Constants.eIDAS_ATTRURN_PLACEOFBIRTH, eidData.getPlaceOfBirth(), false); + addEidasDocumentIfNotAvailable(result, ernpPersonToKitt, eidData.getCitizenCountryCode(), + Constants.eIDAS_ATTRURN_BIRTHNAME, eidData.getBirthName(), false); + + return result; + + } + + private void addEidasDocumentIfNotAvailable(Set result, + Person ernpPersonToKitt, String citizenCountryCode, + String attrName, String attrValue, boolean allowMoreThanOneEntry) { + + if (StringUtils.isEmpty(attrValue)) { + log.trace("No eIDAS document: {}. Nothing todo for KITT process ... ", attrName); + return; + + } + + // check if eIDAS attribute is already includes an eIDAS-Document + boolean alreadyExist = ernpPersonToKitt.getEidas().stream() + .filter(el -> el.getWert().equals(attrValue) + && el.getArt().equals(attrName) + && el.getStaatscode2().equals(citizenCountryCode)) + .findAny() + .isPresent(); + + if (!alreadyExist) { + // check eIDAS documents already contains a document with this pair of country-code and attribute-name + Optional oneDocWithNameExists = ernpPersonToKitt.getEidas().stream() + .filter(el -> el.getStaatscode2().equals(citizenCountryCode) + && el.getArt().equals(attrName)) + .findAny(); + + if (!allowMoreThanOneEntry && oneDocWithNameExists.isPresent() + && !oneDocWithNameExists.get().getWert().equals(attrValue)) { + log.warn("eIDAS document: {} already exists for country: {} but attribute-value does not match. " + + "Skip update process because no multi-value allowed for this ... ", + attrName, citizenCountryCode); + + } else { + + Eidas eidasDocToAdd = new Eidas(); + eidasDocToAdd.setStaatscode2(citizenCountryCode); + eidasDocToAdd.setArt(attrName); + eidasDocToAdd.setWert(attrValue); + log.info("Add eIDAS document: {} for country: {} to ERnP person", attrName, citizenCountryCode); + result.add(eidasDocToAdd); + + } + + } else { + log.debug("eIDAS document: {} already exists for country: {}. Skip update process for this ... ", + attrName, citizenCountryCode); + + } + } + + private Person searchPersonForUpdate(RegisterResult registerResult) throws WorkflowException { + // build generic request metadata + final GenericRequestParams generic = buildGenericRequestParameters("stepKittSearch"); + + // build search request + final Suchdaten searchInfos = new Suchdaten(); + searchInfos.setFamilienname(registerResult.getFamilyName()); + searchInfos.setVorname(registerResult.getGivenName()); + searchInfos.setGeburtsdatum(buildErnpBirthday(registerResult.getDateOfBirth())); + + final PersonSuchen personSuchen = new PersonSuchen(); + personSuchen.setSuchoptionen(generateSearchParameters()); + personSuchen.setBegruendung(PROCESS_KITT_IDENITIES_GET); + personSuchen.setSuchdaten(searchInfos); + + // request ERnP + log.trace("Requesting ERnP for '{}' operation", PROCESS_KITT_IDENITIES_GET); + final SuchenResponse resp = ernpClient.suchen(generic.getClientBehkz(), generic.clientName, + generic.getClientRequestTime(), generic.getClientRequestId(), personSuchen); + + // perform shot validation of ERnP response + if (resp.getPerson() == null || resp.getPerson().size() != 1) { + log.error("ERnP result contains NO 'Person' or 'Person' is empty"); + throw new WorkflowException(PROCESS_KITT_IDENITIES_GET, + "Find NO data-set with already matchted eID during ERnP KITT process"); + + } else { + log.debug("Find person for '{}' operation", PROCESS_KITT_IDENITIES_GET); + return resp.getPerson().get(0); + + } } @Override @@ -270,7 +503,7 @@ public class ErnpRestClient implements IErnpClient { Constants.eIDAS_ATTRURN_PERSONALIDENTIFIER)) .familyName(person.getPersonendaten().getFamilienname()) .givenName(person.getPersonendaten().getVorname()) - .dateOfBirth(buildTextualBirthday(person.getPersonendaten().getGeburtsdatum())) + .dateOfBirth(getTextualBirthday(person.getPersonendaten().getGeburtsdatum())) .bpk(person.getPersonendaten().getBpkZp()) .placeOfBirth(selectSingleEidasDocument(person, citizenCountryCode, Constants.eIDAS_ATTRURN_PLACEOFBIRTH)) @@ -280,18 +513,31 @@ public class ErnpRestClient implements IErnpClient { } + private Suchdaten mapCountrySpecificSearchData(PersonSuchenRequest personSearchDao) { + final Suchdaten searchInfos = new Suchdaten(); + searchInfos.setFamilienname(personSearchDao.getNatuerlichePerson().getPersonenName().getFamilienname()); + searchInfos.setVorname(personSearchDao.getNatuerlichePerson().getPersonenName().getVorname()); + searchInfos.setGeburtsdatum(buildErnpBirthday(personSearchDao.getNatuerlichePerson().getGeburtsdatum())); + + //TODO: search eIDAS has to be a LIST!!!!!! + SuchEidas eidasInfos = new SuchEidas(); + searchInfos.setEidas(eidasInfos ); + return searchInfos; + + } + /** * Build AT specific Date String 'yyyy-MM-dd' from ERnP birthday representation. * *

- * Info: {@link LocalDate} can not be used, because '1940-00-00' is also + * Info: {@link LocalDate} can not be used, because '1940-00-00' is also * a valid birthday on ERnP site. *

* * @param geburtsdatum ERnP birthday representation * @return birthday in 'yyyy-MM-dd' format */ - private String buildTextualBirthday(PartialDate geburtsdatum) { + private String getTextualBirthday(PartialDate geburtsdatum) { return MessageFormat.format("{0}-{1}-{2}", String.valueOf(geburtsdatum.getJahr()), String.format("%02d", geburtsdatum.getMonat()), @@ -299,6 +545,29 @@ public class ErnpRestClient implements IErnpClient { } + /** + * Map an AT specific Date String 'yyyy-MM-dd' to ERnP birthday representation. + * + *

+ * Info: {@link LocalDate} can not be used, because '1940-00-00' is also + * a valid birthday. + *

+ * + * @param dateOfBirth in 'yyyy-MM-dd' format + * @return ERnP birthday representation + */ + private PartialDate buildErnpBirthday(String dateOfBirth) { + String[] elements = dateOfBirth.split("-"); + Assert.isTrue(elements.length == 3, "Find invalid dateOfBirth element: " + dateOfBirth); + + PartialDate result = new PartialDate(); + result.setJahr(Integer.valueOf(elements[0])); + result.setMonat(Integer.valueOf(elements[1])); + result.setTag(Integer.valueOf(elements[2])); + return result; + + } + /** * Get all eIDAS document with the specified country code and document type. * @@ -364,7 +633,7 @@ public class ErnpRestClient implements IErnpClient { private HttpMessageConverter buildCustomJacksonObjectMapper() { final MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); - converter.setSupportedMediaTypes(Collections.singletonList(MediaType.ALL)); + converter.setSupportedMediaTypes(Collections.singletonList(MediaType.APPLICATION_JSON)); converter.getObjectMapper() .setSerializationInclusion(Include.NON_NULL); return converter; @@ -384,17 +653,14 @@ public class ErnpRestClient implements IErnpClient { @Override public void handleError(ClientHttpResponse response) throws IOException { - // TODO: implement errorHandling based on response infos + // TODO: opimize errorHandling based on response info's from real ERnP + + List serverId = response.getHeaders().getOrEmpty(ERNP_RESPONSE_HEADER_SERVER_ID); + log.warn("Receive http-error: {} from ERnP with serverTransactionId", + response.getRawStatusCode(), serverId.isEmpty() ? "'not set'" : serverId.get(0)); - if (response.getStatusCode().series() == HttpStatus.Series.SERVER_ERROR) { - log.warn("Receive http-server-error: {} from ERnP", response.getRawStatusCode()); - - } else if (response.getStatusCode().series() == HttpStatus.Series.CLIENT_ERROR) { - log.warn("Receive http-client-error: {} from ERnP", response.getRawStatusCode()); - - } - throw new ErnpRestCommunicationException(response.getRawStatusCode()); + } }; } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/exception/ErnpRestCommunicationException.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/exception/ErnpRestCommunicationException.java index 72a5ece6..e3224c93 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/exception/ErnpRestCommunicationException.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/exception/ErnpRestCommunicationException.java @@ -19,6 +19,6 @@ public class ErnpRestCommunicationException extends IOException { public ErnpRestCommunicationException(int rawStatusCode) { super("ERnP service answers with an error and HTTP status-code: " + rawStatusCode); this.httpStatusCode = rawStatusCode; - } - + + } } 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 fd9a67a9..488b571b 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 @@ -21,6 +21,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasSAuthenti import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.WorkflowException; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.ZmrCommunicationException; import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.CountrySpecificDetailSearchProcessor; +import at.gv.bmi.namespace.zmr_su.zmr._20040201.PersonSuchenRequest; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.RequiredArgsConstructor; @@ -133,17 +134,22 @@ public class RegisterSearchService { try { @Nullable final CountrySpecificDetailSearchProcessor ccSpecificProcessor = findSpecificProcessor(eidasData); if (ccSpecificProcessor != null) { - log.debug("Selecting country-specific search processor: {}", ccSpecificProcessor.getName()); + log.debug("Selecting country-specific search processor: {}", ccSpecificProcessor.getName()); + PersonSuchenRequest ccSpecificSearchReq = ccSpecificProcessor.generateSearchRequest(eidasData); + + // search in ZMR final ZmrRegisterResult resultsZmr = zmrClient.searchCountrySpecific(operationStatus.getZmrProcessId(), - ccSpecificProcessor.generateSearchRequest(eidasData), - eidasData.getCitizenCountryCode()); - return RegisterStatusResults.fromZmr(resultsZmr); + ccSpecificSearchReq, eidasData.getCitizenCountryCode()); + + //search in ERnP + ErnpRegisterResult resultErnp = ernpClient.searchCountrySpecific( + ccSpecificSearchReq, eidasData.getCitizenCountryCode()); + + return RegisterStatusResults.fromZmrAndErnp(resultsZmr, resultErnp); } else { - // TODO: add search procesfor for ERnP searching - return RegisterStatusResults.fromErnp(operationStatus, - new ErnpRegisterResult(Collections.emptyList())); + return RegisterStatusResults.fromEmpty(operationStatus); } @@ -383,6 +389,10 @@ public class RegisterSearchService { static RegisterStatusResults fromErnp(RegisterOperationStatus status, ErnpRegisterResult updateErnp) { return new RegisterStatusResults(status, Collections.emptyList(), updateErnp.getPersonResult()); } + + static RegisterStatusResults fromEmpty(RegisterOperationStatus status) { + return new RegisterStatusResults(status, Collections.emptyList(), Collections.emptyList()); + } } 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 f295d66b..c720cb7f 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 @@ -185,7 +185,10 @@ public class InitialSearchTask extends AbstractAuthServletTask { log.trace("Starting step3CheckRegisterUpdateNecessary"); if (!eidasData.equalsRegisterData(searchResult)) { log.info("Skipping update-register-information step, because it's not supported yet"); - //TODO: return updated search result if updates are allowed + + //TODO: update of ERnP information are allowed. Add ERnP update-step. Maybe we can use regular KITT steps + + return searchResult; } else { log.debug("Register information match to eIDAS information. No update required"); -- cgit v1.2.3