aboutsummaryrefslogtreecommitdiff
path: root/eidas_modules/authmodule-eIDAS-v2/src/main
diff options
context:
space:
mode:
authorThomas <>2022-02-03 15:51:38 +0100
committerThomas <>2022-02-08 09:35:52 +0100
commit8d19a4097a61723950830c79aaee3168785b683b (patch)
tree45f46025e2abeec6264e2fa09d39efc2be0499da /eidas_modules/authmodule-eIDAS-v2/src/main
parentb70915cf52ecb08c881d33e8c65b6256922fc0f4 (diff)
downloadNational_eIDAS_Gateway-8d19a4097a61723950830c79aaee3168785b683b.tar.gz
National_eIDAS_Gateway-8d19a4097a61723950830c79aaee3168785b683b.tar.bz2
National_eIDAS_Gateway-8d19a4097a61723950830c79aaee3168785b683b.zip
feature(ernp): implement 'searchByPersonalIdentifier' as a first test version
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src/main')
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/Constants.java57
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/ErnpRestClient.java374
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/zmr/ZmrSoapClient.java4
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/resources/eidas_v2_auth.beans.xml9
4 files changed, 409 insertions, 35 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 bfb82474..d48d69bf 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
@@ -100,6 +100,31 @@ public class Constants {
public static final String FORWARD_METHOD_POST = "POST";
public static final String FORWARD_METHOD_GET = "GET";
+
+ // Common SSL client configuration
+ public static final String CONIG_PROPS_EIDAS_COMMON_CLIENT = CONIG_PROPS_EIDAS_PREFIX + ".client.common";
+ public static final String CONIG_PROPS_EIDAS_COMMON_CLIENT_SSL_KEYSTORE_PATH = CONIG_PROPS_EIDAS_COMMON_CLIENT
+ + ".ssl.keyStore.path";
+ public static final String CONIG_PROPS_EIDAS_COMMON_CLIENT_SSL_KEYSTORE_PASSWORD = CONIG_PROPS_EIDAS_COMMON_CLIENT
+ + ".ssl.keyStore.password";
+ public static final String CONIG_PROPS_EIDAS_COMMON_CLIENT_SSL_KEYSTORE_TYPE = CONIG_PROPS_EIDAS_COMMON_CLIENT
+ + ".ssl.keyStore.type";
+ public static final String CONIG_PROPS_EIDAS_COMMON_CLIENT_SSL_KEYSTORE_NAME = CONIG_PROPS_EIDAS_COMMON_CLIENT
+ + ".ssl.keyStore.name";
+ public static final String CONIG_PROPS_EIDAS_COMMON_CLIENT_SSL_KEYS_ALIAS = CONIG_PROPS_EIDAS_COMMON_CLIENT
+ + ".ssl.key.alias";
+ public static final String CONIG_PROPS_EIDAS_COMMON_CLIENT_SSL_KEY_PASSWORD = CONIG_PROPS_EIDAS_COMMON_CLIENT
+ + ".ssl.key.password";
+ public static final String CONIG_PROPS_EIDAS_COMMON_CLIENT_SSL_TRUSTSTORE_PATH = CONIG_PROPS_EIDAS_COMMON_CLIENT
+ + ".ssl.trustStore.path";
+ public static final String CONIG_PROPS_EIDAS_COMMON_CLIENT_SSL_TRUSTSTORE_PASSWORD = CONIG_PROPS_EIDAS_COMMON_CLIENT
+ + ".ssl.trustStore.password";
+ public static final String CONIG_PROPS_EIDAS_COMMON_CLIENT_SSL_TRUSTSTORE_TYPE = CONIG_PROPS_EIDAS_COMMON_CLIENT
+ + ".ssl.trustStore.type";
+ public static final String CONIG_PROPS_EIDAS_COMMON_CLIENT_SSL_TRUSTSTORE_NAME = CONIG_PROPS_EIDAS_COMMON_CLIENT
+ + ".ssl.trustStore.name";
+
+
// ZMR Client configuration properties
public static final String CONIG_PROPS_EIDAS_ZMRCLIENT = CONIG_PROPS_EIDAS_PREFIX + ".zmrclient";
public static final String CONIG_PROPS_EIDAS_ZMRCLIENT_ENDPOINT = CONIG_PROPS_EIDAS_ZMRCLIENT
@@ -110,6 +135,12 @@ public class Constants {
+ ".timeout.connection";
public static final String CONIG_PROPS_EIDAS_ZMRCLIENT_TIMEOUT_RESPONSE = CONIG_PROPS_EIDAS_ZMRCLIENT
+ ".timeout.response";
+ 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";
public static final String CONIG_PROPS_EIDAS_ZMRCLIENT_SSL_KEYSTORE_PATH = CONIG_PROPS_EIDAS_ZMRCLIENT
+ ".ssl.keyStore.path";
public static final String CONIG_PROPS_EIDAS_ZMRCLIENT_SSL_KEYSTORE_PASSWORD = CONIG_PROPS_EIDAS_ZMRCLIENT
@@ -130,15 +161,21 @@ public class Constants {
+ ".ssl.trustStore.type";
public static final String CONIG_PROPS_EIDAS_ZMRCLIENT_SSL_TRUSTSTORE_NAME = CONIG_PROPS_EIDAS_ZMRCLIENT
+ ".ssl.trustStore.name";
-
- public static final String CONIG_PROPS_EIDAS_ZMRCLIENT_REQ_ORGANIZATION_NR = CONIG_PROPS_EIDAS_ZMRCLIENT
+
+ // ErnP Client configuration properties
+ public static final String CONIG_PROPS_EIDAS_ERNPCLIENT = CONIG_PROPS_EIDAS_PREFIX + ".ernpclient";
+ public static final String CONIG_PROPS_EIDAS_ERNPCLIENT_ENDPOINT = CONIG_PROPS_EIDAS_ERNPCLIENT
+ + ".endpoint";
+ public static final String CONIG_PROPS_EIDAS_ERNPCLIENT_DEBUG_TRACEMESSAGES = CONIG_PROPS_EIDAS_ERNPCLIENT
+ + ".debug.logfullmessages";
+ public static final String CONIG_PROPS_EIDAS_ERNPCLIENT_TIMEOUT_CONNECTION = CONIG_PROPS_EIDAS_ERNPCLIENT
+ + ".timeout.connection";
+ public static final String CONIG_PROPS_EIDAS_ERNPCLIENT_TIMEOUT_RESPONSE = CONIG_PROPS_EIDAS_ERNPCLIENT
+ + ".timeout.response";
+ public static final String CONIG_PROPS_EIDAS_ERNPCLIENT_REQ_ORGANIZATION_NR = CONIG_PROPS_EIDAS_ERNPCLIENT
+ ".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
public static final String CONIG_PROPS_EIDAS_SZRCLIENT = CONIG_PROPS_EIDAS_PREFIX + ".szrclient";
public static final String CONIG_PROPS_EIDAS_SZRCLIENT_USETESTSERVICE = CONIG_PROPS_EIDAS_SZRCLIENT
@@ -255,8 +292,10 @@ public class Constants {
public static final String SZR_SCHEMA_LOCATIONS =
"urn:SZRServices" + " " + "/szr_client/szr.xsd";
- // Default values for SZR communication
+ // Default values for SZR / ZMR / ERnP communication
public static final String SZR_CONSTANTS_DEFAULT_DOCUMENT_TYPE = "ELEKTR_DOKUMENT";
+ public static final String CLIENT_INFO = "eIDAS MS-Connector v{0}";
+
// AuthBlock
public static final String SZR_AUTHBLOCK = "authData_AUTHBLOCK";
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 7763fc9d..a651385f 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
@@ -1,13 +1,62 @@
package at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp;
+import java.io.IOException;
+import java.text.MessageFormat;
+import java.time.OffsetDateTime;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+import javax.annotation.Nonnull;
+import javax.annotation.PostConstruct;
+
+import org.apache.http.client.HttpClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.client.ClientHttpRequestFactory;
+import org.springframework.http.client.ClientHttpResponse;
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
+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.web.client.ResponseErrorHandler;
+import org.springframework.web.client.RestTemplate;
+
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
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.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.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;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ernp.model.SuchenResponse;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ernp.model.Suchoptionen;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ernp.model.Suchoptionen.HistorischEnum;
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.utils.VersionHolder;
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;
+import at.gv.egiz.eaaf.core.exceptions.EaafException;
+import at.gv.egiz.eaaf.core.impl.credential.EaafKeyStoreFactory;
+import at.gv.egiz.eaaf.core.impl.http.HttpClientConfiguration;
+import at.gv.egiz.eaaf.core.impl.http.HttpClientConfiguration.ClientAuthMode;
+import at.gv.egiz.eaaf.core.impl.http.IHttpClientFactory;
+import at.gv.egiz.eaaf.core.impl.utils.TransactionIdUtils;
import lombok.AllArgsConstructor;
+import lombok.Builder;
import lombok.Getter;
+import lombok.extern.slf4j.Slf4j;
/**
* Implements an ERnP client that uses REST API for communication.
@@ -15,51 +64,344 @@ import lombok.Getter;
* @author tlenz
*
*/
+@Slf4j
public class ErnpRestClient implements IErnpClient {
- @AllArgsConstructor
- @Getter
- public static class ErnpRegisterResult {
- private final List<RegisterResult> personResult;
-
- }
+ 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";
+
+ private static final String LOGMSG_ERNP_ERROR =
+ "Receive an error from ERnP during '{}' operation with msg: {}";
+ private static final String LOGMSG_ERNP_RESP_PROCESS =
+ "Proces ERnP response during '{}' operation failes with msg: {}";
+
+ private static final String LOGMSG_ERNP_SOAP_ERROR =
+ "ERnP anwser for transaction: {0} with code: {1} and message: {2}";
+
+ private static final String PROCESS_SEARCH_PERSONAL_IDENTIFIER =
+ "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 {0} 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 FRIENDLYNAME_HTTP_CLIENT = "ERnP Client";
+
+ private static final String PATTERN_BIRTHDAY_STRING = "{0}-{1}-{2}";
+
+
+ @Autowired IConfiguration basicConfig;
+ @Autowired EaafKeyStoreFactory keyStoreFactory;
+ @Autowired IHttpClientFactory httpClientFactory;
+ @Autowired VersionHolder versionHolder;
+
+ private DefaultApi ernpClient;
+
@Override
public ErnpRegisterResult searchWithPersonIdentifier(String personIdentifier, String citizenCountryCode)
throws EidasSAuthenticationException {
- // TODO Auto-generated method stub
- return null;
- }
+
+ try {
+
+ // build generic request metadata
+ GenericRequestParams generic = buildGenericRequestParameters("step1");
+ // build search request
+ SuchEidas eidasInfos = new SuchEidas();
+ eidasInfos.setArt(Constants.eIDAS_ATTRURN_PERSONALIDENTIFIER);
+ eidasInfos.setWert(personIdentifier);
+ eidasInfos.setStaatscode2(citizenCountryCode);
+
+ PersonSuchen personSuchen = new PersonSuchen();
+ personSuchen.setSuchoptionen(generateSearchParameters());
+ personSuchen.setBegruendung(PROCESS_SEARCH_PERSONAL_IDENTIFIER);
+ Suchdaten searchInfos = new Suchdaten();
+ searchInfos.setEidas(eidasInfos);
+ personSuchen.setSuchdaten(searchInfos);
+
+ // request ERnP
+ log.trace("Requesting ERnP for '{}' operation", PROCESS_SEARCH_PERSONAL_IDENTIFIER);
+ SuchenResponse resp = ernpClient.suchen(generic.getClientBehkz(), generic.clientName,
+ generic.getClientRequestTime(), generic.getClientRequestId(), personSuchen);
+
+ // parse ZMR response
+ return processErnpResponse(resp, citizenCountryCode, true, PROCESS_SEARCH_PERSONAL_IDENTIFIER);
+
+ } catch (EidasSAuthenticationException e) {
+ throw e;
+
+ } catch (Exception e) {
+ log.warn(LOGMSG_ERNP_RESP_PROCESS, PROCESS_SEARCH_PERSONAL_IDENTIFIER, e.getMessage());
+ throw new EidasSAuthenticationException(ERROR_MATCHING_99, new Object[] { e.getMessage() }, e);
+ }
+
+ }
+
@Override
public ErnpRegisterResult searchWithMds(String givenName, String familyName, String dateOfBirth,
String citizenCountryCode) throws EidasSAuthenticationException {
- // TODO Auto-generated method stub
- return null;
+ return new ErnpRegisterResult(Collections.emptyList());
}
@Override
public ErnpRegisterResult searchCountrySpecific(PersonSuchenRequest personSearchDao,
String citizenCountryCode) throws EidasSAuthenticationException {
- // TODO Auto-generated method stub
- return null;
+ return new ErnpRegisterResult(Collections.emptyList());
}
@Override
public ErnpRegisterResult update(RegisterResult registerResult, SimpleEidasData eidData)
throws EidasSAuthenticationException {
- // TODO Auto-generated method stub
- return null;
+ return new ErnpRegisterResult(Collections.emptyList());
}
@Override
public ErnpRegisterResult searchWithResidenceData(String givenName, String familyName, String dateOfBirth,
String zipcode, String city, String street) {
+ return new ErnpRegisterResult(Collections.emptyList());
+ }
+
+ @PostConstruct
+ private void initialize() throws EaafException {
+ // set-up the Ernp client
+ ernpClient = new DefaultApi(new ApiClient(buildRestClient()));
+
+ // validate additional Ernp communication parameters
+ valdiateAdditionalConfigParameters();
+
+ }
+
+ private void valdiateAdditionalConfigParameters() {
// TODO Auto-generated method stub
- return null;
+
+ }
+
+ private Suchoptionen generateSearchParameters() {
+ Suchoptionen options = new Suchoptionen();
+ options.setZmr(false);
+ options.setHistorisch(HistorischEnum.AKTUELLUNDHISTORISCH);
+ options.setSucheMitNamensteilen(false);
+ options.setSuchwizard(false);
+ return options;
+
+ }
+
+ @Nonnull
+ private ErnpRegisterResult processErnpResponse(SuchenResponse resp, @Nonnull String citizenCountryCode,
+ boolean forceSinglePersonMatch, @Nonnull String processStepFiendlyname) throws EaafAuthenticationException {
+ if (resp.getPerson() == null
+ || resp.getPerson().isEmpty()) {
+ log.debug("ERnP result contains NO 'Person' or 'Person' is empty");
+ return new ErnpRegisterResult(Collections.emptyList());
+
+ } else {
+ log.debug("Get #{} person results from '{}' operation",
+ resp.getPerson().size(), processStepFiendlyname);
+
+ if (forceSinglePersonMatch) {
+ return new ErnpRegisterResult(processSearchPersonResponseSingleResult(
+ resp.getPerson(), citizenCountryCode, processStepFiendlyname));
+
+ } else {
+ return new ErnpRegisterResult(processSearchPersonResponse(
+ resp.getPerson(), citizenCountryCode));
+
+ }
+ }
+ }
+
+ @Nonnull
+ private List<RegisterResult> processSearchPersonResponse(
+ @Nonnull List<Person> list,
+ @Nonnull String citizenCountryCode) throws EaafAuthenticationException {
+ return list.stream()
+ .map(el -> mapErnpResponseToRegisterResult(el, citizenCountryCode))
+ .filter(Objects::nonNull)
+ .collect(Collectors.toList());
+
}
+ @NonNull
+ private List<RegisterResult> processSearchPersonResponseSingleResult(
+ @Nonnull List<Person> persons,
+ @Nonnull String citizenCountryCode, String processStepFiendlyname) throws EaafAuthenticationException {
+ if (persons.size() > 1) {
+ log.error("Find more-than-one ERnP entry with search criteria that has to be unique");
+ throw new WorkflowException(processStepFiendlyname,
+ "Find more-than-one ERnP entry with search criteria that has to be unique", true);
+
+ } else {
+ return Arrays.asList(mapErnpResponseToRegisterResult(persons.get(0), citizenCountryCode));
+
+ }
+ }
+
+ @Nonnull
+ private RegisterResult mapErnpResponseToRegisterResult(@Nonnull Person person,
+ @Nonnull String citizenCountryCode) {
+ // build result
+ return RegisterResult.builder()
+ .pseudonym(selectAllEidasDocument(person, citizenCountryCode,
+ Constants.eIDAS_ATTRURN_PERSONALIDENTIFIER))
+ .familyName(person.getPersonendaten().getFamilienname())
+ .givenName(person.getPersonendaten().getVorname())
+ .dateOfBirth(buildTextualBirthday(person.getPersonendaten().getGeburtsdatum()))
+ .bpk(person.getPersonendaten().getBpkZp())
+ .placeOfBirth(selectSingleEidasDocument(person, citizenCountryCode,
+ Constants.eIDAS_ATTRURN_PLACEOFBIRTH))
+ .birthName(selectSingleEidasDocument(person, citizenCountryCode,
+ Constants.eIDAS_ATTRURN_BIRTHNAME))
+ .build();
+
+ }
+
+ private String buildTextualBirthday(PartialDate geburtsdatum) {
+ return MessageFormat.format(PATTERN_BIRTHDAY_STRING,
+ geburtsdatum.getJahr(), geburtsdatum.getMonat(), geburtsdatum.getTag());
+
+ }
+
+ /**
+ * Get all eIDAS document with the specified country code and document type.
+ *
+ * @param person Person information from ERnP
+ * @param citizenCountryCode Country code of the eIDAS attribute
+ * @param eidasAttrurnPersonalidentifier eIDAS attribute identifier
+ * @return {@link List} of eIDAS attribute values or an empty list if's not
+ * found
+ */
+ @NonNull
+ private List<String> selectAllEidasDocument(Person person, String citizenCountryCode,
+ String eidasAttrurnPersonalidentifier) {
+ return person.getEidas().stream()
+ .filter(el -> eidasAttrurnPersonalidentifier.equals(el.getArt())
+ && el.getStaatscode2().equals(citizenCountryCode))
+ .map(el -> el.getWert())
+ .collect(Collectors.toList());
+
+ }
+
+ /**
+ * Get the first eIDAS document with the specified country code and document
+ * type.
+ *
+ * @param person Person information from ERnP
+ * @param citizenCountryCode Country code of the eIDAS attribute
+ * @param eidasAttrurnPersonalidentifier eIDAS attribute identifier
+ * @return Value of this eIDAS attribute or <code>null</code> if's not found
+ */
+ @Nullable
+ private String selectSingleEidasDocument(Person person, String citizenCountryCode,
+ String eidasAttrurnPersonalidentifier) {
+ return person.getEidas().stream()
+ .filter(el -> eidasAttrurnPersonalidentifier.equals(el.getArt())
+ && el.getStaatscode2().equals(citizenCountryCode))
+ .findFirst()
+ .map(el -> el.getWert())
+ .orElse(null);
+
+ }
+
+ private RestTemplate buildRestClient() throws EaafException {
+ log.debug("Building REST-Client for ERnP communication ... ");
+ final HttpClient httpClient = httpClientFactory.getHttpClient(buildHttpClientConfiguration());
+ final ClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
+ final RestTemplate springClient = new RestTemplate(requestFactory);
+ springClient.setErrorHandler(buildErrorHandler());
+ springClient.getMessageConverters().add(0, buildCustomJacksonObjectMapper());
+ return springClient;
+
+ }
+
+ private HttpMessageConverter<?> buildCustomJacksonObjectMapper() {
+ MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
+ ObjectMapper objectMapper = new ObjectMapper();
+ objectMapper.setSerializationInclusion(Include.NON_NULL);
+ converter.setObjectMapper(objectMapper);
+ return converter;
+
+ }
+
+ @Nonnull
+ private ResponseErrorHandler buildErrorHandler() {
+ return new ResponseErrorHandler() {
+
+ @Override
+ public boolean hasError(ClientHttpResponse response) throws IOException {
+ return response.getStatusCode().is4xxClientError()
+ || response.getStatusCode().is5xxServerError();
+
+ }
+
+ @Override
+ public void handleError(ClientHttpResponse response) throws IOException {
+ //TODO: implement errorHandling based on response infos
+
+ 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());
+
+ }
+ }
+ };
+ }
+ @Nonnull
+ private HttpClientConfiguration buildHttpClientConfiguration() throws EaafException {
+ final HttpClientConfiguration config = new HttpClientConfiguration(FRIENDLYNAME_HTTP_CLIENT);
+ config.setAuthMode(ClientAuthMode.SSL.getMode());
+
+ // Set keystore configuration
+ config.buildKeyStoreConfig(
+ basicConfig.getBasicConfiguration(Constants.CONIG_PROPS_EIDAS_COMMON_CLIENT_SSL_KEYSTORE_TYPE),
+ basicConfig.getBasicConfiguration(Constants.CONIG_PROPS_EIDAS_COMMON_CLIENT_SSL_KEYSTORE_PATH),
+ basicConfig.getBasicConfiguration(Constants.CONIG_PROPS_EIDAS_COMMON_CLIENT_SSL_KEYSTORE_PASSWORD),
+ basicConfig.getBasicConfiguration(Constants.CONIG_PROPS_EIDAS_COMMON_CLIENT_SSL_KEYSTORE_NAME));
+ // Set key information
+ config.setSslKeyAlias(
+ basicConfig.getBasicConfiguration(Constants.CONIG_PROPS_EIDAS_COMMON_CLIENT_SSL_KEYS_ALIAS));
+ config.setSslKeyPassword(
+ basicConfig.getBasicConfiguration(Constants.CONIG_PROPS_EIDAS_COMMON_CLIENT_SSL_KEY_PASSWORD));
+
+ // Set connection parameters
+ //TODO: update EAAF-components to allow custom HTTP Connection-Timeouts
+
+ return config;
+ }
+
+
+ @AllArgsConstructor
+ @Getter
+ public static class ErnpRegisterResult {
+ private final List<RegisterResult> personResult;
+
+ }
+
+ private GenericRequestParams buildGenericRequestParameters(String operationIdentifier) {
+ return GenericRequestParams.builder()
+ .clientBehkz(basicConfig.getBasicConfiguration(Constants.CONIG_PROPS_EIDAS_ZMRCLIENT_REQ_ORGANIZATION_NR))
+ .clientName(MessageFormat.format(Constants.CLIENT_INFO, versionHolder.getVersion()))
+ .clientRequestTime(OffsetDateTime.now())
+ .clientRequestId(TransactionIdUtils.getTransactionId() + "_" + operationIdentifier)
+ .build();
+
+ }
+
+ @Builder
+ @Getter
+ private static class GenericRequestParams {
+ String clientBehkz;
+ String clientName;
+ OffsetDateTime clientRequestTime;
+ String clientRequestId;
+
+ }
}
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 711226e2..432df9ef 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
@@ -100,7 +100,6 @@ public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient {
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";
@@ -429,7 +428,7 @@ public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient {
clientInfo.setOrganisation(clientOrganisation);
// set client information
- clientInfo.setClient(MessageFormat.format(CLIENT_INFO, versionHolder.getVersion()));
+ clientInfo.setClient(MessageFormat.format(Constants.CLIENT_INFO, versionHolder.getVersion()));
// set Behoerdennummer as organization identifier
clientOrganisation.setBehoerdenNr(basicConfig.getBasicConfiguration(
@@ -465,7 +464,6 @@ public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient {
return new ZmrRegisterResult(Collections.emptyList(), extractZmrProcessId(resp.getWorkflowInfoServer()));
} else {
- // TODO: what we to with ERnP results?
log.debug("Get #{} person results from '{}' operation",
searchPersonResp.getPersonensuchergebnis().getGefundeneSaetze(), processStepFiendlyname);
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/resources/eidas_v2_auth.beans.xml b/eidas_modules/authmodule-eIDAS-v2/src/main/resources/eidas_v2_auth.beans.xml
index d82ccec5..40e63a91 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/main/resources/eidas_v2_auth.beans.xml
+++ b/eidas_modules/authmodule-eIDAS-v2/src/main/resources/eidas_v2_auth.beans.xml
@@ -26,13 +26,8 @@
<bean id="zmrAddressClient"
class="at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.zmr.ZmrAddressSoapClient" />
- <!-- bean id="ZmrClientForeIDAS"
- class="at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.DummyZmrClient" /-->
-
-
- <bean id="ErnbClientForeIDAS"
- class="at.asitplus.eidas.specific.modules.auth.eidas.v2.ernp.DummyErnpClient" />
-
+ <bean id="ernpClient"
+ class="at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.ErnpRestClient" />
<bean id="eIDASAuthModule"
class="at.asitplus.eidas.specific.modules.auth.eidas.v2.EidasAuthenticationModulImpl">