diff options
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2')
20 files changed, 366 insertions, 188 deletions
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/Constants.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/Constants.java index 48c114a8..5edde8a4 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/Constants.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/Constants.java @@ -127,6 +127,10 @@ public class Constants { public static final String CONIG_PROPS_EIDAS_ZMRCLIENT_REQ_ORGANIZATION_NR = CONIG_PROPS_EIDAS_ZMRCLIENT + ".req.organisation.behoerdennr"; + public static final String CONIG_PROPS_EIDAS_ZMRCLIENT_REQ_UPDATE_REASON_CODE = CONIG_PROPS_EIDAS_ZMRCLIENT + + ".req.update.reason.code"; + public static final String CONIG_PROPS_EIDAS_ZMRCLIENT_REQ_UPDATE_REASON_TEXT = CONIG_PROPS_EIDAS_ZMRCLIENT + + ".req.update.reason.text"; // SZR Client configuration properties diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/zmr/IZmrClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/zmr/IZmrClient.java index e98573d4..c4e8ece0 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/zmr/IZmrClient.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/zmr/IZmrClient.java @@ -79,10 +79,18 @@ public interface IZmrClient { @Nonnull PersonSuchenRequest personSearchDao, @Nonnull String citizenCountryCode) throws EidasSAuthenticationException; - - void update(@Nullable BigInteger zmrProzessId, RegisterResult registerResult, SimpleEidasData eidData); - - ZmrRegisterResult searchWithBpkZp(@Nullable BigInteger zmrProzessId, String bpkzp); + /** + * Update ZMR entry to KITT existing ZMR identity with this eIDAS authentication. + * + * @param zmrProzessId zmrProzessId ProcessId from ZMR or <code>null</code> if no processId exists + * @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 + ZmrRegisterResult update(@Nullable BigInteger zmrProzessId, RegisterResult registerResult, SimpleEidasData eidData) + throws EidasSAuthenticationException; ZmrRegisterResult searchWithResidenceData(@Nullable BigInteger zmrProzessId, 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/clients/zmr/ZmrSoapClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/zmr/ZmrSoapClient.java index 60e88dca..c5f01392 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/zmr/ZmrSoapClient.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/zmr/ZmrSoapClient.java @@ -4,9 +4,13 @@ import java.math.BigInteger; import java.net.URL; import java.text.MessageFormat; 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; @@ -23,6 +27,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.AbstractSoapClie 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.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.utils.VersionHolder; import at.gv.bmi.namespace.zmr_su.base._20040201.ClientInfoType; @@ -34,17 +39,24 @@ import at.gv.bmi.namespace.zmr_su.base._20040201.WorkflowInfoServer; import at.gv.bmi.namespace.zmr_su.base._20040201_.Service; import at.gv.bmi.namespace.zmr_su.base._20040201_.ServiceFault; import at.gv.bmi.namespace.zmr_su.base._20040201_.ServicePort; +import at.gv.bmi.namespace.zmr_su.zmr._20040201.EidasIdentitaetAnlageType; +import at.gv.bmi.namespace.zmr_su.zmr._20040201.EidasIdentitaetErgebnisType; import at.gv.bmi.namespace.zmr_su.zmr._20040201.EidasSuchdatenType; import at.gv.bmi.namespace.zmr_su.zmr._20040201.ErgebniskriterienType; import at.gv.bmi.namespace.zmr_su.zmr._20040201.NatuerlichePersonErgebnisType; +import at.gv.bmi.namespace.zmr_su.zmr._20040201.PersonAendernInfoType; +import at.gv.bmi.namespace.zmr_su.zmr._20040201.PersonAendernRequest; import at.gv.bmi.namespace.zmr_su.zmr._20040201.PersonErgebnisSatzType; import at.gv.bmi.namespace.zmr_su.zmr._20040201.PersonErgebnisType; +import at.gv.bmi.namespace.zmr_su.zmr._20040201.PersonReferenzType; import at.gv.bmi.namespace.zmr_su.zmr._20040201.PersonSuchenRequest; import at.gv.bmi.namespace.zmr_su.zmr._20040201.PersonSuchenResponse; import at.gv.bmi.namespace.zmr_su.zmr._20040201.PersonensucheInfoType; import at.gv.bmi.namespace.zmr_su.zmr._20040201.SuchkriterienType; +import at.gv.e_government.reference.namespace.persondata.de._20040201.IdentificationType; import at.gv.e_government.reference.namespace.persondata.de._20040201.NatuerlichePersonTyp; import at.gv.e_government.reference.namespace.persondata.de._20040201.PersonenNameTyp; +import at.gv.egiz.eaaf.core.api.data.EaafConstants; import at.gv.egiz.eaaf.core.exceptions.EaafAuthenticationException; import at.gv.egiz.eaaf.core.exceptions.EaafConfigurationException; import lombok.AllArgsConstructor; @@ -60,7 +72,6 @@ import lombok.extern.slf4j.Slf4j; @Slf4j public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient { - private static final String ERROR_MATCHING_00 = "module.eidasauth.matching.00"; private static final String ERROR_MATCHING_01 = "module.eidasauth.matching.01"; private static final String ERROR_MATCHING_02 = "module.eidasauth.matching.02"; private static final String ERROR_MATCHING_99 = "module.eidasauth.matching.99"; @@ -80,7 +91,11 @@ public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient { "Searching " + Constants.eIDAS_ATTR_PERSONALIDENTIFIER; private static final String PROCESS_SEARCH_MDS_ONLY = "Searching with MDS only"; private static final String PROCESS_SEARCH_COUNTRY_SPECIFIC = "Searching {} specific"; - + + private static final String PROCESS_KITT_GENERAL = "KITT general-processing"; + private static final String PROCESS_KITT_IDENITIES_GET = "KITT get-latest-version"; + private static final String PROCESS_KITT_IDENITIES_UPDATE = "KITT update dataset"; + private static final String CLIENT_INFO = "eIDAS MS-Connector v{0}"; private static final String CLIENT_DEFAULT = "ZMR Client"; @@ -133,7 +148,10 @@ public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient { log.warn(LOGMSG_ZMR_ERROR, PROCESS_SEARCH_PERSONAL_IDENTIFIER, errorMsg); throw new ZmrCommunicationException(ERROR_MATCHING_01, new Object[] { errorMsg }, e); - } catch (final EaafAuthenticationException e) { + } catch (EidasSAuthenticationException e) { + throw e; + + } catch (final Exception e) { log.warn(LOGMSG_ZMR_RESP_PROCESS, PROCESS_SEARCH_PERSONAL_IDENTIFIER, e.getMessage()); throw new EidasSAuthenticationException(ERROR_MATCHING_99, new Object[] { e.getMessage() }, e); @@ -179,7 +197,10 @@ public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient { log.warn(LOGMSG_ZMR_ERROR, PROCESS_SEARCH_MDS_ONLY, errorMsg); throw new ZmrCommunicationException(ERROR_MATCHING_01, new Object[] { errorMsg }, e); - } catch (final EaafAuthenticationException e) { + } catch (EidasSAuthenticationException e) { + throw e; + + } catch (final Exception e) { log.warn(LOGMSG_ZMR_RESP_PROCESS, PROCESS_SEARCH_MDS_ONLY, e.getMessage()); throw new EidasSAuthenticationException(ERROR_MATCHING_99, new Object[] { e.getMessage() }, e); @@ -220,7 +241,10 @@ public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient { log.warn(LOGMSG_ZMR_ERROR, friendlyMsg, errorMsg); throw new ZmrCommunicationException(ERROR_MATCHING_01, new Object[] { errorMsg }, e); - } catch (final EaafAuthenticationException e) { + } catch (EidasSAuthenticationException e) { + throw e; + + } catch (final Exception e) { log.warn(LOGMSG_ZMR_RESP_PROCESS, friendlyMsg, e.getMessage()); throw new EidasSAuthenticationException(ERROR_MATCHING_99, new Object[] { e.getMessage() }, e); @@ -228,17 +252,45 @@ public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient { } @Override - public void update(BigInteger zmrProzessId, RegisterResult registerResult, SimpleEidasData eidData) { - // TODO Auto-generated method stub + public ZmrRegisterResult update(BigInteger zmrProzessId, RegisterResult registerResult, + SimpleEidasData eidData) throws EidasSAuthenticationException { + try { + //search person with register result, because update needs information from search response + PersonErgebnisType zmrPersonToKitt = searchPersonForUpdate(zmrProzessId, registerResult); + + // select elements that have to be updated + Collection<? extends EidasIdentitaetAnlageType> eidasDocumentToAdd = + selectEidasDocumentsToAdd(zmrPersonToKitt, eidData); + + if (eidasDocumentToAdd.isEmpty()) { + log.info("Find no eIDAS document for update during: {}. Looks strange but nothing todo", + PROCESS_KITT_GENERAL); + return new ZmrRegisterResult(Arrays.asList(registerResult), zmrProzessId); + + } 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 updatePersonInZmr(zmrPersonToKitt, eidasDocumentToAdd, eidData.getCitizenCountryCode()); + + } + + } catch (final ServiceFault e) { + final String errorMsg = extractReasonFromError(e); + log.warn(LOGMSG_ZMR_ERROR, PROCESS_KITT_GENERAL, errorMsg); + throw new ZmrCommunicationException(ERROR_MATCHING_01, new Object[] { errorMsg }, e); - } + } catch (EidasSAuthenticationException e) { + throw e; + + } catch (final Exception e) { + log.warn(LOGMSG_ZMR_RESP_PROCESS, PROCESS_KITT_GENERAL, e.getMessage()); + throw new EidasSAuthenticationException(ERROR_MATCHING_99, new Object[] { e.getMessage() }, e); - @Override - public ZmrRegisterResult searchWithBpkZp(BigInteger zmrProzessId, String bpkzp) { - // TODO Auto-generated method stub - return null; - } + } + } + @Override public ZmrRegisterResult searchWithResidenceData(BigInteger zmrProzessId, String givenName, String familyName, String dateOfBirth, String zipcode, String city, String street) { @@ -309,8 +361,9 @@ public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient { } private void valdiateAdditionalConfigParameters() { - checkConfigurationValue(Constants.CONIG_PROPS_EIDAS_ZMRCLIENT_REQ_ORGANIZATION_NR); - + checkConfigurationValue(Constants.CONIG_PROPS_EIDAS_ZMRCLIENT_REQ_ORGANIZATION_NR); + checkConfigurationValue(Constants.CONIG_PROPS_EIDAS_ZMRCLIENT_REQ_UPDATE_REASON_CODE); + } private void checkConfigurationValue(String key) { @@ -406,7 +459,8 @@ public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient { if (forceSinglePersonMatch) { return new ZmrRegisterResult(processSearchPersonResponseSingleResult( - searchPersonResp.getPersonensuchergebnis().getPersonErgebnisSatz(), citizenCountryCode), + searchPersonResp.getPersonensuchergebnis().getPersonErgebnisSatz(), + citizenCountryCode, processStepFiendlyname), extractZmrProcessId(resp.getWorkflowInfoServer())); } else { @@ -447,10 +501,11 @@ public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient { @NonNull private List<RegisterResult> processSearchPersonResponseSingleResult( @Nonnull List<PersonErgebnisSatzType> personErgebnisSatz, - @Nonnull String citizenCountryCode) throws EaafAuthenticationException { + @Nonnull String citizenCountryCode, String processStepFiendlyname) throws EaafAuthenticationException { if (personErgebnisSatz.size() > 1) { - log.error("Find more than on person with eIDAS personalIdentifier."); - throw new EaafAuthenticationException(ERROR_MATCHING_00, null); + log.error("Find more-than-one ZMR entry with search criteria that has to be unique"); + throw new WorkflowException(processStepFiendlyname, + "Find more-than-one ZMR entry with search criteria that has to be unique", true); } else { return Arrays.asList(processPersonResult(personErgebnisSatz.get(0), citizenCountryCode)); @@ -554,4 +609,167 @@ public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient { .orElse(null); } + + private PersonErgebnisType searchPersonForUpdate(BigInteger zmrProzessId, RegisterResult registerResult) + throws ServiceFault, WorkflowException { + // build search request + final RequestType req = new RequestType(); + + // set eIDAS person information + final PersonSuchenRequest searchPersonReq = new PersonSuchenRequest(); + req.setPersonSuchenRequest(searchPersonReq); + NatuerlichePersonTyp natPersonInfos = new NatuerlichePersonTyp(); + searchPersonReq.setNatuerlichePerson(natPersonInfos); + PersonenNameTyp nameInfo = new PersonenNameTyp(); + natPersonInfos.setPersonenName(nameInfo); + IdentificationType bpkInfo = new IdentificationType(); + natPersonInfos.getIdentification().add(bpkInfo); + + // set MDS + nameInfo.setVorname(registerResult.getGivenName()); + nameInfo.setFamilienname(registerResult.getFamilyName()); + natPersonInfos.setGeburtsdatum(registerResult.getDateOfBirth()); + + //set bPK + bpkInfo.setValue(registerResult.getBpk()); + bpkInfo.setType(EaafConstants.URN_PREFIX_CDID + "ZP"); + + // set work-flow client information + req.setWorkflowInfoClient(generateWorkFlowInfos(PROCESS_KITT_IDENITIES_GET, zmrProzessId)); + req.setClientInfo(generateClientInfos()); + + // set additionl search parameters + searchPersonReq.setPersonensucheInfo(generateSearchCriteria(false, true, false)); + + // request ZMR + log.trace("Requesting ZMR for '{}' operation", PROCESS_KITT_IDENITIES_GET); + ResponseType resp = zmrClient.service(req, null); + log.trace("Receive response from ZMR for '{}' operation", PROCESS_KITT_IDENITIES_GET); + + return extractPersonResultForUpdaste(resp); + + } + + private PersonErgebnisType extractPersonResultForUpdaste(ResponseType resp) throws WorkflowException { + final PersonSuchenResponse searchPersonResp = resp.getPersonSuchenResponse(); + if (searchPersonResp.getPersonensuchergebnis() == null + || searchPersonResp.getPersonensuchergebnis().getPersonErgebnisSatz().isEmpty()) { + log.error("ZMR result contains NO 'Personensuchergebnis' or 'PersonErgebnisSatz' is empty"); + throw new WorkflowException(PROCESS_KITT_IDENITIES_GET, + "Find NO data-set with already matchted eID during ZMR KITT process"); + + } else { + List<PersonErgebnisSatzType> personErgebnisSatz = + searchPersonResp.getPersonensuchergebnis().getPersonErgebnisSatz(); + if (personErgebnisSatz.size() > 1) { + log.error("Find more than on person with aleady matched information."); + throw new WorkflowException(PROCESS_KITT_IDENITIES_GET, + "Find MORE-THAN-ONE data-sets with already matchted eID during ZMR KITT process"); + + } else { + return personErgebnisSatz.get(0).getPersonendaten().getPersonErgebnis().get(0); + + } + } + } + + private Collection<? extends EidasIdentitaetAnlageType> selectEidasDocumentsToAdd( + PersonErgebnisType zmrPersonToKitt, SimpleEidasData eidData) { + + //TODO: maybe we should re-factor SimpleEidasData to a generic data-model to facilitate arbitrary eIDAS attributes + Set<EidasIdentitaetAnlageType> result = new HashSet<>(); + addEidasDocumentIfNotAvailable(result, zmrPersonToKitt, eidData.getCitizenCountryCode(), + Constants.eIDAS_ATTRURN_PERSONALIDENTIFIER, eidData.getPseudonym(), true); + addEidasDocumentIfNotAvailable(result, zmrPersonToKitt, eidData.getCitizenCountryCode(), + Constants.eIDAS_ATTRURN_PLACEOFBIRTH, eidData.getPlaceOfBirth(), false); + addEidasDocumentIfNotAvailable(result, zmrPersonToKitt, eidData.getCitizenCountryCode(), + Constants.eIDAS_ATTRURN_BIRTHNAME, eidData.getBirthName(), false); + + return result; + + } + + private void addEidasDocumentIfNotAvailable(Set<EidasIdentitaetAnlageType> result, + PersonErgebnisType zmrPersonToKitt, 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 = zmrPersonToKitt.getEidasIdentitaet().stream() + .filter(el -> el.getDokumentNummer().equals(attrValue) + && el.getEidasArt().equals(attrName) + && el.getStaatscode3().equals(citizenCountryCode)) + .findAny() + .isPresent(); + + if (!alreadyExist) { + // check eIDAS documents already contains a document with this pair of country-code and attribute-name + Optional<EidasIdentitaetErgebnisType> oneDocWithNameExists = zmrPersonToKitt.getEidasIdentitaet().stream() + .filter(el -> el.getStaatscode3().equals(citizenCountryCode) + && el.getEidasArt().equals(attrName)) + .findAny(); + + if (!allowMoreThanOneEntry && oneDocWithNameExists.isPresent() + && !oneDocWithNameExists.get().getDokumentNummer().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 { + EidasIdentitaetAnlageType eidasDocToAdd = new EidasIdentitaetAnlageType(); + eidasDocToAdd.setStaatscode3(citizenCountryCode); + eidasDocToAdd.setEidasArt(attrName); + eidasDocToAdd.setEidasNummer(attrValue); + log.info("Add eIDAS document: {} for country: {} to ZMR person", attrName, citizenCountryCode); + result.add(eidasDocToAdd); + + } + + } else { + log.debug("eIDAS document: {} already exists for country: {}. Skip update process for this ... ", + attrName, citizenCountryCode); + + } + } + + private ZmrRegisterResult updatePersonInZmr(PersonErgebnisType zmrPersonToKitt, + Collection<? extends EidasIdentitaetAnlageType> eidasDocumentToAdd, String citizenCountryCode) + throws ServiceFault { + final RequestType req = new RequestType(); + PersonAendernRequest updateReq = new PersonAendernRequest(); + req.setPersonAendernRequest(updateReq); + + // set reference elements for person update + PersonReferenzType updateRef = new PersonReferenzType(); + updateRef.setTechnisch(zmrPersonToKitt.getEntityErgebnisReferenz().getTechnisch()); + updateRef.setZMRZahl(zmrPersonToKitt.getZMRZahl()); + updateReq.setPersonReferenz(updateRef); + + // set reason from this update + PersonAendernInfoType updateInfo = new PersonAendernInfoType(); + updateInfo.setGrundCode(basicConfig.getBasicConfiguration( + Constants.CONIG_PROPS_EIDAS_ZMRCLIENT_REQ_UPDATE_REASON_CODE)); + updateInfo.setGrundFreitext(basicConfig.getBasicConfiguration( + Constants.CONIG_PROPS_EIDAS_ZMRCLIENT_REQ_UPDATE_REASON_TEXT)); + updateReq.setPersonAendernInfo(updateInfo); + + // add new eIDAS documents that should be added + updateReq.getEidasIdentitaetAnlage().addAll(eidasDocumentToAdd); + + // request ZMR + log.trace("Requesting ZMR for '{}' operation", PROCESS_KITT_IDENITIES_UPDATE); + ResponseType resp = zmrClient.service(req, null); + log.trace("Receive response from ZMR for '{}' operation", PROCESS_KITT_IDENITIES_UPDATE); + + return new ZmrRegisterResult(Arrays.asList( + mapZmrResponseToRegisterResult(resp.getPersonAendernResponse().getPersonErgebnis(), citizenCountryCode)), + extractZmrProcessId(resp.getWorkflowInfoServer())); + + } + } 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 065b17a2..77f5e3cd 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 @@ -59,8 +59,9 @@ public class DummyErnpClient implements IErnpClient { } @Override - public void update(RegisterResult registerResult, SimpleEidasData eidData) { + public RegisterResult update(RegisterResult registerResult, SimpleEidasData eidData) { //TODO + return null; } @Override diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/IErnpClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/IErnpClient.java index b3b0c033..b2a9005b 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/IErnpClient.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/IErnpClient.java @@ -39,7 +39,7 @@ public interface IErnpClient { List<RegisterResult> searchItSpecific(String taxNumber); - void update(RegisterResult registerResult, SimpleEidasData eidData); + RegisterResult update(RegisterResult registerResult, SimpleEidasData eidData); List<RegisterResult> searchWithBpkZp(String bpkzp); 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 bcee0f0f..b5e83490 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 java.math.BigInteger; +import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -55,7 +56,7 @@ public class RegisterSearchService { * @throws WorkflowException In case of a register interaction error */ @Nonnull - public RegisterSearchResult searchWithPersonIdentifier(SimpleEidasData eidasData) + public RegisterStatusResults searchWithPersonIdentifier(SimpleEidasData eidasData) throws WorkflowException { try { final ZmrRegisterResult resultsZmr = zmrClient.searchWithPersonIdentifier( @@ -63,7 +64,7 @@ public class RegisterSearchService { final List<RegisterResult> resultsErnp = ernpClient.searchWithPersonIdentifier( eidasData.getPersonalIdentifier()); - return new RegisterSearchResult(new RegisterOperationStatus(resultsZmr.getProcessId()), + return new RegisterStatusResults(new RegisterOperationStatus(resultsZmr.getProcessId()), resultsZmr.getPersonResult(), resultsErnp); } catch (final EidasSAuthenticationException e) { @@ -81,7 +82,7 @@ public class RegisterSearchService { * @throws WorkflowException In case of a register interaction error */ @Nonnull - public RegisterSearchResult searchWithMds(RegisterOperationStatus operationStatus, SimpleEidasData eidasData) + public RegisterStatusResults searchWithMds(RegisterOperationStatus operationStatus, SimpleEidasData eidasData) throws WorkflowException { try { final ZmrRegisterResult resultsZmr = @@ -92,7 +93,7 @@ public class RegisterSearchService { ernpClient.searchWithMds(eidasData.getGivenName(), eidasData.getFamilyName(), eidasData .getDateOfBirth()); - return new RegisterSearchResult(new RegisterOperationStatus(resultsZmr.getProcessId()), + return new RegisterStatusResults(new RegisterOperationStatus(resultsZmr.getProcessId()), resultsZmr.getPersonResult(), resultsErnp); } catch (final EidasSAuthenticationException e) { @@ -112,7 +113,7 @@ public class RegisterSearchService { * @throws WorkflowException In case of a register interaction error */ @Nonnull - public RegisterSearchResult searchWithCountrySpecifics(RegisterOperationStatus operationStatus, + public RegisterStatusResults searchWithCountrySpecifics(RegisterOperationStatus operationStatus, SimpleEidasData eidasData) throws WorkflowException { try { @Nullable @@ -125,10 +126,10 @@ public class RegisterSearchService { eidasData.getCitizenCountryCode()); // TODO: add search procesfor for ERnP searching - return new RegisterSearchResult(operationStatus, resultsZmr.getPersonResult(), Collections.emptyList()); + return new RegisterStatusResults(operationStatus, resultsZmr.getPersonResult(), Collections.emptyList()); } else { - return new RegisterSearchResult(operationStatus, Collections.emptyList(), Collections.emptyList()); + return new RegisterStatusResults(operationStatus, Collections.emptyList(), Collections.emptyList()); } @@ -140,17 +141,6 @@ public class RegisterSearchService { } /** - * Search with BPK-ZP in BMR and ERnP. - */ - public RegisterSearchResult searchWithBpkZp(RegisterOperationStatus operationStatus, String bpkZp) { - final ZmrRegisterResult resultsZmr = zmrClient.searchWithBpkZp( - operationStatus.getZmrProcessId(), bpkZp); - final List<RegisterResult> resultsErnp = ernpClient.searchWithBpkZp(bpkZp); - return new RegisterSearchResult(operationStatus, resultsZmr.getPersonResult(), resultsErnp); - - } - - /** * Search with residence infos. * * @param operationStatus Current register-operation status that contains processing informations @@ -159,12 +149,12 @@ public class RegisterSearchService { * @param street Provided street * @return Results from ZMR or ERnP search */ - public RegisterSearchResult searchWithResidence(RegisterOperationStatus operationStatus, SimpleEidasData eidasData, + public RegisterStatusResults searchWithResidence(RegisterOperationStatus operationStatus, SimpleEidasData eidasData, String zipcode, String city, String street) { final ZmrRegisterResult resultsZmr = zmrClient.searchWithResidenceData( operationStatus.getZmrProcessId(), eidasData.getGivenName(), eidasData.getFamilyName(), eidasData.getDateOfBirth(), zipcode, city, street); - return new RegisterSearchResult(operationStatus, resultsZmr.getPersonResult(), Collections.emptyList()); + return new RegisterStatusResults(operationStatus, resultsZmr.getPersonResult(), Collections.emptyList()); } @@ -173,8 +163,9 @@ public class RegisterSearchService { * * @param specificSearchResult Result of last register search * @param eidasData Received eidas data + * @return */ - public void step7aKittProcess(RegisterSearchResult specificSearchResult, + public RegisterStatusResults step7aKittProcess(RegisterStatusResults specificSearchResult, SimpleEidasData eidasData) throws WorkflowException { log.trace("Starting step7aKittProcess"); // TODO verify with which data this method gets called @@ -182,16 +173,24 @@ public class RegisterSearchService { throw new WorkflowException("step7aKittProcess", "getResultCount() != 1"); } - - if (specificSearchResult.getResultsZmr().size() == 1) { - zmrClient.update(specificSearchResult.getOperationStatus().getZmrProcessId(), - - specificSearchResult.getResultsZmr().get(0), eidasData); - } - - if (specificSearchResult.getResultsErnp().size() == 1) { - ernpClient.update(specificSearchResult.getResultsErnp().get(0), eidasData); + try { + if (specificSearchResult.getResultsZmr().size() == 1) { + final ZmrRegisterResult resultsZmr = zmrClient.update( + specificSearchResult.getOperationStatus().getZmrProcessId(), + specificSearchResult.getResultsZmr().get(0), eidasData); + return new RegisterStatusResults(specificSearchResult.getOperationStatus(), + resultsZmr.getPersonResult(), Collections.emptyList()); + } else { + return new RegisterStatusResults(specificSearchResult.getOperationStatus(), Collections.emptyList(), + Arrays.asList(ernpClient.update(specificSearchResult.getResultsErnp().get(0), eidasData))); + + } + + } catch (final EidasSAuthenticationException e) { + throw new WorkflowException("kittMatchedIdentitiess", e.getMessage(), + !(e instanceof ZmrCommunicationException), e); + } } @@ -225,16 +224,18 @@ public class RegisterSearchService { } + + /** - * Response container for {@link RegisterSearchService}. + * Response container for {@link RegisterSearchService} that holds a set of {@link RegisterResult}. * * @author tlenz * */ @Getter @RequiredArgsConstructor - public static class RegisterSearchResult { + public static class RegisterStatusResults { /** * Operation status for this result. */ 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 01497f8d..220c4e56 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 @@ -51,7 +51,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.WorkflowExcept import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.ICcSpecificEidProcessingService; import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService; import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService.RegisterOperationStatus; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService.RegisterSearchResult; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService.RegisterStatusResults; import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasResponseUtils; import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.MatchingTaskUtils; import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; @@ -131,7 +131,7 @@ public class InitialSearchTask extends AbstractAuthServletTask { ExecutionContext executionContext, SimpleEidasData eidasData) throws WorkflowException, EaafStorageException { try { log.trace("Starting step2RegisterSearchWithPersonIdentifier"); - RegisterSearchResult initialSearchResult = registerSearchService.searchWithPersonIdentifier(eidasData); + RegisterStatusResults initialSearchResult = registerSearchService.searchWithPersonIdentifier(eidasData); int resultCount = initialSearchResult.getResultCount(); if (resultCount == 0) { step6CountrySpecificSearch(executionContext, initialSearchResult.getOperationStatus(), eidasData); @@ -160,7 +160,7 @@ public class InitialSearchTask extends AbstractAuthServletTask { throws EaafStorageException, WorkflowException { log.trace("Starting 'step6CountrySpecificSearch' ... "); - RegisterSearchResult countrySpecificResult = registerSearchService.searchWithCountrySpecifics( + RegisterStatusResults countrySpecificResult = registerSearchService.searchWithCountrySpecifics( registerOperationStatus, eidasData); if (countrySpecificResult.getResultCount() == 0) { log.trace("'step6CountrySpecificSearch' ends with no result. Forward to next matching step ... "); @@ -184,7 +184,7 @@ public class InitialSearchTask extends AbstractAuthServletTask { RegisterOperationStatus registerOperationStatus, SimpleEidasData eidasData) throws EaafStorageException, WorkflowException { log.trace("Starting step8RegisterSearchWithMds"); - RegisterSearchResult registerData = registerSearchService.searchWithMds(registerOperationStatus, eidasData); + RegisterStatusResults registerData = registerSearchService.searchWithMds(registerOperationStatus, eidasData); if (registerData.getResultCount() == 0) { log.debug("Matching step: 'step8RegisterSearchWithMds' has no result. Forward to create new ERnP entry ... "); @@ -202,7 +202,7 @@ public class InitialSearchTask extends AbstractAuthServletTask { - private void foundMatchFinializeTask(RegisterSearchResult searchResult, SimpleEidasData eidasData) + private void foundMatchFinializeTask(RegisterStatusResults searchResult, SimpleEidasData eidasData) throws WorkflowException, EaafStorageException { // check if register update is required RegisterResult updatedResult = step3CheckRegisterUpdateNecessary(searchResult.getResult(), eidasData); diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveAustrianResidenceGuiResponseTask.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveAustrianResidenceGuiResponseTask.java index b71d86c8..83fdf771 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveAustrianResidenceGuiResponseTask.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveAustrianResidenceGuiResponseTask.java @@ -39,7 +39,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.InvalidUserInp 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.service.RegisterSearchService; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService.RegisterSearchResult; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService.RegisterStatusResults; 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.EaafStorageException; @@ -126,9 +126,9 @@ public class ReceiveAustrianResidenceGuiResponseTask extends AbstractAuthServlet try { SimpleEidasData eidasData = MatchingTaskUtils.getInitialEidasData(pendingReq); - RegisterSearchResult initialSearchResult = MatchingTaskUtils.getIntermediateMatchingResult(pendingReq); + RegisterStatusResults initialSearchResult = MatchingTaskUtils.getIntermediateMatchingResult(pendingReq); - RegisterSearchResult residencyResult = + RegisterStatusResults residencyResult = registerSearchService.searchWithResidence(initialSearchResult.getOperationStatus(), eidasData, input.zipcode, input.city, input.street); if (residencyResult.getResultCount() == 0) { @@ -155,7 +155,7 @@ public class ReceiveAustrianResidenceGuiResponseTask extends AbstractAuthServlet } private void compareSearchResultWithInitialData(ExecutionContext executionContext, - RegisterSearchResult residencyResult, SimpleEidasData eidasData) + RegisterStatusResults residencyResult, SimpleEidasData eidasData) throws TaskExecutionException, EaafStorageException { try { /*TODO: check 'equalsRegisterData' because this method maybe this method evaluate to an invalid result. diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseTask.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseTask.java index e0b05892..d43a175f 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseTask.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseTask.java @@ -56,7 +56,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient.IdAustri import at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient.provider.IdAustriaClientAuthCredentialProvider; import at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient.provider.IdAustriaClientAuthMetadataProvider; import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService.RegisterSearchResult; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService.RegisterStatusResults; import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.MatchingTaskUtils; import at.gv.egiz.eaaf.core.api.data.PvpAttributeDefinitions; import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; @@ -161,7 +161,7 @@ public class ReceiveMobilePhoneSignatureResponseTask extends AbstractAuthServlet // load already existing information from session SimpleEidasData eidasData = MatchingTaskUtils.getInitialEidasData(pendingReq); - RegisterSearchResult initialSearchResult = MatchingTaskUtils.getIntermediateMatchingResult(pendingReq); + RegisterStatusResults initialSearchResult = MatchingTaskUtils.getIntermediateMatchingResult(pendingReq); // extract user information from ID Austria authentication AssertionAttributeExtractor extractor = new AssertionAttributeExtractor(processedMsg.getFirst().getResponse()); @@ -175,7 +175,7 @@ public class ReceiveMobilePhoneSignatureResponseTask extends AbstractAuthServlet } // search entry in initial search result from steps before and build new RegisterSearchResult - RegisterSearchResult registerResult = new RegisterSearchResult(initialSearchResult.getOperationStatus(), + RegisterStatusResults registerResult = new RegisterStatusResults(initialSearchResult.getOperationStatus(), extractEntriesByBpk(initialSearchResult.getResultsZmr().stream(), simpleMobileSignatureData.getBpk()), extractEntriesByBpk(initialSearchResult.getResultsErnp().stream(), simpleMobileSignatureData.getBpk())); diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/utils/MatchingTaskUtils.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/utils/MatchingTaskUtils.java index ae4dfb30..c2392a79 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/utils/MatchingTaskUtils.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/utils/MatchingTaskUtils.java @@ -7,7 +7,7 @@ import org.springframework.lang.NonNull; 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; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService.RegisterSearchResult; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService.RegisterStatusResults; import at.gv.egiz.eaaf.core.api.IRequest; import at.gv.egiz.eaaf.core.exceptions.EaafStorageException; import at.gv.egiz.eaaf.core.impl.idp.auth.data.AuthProcessDataWrapper; @@ -48,9 +48,9 @@ public class MatchingTaskUtils { * @return Intermediate matching result or <code>null</code> if not exist */ @Nullable - public static RegisterSearchResult getIntermediateMatchingResult(IRequest pendingReq) { + public static RegisterStatusResults getIntermediateMatchingResult(IRequest pendingReq) { return getAuthProcessDataWrapper(pendingReq).getGenericDataFromSession(Constants.DATA_INTERMEDIATE_RESULT, - RegisterSearchResult.class); + RegisterStatusResults.class); } @@ -62,7 +62,7 @@ public class MatchingTaskUtils { * @throws EaafStorageException In case of data can not be add into session */ @Nullable - public static void storeIntermediateMatchingResult(IRequest pendingReq, RegisterSearchResult registerData) + public static void storeIntermediateMatchingResult(IRequest pendingReq, RegisterStatusResults registerData) throws EaafStorageException { getAuthProcessDataWrapper(pendingReq).setGenericDataToSession( Constants.DATA_INTERMEDIATE_RESULT, registerData); diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/zmr/DummyZmrClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/zmr/DummyZmrClient.java deleted file mode 100644 index b39281c2..00000000 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/zmr/DummyZmrClient.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2020 A-SIT Plus GmbH - * AT-specific eIDAS Connector has been developed in a cooperation between EGIZ, - * A-SIT Plus GmbH, A-SIT, and Graz University of Technology. - * - * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "License"); - * You may not use this work except in compliance with the License. - * You may obtain a copy of the License at: - * https://joinup.ec.europa.eu/news/understanding-eupl-v12 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This product combines work with different licenses. See the "NOTICE" text - * file for details on the various modules and licenses. - * The "NOTICE" text file is part of the distribution. Any derivative works - * that you distribute must include a readable copy of the "NOTICE" text file. - */ - -package at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr; - -import java.math.BigInteger; -import java.util.Collections; - -import org.springframework.stereotype.Service; - -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; -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("ZmrClientForeIDAS") -public class DummyZmrClient implements IZmrClient { - - @Override - public ZmrRegisterResult searchWithPersonIdentifier(BigInteger zmrProzessId, String personIdentifier, - String citizenCountryCode) { - return new ZmrRegisterResult(Collections.emptyList(), null); - - } - - @Override - public ZmrRegisterResult searchWithMds(BigInteger zmrProzessId, String givenName, String familyName, - String dateOfBirth, String countryCode) { - //TODO will I only receive matches where all three values match perfectly? - return new ZmrRegisterResult(Collections.emptyList(), null); - - } - - @Override - public ZmrRegisterResult searchCountrySpecific(BigInteger zmrProzessId, PersonSuchenRequest personSearchDao, - String citizenCountryCode) throws EidasSAuthenticationException { - return new ZmrRegisterResult(Collections.emptyList(), null); - - } - - @Override - public void update(BigInteger zmrProzessId, RegisterResult registerResult, SimpleEidasData eidData) { - //TODO - } - - @Override - public ZmrRegisterResult searchWithBpkZp(BigInteger zmrProzessId, String bpkzp) { - //TODO - return new ZmrRegisterResult(Collections.emptyList(), null); - } - - @Override - public ZmrRegisterResult searchWithResidenceData(BigInteger zmrProzessId, String givenName, String familyName, - String dateOfBirth, String zipcode, String city, String street) { - // TODO - return new ZmrRegisterResult(Collections.emptyList(), null); - } - - -} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java index bb732f1c..cca94188 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java @@ -80,7 +80,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.CountrySpecificD import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.GenericEidProcessor; import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.ICcSpecificEidProcessingService; import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService.RegisterSearchResult; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService.RegisterStatusResults; import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.InitialSearchTask; import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.MatchingTaskUtils; import at.gv.bmi.namespace.zmr_su.zmr._20040201.PersonSuchenRequest; @@ -196,6 +196,8 @@ public class InitialSearchTaskTest { new IllegalStateException("CountrySpecific search search should not be neccessary")); Mockito.when(zmrClient.searchWithMds(any(), any(), any(), any(), any())).thenThrow( new IllegalStateException("MDS search should not be neccessary")); + Mockito.when(zmrClient.update(any(), any(), any())).thenThrow( + new IllegalStateException("ZMR update should not be neccessary")); // execute test task.execute(pendingReq, executionContext); @@ -422,7 +424,9 @@ public class InitialSearchTaskTest { .build()), generateRandomProcessId())); Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_DE)).thenReturn(Collections.emptyList()); - + Mockito.when(zmrClient.update(any(), any(), any())).thenThrow( + new IllegalStateException("ZMR update should not be neccessary")); + // execute test task.execute(pendingReq, executionContext); @@ -443,20 +447,31 @@ public class InitialSearchTaskTest { .setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response); BigInteger zmrProcessId = generateRandomProcessId(); + RegisterResult zmrResult = RegisterResult.builder() + .bpk(randomBpk) + .pseudonym(Arrays.asList(randomPsydonym)) + .givenName(randomGivenName) + .familyName(randomFamilyName) + .dateOfBirth(randomBirthDate) + .placeOfBirth(randomPlaceOfBirth) + .birthName(randomBirthName) + .build(); Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPsydonym, DE)).thenReturn( new ZmrRegisterResult(Collections.emptyList(), zmrProcessId)); Mockito.when(zmrClient.searchCountrySpecific(eq(zmrProcessId), any(PersonSuchenRequest.class), eq(DE))).thenReturn( - new ZmrRegisterResult(Collections.singletonList( - RegisterResult.builder() + new ZmrRegisterResult(Collections.singletonList(zmrResult) + ,zmrProcessId)); + Mockito.when(zmrClient.update(eq(zmrProcessId), eq(zmrResult) , any())).thenReturn( + new ZmrRegisterResult(Collections.singletonList(RegisterResult.builder() .bpk(randomBpk) - .pseudonym(Arrays.asList(randomPsydonym)) + .pseudonym(Arrays.asList(randomPsydonym, RandomStringUtils.randomAlphanumeric(10))) .givenName(randomGivenName) .familyName(randomFamilyName) .dateOfBirth(randomBirthDate) .placeOfBirth(randomPlaceOfBirth) .birthName(randomBirthName) - .build()) - ,zmrProcessId)); + .build()) + ,zmrProcessId)); Mockito.when(zmrClient.searchWithMds(any(), any(), any(), any(), any())).thenThrow( new IllegalStateException("MDS search should not be neccessary")); @@ -541,9 +556,12 @@ public class InitialSearchTaskTest { new ZmrRegisterResult(Collections.emptyList(), zmrProcessId)); Mockito.when(zmrClient.searchWithMds(zmrProcessId, randomGivenName, randomFamilyName, randomBirthDate, EE)).thenReturn( new ZmrRegisterResult(Collections.emptyList(), zmrProcessId)); + Mockito.when(zmrClient.update(any(), any(), any())).thenThrow( + new IllegalStateException("ZMR update should not be neccessary")); Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_EE)).thenReturn(Collections.emptyList()); + // execute task task.execute(pendingReq, executionContext); @@ -608,8 +626,6 @@ public class InitialSearchTaskTest { BigInteger zmrProcessId = generateRandomProcessId(); Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPsydonym, DE)).thenReturn( new ZmrRegisterResult(Collections.emptyList(), zmrProcessId)); - Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_DE)).thenReturn(Collections.emptyList()); - Mockito.when(zmrClient.searchWithMds(zmrProcessId, randomGivenName, randomFamilyName, randomBirthDate, DE)).thenReturn( new ZmrRegisterResult(Collections.singletonList(RegisterResult.builder() .bpk(randomBpk) @@ -619,7 +635,12 @@ public class InitialSearchTaskTest { .dateOfBirth(randomBirthDate) .build()), zmrProcessId)); - + Mockito.when(zmrClient.update(any(), any(), any())).thenThrow( + new IllegalStateException("ZMR update should not be neccessary")); + + Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_DE)).thenReturn(Collections.emptyList()); + + // execute test task.execute(pendingReq, executionContext); @@ -649,7 +670,9 @@ public class InitialSearchTaskTest { .dateOfBirth(randomBirthDate) .build()), zmrProcessId)); - + Mockito.when(zmrClient.update(any(), any(), any())).thenThrow( + new IllegalStateException("ZMR update should not be neccessary")); + Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_DE)).thenReturn(Collections.emptyList()); Mockito.when(ernpClient.searchWithMds(randomGivenName, randomFamilyName, randomBirthDate)).thenReturn( Arrays.asList( @@ -712,7 +735,7 @@ public class InitialSearchTaskTest { assertNull("Find final matching data but no match sould be found", MatchingTaskUtils.getFinalMatchingResult(pendingReq)); - RegisterSearchResult result = MatchingTaskUtils.getIntermediateMatchingResult(pendingReq); + RegisterStatusResults result = MatchingTaskUtils.getIntermediateMatchingResult(pendingReq); assertNotNull("Find no intermediate matching data", result); assertEquals("wrong intermediate result size", resultSize, result.getResultCount()); diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskTest.java index 77c49bb4..25a77cce 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskTest.java @@ -41,7 +41,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.ManualFixNecessaryException; import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService; import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService.RegisterOperationStatus; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService.RegisterSearchResult; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService.RegisterStatusResults; import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.ReceiveAustrianResidenceGuiResponseTask; import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.ReceiveAustrianResidenceGuiResponseTask.UserInput; import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.MatchingTaskUtils; @@ -99,7 +99,7 @@ public class ReceiveAustrianResidenceGuiResponseTaskTest { public void noRegisterResult() throws Exception { UserInput userInput = setupUserInput(); SimpleEidasData eidasData = setupEidasData(); - RegisterSearchResult registerSearchResult = buildEmptyResult(); + RegisterStatusResults registerSearchResult = buildEmptyResult(); mockRegisterSearch(userInput, registerSearchResult, eidasData); MatchingTaskUtils.storeIntermediateMatchingResult(pendingReq, registerSearchResult); @@ -112,7 +112,7 @@ public class ReceiveAustrianResidenceGuiResponseTaskTest { public void exactlyOneRegisterResult_Matching() throws Exception { UserInput userInput = setupUserInput(); SimpleEidasData eidasData = setupEidasData(); - RegisterSearchResult registerSearchResult = buildResultWithOneMatch(buildMatchingRegisterResult(eidasData)); + RegisterStatusResults registerSearchResult = buildResultWithOneMatch(buildMatchingRegisterResult(eidasData)); MatchingTaskUtils.storeIntermediateMatchingResult(pendingReq, registerSearchResult); mockRegisterSearch(userInput, registerSearchResult, eidasData); @@ -127,7 +127,7 @@ public class ReceiveAustrianResidenceGuiResponseTaskTest { public void exactlyOneRegisterResult_NotMatching() throws Exception { UserInput userInput = setupUserInput(); SimpleEidasData eidasData = setupEidasData(); - RegisterSearchResult registerSearchResult = buildResultWithOneMatch(buildNotMatchingRegisterResult(eidasData)); + RegisterStatusResults registerSearchResult = buildResultWithOneMatch(buildNotMatchingRegisterResult(eidasData)); MatchingTaskUtils.storeIntermediateMatchingResult(pendingReq, registerSearchResult); mockRegisterSearch(userInput, registerSearchResult, eidasData); @@ -140,7 +140,7 @@ public class ReceiveAustrianResidenceGuiResponseTaskTest { public void moreThanOneRegisterResult() throws Exception { UserInput userInput = setupUserInput(); SimpleEidasData eidasData = setupEidasData(); - RegisterSearchResult registerSearchResult = buildResultWithTwoMatches(); + RegisterStatusResults registerSearchResult = buildResultWithTwoMatches(); MatchingTaskUtils.storeIntermediateMatchingResult(pendingReq, registerSearchResult); mockRegisterSearch(userInput, registerSearchResult, eidasData); @@ -152,14 +152,14 @@ public class ReceiveAustrianResidenceGuiResponseTaskTest { assertNull("Transition To S16", executionContext.get(Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_TASK)); } - private void mockRegisterSearch(UserInput userInput, RegisterSearchResult registerSearchResult, SimpleEidasData eidasData ) { + private void mockRegisterSearch(UserInput userInput, RegisterStatusResults registerSearchResult, SimpleEidasData eidasData ) { Mockito.when(registerSearchService.searchWithResidence(eq(registerSearchResult.getOperationStatus()), eq(eidasData), eq(userInput.getZipcode()), eq(userInput.getCity()), eq(userInput.getStreet()))).thenReturn(registerSearchResult); } @NotNull - private RegisterSearchResult buildEmptyResult() { - return new RegisterSearchResult(new RegisterOperationStatus(generateRandomProcessId()), + private RegisterStatusResults buildEmptyResult() { + return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId()), Collections.emptyList(), Collections.emptyList()); } @@ -170,16 +170,16 @@ public class ReceiveAustrianResidenceGuiResponseTaskTest { } @NotNull - private RegisterSearchResult buildResultWithOneMatch(RegisterResult registerResult) { - return new RegisterSearchResult(new RegisterOperationStatus(generateRandomProcessId()), + private RegisterStatusResults buildResultWithOneMatch(RegisterResult registerResult) { + return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId()), Collections.singletonList(registerResult), Collections.emptyList()); } @NotNull - private RegisterSearchResult buildResultWithTwoMatches() { + private RegisterStatusResults buildResultWithTwoMatches() { List<RegisterResult> results = Lists.newArrayList(buildRandomRegisterResult(), buildRandomRegisterResult()); - return new RegisterSearchResult(new RegisterOperationStatus(generateRandomProcessId()), + return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId()), results, Collections.emptyList()); } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveMobilePhoneSignatureResponseTaskTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveMobilePhoneSignatureResponseTaskTest.java index 51077e96..b072b8b2 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveMobilePhoneSignatureResponseTaskTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveMobilePhoneSignatureResponseTaskTest.java @@ -54,7 +54,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient.provider import at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient.provider.IdAustriaClientAuthMetadataProvider; import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService; import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService.RegisterOperationStatus; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService.RegisterSearchResult; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService.RegisterStatusResults; import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.ReceiveMobilePhoneSignatureResponseTask; import at.asitplus.eidas.specific.modules.auth.eidas.v2.test.dummy.DummyOA; import at.asitplus.eidas.specific.modules.auth.eidas.v2.test.dummy.DummyPendingRequest; @@ -342,7 +342,7 @@ public class ReceiveMobilePhoneSignatureResponseTaskTest { AuthProcessDataWrapper authProcessData = pendingReq.getSessionData(AuthProcessDataWrapper.class); SimpleEidasData eidData = createEidasDataMatchingToSamlResponse().build(); authProcessData.setGenericDataToSession(Constants.DATA_SIMPLE_EIDAS, eidData); - RegisterSearchResult registerSearchResult = new RegisterSearchResult(new RegisterOperationStatus(generateRandomProcessId()), + RegisterStatusResults registerSearchResult = new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId()), Collections.emptyList(), Collections.emptyList()); MatchingTaskUtils.storeIntermediateMatchingResult(pendingReq, registerSearchResult); @@ -362,7 +362,7 @@ public class ReceiveMobilePhoneSignatureResponseTaskTest { AuthProcessDataWrapper authProcessData = pendingReq.getSessionData(AuthProcessDataWrapper.class); SimpleEidasData eidData = createEidasDataMatchingToSamlResponse().build(); authProcessData.setGenericDataToSession(Constants.DATA_SIMPLE_EIDAS, eidData); - RegisterSearchResult registerSearchResult = buildResultWithOneMatch(); + RegisterStatusResults registerSearchResult = buildResultWithOneMatch(); MatchingTaskUtils.storeIntermediateMatchingResult(pendingReq, registerSearchResult); task.execute(pendingReq, executionContext); @@ -403,8 +403,8 @@ public class ReceiveMobilePhoneSignatureResponseTaskTest { } @NotNull - private RegisterSearchResult buildResultWithOneMatch() { - return new RegisterSearchResult(new RegisterOperationStatus(generateRandomProcessId()), + private RegisterStatusResults buildResultWithOneMatch() { + return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId()), Collections.singletonList(RegisterResult.builder() .bpk(BPK_FROM_ID_AUSTRIA) .pseudonym(Arrays.asList("bar")) @@ -417,7 +417,7 @@ public class ReceiveMobilePhoneSignatureResponseTaskTest { } @NotNull - private RegisterSearchResult buildResultWithTwoMatches() { + private RegisterStatusResults buildResultWithTwoMatches() { List<RegisterResult> results = Lists.newArrayList( RegisterResult.builder() .bpk(BPK_FROM_ID_AUSTRIA) @@ -434,7 +434,7 @@ public class ReceiveMobilePhoneSignatureResponseTaskTest { .dateOfBirth("dateOfBirth") .build()); - return new RegisterSearchResult(new RegisterOperationStatus(generateRandomProcessId()), + return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId()), results, Collections.emptyList()); } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_1.properties b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_1.properties index 266c78bb..f5895f76 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_1.properties +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_1.properties @@ -97,7 +97,7 @@ eidas.ms.auth.eIDAS.node_v2.attributes.requested.representation.5=LegalName,true # ZMR communication eidas.ms.auth.eIDAS.zmrclient.endpoint=http://localhost:1234/demoszr eidas.ms.auth.eIDAS.zmrclient.req.organisation.behoerdennr=jUnit123456 - +eidas.ms.auth.eIDAS.zmrclient.req.update.reason.code=EIDAS-KITT ## PVP2 S-Profile end-point configuration diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_1_springboot.properties b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_1_springboot.properties index 640138d8..294d340f 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_1_springboot.properties +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_1_springboot.properties @@ -54,7 +54,8 @@ eidas.ms.auth.eIDAS.zmrclient.ssl.trustStore.path= eidas.ms.auth.eIDAS.zmrclient.ssl.trustStore.password= eidas.ms.auth.eIDAS.zmrclient.req.organisation.behoerdennr=jUnit123456 - +eidas.ms.auth.eIDAS.zmrclient.req.update.reason.code=EIDAS-KITT +eidas.ms.auth.eIDAS.zmrclient.req.update.reason.text=KITT for eIDAS Matching ## PVP2 S-Profile end-point configuration diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_2.properties b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_2.properties index c3cec434..f07f86f6 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_2.properties +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_2.properties @@ -90,6 +90,7 @@ eidas.ms.auth.eIDAS.node_v2.attributes.requested.representation.5=LegalName,true # ZMR communication eidas.ms.auth.eIDAS.zmrclient.endpoint=http://localhost:1234/demoszr eidas.ms.auth.eIDAS.zmrclient.req.organisation.behoerdennr=jUnit123456 +eidas.ms.auth.eIDAS.zmrclient.req.update.reason.code=EIDAS-KITT ## PVP2 S-Profile end-point configuration diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_3.properties b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_3.properties index 3cd9fcb4..7b975752 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_3.properties +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_3.properties @@ -92,6 +92,7 @@ eidas.ms.auth.eIDAS.node_v2.attributes.requested.representation.5=LegalName,true # ZMR communication eidas.ms.auth.eIDAS.zmrclient.endpoint=http://localhost:1234/demoszr eidas.ms.auth.eIDAS.zmrclient.req.organisation.behoerdennr=jUnit123456 +eidas.ms.auth.eIDAS.zmrclient.req.update.reason.code=EIDAS-KITT ## PVP2 S-Profile end-point configuration diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_4.properties b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_4.properties index 82f9a798..7fda2871 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_4.properties +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_4.properties @@ -90,6 +90,7 @@ eidas.ms.auth.eIDAS.node_v2.attributes.requested.representation.5=LegalName,true # ZMR communication eidas.ms.auth.eIDAS.zmrclient.endpoint=http://localhost:1234/demoszr eidas.ms.auth.eIDAS.zmrclient.req.organisation.behoerdennr=jUnit123456 +eidas.ms.auth.eIDAS.zmrclient.req.update.reason.code=EIDAS-KITT ## PVP2 S-Profile end-point configuration diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_de_attributes.properties b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_de_attributes.properties index 5261aef9..0cdb4459 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_de_attributes.properties +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_de_attributes.properties @@ -92,6 +92,7 @@ eidas.ms.auth.eIDAS.node_v2.attributes.requested.representation.5=LegalName,true # ZMR communication eidas.ms.auth.eIDAS.zmrclient.endpoint=http://localhost:1234/demoszr eidas.ms.auth.eIDAS.zmrclient.req.organisation.behoerdennr=jUnit123456 +eidas.ms.auth.eIDAS.zmrclient.req.update.reason.code=EIDAS-KITT ## PVP2 S-Profile end-point configuration |