aboutsummaryrefslogtreecommitdiff
path: root/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas
diff options
context:
space:
mode:
authorThomas <>2023-06-07 08:58:57 +0200
committerThomas <>2023-06-07 08:58:57 +0200
commit11520da12531f7484bc716f6c6284f65d4e5c201 (patch)
tree82db4cf22a40b6b2130974b08ecfae1f24bbcc6b /modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas
parenta2b1df739eefaa4babd7f67f905a18127135b94d (diff)
downloadNational_eIDAS_Gateway-11520da12531f7484bc716f6c6284f65d4e5c201.tar.gz
National_eIDAS_Gateway-11520da12531f7484bc716f6c6284f65d4e5c201.tar.bz2
National_eIDAS_Gateway-11520da12531f7484bc716f6c6284f65d4e5c201.zip
feat(ernp): switch to new ERnP REST API v2.0.3(2023) that implements "Meldegesetznovelle 2023)
Diffstat (limited to 'modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas')
-rw-r--r--modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/Constants.java7
-rw-r--r--modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/ErnpRestClient.java36
2 files changed, 38 insertions, 5 deletions
diff --git a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/Constants.java b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/Constants.java
index 5468cd56..778739e2 100644
--- a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/Constants.java
+++ b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/Constants.java
@@ -215,15 +215,18 @@ public class Constants {
+ ".ssl.trustStore.name";
-
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_ERNPCLIENT_API_ADDPERSON_GENDER = CONIG_PROPS_EIDAS_ERNPCLIENT
+ + ".api.person.add.gender";
+ public static final String CONIG_PROPS_EIDAS_ERNPCLIENT_NEW_API_FEATURES = CONIG_PROPS_EIDAS_ERNPCLIENT
+ + ".api.features.2023";
-
+
// SZR Client configuration properties
public static final String CONIG_PROPS_EIDAS_SZRCLIENT =
EidasConstants.CONIG_PROPS_EIDAS_PREFIX + ".szrclient";
diff --git a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/ErnpRestClient.java b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/ErnpRestClient.java
index bbb245f1..a64671ec 100644
--- a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/ErnpRestClient.java
+++ b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/ErnpRestClient.java
@@ -44,6 +44,7 @@ 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 com.google.common.collect.Lists;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ErnpPersonRegisterResult;
@@ -134,6 +135,9 @@ public class ErnpRestClient implements IErnpClient {
private static final String HEADER_PVP_TXID = "pvp-txid";
private static final String HEADER_MSG_NOT_SET = "NOT-set";
+ private static final String HEADER_ERNP_FEATURE_ADDRESS_ARRAY = "Json-Anschrift-Array";
+ private static final String HEADER_ERNP_FEATURE_NEW_DATETIME_FORMAT = "Json-Use-Date-Type";
+
@Autowired
IConfiguration basicConfig;
@Autowired
@@ -319,6 +323,7 @@ public class ErnpRestClient implements IErnpClient {
person.setFamilienname(eidData.getFamilyName());
person.setVorname(eidData.getGivenName());
person.setGeburtsdatum(buildErnpBirthday(eidData.getDateOfBirth()));
+ person.setGeschlecht(buildErnpGenderType());
ernpReq.setPersonendaten(person);
buildNewEidasDocumens(ernpReq, eidData);
@@ -387,6 +392,11 @@ public class ErnpRestClient implements IErnpClient {
}
+ private String buildErnpGenderType() {
+ return basicConfig.getBasicConfiguration(Constants.CONIG_PROPS_EIDAS_ERNPCLIENT_API_ADDPERSON_GENDER);
+
+ }
+
@Nonnull
private ErnpRegisterResult processErnpResponse(SuchenResponse resp, @Nonnull String citizenCountryCode,
boolean forceSinglePersonMatch, @Nonnull String processStepFiendlyname)
@@ -772,8 +782,7 @@ public class ErnpRestClient implements IErnpClient {
}
if (input.getGeschlecht() != null) {
- person.setGeschlecht(
- Personendaten.GeschlechtEnum.fromValue(input.getGeschlecht().getValue()));
+ person.setGeschlecht(input.getGeschlecht());
}
return person;
@@ -894,11 +903,32 @@ public class ErnpRestClient implements IErnpClient {
final RestTemplate springClient = new RestTemplate(requestFactory);
springClient.setErrorHandler(buildErrorHandler());
springClient.getMessageConverters().add(0, buildCustomJacksonObjectMapper());
- springClient.setInterceptors(Collections.singletonList(buildTransactionIdInterceptor()));
+ springClient.setInterceptors(Lists.newArrayList(
+ buildErnpFeatureHeaderInterceptor(),
+ buildTransactionIdInterceptor()));
return springClient;
}
+ private ClientHttpRequestInterceptor buildErnpFeatureHeaderInterceptor() {
+ return new ClientHttpRequestInterceptor() {
+
+ @Override
+ public ClientHttpResponse intercept(HttpRequest request, byte[] body,
+ ClientHttpRequestExecution execution) throws IOException {
+ boolean ernpApi2023Enabled = basicConfig.getBasicConfigurationBoolean(
+ Constants.CONIG_PROPS_EIDAS_ERNPCLIENT_NEW_API_FEATURES, true);
+ if (ernpApi2023Enabled) {
+ log.debug("Injecting HTTP headers to enable new ERnP features ... ");
+ request.getHeaders().add(HEADER_ERNP_FEATURE_ADDRESS_ARRAY, String.valueOf(ernpApi2023Enabled));
+ request.getHeaders().add(HEADER_ERNP_FEATURE_NEW_DATETIME_FORMAT, String.valueOf(ernpApi2023Enabled));
+ }
+
+ return execution.execute(request, body);
+ }
+ };
+ }
+
private ClientHttpRequestInterceptor buildTransactionIdInterceptor() {
return new ClientHttpRequestInterceptor() {