From 7b2c31e14aa5f4823d970ec6ebd3e134a280f442 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Thu, 3 Mar 2022 15:06:28 +0100 Subject: fix(ernp): fix some problems in ERnP client that we found during tests --- .../auth/eidas/v2/clients/ernp/ErnpRestClient.java | 78 +++++++++++----------- 1 file changed, 38 insertions(+), 40 deletions(-) (limited to 'eidas_modules/authmodule-eIDAS-v2/src') 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 66fec9dc..4c4e3d87 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 @@ -232,7 +232,7 @@ public class ErnpRestClient implements IErnpClient { generic.getClientRequestTime(), generic.getClientRequestId(), personSuchen); // parse ZMR response - return processErnpResponse(resp, citizenCountryCode, false, countrySearchMsg); + return processErnpResponse(resp, citizenCountryCode, true, countrySearchMsg); } catch (RestClientException e) { log.warn(LOGMSG_ERNP_ERROR, countrySearchMsg, e.getMessage()); @@ -289,31 +289,41 @@ public class ErnpRestClient implements IErnpClient { @Override public ErnpRegisterResult add(SimpleEidasData eidData) throws EidasSAuthenticationException { - // build generic request metadata - final GenericRequestParams generic = buildGenericRequestParameters("stepNew"); - - // build update request - PersonAnlegen ernpReq = new PersonAnlegen(); - ernpReq.setBegruendung(PROCESS_ADD_IDENITY); - - // inject person data - Personendaten person = new Personendaten(); - person.setFamilienname(eidData.getFamilyName()); - person.setVorname(eidData.getGivenName()); - person.setGeburtsdatum(buildErnpBirthday(eidData.getDateOfBirth())); - ernpReq.setPersonendaten(person); - - buildNewEidasDocumens(ernpReq, eidData); - - // request ERnP - log.trace("Requesting ERnP for '{}' operation", PROCESS_ADD_IDENITY); - AnlegenResponse ernpResp = ernpClient.anlegen(generic.getClientBehkz(), generic.clientName, - generic.getClientRequestTime(), generic.getClientRequestId(), ernpReq); - log.trace("Receive response from ERnP for '{}' operation", PROCESS_ADD_IDENITY); - - return new ErnpRegisterResult(Arrays.asList( - mapErnpResponseToRegisterResult(ernpResp.getPerson(), eidData.getCitizenCountryCode()))); + try { + // build generic request metadata + final GenericRequestParams generic = buildGenericRequestParameters("stepNew"); + + // build update request + PersonAnlegen ernpReq = new PersonAnlegen(); + ernpReq.setBegruendung(PROCESS_ADD_IDENITY); + + // inject person data + Personendaten person = new Personendaten(); + person.setFamilienname(eidData.getFamilyName()); + person.setVorname(eidData.getGivenName()); + person.setGeburtsdatum(buildErnpBirthday(eidData.getDateOfBirth())); + ernpReq.setPersonendaten(person); + + buildNewEidasDocumens(ernpReq, eidData); + + // request ERnP + log.trace("Requesting ERnP for '{}' operation", PROCESS_ADD_IDENITY); + AnlegenResponse ernpResp = ernpClient.anlegen(generic.getClientBehkz(), generic.clientName, + generic.getClientRequestTime(), generic.getClientRequestId(), ernpReq); + log.trace("Receive response from ERnP for '{}' operation", PROCESS_ADD_IDENITY); + + return new ErnpRegisterResult(Arrays.asList( + mapErnpResponseToRegisterResult(ernpResp.getPerson(), eidData.getCitizenCountryCode()))); + } catch (RestClientException e) { + log.warn(LOGMSG_ERNP_ERROR, PROCESS_ADD_IDENITY, e.getMessage()); + throw new EidasSAuthenticationException(ERROR_MATCHING_11, new Object[] { e.getMessage() }, e); + + } catch (final Exception e) { + log.warn(LOGMSG_ERNP_RESP_PROCESS, PROCESS_ADD_IDENITY, e.getMessage()); + throw new EidasSAuthenticationException(ERROR_MATCHING_99, new Object[] { e.getMessage() }, e); + + } } @Override @@ -629,21 +639,9 @@ public class ErnpRestClient implements IErnpClient { Personendaten person = new Personendaten(); person.setEntityId(ernpPersonToKitt.getPersonendaten().getEntityId()); el.setPersonendaten(person); - - if (StringUtils.isNotEmpty(mdsToUpdate.getFamilyName())) { - person.setFamilienname(mdsToUpdate.getFamilyName()); - - } - - if (StringUtils.isNotEmpty(mdsToUpdate.getGivenName())) { - person.setVorname(mdsToUpdate.getGivenName()); - - } - - if (StringUtils.isNotEmpty(mdsToUpdate.getDateOfBirth())) { - person.setGeburtsdatum(buildErnpBirthday(mdsToUpdate.getDateOfBirth())); - - } + person.setFamilienname(mdsToUpdate.getFamilyName()); + person.setVorname(mdsToUpdate.getGivenName()); + person.setGeburtsdatum(buildErnpBirthday(mdsToUpdate.getDateOfBirth())); return el; } -- cgit v1.2.3