diff options
3 files changed, 52 insertions, 42 deletions
diff --git a/eidas_modules/authmodule-eIDAS-v2/pom.xml b/eidas_modules/authmodule-eIDAS-v2/pom.xml index a3d855bd..5f7edef0 100644 --- a/eidas_modules/authmodule-eIDAS-v2/pom.xml +++ b/eidas_modules/authmodule-eIDAS-v2/pom.xml @@ -137,12 +137,9 @@ <groupId>com.fasterxml.jackson.datatype</groupId> <artifactId>jackson-datatype-jsr310</artifactId> </dependency> - <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> - <version>2.11.2</version> - <scope>compile</scope> </dependency> <dependency> <groupId>org.openapitools</groupId> 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 45a4010b..66fec9dc 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 @@ -17,6 +17,7 @@ import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.annotation.PostConstruct; +import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.apache.http.client.HttpClient; import org.springframework.beans.factory.annotation.Autowired; @@ -34,6 +35,8 @@ import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestTemplate; import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult; @@ -43,6 +46,7 @@ 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.Aendern; 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.Anlegen; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ernp.model.AnlegenResponse; 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; @@ -206,37 +210,39 @@ public class ErnpRestClient implements IErnpClient { throw new EidasSAuthenticationException(ERROR_MATCHING_99, new Object[] { e.getMessage() }, e); } } - + @Override public ErnpRegisterResult searchCountrySpecific(PersonSuchenRequest personSearchDao, String citizenCountryCode) throws EidasSAuthenticationException { - try { + String countrySearchMsg = MessageFormat.format(PROCESS_SEARCH_COUNTRY_SPECIFIC, citizenCountryCode); + + 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.setBegruendung(countrySearchMsg); personSuchen.setSuchdaten(mapCountrySpecificSearchData(personSearchDao)); // request ERnP - log.trace("Requesting ERnP for '{}' operation", PROCESS_SEARCH_COUNTRY_SPECIFIC); + log.trace("Requesting ERnP for '{}' operation", countrySearchMsg); 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); + return processErnpResponse(resp, citizenCountryCode, false, countrySearchMsg); } catch (RestClientException e) { - log.warn(LOGMSG_ERNP_ERROR, PROCESS_SEARCH_COUNTRY_SPECIFIC, e.getMessage()); + log.warn(LOGMSG_ERNP_ERROR, countrySearchMsg, 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()); + log.warn(LOGMSG_ERNP_RESP_PROCESS, countrySearchMsg, e.getMessage()); throw new EidasSAuthenticationException(ERROR_MATCHING_99, new Object[] { e.getMessage() }, e); } @@ -268,14 +274,14 @@ public class ErnpRestClient implements IErnpClient { } } catch (RestClientException e) { - log.warn(LOGMSG_ERNP_ERROR, PROCESS_SEARCH_COUNTRY_SPECIFIC, e.getMessage()); + log.warn(LOGMSG_ERNP_ERROR, PROCESS_KITT_GENERAL, 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()); + log.warn(LOGMSG_ERNP_RESP_PROCESS, PROCESS_KITT_GENERAL, e.getMessage()); throw new EidasSAuthenticationException(ERROR_MATCHING_99, new Object[] { e.getMessage() }, e); } @@ -454,7 +460,12 @@ public class ErnpRestClient implements IErnpClient { ernpReq.setVersion(ernpPersonToKitt.getVersion()); // add new eIDAS attributes - eidasDocumentToAdd.stream().forEach(el -> ernpReq.getAnlegen().addEidasItem(el)); + if (!eidasDocumentToAdd.isEmpty()) { + log.debug("Find eIDAS Documents to update. Injection update entries into ERnP request ... "); + ernpReq.setAnlegen(new Anlegen()); + eidasDocumentToAdd.stream().forEach(el -> ernpReq.getAnlegen().addEidasItem(el)); + + } // update MDS if required if (mdsToUpdate != null) { @@ -545,10 +556,11 @@ public class ErnpRestClient implements IErnpClient { // build search request final Suchdaten searchInfos = new Suchdaten(); + searchInfos.setBpkZp(registerResult.getBpk()); searchInfos.setFamilienname(registerResult.getFamilyName()); searchInfos.setVorname(registerResult.getGivenName()); - searchInfos.setGeburtsdatum(buildErnpBirthday(registerResult.getDateOfBirth())); - + searchInfos.setGeburtsdatum(buildErnpBirthday(registerResult.getDateOfBirth())); + final PersonSuchen personSuchen = new PersonSuchen(); personSuchen.setSuchoptionen(generateSearchParameters()); personSuchen.setBegruendung(PROCESS_KITT_IDENITIES_GET); @@ -600,28 +612,16 @@ public class ErnpRestClient implements IErnpClient { private SimpleEidasData selectMdsInformationToUpdate(Person ernpPersonToKitt, SimpleEidasData eidData) { PersonendatenErgebnis person = ernpPersonToKitt.getPersonendaten(); - SimpleEidasDataBuilder builder = SimpleEidasData.builder(); + SimpleEidasDataBuilder builder = SimpleEidasData.builder() + .givenName(eidData.getGivenName()) + .familyName(eidData.getFamilyName()) + .dateOfBirth(eidData.getDateOfBirth()); - boolean findMismatch = false; - if (!person.getVorname().equals(eidData.getGivenName())) { - findMismatch = true; - builder.givenName(eidData.getGivenName()); - - } - - if (!person.getFamilienname().equals(eidData.getFamilyName())) { - findMismatch = true; - builder.familyName(eidData.getFamilyName()); - - } - - if (!getTextualBirthday(person.getGeburtsdatum()).equals(eidData.getDateOfBirth())) { - findMismatch = true; - builder.dateOfBirth(eidData.getDateOfBirth()); - - } + boolean findMatch = person.getVorname().equals(eidData.getGivenName()) + && person.getFamilienname().equals(eidData.getFamilyName()) + && getTextualBirthday(person.getGeburtsdatum()).equals(eidData.getDateOfBirth()); + return findMatch ? null : builder.build(); - return findMismatch ? builder.build() : null; } private Aendern generateMdsChangeRequest(Person ernpPersonToKitt, SimpleEidasData mdsToUpdate) { @@ -771,8 +771,10 @@ public class ErnpRestClient implements IErnpClient { private HttpMessageConverter<?> buildCustomJacksonObjectMapper() { final MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); converter.setSupportedMediaTypes(Collections.singletonList(MediaType.APPLICATION_JSON)); - converter.getObjectMapper() - .setSerializationInclusion(Include.NON_NULL); + converter.getObjectMapper().setSerializationInclusion(Include.NON_NULL); + + converter.getObjectMapper().registerModule(new JavaTimeModule()); + converter.getObjectMapper().configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); return converter; } @@ -793,9 +795,9 @@ public class ErnpRestClient implements IErnpClient { // TODO: opimize errorHandling based on response info's from real ERnP List<String> serverId = response.getHeaders().getOrEmpty(ERNP_RESPONSE_HEADER_SERVER_ID); - log.warn("Receive http-error: {} from ERnP with serverTransactionId", + log.warn("Receive http-error: {} from ERnP with serverTransactionId {}", response.getRawStatusCode(), serverId.isEmpty() ? "'not set'" : serverId.get(0)); - + log.warn(" Full ERnP response-body: {}", IOUtils.toString(response.getBody(), "UTF-8")); throw new ErnpRestCommunicationException(response.getRawStatusCode()); } @@ -43,8 +43,8 @@ <org.slf4j.version>1.7.32</org.slf4j.version> <log4j.version>2.17.1</log4j.version> <ch.qos.logback.version>1.2.10</ch.qos.logback.version> - - <jackson-datatype-jsr310.version>2.13.1</jackson-datatype-jsr310.version> + + <jackson.version>2.13.1</jackson.version> <jackson-databind-nullable.version>0.2.2</jackson-databind-nullable.version> <swagger-parser.version>2.0.29</swagger-parser.version> @@ -374,11 +374,22 @@ <version>${commons-collections4.version}</version> </dependency> <dependency> + <groupId>com.fasterxml.jackson.dataformat</groupId> + <artifactId>jackson-dataformat-yaml</artifactId> + <version>${jackson.version}</version> + </dependency> + <dependency> <groupId>com.fasterxml.jackson.datatype</groupId> <artifactId>jackson-datatype-jsr310</artifactId> - <version>${jackson-datatype-jsr310.version}</version> + <version>${jackson.version}</version> </dependency> <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + <version>${jackson.version}</version> + </dependency> + + <dependency> <groupId>org.openapitools</groupId> <artifactId>jackson-databind-nullable</artifactId> <version>${jackson-databind-nullable.version}</version> |