From feaa0a61527f0eb29ce33fb9e1aa1ddb0703779d Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Wed, 2 Feb 2022 18:01:06 +0100 Subject: feature(ernp): generate ERnP client from openAPI specification --- connector/pom.xml | 1 + eidas_modules/authmodule-eIDAS-v2/pom.xml | 48 +- .../main/resources/wsdl/ernp_client/openapi.json | 1886 ++++++++++++++++++++ pom.xml | 25 +- 4 files changed, 1956 insertions(+), 4 deletions(-) create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/main/resources/wsdl/ernp_client/openapi.json diff --git a/connector/pom.xml b/connector/pom.xml index dff75c08..6f67091c 100644 --- a/connector/pom.xml +++ b/connector/pom.xml @@ -156,6 +156,7 @@ at.gv.egiz.eaaf eaaf_module_pvp2_sp test + test-jar at.asitplus.eidas.ms_specific.modules diff --git a/eidas_modules/authmodule-eIDAS-v2/pom.xml b/eidas_modules/authmodule-eIDAS-v2/pom.xml index 5a24b67f..3ee16b0c 100644 --- a/eidas_modules/authmodule-eIDAS-v2/pom.xml +++ b/eidas_modules/authmodule-eIDAS-v2/pom.xml @@ -144,6 +144,16 @@ 2.11.2 compile + + org.openapitools + jackson-databind-nullable + + + + io.swagger.parser.v3 + swagger-parser + + org.bitbucket.b_c jose4j @@ -229,6 +239,9 @@ target/generated-sources/cxf + + target/generated-sources/swagger + @@ -262,7 +275,7 @@ - generate-sources + generate-sources-soap generate-sources ${project.build.directory}/generated/cxf @@ -302,6 +315,39 @@ + + org.openapitools + openapi-generator-maven-plugin + + + generate-sources-json + generate-sources + + false + false + ${project.basedir}/src/main/resources/wsdl/ernp_client/openapi.json + java + ${project.build.directory}/generated/swagger + at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ernp.api + at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ernp.model + at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ernp.invoker + + at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp + true + at.asitplus.eidas.specific.modules.auth.eidas.v2 + true + java8 + jackson + resttemplate + + + + generate + + + + + com.github.spotbugs spotbugs-maven-plugin diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/resources/wsdl/ernp_client/openapi.json b/eidas_modules/authmodule-eIDAS-v2/src/main/resources/wsdl/ernp_client/openapi.json new file mode 100644 index 00000000..c8276f3a --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/resources/wsdl/ernp_client/openapi.json @@ -0,0 +1,1886 @@ +{ + "openapi" : "3.0.1", + "info" : { + "title" : "ERNP", + "version" : "1.0.0" + }, + "servers" : [ { + "url" : "https://stportal.bmi.intra.gv.at/at.gv.bmi.erpsrv-p/srv/rest/", + "description" : "Produktion", + "variables" : { } + }, { + "url" : "https://stportal.bmi.intra.gv.at/at.gv.bmi.erpsrv-e/srv/rest/", + "description" : "Entwicklung", + "variables" : { } + }, { + "url" : "https://stportal.bmi.intra.gv.at/at.gv.bmi.erpsrv-t/srv/rest/", + "description" : "Interne Test", + "variables" : { } + }, { + "url" : "https://stportal.bmi.intra.gv.at/at.gv.bmi.erpsrv-a/srv/rest/", + "description" : "Externe Test", + "variables" : { } + }, { + "url" : "https://stportal.bmi.intra.gv.at/at.gv.bmi.erpsrv-b/srv/rest/", + "description" : "Businespartner Test", + "variables" : { } + }, { + "url" : "http://localhost:29200/at.gv.bmi.erpv01-d/srv/rest/", + "description" : "Lokal", + "variables" : { } + }, { + "url" : "http://localhost:29200/at.gv.bmi.erpv01-e/srv/rest/", + "description" : "Entwicklung (kein Portal)", + "variables" : { } + }, { + "url" : "http://localhost:29200/at.gv.bmi.erpv01-t/srv/rest/", + "description" : "Interne Test (kein Portal)", + "variables" : { } + }, { + "url" : "http://localhost:29200/at.gv.bmi.erpv01-a/srv/rest/", + "description" : "Externe Test (kein Portal)", + "variables" : { } + }, { + "url" : "http://localhost:29200/at.gv.bmi.erpv11-a/srv/rest/", + "description" : "Businespartner Test (kein Portal)", + "variables" : { } + } ], + "paths" : { + "/eidas/person/aendern" : { + "post" : { + "operationId" : "aendern", + "parameters" : [ { + "name" : "Client-Request-Time", + "in" : "header", + "description" : "Client-Requestzeit im ISO-8601 Format mit optionaler Zeitzone (zb '2016-10-27T16:36:08.993')", + "schema" : { + "type" : "string", + "format" : "date-time" + } + }, { + "name" : "Client-Request-Id", + "in" : "header", + "description" : "Client-Request ID (um Systemübergreifende Fehlersuche zu vereinfache)", + "schema" : { + "type" : "string" + } + }, { + "name" : "Client-Behkz", + "in" : "header", + "description" : "Client-Behördenkennzeichen", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "Client-Name", + "in" : "header", + "description" : "Client-Name bzw Applikationskürzel und Version des aufrufenden Systems (zb 'ZMR 3.4.5')", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "requestBody" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/PersonAendern" + } + } + } + }, + "responses" : { + "default" : { + "description" : "Erfolgreicher Response hat Status 200 wenn Responsepayload vorhanden, sonst 204", + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/AendernResponse" + } + } + } + }, + "4XX" : { + "description" : "Client Fehler (kann vom Client behoben werden)", + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Fault" + } + } + } + }, + "5XX" : { + "description" : "Server Fehler (normalerweise nicht vom Client behebbar)", + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Fault" + } + } + } + } + } + } + }, + "/eidas/person/anlegen" : { + "post" : { + "operationId" : "anlegen", + "parameters" : [ { + "name" : "Client-Request-Time", + "in" : "header", + "description" : "Client-Requestzeit im ISO-8601 Format mit optionaler Zeitzone (zb '2016-10-27T16:36:08.993')", + "schema" : { + "type" : "string", + "format" : "date-time" + } + }, { + "name" : "Client-Request-Id", + "in" : "header", + "description" : "Client-Request ID (um Systemübergreifende Fehlersuche zu vereinfache)", + "schema" : { + "type" : "string" + } + }, { + "name" : "Client-Behkz", + "in" : "header", + "description" : "Client-Behördenkennzeichen", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "Client-Name", + "in" : "header", + "description" : "Client-Name bzw Applikationskürzel und Version des aufrufenden Systems (zb 'ZMR 3.4.5')", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "requestBody" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/PersonAnlegen" + } + } + } + }, + "responses" : { + "default" : { + "description" : "Erfolgreicher Response hat Status 200 wenn Responsepayload vorhanden, sonst 204", + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/AnlegenResponse" + } + } + } + }, + "4XX" : { + "description" : "Client Fehler (kann vom Client behoben werden)", + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Fault" + } + } + } + }, + "5XX" : { + "description" : "Server Fehler (normalerweise nicht vom Client behebbar)", + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Fault" + } + } + } + } + } + } + }, + "/eidas/person/suchen" : { + "post" : { + "operationId" : "suchen", + "parameters" : [ { + "name" : "Client-Request-Time", + "in" : "header", + "description" : "Client-Requestzeit im ISO-8601 Format mit optionaler Zeitzone (zb '2016-10-27T16:36:08.993')", + "schema" : { + "type" : "string", + "format" : "date-time" + } + }, { + "name" : "Client-Request-Id", + "in" : "header", + "description" : "Client-Request ID (um Systemübergreifende Fehlersuche zu vereinfache)", + "schema" : { + "type" : "string" + } + }, { + "name" : "Client-Behkz", + "in" : "header", + "description" : "Client-Behördenkennzeichen", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "Client-Name", + "in" : "header", + "description" : "Client-Name bzw Applikationskürzel und Version des aufrufenden Systems (zb 'ZMR 3.4.5')", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "requestBody" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/PersonSuchen" + } + } + } + }, + "responses" : { + "default" : { + "description" : "Erfolgreicher Response hat Status 200 wenn Responsepayload vorhanden, sonst 204", + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/SuchenResponse" + } + } + } + }, + "4XX" : { + "description" : "Client Fehler (kann vom Client behoben werden)", + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Fault" + } + } + } + }, + "5XX" : { + "description" : "Server Fehler (normalerweise nicht vom Client behebbar)", + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Fault" + } + } + } + } + } + } + } + }, + "components" : { + "schemas" : { + "Fault" : { + "required" : [ "message" ], + "type" : "object", + "properties" : { + "message" : { + "type" : "string", + "xml" : { + "name" : "Message" + } + }, + "faultDetails" : { + "$ref" : "#/components/schemas/FaultDetails" + } + }, + "xml" : { + "name" : "Fault" + } + }, + "FaultDetails" : { + "required" : [ "fault" ], + "type" : "object", + "properties" : { + "faultNumber" : { + "type" : "integer", + "format" : "int32", + "xml" : { + "name" : "FaultNumber" + } + }, + "fault" : { + "type" : "array", + "xml" : { + "name" : "Fault" + }, + "items" : { + "$ref" : "#/components/schemas/FaultDetailsEntry" + } + } + } + }, + "FaultDetailsEntry" : { + "type" : "object", + "properties" : { + "key" : { + "type" : "string", + "xml" : { + "attribute" : true + } + }, + "message" : { + "type" : "string", + "xml" : { + "attribute" : true + } + } + } + }, + "AendernResponse" : { + "required" : [ "person" ], + "type" : "object", + "properties" : { + "person" : { + "$ref" : "#/components/schemas/Person" + } + }, + "xml" : { + "name" : "AendernResponse" + } + }, + "AkademischerGrad" : { + "required" : [ "ebene", "kurzerName", "langerName", "stellung" ], + "type" : "object", + "properties" : { + "entityId" : { + "type" : "string", + "xml" : { + "attribute" : true + } + }, + "gueltigAb" : { + "type" : "string", + "format" : "date-time", + "xml" : { + "attribute" : true + } + }, + "gueltigBis" : { + "type" : "string", + "format" : "date-time", + "xml" : { + "attribute" : true + } + }, + "ausgestelltVon" : { + "$ref" : "#/components/schemas/AusgestelltVon" + }, + "ebene" : { + "type" : "string", + "xml" : { + "name" : "Ebene" + }, + "enum" : [ "0", "1", "2", "2/3", "3" ] + }, + "stellung" : { + "type" : "string", + "xml" : { + "name" : "Stellung" + }, + "enum" : [ "Vorangestellt", "Nachgestellt" ] + }, + "langerName" : { + "type" : "string", + "xml" : { + "name" : "LangerName" + } + }, + "kurzerName" : { + "type" : "string", + "xml" : { + "name" : "KurzerName" + } + } + } + }, + "Anschrift" : { + "required" : [ "staat", "strasse", "type" ], + "type" : "object", + "properties" : { + "entityId" : { + "type" : "string", + "xml" : { + "attribute" : true + } + }, + "gueltigAb" : { + "type" : "string", + "format" : "date-time", + "xml" : { + "attribute" : true + } + }, + "gueltigBis" : { + "type" : "string", + "format" : "date-time", + "xml" : { + "attribute" : true + } + }, + "staat" : { + "$ref" : "#/components/schemas/Staat" + }, + "gemeinde" : { + "type" : "string", + "xml" : { + "name" : "Gemeinde" + } + }, + "strasse" : { + "type" : "string", + "xml" : { + "name" : "Strasse" + } + }, + "postleitzahl" : { + "type" : "string", + "xml" : { + "name" : "Postleitzahl" + } + }, + "hausnummer" : { + "type" : "string", + "xml" : { + "name" : "Hausnummer" + } + }, + "adresszusatz" : { + "type" : "string", + "xml" : { + "name" : "Adresszusatz" + } + }, + "stiege" : { + "type" : "string", + "xml" : { + "name" : "Stiege" + } + }, + "tuer" : { + "type" : "string", + "xml" : { + "name" : "Tuer" + } + }, + "kontaktinformationen" : { + "$ref" : "#/components/schemas/Kontaktinformationen" + }, + "type" : { + "type" : "string" + } + }, + "discriminator" : { + "propertyName" : "type" + } + }, + "AnschriftInland" : { + "required" : [ "gemeinde", "hausnummer", "ort", "postleitzahl", "staat", "strasse" ], + "type" : "object", + "allOf" : [ { + "$ref" : "#/components/schemas/Anschrift" + }, { + "type" : "object", + "properties" : { + "adressstatus" : { + "type" : "string", + "xml" : { + "name" : "Adressstatus" + } + }, + "ort" : { + "type" : "string", + "xml" : { + "name" : "Ort" + } + }, + "ortZweisprachig" : { + "type" : "string", + "xml" : { + "name" : "OrtZweisprachig" + } + }, + "postort" : { + "type" : "string", + "xml" : { + "name" : "Postort" + } + }, + "codes" : { + "$ref" : "#/components/schemas/Anschriftcodes" + }, + "auskunftssperre" : { + "type" : "boolean", + "xml" : { + "name" : "Auskunftssperre" + } + }, + "wohnsitzqualitaet" : { + "type" : "string", + "xml" : { + "name" : "Wohnsitzqualitaet" + }, + "enum" : [ "H", "N", "O" ] + } + } + } ] + }, + "AnschriftInlandAgs" : { + "required" : [ "gemeinde", "hausnummer", "ort", "postleitzahl", "staat", "strasse" ], + "type" : "object", + "allOf" : [ { + "$ref" : "#/components/schemas/Anschrift" + }, { + "type" : "object", + "properties" : { + "adressstatus" : { + "type" : "string", + "xml" : { + "name" : "Adressstatus" + } + }, + "ort" : { + "type" : "string", + "xml" : { + "name" : "Ort" + } + }, + "ortZweisprachig" : { + "type" : "string", + "xml" : { + "name" : "OrtZweisprachig" + } + }, + "postort" : { + "type" : "string", + "xml" : { + "name" : "Postort" + } + }, + "codes" : { + "$ref" : "#/components/schemas/Anschriftcodes" + }, + "auskunftssperre" : { + "type" : "boolean", + "xml" : { + "name" : "Auskunftssperre" + } + }, + "wohnsitzqualitaet" : { + "type" : "string", + "xml" : { + "name" : "Wohnsitzqualitaet" + }, + "enum" : [ "H", "N", "O" ] + }, + "detailgrad" : { + "type" : "string", + "xml" : { + "name" : "Detailgrad" + } + }, + "nutzungsartCode" : { + "type" : "string", + "xml" : { + "name" : "NutzungsartCode" + } + }, + "gebaeudeeigenschaft" : { + "type" : "string", + "xml" : { + "name" : "Gebaeudeeigenschaft" + } + } + } + } ] + }, + "Anschriftcodes" : { + "type" : "object", + "properties" : { + "adresscode" : { + "type" : "string", + "xml" : { + "name" : "Adresscode", + "attribute" : true + } + }, + "subcode" : { + "type" : "string", + "xml" : { + "name" : "Subcode", + "attribute" : true + } + }, + "ortskennziffer" : { + "type" : "string", + "xml" : { + "name" : "Ortskennziffer", + "attribute" : true + } + }, + "strassenkennziffer" : { + "type" : "string", + "xml" : { + "name" : "Strassenkennziffer", + "attribute" : true + } + }, + "objektnummer" : { + "type" : "string", + "xml" : { + "name" : "Objektnummer", + "attribute" : true + } + }, + "nutzungseinheitlaufnummer" : { + "type" : "string", + "xml" : { + "name" : "Nutzungseinheitlaufnummer", + "attribute" : true + } + }, + "adrRefkey" : { + "type" : "string", + "xml" : { + "name" : "AdrRefkey", + "attribute" : true + } + }, + "gbrRefkey" : { + "type" : "string", + "xml" : { + "name" : "GbrRefkey", + "attribute" : true + } + }, + "gemeindekennziffer" : { + "type" : "string", + "xml" : { + "name" : "Gemeindekennziffer", + "attribute" : true + } + } + } + }, + "AusgestelltVon" : { + "required" : [ "behoerde", "datum", "staat" ], + "type" : "object", + "properties" : { + "datum" : { + "type" : "string", + "format" : "date-time", + "xml" : { + "name" : "Datum" + } + }, + "behoerde" : { + "type" : "string", + "xml" : { + "name" : "Behoerde" + } + }, + "staat" : { + "$ref" : "#/components/schemas/Staat" + } + } + }, + "Benutzer" : { + "required" : [ "benutzer" ], + "type" : "object", + "properties" : { + "benutzer" : { + "type" : "string", + "xml" : { + "attribute" : true + } + }, + "behoerdenkennzeichen" : { + "type" : "string", + "xml" : { + "attribute" : true + } + } + } + }, + "Eidas" : { + "type" : "object", + "properties" : { + "entityId" : { + "type" : "string", + "xml" : { + "attribute" : true + } + }, + "gueltigAb" : { + "type" : "string", + "format" : "date-time", + "xml" : { + "attribute" : true + } + }, + "gueltigBis" : { + "type" : "string", + "format" : "date-time", + "xml" : { + "attribute" : true + } + }, + "art" : { + "type" : "string", + "xml" : { + "name" : "Art" + } + }, + "wert" : { + "type" : "string", + "xml" : { + "name" : "Wert" + } + }, + "ausstellDatum" : { + "type" : "string", + "format" : "date-time", + "xml" : { + "name" : "AusstellDatum" + } + }, + "ablaufDatum" : { + "type" : "string", + "format" : "date-time", + "xml" : { + "name" : "AblaufDatum" + } + }, + "ausstellBehoerde" : { + "type" : "string", + "xml" : { + "name" : "AusstellBehoerde" + } + }, + "staatscode2" : { + "type" : "string", + "xml" : { + "name" : "Staatscode2" + } + }, + "image" : { + "type" : "array", + "xml" : { + "name" : "Image" + }, + "items" : { + "type" : "string", + "format" : "byte", + "xml" : { + "name" : "Image" + } + } + } + } + }, + "Kontaktinformationen" : { + "type" : "object", + "properties" : { + "firmenname1" : { + "type" : "string", + "xml" : { + "name" : "Firmenname1" + } + }, + "firmenname2" : { + "type" : "string", + "xml" : { + "name" : "Firmenname2" + } + }, + "ansprechpartner" : { + "type" : "string", + "xml" : { + "name" : "Ansprechpartner" + } + }, + "telefon" : { + "type" : "string", + "xml" : { + "name" : "Telefon" + } + }, + "mobil" : { + "type" : "string", + "xml" : { + "name" : "Mobil" + } + }, + "fax" : { + "type" : "string", + "xml" : { + "name" : "Fax" + } + }, + "email" : { + "type" : "string", + "xml" : { + "name" : "Email" + } + }, + "postfach" : { + "type" : "string", + "xml" : { + "name" : "Postfach" + } + } + } + }, + "LetzteOperation" : { + "required" : [ "begruendung", "durchgefuehrtVon" ], + "type" : "object", + "properties" : { + "begruendung" : { + "type" : "string", + "xml" : { + "name" : "Begruendung" + } + }, + "durchgefuehrtVon" : { + "$ref" : "#/components/schemas/Benutzer" + }, + "vorgang" : { + "type" : "string", + "xml" : { + "attribute" : true + } + }, + "zeitpunkt" : { + "type" : "string", + "format" : "date-time", + "xml" : { + "attribute" : true + } + } + } + }, + "PartialDate" : { + "required" : [ "jahr" ], + "type" : "object", + "properties" : { + "jahr" : { + "type" : "integer", + "format" : "int32", + "xml" : { + "attribute" : true + } + }, + "monat" : { + "type" : "integer", + "format" : "int32", + "xml" : { + "attribute" : true + } + }, + "tag" : { + "type" : "integer", + "format" : "int32", + "xml" : { + "attribute" : true + } + } + } + }, + "Person" : { + "required" : [ "letzteOperation", "personendaten", "type" ], + "type" : "object", + "properties" : { + "letzteOperation" : { + "$ref" : "#/components/schemas/LetzteOperation" + }, + "personendaten" : { + "$ref" : "#/components/schemas/PersonendatenErgebnis" + }, + "anschrift" : { + "$ref" : "#/components/schemas/Anschrift" + }, + "akademischerGrad" : { + "type" : "array", + "xml" : { + "name" : "AkademischerGrad" + }, + "items" : { + "$ref" : "#/components/schemas/AkademischerGrad" + } + }, + "reisedokument" : { + "type" : "array", + "xml" : { + "name" : "Reisedokument" + }, + "items" : { + "$ref" : "#/components/schemas/Reisedokument" + } + }, + "sonstigesDokument" : { + "type" : "array", + "xml" : { + "name" : "SonstigesDokument" + }, + "items" : { + "$ref" : "#/components/schemas/SonstigesDokument" + } + }, + "staatsangehoerigkeit" : { + "type" : "array", + "xml" : { + "name" : "Staatsangehoerigkeit" + }, + "items" : { + "$ref" : "#/components/schemas/Staatsangehoerigkeit" + } + }, + "eidas" : { + "type" : "array", + "xml" : { + "name" : "Eidas" + }, + "items" : { + "$ref" : "#/components/schemas/Eidas" + } + }, + "gueltigAb" : { + "type" : "string", + "format" : "date-time", + "xml" : { + "attribute" : true + } + }, + "gueltigBis" : { + "type" : "string", + "format" : "date-time", + "xml" : { + "attribute" : true + } + }, + "entityId" : { + "type" : "string", + "xml" : { + "attribute" : true + } + }, + "version" : { + "type" : "string", + "format" : "date-time", + "xml" : { + "attribute" : true + } + }, + "type" : { + "type" : "string" + } + }, + "discriminator" : { + "propertyName" : "type" + } + }, + "PersonendatenErgebnis" : { + "required" : [ "basiszahl", "familienname", "geburtsdatum", "vorname" ], + "type" : "object", + "properties" : { + "entityId" : { + "type" : "string", + "xml" : { + "attribute" : true + } + }, + "gueltigAb" : { + "type" : "string", + "format" : "date-time", + "xml" : { + "attribute" : true + } + }, + "gueltigBis" : { + "type" : "string", + "format" : "date-time", + "xml" : { + "attribute" : true + } + }, + "familienname" : { + "type" : "string", + "xml" : { + "name" : "Familienname" + } + }, + "nameVorEhe" : { + "type" : "string", + "xml" : { + "name" : "NameVorEhe" + } + }, + "vorname" : { + "type" : "string", + "xml" : { + "name" : "Vorname" + } + }, + "geburtsbundesland" : { + "type" : "string", + "xml" : { + "name" : "Geburtsbundesland" + }, + "enum" : [ "Burgenland", "Kärnten", "Niederösterreich", "Oberösterreich", "Salzburg", "Steiermark", "Tirol", "Vorarlberg", "Wien" ] + }, + "geburtsort" : { + "type" : "string", + "xml" : { + "name" : "Geburtsort" + } + }, + "geburtsstaat" : { + "$ref" : "#/components/schemas/Staat" + }, + "geburtsdatum" : { + "$ref" : "#/components/schemas/PartialDate" + }, + "geschlecht" : { + "type" : "string", + "xml" : { + "name" : "Geschlecht" + }, + "enum" : [ "Männlich", "Weiblich" ] + }, + "basiszahl" : { + "type" : "string", + "xml" : { + "name" : "Basiszahl" + } + }, + "kitquelle" : { + "type" : "string", + "xml" : { + "name" : "Kitquelle" + } + }, + "bpkZp" : { + "type" : "string", + "xml" : { + "name" : "BpkZp" + } + }, + "sterbedatum" : { + "$ref" : "#/components/schemas/PartialDate" + }, + "geprueft" : { + "type" : "boolean", + "xml" : { + "name" : "Geprueft" + } + } + } + }, + "Reisedokument" : { + "required" : [ "art" ], + "type" : "object", + "properties" : { + "entityId" : { + "type" : "string", + "xml" : { + "attribute" : true + } + }, + "gueltigAb" : { + "type" : "string", + "format" : "date-time", + "xml" : { + "attribute" : true + } + }, + "gueltigBis" : { + "type" : "string", + "format" : "date-time", + "xml" : { + "attribute" : true + } + }, + "ausgestelltVon" : { + "$ref" : "#/components/schemas/AusgestelltVon" + }, + "art" : { + "type" : "string", + "xml" : { + "name" : "Art" + }, + "enum" : [ "Asylwerber", "Dienstpass", "Elektronisch", "Fremdenpass", "Konventionspass", "Personalausweis", "Reisepass", "Staatenlos", "Sonstiges" ] + }, + "nummer" : { + "type" : "string", + "xml" : { + "name" : "Nummer" + } + } + } + }, + "SonstigesDokument" : { + "required" : [ "art", "nummer" ], + "type" : "object", + "properties" : { + "entityId" : { + "type" : "string", + "xml" : { + "attribute" : true + } + }, + "gueltigAb" : { + "type" : "string", + "format" : "date-time", + "xml" : { + "attribute" : true + } + }, + "gueltigBis" : { + "type" : "string", + "format" : "date-time", + "xml" : { + "attribute" : true + } + }, + "ausgestelltVon" : { + "$ref" : "#/components/schemas/AusgestelltVon" + }, + "art" : { + "type" : "string", + "xml" : { + "name" : "Art" + }, + "enum" : [ "Führerschein", "Geburtsurkunde", "Heiratsurkunde", "Sonstiges", "Staatsbürgerschaftsnachweis", "Sterbeurkunde", "Todeserklärung" ] + }, + "lichtbildausweis" : { + "type" : "boolean", + "xml" : { + "name" : "Lichtbildausweis" + } + }, + "nummer" : { + "type" : "string", + "xml" : { + "name" : "Nummer" + } + }, + "name" : { + "type" : "string", + "xml" : { + "name" : "Name" + } + } + } + }, + "Staat" : { + "type" : "object", + "properties" : { + "isoCode3" : { + "type" : "string", + "xml" : { + "attribute" : true + } + }, + "name" : { + "type" : "string", + "xml" : { + "attribute" : true + } + } + } + }, + "Staatsangehoerigkeit" : { + "required" : [ "staat" ], + "type" : "object", + "properties" : { + "entityId" : { + "type" : "string", + "xml" : { + "attribute" : true + } + }, + "gueltigAb" : { + "type" : "string", + "format" : "date-time", + "xml" : { + "attribute" : true + } + }, + "gueltigBis" : { + "type" : "string", + "format" : "date-time", + "xml" : { + "attribute" : true + } + }, + "staat" : { + "$ref" : "#/components/schemas/Staat" + } + } + }, + "ZmrPerson" : { + "required" : [ "letzteOperation", "personendaten", "qkz" ], + "type" : "object", + "allOf" : [ { + "$ref" : "#/components/schemas/Person" + }, { + "type" : "object", + "properties" : { + "auskunftssperre" : { + "type" : "boolean", + "xml" : { + "name" : "Auskunftssperre" + } + }, + "qkz" : { + "type" : "array", + "xml" : { + "name" : "Qkz" + }, + "items" : { + "type" : "string" + } + } + } + } ] + }, + "Aendern" : { + "type" : "object", + "properties" : { + "personendaten" : { + "$ref" : "#/components/schemas/Personendaten" + }, + "anschrift" : { + "$ref" : "#/components/schemas/Anschrift" + }, + "akademischerGrad" : { + "type" : "array", + "xml" : { + "name" : "AkademischerGrad" + }, + "items" : { + "$ref" : "#/components/schemas/AkademischerGrad" + } + }, + "reisedokument" : { + "type" : "array", + "xml" : { + "name" : "Reisedokument" + }, + "items" : { + "$ref" : "#/components/schemas/Reisedokument" + } + }, + "sonstigesDokument" : { + "type" : "array", + "xml" : { + "name" : "SonstigesDokument" + }, + "items" : { + "$ref" : "#/components/schemas/SonstigesDokument" + } + }, + "staatsangehoerigkeit" : { + "type" : "array", + "xml" : { + "name" : "Staatsangehoerigkeit" + }, + "items" : { + "$ref" : "#/components/schemas/Staatsangehoerigkeit" + } + }, + "eidas" : { + "type" : "array", + "xml" : { + "name" : "Eidas" + }, + "items" : { + "$ref" : "#/components/schemas/Eidas" + } + } + } + }, + "Anlegen" : { + "type" : "object", + "properties" : { + "anschrift" : { + "$ref" : "#/components/schemas/Anschrift" + }, + "akademischerGrad" : { + "type" : "array", + "xml" : { + "name" : "AkademischerGrad" + }, + "items" : { + "$ref" : "#/components/schemas/AkademischerGrad" + } + }, + "reisedokument" : { + "type" : "array", + "xml" : { + "name" : "Reisedokument" + }, + "items" : { + "$ref" : "#/components/schemas/Reisedokument" + } + }, + "sonstigesDokument" : { + "type" : "array", + "xml" : { + "name" : "SonstigesDokument" + }, + "items" : { + "$ref" : "#/components/schemas/SonstigesDokument" + } + }, + "staatsangehoerigkeit" : { + "type" : "array", + "xml" : { + "name" : "Staatsangehoerigkeit" + }, + "items" : { + "$ref" : "#/components/schemas/Staatsangehoerigkeit" + } + }, + "eidas" : { + "type" : "array", + "xml" : { + "name" : "Eidas" + }, + "items" : { + "$ref" : "#/components/schemas/Eidas" + } + } + } + }, + "Beenden" : { + "type" : "object", + "properties" : { + "entityId" : { + "type" : "array", + "xml" : { + "name" : "EntityId" + }, + "items" : { + "type" : "string", + "xml" : { + "name" : "EntityId" + } + } + } + } + }, + "PersonAendern" : { + "required" : [ "begruendung", "entityId", "version" ], + "type" : "object", + "properties" : { + "begruendung" : { + "type" : "string", + "xml" : { + "name" : "Begruendung" + } + }, + "anlegen" : { + "$ref" : "#/components/schemas/Anlegen" + }, + "aendern" : { + "$ref" : "#/components/schemas/Aendern" + }, + "beenden" : { + "$ref" : "#/components/schemas/Beenden" + }, + "entityId" : { + "type" : "string", + "xml" : { + "attribute" : true + } + }, + "version" : { + "type" : "string", + "format" : "date-time", + "xml" : { + "attribute" : true + } + } + }, + "xml" : { + "name" : "PersonAendern" + } + }, + "Personendaten" : { + "required" : [ "familienname", "geburtsdatum", "vorname" ], + "type" : "object", + "properties" : { + "entityId" : { + "type" : "string", + "xml" : { + "attribute" : true + } + }, + "gueltigAb" : { + "type" : "string", + "format" : "date-time", + "xml" : { + "attribute" : true + } + }, + "gueltigBis" : { + "type" : "string", + "format" : "date-time", + "xml" : { + "attribute" : true + } + }, + "familienname" : { + "type" : "string", + "xml" : { + "name" : "Familienname" + } + }, + "nameVorEhe" : { + "type" : "string", + "xml" : { + "name" : "NameVorEhe" + } + }, + "vorname" : { + "type" : "string", + "xml" : { + "name" : "Vorname" + } + }, + "geburtsbundesland" : { + "type" : "string", + "xml" : { + "name" : "Geburtsbundesland" + }, + "enum" : [ "Burgenland", "Kärnten", "Niederösterreich", "Oberösterreich", "Salzburg", "Steiermark", "Tirol", "Vorarlberg", "Wien" ] + }, + "geburtsort" : { + "type" : "string", + "xml" : { + "name" : "Geburtsort" + } + }, + "geburtsstaat" : { + "$ref" : "#/components/schemas/Staat" + }, + "geburtsdatum" : { + "$ref" : "#/components/schemas/PartialDate" + }, + "geschlecht" : { + "type" : "string", + "xml" : { + "name" : "Geschlecht" + }, + "enum" : [ "Männlich", "Weiblich" ] + } + } + }, + "AnlegenResponse" : { + "required" : [ "person" ], + "type" : "object", + "properties" : { + "person" : { + "$ref" : "#/components/schemas/Person" + } + }, + "xml" : { + "name" : "AnlegenResponse" + } + }, + "PersonAnlegen" : { + "required" : [ "anschrift", "begruendung", "personendaten" ], + "type" : "object", + "properties" : { + "begruendung" : { + "type" : "string", + "xml" : { + "name" : "Begruendung" + } + }, + "personendaten" : { + "$ref" : "#/components/schemas/Personendaten" + }, + "anschrift" : { + "$ref" : "#/components/schemas/Anschrift" + }, + "akademischerGrad" : { + "type" : "array", + "xml" : { + "name" : "AkademischerGrad" + }, + "items" : { + "$ref" : "#/components/schemas/AkademischerGrad" + } + }, + "reisedokument" : { + "type" : "array", + "xml" : { + "name" : "Reisedokument" + }, + "items" : { + "$ref" : "#/components/schemas/Reisedokument" + } + }, + "sonstigesDokument" : { + "type" : "array", + "xml" : { + "name" : "SonstigesDokument" + }, + "items" : { + "$ref" : "#/components/schemas/SonstigesDokument" + } + }, + "staatsangehoerigkeit" : { + "type" : "array", + "xml" : { + "name" : "Staatsangehoerigkeit" + }, + "items" : { + "$ref" : "#/components/schemas/Staatsangehoerigkeit" + } + }, + "eidas" : { + "type" : "array", + "xml" : { + "name" : "Eidas" + }, + "items" : { + "$ref" : "#/components/schemas/Eidas" + } + } + }, + "xml" : { + "name" : "PersonAnlegen" + } + }, + "SuchenResponse" : { + "type" : "object", + "properties" : { + "person" : { + "type" : "array", + "xml" : { + "name" : "Person" + }, + "items" : { + "$ref" : "#/components/schemas/Person" + } + } + }, + "xml" : { + "name" : "SuchenResponse" + } + }, + "PersonSuchen" : { + "required" : [ "begruendung", "suchdaten", "suchoptionen" ], + "type" : "object", + "properties" : { + "begruendung" : { + "type" : "string", + "xml" : { + "name" : "Begruendung" + } + }, + "suchoptionen" : { + "$ref" : "#/components/schemas/Suchoptionen" + }, + "suchdaten" : { + "$ref" : "#/components/schemas/Suchdaten" + } + }, + "xml" : { + "name" : "PersonSuchen" + } + }, + "SuchAnschrift" : { + "type" : "object", + "properties" : { + "staat" : { + "$ref" : "#/components/schemas/Staat" + }, + "gemeinde" : { + "type" : "string", + "xml" : { + "name" : "Gemeinde" + } + }, + "strasse" : { + "type" : "string", + "xml" : { + "name" : "Strasse" + } + }, + "ort" : { + "type" : "string", + "xml" : { + "name" : "Ort" + } + }, + "postleitzahl" : { + "type" : "string", + "xml" : { + "name" : "Postleitzahl" + } + }, + "hausnummer" : { + "type" : "string", + "xml" : { + "name" : "Hausnummer" + } + }, + "adresszusatz" : { + "type" : "string", + "xml" : { + "name" : "Adresszusatz" + } + }, + "stiege" : { + "type" : "string", + "xml" : { + "name" : "Stiege" + } + }, + "tuer" : { + "type" : "string", + "xml" : { + "name" : "Tuer" + } + }, + "postfach" : { + "type" : "string", + "xml" : { + "name" : "Postfach" + } + } + } + }, + "SuchAusgestelltVon" : { + "type" : "object", + "properties" : { + "datum" : { + "type" : "string", + "format" : "date-time", + "xml" : { + "name" : "Datum" + } + }, + "behoerde" : { + "type" : "string", + "xml" : { + "name" : "Behoerde" + } + }, + "staat" : { + "$ref" : "#/components/schemas/Staat" + } + } + }, + "SuchEidas" : { + "type" : "object", + "properties" : { + "art" : { + "type" : "string", + "xml" : { + "name" : "Art" + } + }, + "wert" : { + "type" : "string", + "xml" : { + "name" : "Wert" + } + }, + "ausstellDatum" : { + "type" : "string", + "format" : "date-time", + "xml" : { + "name" : "AusstellDatum" + } + }, + "ablaufDatum" : { + "type" : "string", + "format" : "date-time", + "xml" : { + "name" : "AblaufDatum" + } + }, + "ausstellBehoerde" : { + "type" : "string", + "xml" : { + "name" : "AusstellBehoerde" + } + }, + "staatscode2" : { + "type" : "string", + "xml" : { + "name" : "Staatscode2" + } + } + } + }, + "SuchReisedokument" : { + "type" : "object", + "properties" : { + "art" : { + "type" : "string", + "xml" : { + "name" : "Art" + }, + "enum" : [ "Asylwerber", "Dienstpass", "Elektronisch", "Fremdenpass", "Konventionspass", "Personalausweis", "Reisepass", "Staatenlos", "Sonstiges" ] + }, + "ausgestelltVon" : { + "$ref" : "#/components/schemas/SuchAusgestelltVon" + }, + "nummer" : { + "type" : "string", + "xml" : { + "name" : "Nummer" + } + } + } + }, + "SuchStaatsangehoerigkeit" : { + "type" : "object", + "properties" : { + "staat" : { + "$ref" : "#/components/schemas/Staat" + } + } + }, + "Suchdaten" : { + "required" : [ "familienname", "vorname" ], + "type" : "object", + "properties" : { + "basiszahl" : { + "type" : "string", + "xml" : { + "name" : "Basiszahl" + } + }, + "bpkZp" : { + "type" : "string", + "xml" : { + "name" : "BpkZp" + } + }, + "fremdBpkBmiZp" : { + "type" : "string", + "xml" : { + "name" : "FremdBpkBmiZp" + } + }, + "entityId" : { + "type" : "string", + "xml" : { + "name" : "EntityId" + } + }, + "familienname" : { + "type" : "string", + "xml" : { + "name" : "Familienname" + } + }, + "nameVorEhe" : { + "type" : "string", + "xml" : { + "name" : "NameVorEhe" + } + }, + "vorname" : { + "type" : "string", + "xml" : { + "name" : "Vorname" + } + }, + "geburtsdatum" : { + "$ref" : "#/components/schemas/PartialDate" + }, + "geburtsort" : { + "type" : "string", + "xml" : { + "name" : "Geburtsort" + } + }, + "geburtsstaat" : { + "$ref" : "#/components/schemas/Staat" + }, + "geschlecht" : { + "type" : "string", + "xml" : { + "name" : "Geschlecht" + }, + "enum" : [ "Männlich", "Weiblich" ] + }, + "anschrift" : { + "$ref" : "#/components/schemas/SuchAnschrift" + }, + "reisedokument" : { + "$ref" : "#/components/schemas/SuchReisedokument" + }, + "staatsangehoerigkeit" : { + "$ref" : "#/components/schemas/SuchStaatsangehoerigkeit" + }, + "eidas" : { + "$ref" : "#/components/schemas/SuchEidas" + } + } + }, + "Suchoptionen" : { + "required" : [ "historisch" ], + "type" : "object", + "properties" : { + "historisch" : { + "type" : "string", + "xml" : { + "name" : "Historisch" + }, + "enum" : [ "Aktuell", "AktuellDannHistorisch", "AktuellUndHistorisch" ] + }, + "formalisiert" : { + "type" : "boolean", + "xml" : { + "name" : "Formalisiert" + } + }, + "sucheMitNamensteilen" : { + "type" : "boolean", + "xml" : { + "name" : "SucheMitNamensteilen" + } + }, + "suchwizard" : { + "type" : "boolean", + "xml" : { + "name" : "Suchwizard" + } + }, + "zmr" : { + "type" : "boolean", + "xml" : { + "name" : "Zmr" + } + } + }, + "xml" : { + "name" : "Suchoptionen", + "namespace" : "http://bmi.gv.at/ernp" + } + } + } + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 60996c16..7cc47323 100644 --- a/pom.xml +++ b/pom.xml @@ -28,8 +28,9 @@ 2.5.4 5.3.14 3.0.14.RELEASE - 3.5.0 + 3.5.0 + 2.5.0 3.12.0 @@ -44,12 +45,15 @@ 1.2.10 2.13.1 - + 0.2.2 + 2.0.29 2.0.1.Final 6.1.5.Final 0.7.9 - + + + 5.4.0 2.6.0 @@ -374,6 +378,16 @@ jackson-datatype-jsr310 ${jackson-datatype-jsr310.version} + + org.openapitools + jackson-databind-nullable + ${jackson-databind-nullable.version} + + + io.swagger.parser.v3 + swagger-parser + ${swagger-parser.version} + javax.validation validation-api @@ -635,6 +649,11 @@ + + org.openapitools + openapi-generator-maven-plugin + ${openapi-generator-maven-plugin.version} + -- cgit v1.2.3 From a3d1b2e9aaad4b00031cfcd76e26940697c876c2 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Wed, 2 Feb 2022 18:02:11 +0100 Subject: refactor(ernp): move IErnpClient interface into another package --- .../auth/eidas/v2/clients/ernp/IErnpClient.java | 46 ++++++++++++++++++++++ .../auth/eidas/v2/ernp/DummyErnpClient.java | 1 + .../modules/auth/eidas/v2/ernp/IErnpClient.java | 46 ---------------------- .../eidas/v2/service/RegisterSearchService.java | 2 +- .../AlternativeSearchTaskWithRegisterTest.java | 2 +- .../eidas/v2/test/tasks/InitialSearchTaskTest.java | 2 +- .../tasks/InitialSearchTaskWithRegistersTest.java | 2 +- 7 files changed, 51 insertions(+), 50 deletions(-) create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/IErnpClient.java delete mode 100644 eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/IErnpClient.java diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/IErnpClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/IErnpClient.java new file mode 100644 index 00000000..377048d9 --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/IErnpClient.java @@ -0,0 +1,46 @@ +/* + * 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.clients.ernp; + +import java.util.List; + +import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; + +public interface IErnpClient { + + List searchWithPersonIdentifier(String personIdentifier); + + List searchWithMds(String givenName, String familyName, String dateOfBirth); + + List searchDeSpecific(String givenName, String familyName, String dateOfBirth, + String birthPlace, String birthName); + + List searchItSpecific(String taxNumber); + + RegisterResult update(RegisterResult registerResult, SimpleEidasData eidData); + + List searchWithBpkZp(String bpkzp); + +} 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 77f5e3cd..db10752b 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 @@ -28,6 +28,7 @@ import java.util.List; import org.springframework.stereotype.Service; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.IErnpClient; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; 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 deleted file mode 100644 index b2a9005b..00000000 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/IErnpClient.java +++ /dev/null @@ -1,46 +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.ernp; - -import java.util.List; - -import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; - -public interface IErnpClient { - - List searchWithPersonIdentifier(String personIdentifier); - - List searchWithMds(String givenName, String familyName, String dateOfBirth); - - List searchDeSpecific(String givenName, String familyName, String dateOfBirth, - String birthPlace, String birthName); - - List searchItSpecific(String taxNumber); - - RegisterResult update(RegisterResult registerResult, SimpleEidasData eidData); - - List 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 047d75ae..5f1e96a4 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 @@ -11,11 +11,11 @@ import org.springframework.stereotype.Service; import com.google.common.collect.Streams; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.IErnpClient; 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.ernp.IErnpClient; 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; diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java index 63266cf6..0c6ec95d 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java @@ -49,12 +49,12 @@ import org.springframework.web.context.request.ServletRequestAttributes; import com.github.skjolber.mockito.soap.SoapServiceRule; import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.IErnpClient; 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.MatchedPersonResult; 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.ernp.IErnpClient; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidPostProcessingException; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasAttributeException; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.WorkflowException; 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 e5ba2e07..c14af84c 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 @@ -24,13 +24,13 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.test.tasks; import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.IErnpClient; import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.zmr.IZmrClient; import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.zmr.ZmrSoapClient; import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.zmr.ZmrSoapClient.ZmrRegisterResult; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.MatchedPersonResult; 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.ernp.IErnpClient; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.*; import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.CountrySpecificDetailSearchProcessor; import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.GenericEidProcessor; diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java index 14ad3519..ea84c39c 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java @@ -69,12 +69,12 @@ import org.springframework.web.context.request.ServletRequestAttributes; import com.github.skjolber.mockito.soap.SoapServiceRule; import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.IErnpClient; 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.MatchedPersonResult; 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.ernp.IErnpClient; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidPostProcessingException; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasAttributeException; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasSAuthenticationException; -- cgit v1.2.3 From b70915cf52ecb08c881d33e8c65b6256922fc0f4 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Thu, 3 Feb 2022 15:50:33 +0100 Subject: refactor(ernp): change API of ERnP client to same model as ZMR client --- .../auth/eidas/v2/clients/ernp/ErnpRestClient.java | 65 ++++++++ .../auth/eidas/v2/clients/ernp/IErnpClient.java | 74 ++++++++- .../auth/eidas/v2/ernp/DummyErnpClient.java | 43 ++--- .../eidas/v2/service/RegisterSearchService.java | 30 ++-- .../eidas/v2/test/tasks/InitialSearchTaskTest.java | 185 +++++++++++++-------- 5 files changed, 287 insertions(+), 110 deletions(-) create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/ErnpRestClient.java 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 new file mode 100644 index 00000000..7763fc9d --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/ErnpRestClient.java @@ -0,0 +1,65 @@ +package at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp; + +import java.util.List; + +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; +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * Implements an ERnP client that uses REST API for communication. + * + * @author tlenz + * + */ +public class ErnpRestClient implements IErnpClient { + + @AllArgsConstructor + @Getter + public static class ErnpRegisterResult { + private final List personResult; + + } + + @Override + public ErnpRegisterResult searchWithPersonIdentifier(String personIdentifier, String citizenCountryCode) + throws EidasSAuthenticationException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ErnpRegisterResult searchWithMds(String givenName, String familyName, String dateOfBirth, + String citizenCountryCode) throws EidasSAuthenticationException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ErnpRegisterResult searchCountrySpecific(PersonSuchenRequest personSearchDao, + String citizenCountryCode) throws EidasSAuthenticationException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ErnpRegisterResult update(RegisterResult registerResult, SimpleEidasData eidData) + throws EidasSAuthenticationException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ErnpRegisterResult searchWithResidenceData(String givenName, String familyName, String dateOfBirth, + String zipcode, String city, String street) { + // TODO Auto-generated method stub + return null; + } + + + + +} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/IErnpClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/IErnpClient.java index 377048d9..4c8bcd3e 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/IErnpClient.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/IErnpClient.java @@ -23,24 +23,80 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp; -import java.util.List; +import javax.annotation.Nonnull; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.ErnpRestClient.ErnpRegisterResult; 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; public interface IErnpClient { - List searchWithPersonIdentifier(String personIdentifier); + /** + * Search person based on eIDAS personal identifier. + * + * @param personIdentifier Full eIDAS personal identifier with prefix + * @param citizenCountryCode CountryCode of the eIDAS proxy-service + * @return Search result but never null + * @throws EidasSAuthenticationException In case of a communication error + */ + @Nonnull + ErnpRegisterResult searchWithPersonIdentifier(@Nonnull String personIdentifier, + @Nonnull String citizenCountryCode) throws EidasSAuthenticationException; - List searchWithMds(String givenName, String familyName, String dateOfBirth); + /** + * Search person based on eIDSA MDS information. + * + * @param givenName eIDAS given name + * @param familyName eIDAS principle name + * @param dateOfBirth eIDAS date-of-birth + * @param citizenCountryCode CountryCode of the eIDAS proxy-service + * @return Search result but never null + * @throws EidasSAuthenticationException In case of a communication error + */ + @Nonnull + ErnpRegisterResult searchWithMds(@Nonnull String givenName, @Nonnull String familyName, + @Nonnull String dateOfBirth, @Nonnull String citizenCountryCode) + throws EidasSAuthenticationException; - List searchDeSpecific(String givenName, String familyName, String dateOfBirth, - String birthPlace, String birthName); + /** + * Search person based on country-specific natural person set. + * + * @param personSearchDao Specific set of natural person informations. + * @param citizenCountryCode CountryCode of the eIDAS proxy-service + * @return Search result but never null + * @throws EidasSAuthenticationException In case of a communication error + */ + @Nonnull + ErnpRegisterResult searchCountrySpecific(@Nonnull PersonSuchenRequest personSearchDao, + @Nonnull String citizenCountryCode) throws EidasSAuthenticationException; - List searchItSpecific(String taxNumber); + /** + * Update ERnP entry to KITT existing ERnP identity with this eIDAS authentication. + * + * @param registerResult Already matched eIDAS identity that should be KITT + * @param eidData eIDAS eID information from current authentication process + * @return Update result but never null + * @throws EidasSAuthenticationException In case of a communication error + */ + @Nonnull + ErnpRegisterResult update(RegisterResult registerResult, SimpleEidasData eidData) + throws EidasSAuthenticationException; - RegisterResult update(RegisterResult registerResult, SimpleEidasData eidData); - - List searchWithBpkZp(String bpkzp); + /** + * Search person based on address information. + * + * @param givenName eIDAS given name + * @param familyName eIDAS principle name + * @param dateOfBirth eIDAS date-of-birth + * @param zipcode ZipCode + * @param city City + * @param street Street + * @return Search result but never null + */ + @Nonnull + ErnpRegisterResult searchWithResidenceData(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/ernp/DummyErnpClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/DummyErnpClient.java index db10752b..52703232 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 @@ -24,52 +24,53 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.ernp; import java.util.Collections; -import java.util.List; import org.springframework.stereotype.Service; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.ErnpRestClient.ErnpRegisterResult; import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.IErnpClient; 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("ErnbClientForeIDAS") public class DummyErnpClient implements IErnpClient { + @Override - public List searchWithPersonIdentifier(String personIdentifier) { - return Collections.emptyList(); + public ErnpRegisterResult searchWithPersonIdentifier(String personIdentifier, String citizenCountryCode) + throws EidasSAuthenticationException { + return buildEmptyResult(); } @Override - public List searchWithMds(String givenName, String familyName, String dateOfBirth) { - //TODO will I only receive matches where all three values match perfectly? - return Collections.emptyList(); + public ErnpRegisterResult searchWithMds(String givenName, String familyName, String dateOfBirth, + String citizenCountryCode) throws EidasSAuthenticationException { + return buildEmptyResult(); } @Override - public List searchDeSpecific(String givenName, String familyName, String dateOfBirth, - String birthPlace, String birthName) { - //TODO - return Collections.emptyList(); + public ErnpRegisterResult searchCountrySpecific(PersonSuchenRequest personSearchDao, + String citizenCountryCode) throws EidasSAuthenticationException { + return buildEmptyResult(); } @Override - public List searchItSpecific(String taxNumber) { - //TODO - return Collections.emptyList(); + public ErnpRegisterResult update(RegisterResult registerResult, SimpleEidasData eidData) + throws EidasSAuthenticationException { + return buildEmptyResult(); } @Override - public RegisterResult update(RegisterResult registerResult, SimpleEidasData eidData) { - //TODO - return null; + public ErnpRegisterResult searchWithResidenceData(String givenName, String familyName, String dateOfBirth, + String zipcode, String city, String street) { + return buildEmptyResult(); } - @Override - public List searchWithBpkZp(String bpkzp) { - //TODO - return Collections.emptyList(); + private static ErnpRegisterResult buildEmptyResult() { + return new ErnpRegisterResult(Collections.emptyList()); + } - } 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 5f1e96a4..fd9a67a9 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 @@ -11,6 +11,7 @@ import org.springframework.stereotype.Service; import com.google.common.collect.Streams; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.ErnpRestClient.ErnpRegisterResult; import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.IErnpClient; 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; @@ -77,8 +78,8 @@ public class RegisterSearchService { final ZmrRegisterResult resultsZmr = zmrClient.searchWithPersonIdentifier( operationStatus != null ? operationStatus.getZmrProcessId() : null, eidasData.getPseudonym(), eidasData.getCitizenCountryCode()); - final List resultsErnp = ernpClient.searchWithPersonIdentifier( - eidasData.getPersonalIdentifier()); + final ErnpRegisterResult resultsErnp = ernpClient.searchWithPersonIdentifier( + eidasData.getPseudonym(), eidasData.getCitizenCountryCode()); return RegisterStatusResults.fromZmrAndErnp(resultsZmr, resultsErnp); @@ -104,9 +105,9 @@ public class RegisterSearchService { zmrClient.searchWithMds(operationStatus.getZmrProcessId(), eidasData.getGivenName(), eidasData.getFamilyName(), eidasData.getDateOfBirth(), eidasData.getCitizenCountryCode()); - final List resultsErnp = - ernpClient.searchWithMds(eidasData.getGivenName(), eidasData.getFamilyName(), eidasData - .getDateOfBirth()); + final ErnpRegisterResult resultsErnp = + ernpClient.searchWithMds(eidasData.getGivenName(), + eidasData.getFamilyName(), eidasData.getDateOfBirth(), eidasData.getCitizenCountryCode()); return RegisterStatusResults.fromZmrAndErnp(resultsZmr, resultsErnp); @@ -141,7 +142,8 @@ public class RegisterSearchService { } else { // TODO: add search procesfor for ERnP searching - return RegisterStatusResults.fromErnp(operationStatus, Collections.emptyList()); + return RegisterStatusResults.fromErnp(operationStatus, + new ErnpRegisterResult(Collections.emptyList())); } @@ -193,8 +195,8 @@ public class RegisterSearchService { return RegisterStatusResults.fromZmr(updateZmr); } else { RegisterResult entryErnp = registerResult.getResultsErnp().get(0); - RegisterResult updateErnp = ernpClient.update(entryErnp, initialEidasData); - return RegisterStatusResults.fromErnp(registerResult.operationStatus, Collections.singletonList(updateErnp)); + ErnpRegisterResult updateErnp = ernpClient.update(entryErnp, initialEidasData); + return RegisterStatusResults.fromErnp(registerResult.operationStatus, updateErnp); } } catch (final EidasSAuthenticationException e) { throw new WorkflowException("kittMatchedIdentitiess", e.getMessage(), @@ -263,9 +265,9 @@ public class RegisterSearchService { ernpClient.update(entryErnp, initialEidasData); // update ZMR entry by using eIDAS information from alternative authentication - RegisterResult updateAlt = ernpClient.update(entryErnp, altEidasData); + ErnpRegisterResult updateAlt = ernpClient.update(entryErnp, altEidasData); - return RegisterStatusResults.fromErnp(altSearchResult.operationStatus, Collections.singletonList(updateAlt)); + return RegisterStatusResults.fromErnp(altSearchResult.operationStatus, updateAlt); } } catch (final EidasSAuthenticationException e) { throw new WorkflowException("kittMatchedIdentitiess", e.getMessage(), @@ -373,13 +375,13 @@ public class RegisterSearchService { result.getPersonResult(), Collections.emptyList()); } - static RegisterStatusResults fromZmrAndErnp(ZmrRegisterResult result, List resultsErnp) { + static RegisterStatusResults fromZmrAndErnp(ZmrRegisterResult result, ErnpRegisterResult resultErnp) { return new RegisterStatusResults(new RegisterOperationStatus(result.getProcessId()), - result.getPersonResult(), resultsErnp); + result.getPersonResult(), resultErnp.getPersonResult()); } - static RegisterStatusResults fromErnp(RegisterOperationStatus status, List resultsErnp) { - return new RegisterStatusResults(status, Collections.emptyList(), resultsErnp); + static RegisterStatusResults fromErnp(RegisterOperationStatus status, ErnpRegisterResult updateErnp) { + return new RegisterStatusResults(status, Collections.emptyList(), updateErnp.getPersonResult()); } } 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 c14af84c..d6d49370 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 @@ -23,7 +23,48 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.test.tasks; +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; + +import java.math.BigInteger; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Random; + +import javax.xml.namespace.QName; + +import org.apache.commons.lang3.RandomStringUtils; +import org.jetbrains.annotations.NotNull; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.mock.web.MockHttpServletResponse; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.ErnpRestClient.ErnpRegisterResult; import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.IErnpClient; import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.zmr.IZmrClient; import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.zmr.ZmrSoapClient; @@ -31,7 +72,11 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.zmr.ZmrSoapClien import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.MatchedPersonResult; 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.*; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidPostProcessingException; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasAttributeException; +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.handler.CountrySpecificDetailSearchProcessor; import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.GenericEidProcessor; import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.ICcSpecificEidProcessingService; @@ -52,36 +97,6 @@ import eu.eidas.auth.commons.attribute.ImmutableAttributeMap; import eu.eidas.auth.commons.attribute.PersonType; import eu.eidas.auth.commons.light.impl.LightRequest; import eu.eidas.auth.commons.protocol.impl.AuthenticationResponse; -import org.apache.commons.lang3.RandomStringUtils; -import org.jetbrains.annotations.NotNull; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.mock.web.MockHttpServletResponse; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.annotation.DirtiesContext.ClassMode; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; - -import javax.xml.namespace.QName; -import java.math.BigInteger; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.*; - -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; -import static org.junit.Assert.*; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { @@ -176,6 +191,13 @@ public class InitialSearchTaskTest { Mockito.when(zmrClient.update(any(), any(), any())) .thenThrow(new IllegalStateException("ZMR update should not be neccessary")); + Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE)) + .thenReturn(emptyErnpRegisterResult()); + Mockito.when(ernpClient.searchWithMds(any(), any(), any(), any())) + .thenThrow(new IllegalStateException("MDS search should not be neccessary")); + Mockito.when(ernpClient.update(any(), any())) + .thenThrow(new IllegalStateException("ERnP update should not be neccessary")); + // execute test task.execute(pendingReq, executionContext); @@ -200,8 +222,8 @@ public class InitialSearchTaskTest { .thenReturn(emptyZmrRegisterResult()); String oldRandomGivenName = randomAlphabetic(10); - Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_DE)) - .thenReturn(Collections.singletonList(randomRegisterResult(oldRandomGivenName, randomBpk))); + Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE)) + .thenReturn(ernpRegisterResult(randomRegisterResult(oldRandomGivenName, randomBpk))); // execute test task.execute(pendingReq, executionContext); @@ -210,11 +232,8 @@ public class InitialSearchTaskTest { checkMatchingSuccessState(pendingReq, randomBpk, randomFamilyName, randomGivenName, randomBirthDate, DE); } - @NotNull - private ZmrSoapClient.ZmrRegisterResult emptyZmrRegisterResult() { - return new ZmrRegisterResult(Collections.emptyList(), generateRandomProcessId()); - } + /** * Two matches by PersonalId found in ZMR * @@ -226,8 +245,8 @@ public class InitialSearchTaskTest { String newRandomGivenName = randomAlphabetic(10); Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPseudonym, DE)) .thenReturn(new ZmrRegisterResult(Arrays.asList(randomRegisterResult(), randomRegisterResult(newRandomGivenName, randomBpk)), generateRandomProcessId())); - Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_DE)) - .thenReturn(Collections.emptyList()); + Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE)) + .thenReturn(emptyErnpRegisterResult()); // execute task TaskExecutionException exception = assertThrows(TaskExecutionException.class, @@ -251,8 +270,8 @@ public class InitialSearchTaskTest { public void withErrorFromZmr() throws EidasSAuthenticationException { Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPseudonym, DE)) .thenThrow(new ZmrCommunicationException("jUnit ZMR error", null)); - Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_DE)) - .thenReturn(Collections.emptyList()); + Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE)) + .thenReturn(emptyErnpRegisterResult()); // execute task TaskExecutionException exception = assertThrows(TaskExecutionException.class, @@ -277,8 +296,9 @@ public class InitialSearchTaskTest { Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPseudonym, DE)) .thenReturn(emptyZmrRegisterResult()); String newRandomGivenName = randomAlphabetic(10); - Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_DE)) - .thenReturn(Arrays.asList(randomRegisterResult(), randomRegisterResult(newRandomGivenName, randomBpk))); + Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE)) + .thenReturn(ernpRegisterResult( + Arrays.asList(randomRegisterResult(), randomRegisterResult(newRandomGivenName, randomBpk)))); // execute task TaskExecutionException exception = assertThrows(TaskExecutionException.class, @@ -301,9 +321,8 @@ public class InitialSearchTaskTest { public void multiPersonalIdMatch_ErnpAndZmr() throws EidasSAuthenticationException { Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPseudonym, DE)) .thenReturn(zmrRegisterResult(randomRegisterResult())); - String newRandomGivenName = randomAlphabetic(10); - Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_DE)) - .thenReturn(Collections.singletonList(randomRegisterResult())); + Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE)) + .thenReturn(ernpRegisterResult(randomRegisterResult())); // execute task TaskExecutionException exception = assertThrows(TaskExecutionException.class, @@ -324,8 +343,13 @@ public class InitialSearchTaskTest { public void singlePersonalIdMatchNoUpdate_Ernp() throws Exception { Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPseudonym, DE)) .thenReturn(emptyZmrRegisterResult()); - Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_DE)) - .thenReturn(Collections.singletonList(randomRegisterResult())); + Mockito.when(zmrClient.update(any(), any(), any())) + .thenThrow(new IllegalStateException("ZMR update should not be neccessary")); + + Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE)) + .thenReturn(ernpRegisterResult(randomRegisterResult())); + Mockito.when(ernpClient.update(any(), any())) + .thenThrow(new IllegalStateException("ERnP update should not be neccessary")); // execute test task.execute(pendingReq, executionContext); @@ -342,8 +366,8 @@ public class InitialSearchTaskTest { public void singlePersonalIdMatchNoUpdate_Zmr() throws Exception { Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPseudonym, DE)) .thenReturn(zmrRegisterResult(randomRegisterResult())); - Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_DE)) - .thenReturn(Collections.emptyList()); + Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE)) + .thenReturn(emptyErnpRegisterResult()); Mockito.when(zmrClient.update(any(), any(), any())) .thenThrow(new IllegalStateException("ZMR update should not be neccessary")); @@ -394,8 +418,8 @@ public class InitialSearchTaskTest { Mockito.when(zmrClient.searchWithMds(any(), any(), any(), any(), any())) .thenThrow(new IllegalStateException("MDS search should not be neccessary")); - Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_DE)) - .thenReturn(Collections.emptyList()); + Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE)) + .thenReturn(emptyErnpRegisterResult()); // execute test task.execute(pendingReq1, executionContext); @@ -444,8 +468,8 @@ public class InitialSearchTaskTest { Mockito.when(zmrClient.searchCountrySpecific(eq(zmrProcessId), any(PersonSuchenRequest.class), eq(DE))) .thenReturn(new ZmrRegisterResult(Arrays.asList(randomResult1, randomResult2), zmrProcessId)); - Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_DE)) - .thenReturn(Collections.emptyList()); + Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE)) + .thenReturn(emptyErnpRegisterResult()); // execute task TaskExecutionException exception = assertThrows(TaskExecutionException.class, @@ -480,9 +504,12 @@ public class InitialSearchTaskTest { 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()); - + Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, EE)) + .thenReturn(emptyErnpRegisterResult()); + Mockito.when(ernpClient.searchWithMds(randomGivenName, randomFamilyName, randomBirthDate, EE)) + .thenReturn(new ErnpRegisterResult(Collections.emptyList())); + Mockito.when(ernpClient.update(any(), any())) + .thenThrow(new IllegalStateException("ZMR update should not be neccessary")); // execute task task.execute(pendingReq, executionContext); @@ -519,10 +546,10 @@ public class InitialSearchTaskTest { Mockito.when(zmrClient.searchWithMds(zmrProcessId, randomGivenName, randomFamilyName, randomBirthDate, EE)) .thenReturn(new ZmrRegisterResult(Collections.emptyList(), zmrProcessId)); - Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_EE)) - .thenReturn(Collections.emptyList()); - Mockito.when(ernpClient.searchWithMds(randomGivenName, randomFamilyName, randomBirthDate)) - .thenReturn(Collections.singletonList(randomRegisterResult())); + Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, EE)) + .thenReturn(emptyErnpRegisterResult()); + Mockito.when(ernpClient.searchWithMds(randomGivenName, randomFamilyName, randomBirthDate, EE)) + .thenReturn(ernpRegisterResult(randomRegisterResult())); // execute test task.execute(pendingReq, executionContext); @@ -546,8 +573,14 @@ public class InitialSearchTaskTest { 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.searchWithPersonIdentifier(randomPseudonym, DE)).thenReturn( + emptyErnpRegisterResult()); + Mockito.when(ernpClient.searchWithMds(randomGivenName, randomFamilyName, randomBirthDate, DE)) + .thenReturn(emptyErnpRegisterResult()); + Mockito.when(ernpClient.update(any(), any())) + .thenThrow(new IllegalStateException("ERnP update should not be neccessary")); + // execute test task.execute(pendingReq, executionContext); @@ -573,10 +606,10 @@ public class InitialSearchTaskTest { 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(randomRegisterResult(), randomRegisterResult(randomBpk + "1"))); + Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE)) + .thenReturn(emptyErnpRegisterResult()); + Mockito.when(ernpClient.searchWithMds(randomGivenName, randomFamilyName, randomBirthDate, DE)) + .thenReturn(ernpRegisterResult(Arrays.asList(randomRegisterResult(), randomRegisterResult(randomBpk + "1")))); // execute test task.execute(pendingReq, executionContext); @@ -586,6 +619,16 @@ public class InitialSearchTaskTest { } + @NotNull + private ZmrSoapClient.ZmrRegisterResult emptyZmrRegisterResult() { + return new ZmrRegisterResult(Collections.emptyList(), generateRandomProcessId()); + } + + @NotNull + private ErnpRegisterResult emptyErnpRegisterResult() { + return new ErnpRegisterResult(Collections.emptyList()); + } + @NotNull private ZmrRegisterResult zmrRegisterResult(RegisterResult registerResult, BigInteger processId) { return new ZmrRegisterResult(Collections.singletonList(registerResult), processId); @@ -596,6 +639,16 @@ public class InitialSearchTaskTest { return zmrRegisterResult(registerResult, generateRandomProcessId()); } + @NotNull + private ErnpRegisterResult ernpRegisterResult(RegisterResult registerResult) { + return new ErnpRegisterResult(Collections.singletonList(registerResult)); + } + + @NotNull + private ErnpRegisterResult ernpRegisterResult(List registerResult) { + return new ErnpRegisterResult(registerResult); + } + @NotNull private RegisterResult randomRegisterResult() { return randomRegisterResult(randomGivenName, randomBpk); -- cgit v1.2.3 From 8d19a4097a61723950830c79aaee3168785b683b Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Thu, 3 Feb 2022 15:51:38 +0100 Subject: feature(ernp): implement 'searchByPersonalIdentifier' as a first test version --- .../specific/modules/auth/eidas/v2/Constants.java | 57 +++- .../auth/eidas/v2/clients/ernp/ErnpRestClient.java | 374 ++++++++++++++++++++- .../auth/eidas/v2/clients/zmr/ZmrSoapClient.java | 4 +- .../src/main/resources/eidas_v2_auth.beans.xml | 9 +- 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 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 processSearchPersonResponse( + @Nonnull List list, + @Nonnull String citizenCountryCode) throws EaafAuthenticationException { + return list.stream() + .map(el -> mapErnpResponseToRegisterResult(el, citizenCountryCode)) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + } + @NonNull + private List processSearchPersonResponseSingleResult( + @Nonnull List 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 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 null 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 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 @@ - - - - - + -- cgit v1.2.3 From 837ce1a4fbece82fd84ab77fdd1eb0284ad2106a Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Thu, 3 Feb 2022 19:05:47 +0100 Subject: refactor(ernp): update openAPI specification from BM.I to use 'application/json' instead of 'application/xml' --- .../main/resources/wsdl/ernp_client/openapi.json | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/resources/wsdl/ernp_client/openapi.json b/eidas_modules/authmodule-eIDAS-v2/src/main/resources/wsdl/ernp_client/openapi.json index c8276f3a..fef86c1b 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/resources/wsdl/ernp_client/openapi.json +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/resources/wsdl/ernp_client/openapi.json @@ -83,7 +83,7 @@ } ], "requestBody" : { "content" : { - "application/xml" : { + "application/json" : { "schema" : { "$ref" : "#/components/schemas/PersonAendern" } @@ -94,7 +94,7 @@ "default" : { "description" : "Erfolgreicher Response hat Status 200 wenn Responsepayload vorhanden, sonst 204", "content" : { - "application/xml" : { + "application/json" : { "schema" : { "$ref" : "#/components/schemas/AendernResponse" } @@ -104,7 +104,7 @@ "4XX" : { "description" : "Client Fehler (kann vom Client behoben werden)", "content" : { - "application/xml" : { + "application/json" : { "schema" : { "$ref" : "#/components/schemas/Fault" } @@ -114,7 +114,7 @@ "5XX" : { "description" : "Server Fehler (normalerweise nicht vom Client behebbar)", "content" : { - "application/xml" : { + "application/json" : { "schema" : { "$ref" : "#/components/schemas/Fault" } @@ -161,7 +161,7 @@ } ], "requestBody" : { "content" : { - "application/xml" : { + "application/json" : { "schema" : { "$ref" : "#/components/schemas/PersonAnlegen" } @@ -172,7 +172,7 @@ "default" : { "description" : "Erfolgreicher Response hat Status 200 wenn Responsepayload vorhanden, sonst 204", "content" : { - "application/xml" : { + "application/json" : { "schema" : { "$ref" : "#/components/schemas/AnlegenResponse" } @@ -182,7 +182,7 @@ "4XX" : { "description" : "Client Fehler (kann vom Client behoben werden)", "content" : { - "application/xml" : { + "application/json" : { "schema" : { "$ref" : "#/components/schemas/Fault" } @@ -192,7 +192,7 @@ "5XX" : { "description" : "Server Fehler (normalerweise nicht vom Client behebbar)", "content" : { - "application/xml" : { + "application/json" : { "schema" : { "$ref" : "#/components/schemas/Fault" } @@ -239,7 +239,7 @@ } ], "requestBody" : { "content" : { - "application/xml" : { + "application/json" : { "schema" : { "$ref" : "#/components/schemas/PersonSuchen" } @@ -250,7 +250,7 @@ "default" : { "description" : "Erfolgreicher Response hat Status 200 wenn Responsepayload vorhanden, sonst 204", "content" : { - "application/xml" : { + "application/json" : { "schema" : { "$ref" : "#/components/schemas/SuchenResponse" } @@ -260,7 +260,7 @@ "4XX" : { "description" : "Client Fehler (kann vom Client behoben werden)", "content" : { - "application/xml" : { + "application/json" : { "schema" : { "$ref" : "#/components/schemas/Fault" } @@ -270,7 +270,7 @@ "5XX" : { "description" : "Server Fehler (normalerweise nicht vom Client behebbar)", "content" : { - "application/xml" : { + "application/json" : { "schema" : { "$ref" : "#/components/schemas/Fault" } -- cgit v1.2.3 From 84bb45ecb417f6a92b7d8884048bd7901c6b1b42 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Thu, 3 Feb 2022 20:28:50 +0100 Subject: fix(ernp): fix some bugs in ERnP client implementation --- .../specific/modules/auth/eidas/v2/Constants.java | 2 - .../auth/eidas/v2/clients/ernp/ErnpRestClient.java | 265 ++++++++++++--------- .../exception/ErnpRestCommunicationException.java | 24 ++ 3 files changed, 180 insertions(+), 111 deletions(-) create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/exception/ErnpRestCommunicationException.java 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 d48d69bf..6da30299 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 @@ -166,8 +166,6 @@ public class Constants { 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 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 a651385f..605f1d0f 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 @@ -2,6 +2,7 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp; import java.io.IOException; import java.text.MessageFormat; +import java.time.LocalDate; import java.time.OffsetDateTime; import java.util.Arrays; import java.util.Collections; @@ -12,9 +13,11 @@ import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.annotation.PostConstruct; +import org.apache.commons.lang3.StringUtils; import org.apache.http.client.HttpClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.http.client.ClientHttpRequestFactory; import org.springframework.http.client.ClientHttpResponse; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; @@ -23,10 +26,10 @@ import org.springframework.http.converter.json.MappingJackson2HttpMessageConvert import org.springframework.lang.NonNull; import org.springframework.lang.Nullable; import org.springframework.web.client.ResponseErrorHandler; +import org.springframework.web.client.RestClientException; 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; @@ -42,6 +45,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ernp.model.SuchenRes 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.ErnpRestCommunicationException; 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; @@ -60,17 +64,18 @@ import lombok.extern.slf4j.Slf4j; /** * Implements an ERnP client that uses REST API for communication. - * + * * @author tlenz * */ @Slf4j public class ErnpRestClient implements IErnpClient { - 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_11 = "module.eidasauth.matching.11"; + private static final String ERROR_MATCHING_12 = "module.eidasauth.matching.12"; private static final String ERROR_MATCHING_99 = "module.eidasauth.matching.99"; - + + private static final String LOGMSG_MISSING_CONFIG = "Missing configuration with key: {0}"; private static final String LOGMSG_ERNP_ERROR = "Receive an error from ERnP during '{}' operation with msg: {}"; private static final String LOGMSG_ERNP_RESP_PROCESS = @@ -78,69 +83,73 @@ public class ErnpRestClient implements IErnpClient { 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 = + + 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; - + + @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 { - + try { - + // build generic request metadata - GenericRequestParams generic = buildGenericRequestParameters("step1"); + final GenericRequestParams generic = buildGenericRequestParameters("step1"); - // build search request - SuchEidas eidasInfos = new SuchEidas(); + // build search request + final SuchEidas eidasInfos = new SuchEidas(); eidasInfos.setArt(Constants.eIDAS_ATTRURN_PERSONALIDENTIFIER); eidasInfos.setWert(personIdentifier); eidasInfos.setStaatscode2(citizenCountryCode); - - PersonSuchen personSuchen = new PersonSuchen(); + + final PersonSuchen personSuchen = new PersonSuchen(); personSuchen.setSuchoptionen(generateSearchParameters()); - personSuchen.setBegruendung(PROCESS_SEARCH_PERSONAL_IDENTIFIER); - Suchdaten searchInfos = new Suchdaten(); - searchInfos.setEidas(eidasInfos); + personSuchen.setBegruendung(PROCESS_SEARCH_PERSONAL_IDENTIFIER); + final 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, + final 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 (RestClientException e) { + log.warn(LOGMSG_ERNP_ERROR, PROCESS_SEARCH_PERSONAL_IDENTIFIER, e.getMessage()); + throw new EidasSAuthenticationException(ERROR_MATCHING_11, new Object[] { e.getMessage() }, e); - } catch (EidasSAuthenticationException e) { + } catch (final EidasSAuthenticationException e) { throw e; - - } catch (Exception e) { + + } catch (final 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 { @@ -164,54 +173,66 @@ public class ErnpRestClient implements IErnpClient { 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(); - + + // set-up the Ernp client + final ApiClient baseClient = new ApiClient(buildRestClient()); + baseClient.setBasePath(basicConfig.getBasicConfiguration( + Constants.CONIG_PROPS_EIDAS_ERNPCLIENT_ENDPOINT)); + ernpClient = new DefaultApi(baseClient); + } - + private void valdiateAdditionalConfigParameters() { - // TODO Auto-generated method stub - + checkConfigurationValue(Constants.CONIG_PROPS_EIDAS_ERNPCLIENT_ENDPOINT); + checkConfigurationValue(Constants.CONIG_PROPS_EIDAS_ERNPCLIENT_REQ_ORGANIZATION_NR); + + } + + private void checkConfigurationValue(String key) { + if (StringUtils.isEmpty(basicConfig.getBasicConfiguration(key))) { + throw new RuntimeException(MessageFormat.format(LOGMSG_MISSING_CONFIG, key)); + + } } private Suchoptionen generateSearchParameters() { - Suchoptionen options = new Suchoptionen(); + final Suchoptionen options = new Suchoptionen(); options.setZmr(false); options.setHistorisch(HistorischEnum.AKTUELLUNDHISTORISCH); options.setSucheMitNamensteilen(false); - options.setSuchwizard(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 + 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", + + } 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 @@ -224,22 +245,22 @@ public class ErnpRestClient implements IErnpClient { .collect(Collectors.toList()); } - + @NonNull private List processSearchPersonResponseSingleResult( @Nonnull List 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, + 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) { @@ -254,15 +275,28 @@ public class ErnpRestClient implements IErnpClient { .placeOfBirth(selectSingleEidasDocument(person, citizenCountryCode, Constants.eIDAS_ATTRURN_PLACEOFBIRTH)) .birthName(selectSingleEidasDocument(person, citizenCountryCode, - Constants.eIDAS_ATTRURN_BIRTHNAME)) + Constants.eIDAS_ATTRURN_BIRTHNAME)) .build(); } - + + /** + * Build AT specific Date String 'yyyy-MM-dd' from ERnP birthday representation. + * + *

+ * Info: {@link LocalDate} can not be used, because '1940-00-00' is also + * a valid birthday on ERnP site. + *

+ * + * @param geburtsdatum ERnP birthday representation + * @return birthday in 'yyyy-MM-dd' format + */ private String buildTextualBirthday(PartialDate geburtsdatum) { - return MessageFormat.format(PATTERN_BIRTHDAY_STRING, - geburtsdatum.getJahr(), geburtsdatum.getMonat(), geburtsdatum.getTag()); - + return MessageFormat.format("{0}-{1}-{2}", + String.valueOf(geburtsdatum.getJahr()), + String.format("%02d", geburtsdatum.getMonat()), + String.format("%02d", geburtsdatum.getTag())); + } /** @@ -276,12 +310,18 @@ public class ErnpRestClient implements IErnpClient { */ @NonNull private List 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()); + String eidasAttrurnPersonalidentifier) { + if (person.getEidas() != null) { + return person.getEidas().stream() + .filter(el -> eidasAttrurnPersonalidentifier.equals(el.getArt()) + && el.getStaatscode2().equals(citizenCountryCode)) + .map(el -> el.getWert()) + .collect(Collectors.toList()); + + } else { + return Collections.emptyList(); + + } } @@ -297,15 +337,20 @@ public class ErnpRestClient implements IErnpClient { @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); + if (person.getEidas() != null) { + return person.getEidas().stream() + .filter(el -> eidasAttrurnPersonalidentifier.equals(el.getArt()) + && el.getStaatscode2().equals(citizenCountryCode)) + .findFirst() + .map(el -> el.getWert()) + .orElse(null); + + } else { + return null; + } } - + private RestTemplate buildRestClient() throws EaafException { log.debug("Building REST-Client for ERnP communication ... "); final HttpClient httpClient = httpClientFactory.getHttpClient(buildHttpClientConfiguration()); @@ -316,42 +361,44 @@ public class ErnpRestClient implements IErnpClient { return springClient; } - + private HttpMessageConverter buildCustomJacksonObjectMapper() { - MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.setSerializationInclusion(Include.NON_NULL); - converter.setObjectMapper(objectMapper); + final MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); + converter.setSupportedMediaTypes(Collections.singletonList(MediaType.ALL)); + converter.getObjectMapper() + .setSerializationInclusion(Include.NON_NULL); return converter; - + } - + @Nonnull private ResponseErrorHandler buildErrorHandler() { return new ResponseErrorHandler() { @Override public boolean hasError(ClientHttpResponse response) throws IOException { - return response.getStatusCode().is4xxClientError() - || response.getStatusCode().is5xxServerError(); - + return response.getStatusCode().is4xxClientError() + || response.getStatusCode().is5xxServerError(); + } @Override - public void handleError(ClientHttpResponse response) throws IOException { - //TODO: implement errorHandling based on response infos - + 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()); - + } + + throw new ErnpRestCommunicationException(response.getRawStatusCode()); } }; } - + @Nonnull private HttpClientConfiguration buildHttpClientConfiguration() throws EaafException { final HttpClientConfiguration config = new HttpClientConfiguration(FRIENDLYNAME_HTTP_CLIENT); @@ -369,39 +416,39 @@ public class ErnpRestClient implements IErnpClient { 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 - + // TODO: update EAAF-components to allow custom HTTP Connection-Timeouts + return config; } - @AllArgsConstructor @Getter public static class ErnpRegisterResult { private final List personResult; - + } private GenericRequestParams buildGenericRequestParameters(String operationIdentifier) { return GenericRequestParams.builder() - .clientBehkz(basicConfig.getBasicConfiguration(Constants.CONIG_PROPS_EIDAS_ZMRCLIENT_REQ_ORGANIZATION_NR)) + .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(); - + .build(); + } - + @Builder @Getter - private static class GenericRequestParams { + private static class GenericRequestParams { String clientBehkz; - String clientName; - OffsetDateTime clientRequestTime; + 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/exception/ErnpRestCommunicationException.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/exception/ErnpRestCommunicationException.java new file mode 100644 index 00000000..72a5ece6 --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/exception/ErnpRestCommunicationException.java @@ -0,0 +1,24 @@ +package at.asitplus.eidas.specific.modules.auth.eidas.v2.exception; + +import java.io.IOException; + +import lombok.Getter; + +/** + * ERnP exception in case of a REST communication error. + * + * @author tlenz + * + */ +public class ErnpRestCommunicationException extends IOException { + private static final long serialVersionUID = -3178689122077228976L; + + @Getter + int httpStatusCode; + + public ErnpRestCommunicationException(int rawStatusCode) { + super("ERnP service answers with an error and HTTP status-code: " + rawStatusCode); + this.httpStatusCode = rawStatusCode; + } + +} -- cgit v1.2.3 From 8d4680da725db89c5fc11767d8892f3fb16aa0e7 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Thu, 3 Feb 2022 20:30:06 +0100 Subject: test(core): fix broken tests after refactoring of ERnPClient API --- .../src/main/resources/application.properties | 10 +++++ .../messages/eidas_connector_message.properties | 4 ++ .../AlternativeSearchTaskWithRegisterTest.java | 46 +++++++++++++++++++++- .../tasks/InitialSearchTaskWithRegistersTest.java | 31 ++++++++++++--- .../resources/config/junit_config_1.properties | 19 +++++++-- .../config/junit_config_1_springboot.properties | 11 ++++++ 6 files changed, 110 insertions(+), 11 deletions(-) diff --git a/connector/src/main/resources/application.properties b/connector/src/main/resources/application.properties index bec125dc..0b36b103 100644 --- a/connector/src/main/resources/application.properties +++ b/connector/src/main/resources/application.properties @@ -112,6 +112,16 @@ eidas.ms.auth.eIDAS.szrclient.eidasbind.mds.inject=false #eidas.ms.auth.eIDAS.zmrclient.req.update.reason.code=PERS_AENDERN #eidas.ms.auth.eIDAS.zmrclient.req.update.reason.text=KITT for eIDAS Matching +# ERnP communication +#eidas.ms.auth.eIDAS.ernpclient.endpoint=http://localhost:1718/demoernp +#eidas.ms.auth.eIDAS.ernpclient.req.organisation.behoerdennr=jUnit123456 +#eidas.ms.auth.eIDAS.client.common.ssl.keyStore.type=jks +#eidas.ms.auth.eIDAS.client.common.ssl.keyStore.path=../keystore/junit_test.jks +#eidas.ms.auth.eIDAS.client.common.ssl.keyStore.password=password +#eidas.ms.auth.eIDAS.client.common.ssl.key.alias=meta +#eidas.ms.auth.eIDAS.client.common.ssl.key.password=password + + #Raw eIDAS Id data storage diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/resources/messages/eidas_connector_message.properties b/eidas_modules/authmodule-eIDAS-v2/src/main/resources/messages/eidas_connector_message.properties index 3ccfff19..188c5a8f 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/resources/messages/eidas_connector_message.properties +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/resources/messages/eidas_connector_message.properties @@ -20,4 +20,8 @@ module.eidasauth.matching.02=Matching failed, because ZMR response contains hist module.eidasauth.matching.03=Matching failed in workflow step: {0} with error: {1} module.eidasauth.matching.04=An error occurred while loading your data from official registers. Please contact the support. +module.eidasauth.matching.11=Matching failed, because of an ERnP communication error. Reason: {0} +module.eidasauth.matching.12=Matching failed, because ERnP response contains historic information which is not supported. + module.eidasauth.matching.99=Matching failed, because of an unexpected processing error. Reason: {0} + diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java index 0c6ec95d..028c0359 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java @@ -35,7 +35,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; -import org.mockito.MockitoAnnotations; +import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; @@ -49,6 +49,7 @@ import org.springframework.web.context.request.ServletRequestAttributes; import com.github.skjolber.mockito.soap.SoapServiceRule; import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.ErnpRestClient.ErnpRegisterResult; import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.IErnpClient; 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; @@ -407,7 +408,10 @@ public class AlternativeSearchTaskWithRegisterTest { when(zmrMock.service(zmrReq.capture(), any())) .thenReturn(loadResponseFromFile("/data/zmr/seq_1-8_search_with_personalId_only_resp.xml")) .thenThrow(new RuntimeException("This request is not needed any more")); - + + Mockito.when(ernpClient.searchWithPersonIdentifier(any(), any())) + .thenReturn(emptyErnpRegisterResult()); + // execute task TaskExecutionException exception = assertThrows(TaskExecutionException.class, () -> task.execute(pendingReq, executionContext)); @@ -470,6 +474,13 @@ public class AlternativeSearchTaskWithRegisterTest { .thenReturn(loadResponseFromFile("/data/zmr/seq_3-8_kitt_get_latest_version_resp.xml")) .thenThrow(new RuntimeException("This request is not needed any more")); + Mockito.when(ernpClient.searchWithPersonIdentifier(any(), any())) + .thenReturn(emptyErnpRegisterResult()); + Mockito.when(ernpClient.searchWithMds(any(), any(), any(), any())) + .thenReturn(emptyErnpRegisterResult()); + Mockito.when(ernpClient.update(any(), any())) + .thenThrow(new IllegalStateException("ERnP update should not be neccessary")); + // execute task task.execute(pendingReq, executionContext); @@ -549,6 +560,15 @@ public class AlternativeSearchTaskWithRegisterTest { .thenReturn(loadResponseFromFile("/data/zmr/seq_3-10_kitt_update_resp.xml")) .thenThrow(new RuntimeException("This request is not needed any more")); + Mockito.when(ernpClient.searchWithPersonIdentifier(any(), any())) + .thenReturn(emptyErnpRegisterResult()); + Mockito.when(ernpClient.searchCountrySpecific(any(), any())) + .thenReturn(emptyErnpRegisterResult()); + Mockito.when(ernpClient.searchWithMds(any(), any(), any(), any())) + .thenReturn(emptyErnpRegisterResult()); + Mockito.when(ernpClient.update(any(), any())) + .thenThrow(new IllegalStateException("ERnP update should not be neccessary")); + // execute task task.execute(pendingReq, executionContext); @@ -636,6 +656,9 @@ public class AlternativeSearchTaskWithRegisterTest { .thenReturn(loadResponseFromFile("/data/zmr/empty_zmr_result.xml")) .thenThrow(new RuntimeException("This request is not needed any more")); + Mockito.when(ernpClient.searchWithPersonIdentifier(any(), any())) + .thenReturn(emptyErnpRegisterResult()); + // execute task task.execute(pendingReq, executionContext); @@ -697,6 +720,13 @@ public class AlternativeSearchTaskWithRegisterTest { .thenReturn(loadResponseFromFile("/data/zmr/search_with_personalId_only_resp_moreThanOne.xml")) .thenThrow(new RuntimeException("This request is not needed any more")); + Mockito.when(ernpClient.searchWithPersonIdentifier(any(), any())) + .thenReturn(emptyErnpRegisterResult()); + Mockito.when(ernpClient.searchWithMds(any(), any(), any(), any())) + .thenReturn(emptyErnpRegisterResult()); + Mockito.when(ernpClient.update(any(), any())) + .thenThrow(new IllegalStateException("ERnP update should not be neccessary")); + // execute task TaskExecutionException exception = assertThrows(TaskExecutionException.class, () -> task.execute(pendingReq, executionContext)); @@ -769,6 +799,14 @@ public class AlternativeSearchTaskWithRegisterTest { .thenReturn(loadResponseFromFile("/data/zmr/empty_zmr_result.xml")) .thenThrow(new RuntimeException("This request is not needed any more")); + Mockito.when(ernpClient.searchWithPersonIdentifier("7cEYasdfsafsaf4CDVzNT4E7cjkU4VqForjUnit", "DE")) + .thenReturn(emptyErnpRegisterResult()); + Mockito.when(ernpClient.searchWithMds("XXXKlaus - Maria", "XXXvon Brandenburg", "1994-12-31","DE")) + .thenReturn(emptyErnpRegisterResult()); + Mockito.when(ernpClient.update(any(), any())) + .thenThrow(new IllegalStateException("ERnP update should not be neccessary")); + + // execute task task.execute(pendingReq, executionContext); @@ -970,6 +1008,10 @@ public class AlternativeSearchTaskWithRegisterTest { } + @NotNull + private ErnpRegisterResult emptyErnpRegisterResult() { + return new ErnpRegisterResult(Collections.emptyList()); + } } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java index ea84c39c..565efe09 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java @@ -47,6 +47,7 @@ import javax.xml.namespace.QName; import org.apache.commons.lang3.RandomStringUtils; import org.jetbrains.annotations.NotNull; +import org.junit.AfterClass; import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; @@ -54,8 +55,6 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; @@ -103,6 +102,8 @@ import eu.eidas.auth.commons.attribute.PersonType; import eu.eidas.auth.commons.light.impl.LightRequest; import eu.eidas.auth.commons.protocol.impl.AuthenticationResponse; import lombok.SneakyThrows; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { @@ -119,14 +120,16 @@ public class InitialSearchTaskWithRegistersTest { @Rule public SoapServiceRule soap = SoapServiceRule.newInstance(); - @Mock private IErnpClient ernpClient; - - @Autowired private IZmrClient zmrClient; - @Autowired private List handlers; + @Autowired IErnpClient ernpClient; + @Autowired IZmrClient zmrClient; + @Autowired List handlers; + private RegisterSearchService registerSearchService; private ServicePort zmrMock = null; + private static MockWebServer mockWebServer; + private final ICcSpecificEidProcessingService eidPostProcessor = createEidPostProcessor(); private InitialSearchTask task; @@ -144,13 +147,24 @@ public class InitialSearchTaskWithRegistersTest { at.gv.bmi.namespace.zmr_su.zmr._20040201.ObjectFactory.class, at.gv.bmi.namespace.zmr_su.gis._20070725.ObjectFactory.class, at.gv.bmi.namespace.zmr_su.base._20040201.ObjectFactory.class); + + mockWebServer = new MockWebServer(); + mockWebServer.start(1718); + } + @AfterClass + @SneakyThrows + public static void resetTestEnviroment() { + mockWebServer.shutdown(); + + } /** * jUnit test set-up. */ @Before + @SneakyThrows public void setUp() throws URISyntaxException, EaafStorageException { if (zmrMock == null) { zmrMock = soap.mock(ServicePort.class, "http://localhost:1234/demozmr"); @@ -167,6 +181,11 @@ public class InitialSearchTaskWithRegistersTest { pendingReq = new TestRequestImpl(); + + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody("{}") + .setHeader("Content-Type", "application/json;charset=utf-8")); + } /** 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 be716e95..d84777f3 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 @@ -8,9 +8,9 @@ eidas.ms.context.use.clustermode=true eidas.ms.monitoring.eIDASNode.metadata.url= -eidas.ms.client.http.connection.timeout.socket=1 -eidas.ms.client.http.connection.timeout.connection=1 -eidas.ms.client.http.connection.timeout.request=1 +eidas.ms.client.http.connection.timeout.socket=5 +eidas.ms.client.http.connection.timeout.connection=5 +eidas.ms.client.http.connection.timeout.request=5 ##Specific logger configuration @@ -100,6 +100,19 @@ eidas.ms.auth.eIDAS.zmrclient.req.organisation.behoerdennr=jUnit123456 eidas.ms.auth.eIDAS.zmrclient.req.update.reason.code=EIDAS-KITT + +# ERnP communication +eidas.ms.auth.eIDAS.ernpclient.endpoint=http://localhost:1718/demoernp +eidas.ms.auth.eIDAS.ernpclient.req.organisation.behoerdennr=jUnit123456 +eidas.ms.auth.eIDAS.client.common.ssl.keyStore.type=jks +eidas.ms.auth.eIDAS.client.common.ssl.keyStore.path=../keystore/junit_test.jks +eidas.ms.auth.eIDAS.client.common.ssl.keyStore.password=password +eidas.ms.auth.eIDAS.client.common.ssl.key.alias=meta +eidas.ms.auth.eIDAS.client.common.ssl.key.password=password + + + +#### SP End-Points ##### ## PVP2 S-Profile end-point configuration eidas.ms.pvp2.keystore.path=keys/..... eidas.ms.pvp2.keystore.password= 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 224e1b1f..0cc89a4a 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 @@ -57,7 +57,18 @@ 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 +# ERnP communication +eidas.ms.auth.eIDAS.ernpclient.endpoint=http://localhost:1718/demoernp +eidas.ms.auth.eIDAS.ernpclient.req.organisation.behoerdennr=jUnit123456 +eidas.ms.auth.eIDAS.client.common.ssl.keyStore.type=jks +eidas.ms.auth.eIDAS.client.common.ssl.keyStore.path=../keystore/junit_test.jks +eidas.ms.auth.eIDAS.client.common.ssl.keyStore.password=password +eidas.ms.auth.eIDAS.client.common.ssl.key.alias=meta +eidas.ms.auth.eIDAS.client.common.ssl.key.password=password + + +#### SP End-Points ##### ## PVP2 S-Profile end-point configuration eidas.ms.pvp2.keystore.type=jks eidas.ms.pvp2.keystore.path=keys/junit.jks -- cgit v1.2.3 From 0908fbc33f0ba7a1811cc988a30b571ab53ffa99 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Thu, 3 Feb 2022 20:30:45 +0100 Subject: test(ernp): add first simple test to get familary with ERnP client --- .../eidas/v2/test/clients/ErnpRestClientTest.java | 132 +++++++++++++++++++++ .../resources/data/ernp/ernp_handbook_example.json | 85 +++++++++++++ 2 files changed, 217 insertions(+) create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ErnpRestClientTest.java create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/ernp_handbook_example.json diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ErnpRestClientTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ErnpRestClientTest.java new file mode 100644 index 00000000..9eb574fd --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ErnpRestClientTest.java @@ -0,0 +1,132 @@ +package at.asitplus.eidas.specific.modules.auth.eidas.v2.test.clients; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThrows; + +import org.apache.commons.io.IOUtils; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import at.asitplus.eidas.specific.connector.test.config.dummy.MsConnectorDummyConfigMap; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.ErnpRestClient.ErnpRegisterResult; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.IErnpClient; +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 lombok.SneakyThrows; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = { + "/SpringTest-context_tasks_test.xml", + "/SpringTest-context_basic_mapConfig.xml" }) +@DirtiesContext(classMode = ClassMode.AFTER_CLASS) +public class ErnpRestClientTest { + + @Autowired MsConnectorDummyConfigMap basicConfig; + @Autowired IErnpClient client; + + private static MockWebServer mockWebServer; + + /** + * JUnit class initializer. + * + * @throws Exception In case of an OpenSAML3 initialization error + */ + @BeforeClass + @SneakyThrows + public static void classInitializer() { + mockWebServer = new MockWebServer(); + mockWebServer.start(1718); + + } + + @AfterClass + @SneakyThrows + public static void resetTestEnviroment() { + mockWebServer.shutdown(); + + } + + @Test + @SneakyThrows + public void searchWithPersonalIdentifierServerError() { + final String personalIdentifierFirst = "7cEYWithDEElementsasdfsafsaf4CDVzNT4E7cjkU4VqForjUnit"; + final String cc = "DE"; + final SimpleEidasData eidasDataFirst = SimpleEidasData.builder() + .citizenCountryCode(cc) + .familyName("XXXvon Brandenburg") + .givenName("XXXClaus - Maria") + .dateOfBirth("1994-12-31") + .personalIdentifier(cc + "/AT/" + personalIdentifierFirst) + .pseudonym(personalIdentifierFirst) + .build(); + + // set ERnP response + mockWebServer.enqueue(new MockResponse().setResponseCode(500) + .setBody("Internal error")); + + // execute operation + EidasSAuthenticationException error = assertThrows("wrong Exception", EidasSAuthenticationException.class, + () -> client.searchWithPersonIdentifier( + eidasDataFirst.getPseudonym(), eidasDataFirst.getCitizenCountryCode())); + + assertEquals("wrong errorCode", "module.eidasauth.matching.11", error.getErrorId()); + + } + + @Test + @SneakyThrows + public void searchWithPersonalIdentifierSuccess() { + final String personalIdentifierFirst = "7cEYWithDEElementsasdfsafsaf4CDVzNT4E7cjkU4VqForjUnit"; + final String cc = "DE"; + final SimpleEidasData eidasDataFirst = SimpleEidasData.builder() + .citizenCountryCode(cc) + .familyName("XXXvon Brandenburg") + .givenName("XXXClaus - Maria") + .dateOfBirth("1994-12-31") + .personalIdentifier(cc + "/AT/" + personalIdentifierFirst) + .pseudonym(personalIdentifierFirst) + .build(); + + + // set ERnP response + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/ernp_handbook_example.json"), + "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + + + // execute operation + ErnpRegisterResult resp = client.searchWithPersonIdentifier( + eidasDataFirst.getPseudonym(), eidasDataFirst.getCitizenCountryCode()); + + // validate request + final RecordedRequest request = mockWebServer.takeRequest(); + String reqBody = request.getBody().readUtf8(); + assertFalse("no request body", reqBody.isEmpty()); + + // validate state + assertNotNull("no ERnP response", resp); + assertEquals("wrong resp size", 1, resp.getPersonResult().size()); + + RegisterResult persInfo = resp.getPersonResult().get(0); + assertEquals("wrong familyname", "XXXSZR", persInfo.getFamilyName()); + + + } + + +} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/ernp_handbook_example.json b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/ernp_handbook_example.json new file mode 100644 index 00000000..f4485ff7 --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/ernp_handbook_example.json @@ -0,0 +1,85 @@ +{ + "person": [ + { + "type": "Person", + "anschrift": { + "type": "AnschriftInland", + "adressstatus": "XXXXXXXXX", + "codes": { + "gemeindekennziffer": "09988", + "strassenkennziffer": "T80001" + }, + "entityId": 33069800000171092, + "gemeinde": "Testgemeinde", + "gueltigAb": "2011-09-06T11:23:55.306+02:00", + "hausnummer": "99", + "postleitzahl": "0077", + "postort": "Testpostort 77 mit maximalmögl. Längen", + "staat": { + "isoCode3": "AUT", + "name": "Österreich" + }, + "strasse": "Testgasse" + }, + "entityId": 33069800000171080, + "gueltigAb": "2011-09-06T11:23:55.306+02:00", + "letzteOperation": { + "begruendung": "Testperson", + "durchgefuehrtVon": { + "behoerdenkennzeichen": "346743", + "benutzer": "xlechne@bmi.gv.at" + }, + "vorgang": "PERSON_ANLEGEN", + "zeitpunkt": "2011-09-06T11:23:55.306+02:00" + }, + "personendaten": { + "basiszahl": "000766083209", + "bpkZp": "BC1ifQanMKaDQG0yLBPbQ9AHgb4=", + "entityId": 33069800000171080, + "familienname": "XXXSZR", + "geburtsbundesland": "Wien", + "geburtsdatum": { + "jahr": 1985, + "monat": 1, + "tag": 1 + }, + "geburtsort": "Wien", + "geburtsstaat": { + "isoCode3": "AUT", + "name": "Österreich" + }, + "geprueft": true, + "geschlecht": "Männlich", + "gueltigAb": "2011-09-06T11:23:55.306+02:00", + "vorname": "XXXTest" + }, + "reisedokument": [ + { + "art": "Personalausweis", + "ausgestelltVon": { + "behoerde": "Wien", + "datum": "1985-01-01T00:00:00.000+01:00", + "staat": { + "isoCode3": "AUT", + "name": "Österreich" + } + }, + "entityId": 33069800000171090, + "gueltigAb": "2011-09-06T11:23:55.306+02:00", + "nummer": "123456789" + } + ], + "staatsangehoerigkeit": [ + { + "entityId": 33069800000171084, + "gueltigAb": "2011-09-06T11:23:55.306+02:00", + "staat": { + "isoCode3": "AUT", + "name": "Österreich" + } + } + ], + "version": "2011-09-06T11:23:55.306+02:00" + } + ] +} \ No newline at end of file -- cgit v1.2.3 From 87a347c359ec7ee2a39bfcace1975f60c4eb9375 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Mon, 7 Feb 2022 07:55:13 +0100 Subject: feature(ernp): port search and update steps from ZMR client to ERnP client because we need the same functionality on different API --- .../auth/eidas/v2/clients/ernp/ErnpRestClient.java | 308 +++++++++++++++++++-- .../exception/ErnpRestCommunicationException.java | 4 +- .../eidas/v2/service/RegisterSearchService.java | 24 +- .../auth/eidas/v2/tasks/InitialSearchTask.java | 5 +- 4 files changed, 310 insertions(+), 31 deletions(-) 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 605f1d0f..2eaece1d 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 @@ -5,9 +5,13 @@ import java.text.MessageFormat; import java.time.LocalDate; import java.time.OffsetDateTime; 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; @@ -16,7 +20,6 @@ import javax.annotation.PostConstruct; import org.apache.commons.lang3.StringUtils; import org.apache.http.client.HttpClient; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.client.ClientHttpRequestFactory; import org.springframework.http.client.ClientHttpResponse; @@ -25,6 +28,7 @@ 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.util.Assert; import org.springframework.web.client.ResponseErrorHandler; import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestTemplate; @@ -36,8 +40,11 @@ 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.AendernResponse; +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; 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.PersonAendern; 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; @@ -48,6 +55,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasSAuthenti import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.ErnpRestCommunicationException; 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.base._20040201_.ServiceFault; 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; @@ -81,7 +89,7 @@ public class ErnpRestClient implements IErnpClient { private static final String LOGMSG_ERNP_RESP_PROCESS = "Proces ERnP response during '{}' operation failes with msg: {}"; - private static final String LOGMSG_ERNP_SOAP_ERROR = + private static final String LOGMSG_ERNP_REST_ERROR = "ERnP anwser for transaction: {0} with code: {1} and message: {2}"; private static final String PROCESS_SEARCH_PERSONAL_IDENTIFIER = @@ -95,6 +103,10 @@ public class ErnpRestClient implements IErnpClient { private static final String FRIENDLYNAME_HTTP_CLIENT = "ERnP Client"; + // HTTP header-names from ERnP response + private static final String ERNP_RESPONSE_HEADER_SERVER_ID = "Server-Request-Id"; + + @Autowired IConfiguration basicConfig; @Autowired @@ -109,11 +121,9 @@ public class ErnpRestClient implements IErnpClient { @Override public ErnpRegisterResult searchWithPersonIdentifier(String personIdentifier, String citizenCountryCode) throws EidasSAuthenticationException { - try { - // build generic request metadata - final GenericRequestParams generic = buildGenericRequestParameters("step1"); + final GenericRequestParams generic = buildGenericRequestParameters("stepId"); // build search request final SuchEidas eidasInfos = new SuchEidas(); @@ -153,19 +163,242 @@ public class ErnpRestClient implements IErnpClient { @Override public ErnpRegisterResult searchWithMds(String givenName, String familyName, String dateOfBirth, String citizenCountryCode) throws EidasSAuthenticationException { - return new ErnpRegisterResult(Collections.emptyList()); + try { + // build generic request metadata + final GenericRequestParams generic = buildGenericRequestParameters("stepMDS"); + + // build search request + final Suchdaten searchInfos = new Suchdaten(); + searchInfos.setFamilienname(familyName); + searchInfos.setVorname(givenName); + searchInfos.setGeburtsdatum(buildErnpBirthday(dateOfBirth)); + + final PersonSuchen personSuchen = new PersonSuchen(); + personSuchen.setSuchoptionen(generateSearchParameters()); + personSuchen.setBegruendung(PROCESS_SEARCH_MDS_ONLY); + personSuchen.setSuchdaten(searchInfos); + + // request ERnP + log.trace("Requesting ERnP for '{}' operation", PROCESS_SEARCH_MDS_ONLY); + final SuchenResponse resp = ernpClient.suchen(generic.getClientBehkz(), generic.clientName, + generic.getClientRequestTime(), generic.getClientRequestId(), personSuchen); + + // parse ZMR response + return processErnpResponse(resp, citizenCountryCode, false, PROCESS_SEARCH_MDS_ONLY); + + } catch (RestClientException e) { + log.warn(LOGMSG_ERNP_ERROR, PROCESS_SEARCH_MDS_ONLY, 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_MDS_ONLY, e.getMessage()); + throw new EidasSAuthenticationException(ERROR_MATCHING_99, new Object[] { e.getMessage() }, e); + } } @Override public ErnpRegisterResult searchCountrySpecific(PersonSuchenRequest personSearchDao, String citizenCountryCode) throws EidasSAuthenticationException { - return new ErnpRegisterResult(Collections.emptyList()); + 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.setSuchdaten(mapCountrySpecificSearchData(personSearchDao)); + + // request ERnP + log.trace("Requesting ERnP for '{}' operation", PROCESS_SEARCH_COUNTRY_SPECIFIC); + 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); + + } catch (RestClientException e) { + log.warn(LOGMSG_ERNP_ERROR, PROCESS_SEARCH_COUNTRY_SPECIFIC, 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()); + throw new EidasSAuthenticationException(ERROR_MATCHING_99, new Object[] { e.getMessage() }, e); + + } } @Override public ErnpRegisterResult update(RegisterResult registerResult, SimpleEidasData eidData) throws EidasSAuthenticationException { - return new ErnpRegisterResult(Collections.emptyList()); + try { + //search person with register result, because update needs information from search response + Person ernpPersonToKitt = searchPersonForUpdate(registerResult); + + // select elements that have to be updated + Collection eidasDocumentToAdd = + selectEidasDocumentsToAdd(ernpPersonToKitt, eidData); + + if (eidasDocumentToAdd.isEmpty()) { + log.info("Find no eIDAS document for update during: {}. Looks strange but nothing todo", + PROCESS_KITT_GENERAL); + return new ErnpRegisterResult(Arrays.asList(registerResult)); + + } 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 updatePersonInErnp(ernpPersonToKitt, eidasDocumentToAdd, eidData.getCitizenCountryCode()); + + } + + } catch (RestClientException e) { + log.warn(LOGMSG_ERNP_ERROR, PROCESS_SEARCH_COUNTRY_SPECIFIC, 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()); + throw new EidasSAuthenticationException(ERROR_MATCHING_99, new Object[] { e.getMessage() }, e); + + } + } + + private ErnpRegisterResult updatePersonInErnp(Person ernpPersonToKitt, + Collection eidasDocumentToAdd, String citizenCountryCode) + throws ServiceFault { + // build generic request metadata + final GenericRequestParams generic = buildGenericRequestParameters("stepKittUpdate"); + + // build update request + PersonAendern ernpReq = new PersonAendern(); + ernpReq.setBegruendung(PROCESS_KITT_IDENITIES_UPDATE); + + // set reference elements for person update + ernpReq.setEntityId(ernpPersonToKitt.getEntityId()); + ernpReq.setVersion(ernpPersonToKitt.getVersion()); + + // add new eIDAS attributes + eidasDocumentToAdd.stream().forEach(el -> ernpReq.getAnlegen().addEidasItem(el)); + + // TODO: should we update MDS also in that step? + + + // request ZMR + log.trace("Requesting ERnP for '{}' operation", PROCESS_KITT_IDENITIES_UPDATE); + AendernResponse ernpResp = ernpClient.aendern(generic.getClientBehkz(), generic.clientName, + generic.getClientRequestTime(), generic.getClientRequestId(), ernpReq); + log.trace("Receive response from ERnP for '{}' operation", PROCESS_KITT_IDENITIES_UPDATE); + + return new ErnpRegisterResult(Arrays.asList( + mapErnpResponseToRegisterResult(ernpResp.getPerson(), citizenCountryCode))); + + } + + private Collection selectEidasDocumentsToAdd( + Person ernpPersonToKitt, SimpleEidasData eidData) { + + //TODO: maybe we should re-factor SimpleEidasData to a generic data-model to facilitate arbitrary eIDAS attributes + Set result = new HashSet<>(); + addEidasDocumentIfNotAvailable(result, ernpPersonToKitt, eidData.getCitizenCountryCode(), + Constants.eIDAS_ATTRURN_PERSONALIDENTIFIER, eidData.getPseudonym(), true); + addEidasDocumentIfNotAvailable(result, ernpPersonToKitt, eidData.getCitizenCountryCode(), + Constants.eIDAS_ATTRURN_PLACEOFBIRTH, eidData.getPlaceOfBirth(), false); + addEidasDocumentIfNotAvailable(result, ernpPersonToKitt, eidData.getCitizenCountryCode(), + Constants.eIDAS_ATTRURN_BIRTHNAME, eidData.getBirthName(), false); + + return result; + + } + + private void addEidasDocumentIfNotAvailable(Set result, + Person ernpPersonToKitt, 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 = ernpPersonToKitt.getEidas().stream() + .filter(el -> el.getWert().equals(attrValue) + && el.getArt().equals(attrName) + && el.getStaatscode2().equals(citizenCountryCode)) + .findAny() + .isPresent(); + + if (!alreadyExist) { + // check eIDAS documents already contains a document with this pair of country-code and attribute-name + Optional oneDocWithNameExists = ernpPersonToKitt.getEidas().stream() + .filter(el -> el.getStaatscode2().equals(citizenCountryCode) + && el.getArt().equals(attrName)) + .findAny(); + + if (!allowMoreThanOneEntry && oneDocWithNameExists.isPresent() + && !oneDocWithNameExists.get().getWert().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 { + + Eidas eidasDocToAdd = new Eidas(); + eidasDocToAdd.setStaatscode2(citizenCountryCode); + eidasDocToAdd.setArt(attrName); + eidasDocToAdd.setWert(attrValue); + log.info("Add eIDAS document: {} for country: {} to ERnP person", attrName, citizenCountryCode); + result.add(eidasDocToAdd); + + } + + } else { + log.debug("eIDAS document: {} already exists for country: {}. Skip update process for this ... ", + attrName, citizenCountryCode); + + } + } + + private Person searchPersonForUpdate(RegisterResult registerResult) throws WorkflowException { + // build generic request metadata + final GenericRequestParams generic = buildGenericRequestParameters("stepKittSearch"); + + // build search request + final Suchdaten searchInfos = new Suchdaten(); + searchInfos.setFamilienname(registerResult.getFamilyName()); + searchInfos.setVorname(registerResult.getGivenName()); + searchInfos.setGeburtsdatum(buildErnpBirthday(registerResult.getDateOfBirth())); + + final PersonSuchen personSuchen = new PersonSuchen(); + personSuchen.setSuchoptionen(generateSearchParameters()); + personSuchen.setBegruendung(PROCESS_KITT_IDENITIES_GET); + personSuchen.setSuchdaten(searchInfos); + + // request ERnP + log.trace("Requesting ERnP for '{}' operation", PROCESS_KITT_IDENITIES_GET); + final SuchenResponse resp = ernpClient.suchen(generic.getClientBehkz(), generic.clientName, + generic.getClientRequestTime(), generic.getClientRequestId(), personSuchen); + + // perform shot validation of ERnP response + if (resp.getPerson() == null || resp.getPerson().size() != 1) { + log.error("ERnP result contains NO 'Person' or 'Person' is empty"); + throw new WorkflowException(PROCESS_KITT_IDENITIES_GET, + "Find NO data-set with already matchted eID during ERnP KITT process"); + + } else { + log.debug("Find person for '{}' operation", PROCESS_KITT_IDENITIES_GET); + return resp.getPerson().get(0); + + } } @Override @@ -270,7 +503,7 @@ public class ErnpRestClient implements IErnpClient { Constants.eIDAS_ATTRURN_PERSONALIDENTIFIER)) .familyName(person.getPersonendaten().getFamilienname()) .givenName(person.getPersonendaten().getVorname()) - .dateOfBirth(buildTextualBirthday(person.getPersonendaten().getGeburtsdatum())) + .dateOfBirth(getTextualBirthday(person.getPersonendaten().getGeburtsdatum())) .bpk(person.getPersonendaten().getBpkZp()) .placeOfBirth(selectSingleEidasDocument(person, citizenCountryCode, Constants.eIDAS_ATTRURN_PLACEOFBIRTH)) @@ -280,18 +513,31 @@ public class ErnpRestClient implements IErnpClient { } + private Suchdaten mapCountrySpecificSearchData(PersonSuchenRequest personSearchDao) { + final Suchdaten searchInfos = new Suchdaten(); + searchInfos.setFamilienname(personSearchDao.getNatuerlichePerson().getPersonenName().getFamilienname()); + searchInfos.setVorname(personSearchDao.getNatuerlichePerson().getPersonenName().getVorname()); + searchInfos.setGeburtsdatum(buildErnpBirthday(personSearchDao.getNatuerlichePerson().getGeburtsdatum())); + + //TODO: search eIDAS has to be a LIST!!!!!! + SuchEidas eidasInfos = new SuchEidas(); + searchInfos.setEidas(eidasInfos ); + return searchInfos; + + } + /** * Build AT specific Date String 'yyyy-MM-dd' from ERnP birthday representation. * *

- * Info: {@link LocalDate} can not be used, because '1940-00-00' is also + * Info: {@link LocalDate} can not be used, because '1940-00-00' is also * a valid birthday on ERnP site. *

* * @param geburtsdatum ERnP birthday representation * @return birthday in 'yyyy-MM-dd' format */ - private String buildTextualBirthday(PartialDate geburtsdatum) { + private String getTextualBirthday(PartialDate geburtsdatum) { return MessageFormat.format("{0}-{1}-{2}", String.valueOf(geburtsdatum.getJahr()), String.format("%02d", geburtsdatum.getMonat()), @@ -299,6 +545,29 @@ public class ErnpRestClient implements IErnpClient { } + /** + * Map an AT specific Date String 'yyyy-MM-dd' to ERnP birthday representation. + * + *

+ * Info: {@link LocalDate} can not be used, because '1940-00-00' is also + * a valid birthday. + *

+ * + * @param dateOfBirth in 'yyyy-MM-dd' format + * @return ERnP birthday representation + */ + private PartialDate buildErnpBirthday(String dateOfBirth) { + String[] elements = dateOfBirth.split("-"); + Assert.isTrue(elements.length == 3, "Find invalid dateOfBirth element: " + dateOfBirth); + + PartialDate result = new PartialDate(); + result.setJahr(Integer.valueOf(elements[0])); + result.setMonat(Integer.valueOf(elements[1])); + result.setTag(Integer.valueOf(elements[2])); + return result; + + } + /** * Get all eIDAS document with the specified country code and document type. * @@ -364,7 +633,7 @@ public class ErnpRestClient implements IErnpClient { private HttpMessageConverter buildCustomJacksonObjectMapper() { final MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); - converter.setSupportedMediaTypes(Collections.singletonList(MediaType.ALL)); + converter.setSupportedMediaTypes(Collections.singletonList(MediaType.APPLICATION_JSON)); converter.getObjectMapper() .setSerializationInclusion(Include.NON_NULL); return converter; @@ -384,17 +653,14 @@ public class ErnpRestClient implements IErnpClient { @Override public void handleError(ClientHttpResponse response) throws IOException { - // TODO: implement errorHandling based on response infos + // TODO: opimize errorHandling based on response info's from real ERnP + + List serverId = response.getHeaders().getOrEmpty(ERNP_RESPONSE_HEADER_SERVER_ID); + log.warn("Receive http-error: {} from ERnP with serverTransactionId", + response.getRawStatusCode(), serverId.isEmpty() ? "'not set'" : serverId.get(0)); - 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()); - - } - throw new ErnpRestCommunicationException(response.getRawStatusCode()); + } }; } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/exception/ErnpRestCommunicationException.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/exception/ErnpRestCommunicationException.java index 72a5ece6..e3224c93 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/exception/ErnpRestCommunicationException.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/exception/ErnpRestCommunicationException.java @@ -19,6 +19,6 @@ public class ErnpRestCommunicationException extends IOException { public ErnpRestCommunicationException(int rawStatusCode) { super("ERnP service answers with an error and HTTP status-code: " + rawStatusCode); this.httpStatusCode = rawStatusCode; - } - + + } } 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 fd9a67a9..488b571b 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 @@ -21,6 +21,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasSAuthenti 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.handler.CountrySpecificDetailSearchProcessor; +import at.gv.bmi.namespace.zmr_su.zmr._20040201.PersonSuchenRequest; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.RequiredArgsConstructor; @@ -133,17 +134,22 @@ public class RegisterSearchService { try { @Nullable final CountrySpecificDetailSearchProcessor ccSpecificProcessor = findSpecificProcessor(eidasData); if (ccSpecificProcessor != null) { - log.debug("Selecting country-specific search processor: {}", ccSpecificProcessor.getName()); + log.debug("Selecting country-specific search processor: {}", ccSpecificProcessor.getName()); + PersonSuchenRequest ccSpecificSearchReq = ccSpecificProcessor.generateSearchRequest(eidasData); + + // search in ZMR final ZmrRegisterResult resultsZmr = zmrClient.searchCountrySpecific(operationStatus.getZmrProcessId(), - ccSpecificProcessor.generateSearchRequest(eidasData), - eidasData.getCitizenCountryCode()); - return RegisterStatusResults.fromZmr(resultsZmr); + ccSpecificSearchReq, eidasData.getCitizenCountryCode()); + + //search in ERnP + ErnpRegisterResult resultErnp = ernpClient.searchCountrySpecific( + ccSpecificSearchReq, eidasData.getCitizenCountryCode()); + + return RegisterStatusResults.fromZmrAndErnp(resultsZmr, resultErnp); } else { - // TODO: add search procesfor for ERnP searching - return RegisterStatusResults.fromErnp(operationStatus, - new ErnpRegisterResult(Collections.emptyList())); + return RegisterStatusResults.fromEmpty(operationStatus); } @@ -383,6 +389,10 @@ public class RegisterSearchService { static RegisterStatusResults fromErnp(RegisterOperationStatus status, ErnpRegisterResult updateErnp) { return new RegisterStatusResults(status, Collections.emptyList(), updateErnp.getPersonResult()); } + + static RegisterStatusResults fromEmpty(RegisterOperationStatus status) { + return new RegisterStatusResults(status, Collections.emptyList(), Collections.emptyList()); + } } 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 f295d66b..c720cb7f 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 @@ -185,7 +185,10 @@ public class InitialSearchTask extends AbstractAuthServletTask { log.trace("Starting step3CheckRegisterUpdateNecessary"); if (!eidasData.equalsRegisterData(searchResult)) { log.info("Skipping update-register-information step, because it's not supported yet"); - //TODO: return updated search result if updates are allowed + + //TODO: update of ERnP information are allowed. Add ERnP update-step. Maybe we can use regular KITT steps + + return searchResult; } else { log.debug("Register information match to eIDAS information. No update required"); -- cgit v1.2.3 From 8c08120d543f4eba2b1d1480d6649f13c46e9ef0 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Mon, 7 Feb 2022 10:37:42 +0100 Subject: feature(ernp): add person into ERnP of mathing ends with no result --- .../auth/eidas/v2/clients/ernp/ErnpRestClient.java | 301 ++++++++++++--------- .../auth/eidas/v2/clients/ernp/IErnpClient.java | 12 + .../auth/eidas/v2/ernp/DummyErnpClient.java | 5 + .../eidas/v2/tasks/CreateNewErnpEntryTask.java | 58 ++-- .../test/clients/ErnpRestClientProductionTest.java | 87 ++++++ .../v2/test/tasks/CreateNewErnpEntryTaskTest.java | 198 ++++++++++++++ 6 files changed, 517 insertions(+), 144 deletions(-) create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ErnpRestClientProductionTest.java create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateNewErnpEntryTaskTest.java 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 2eaece1d..58b3ca45 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 @@ -41,11 +41,14 @@ 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.AendernResponse; +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; 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.PersonAendern; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ernp.model.PersonAnlegen; 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.Personendaten; 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; @@ -100,7 +103,8 @@ public class ErnpRestClient implements IErnpClient { 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 PROCESS_ADD_IDENITY = "Add new person"; + private static final String FRIENDLYNAME_HTTP_CLIENT = "ERnP Client"; // HTTP header-names from ERnP response @@ -272,141 +276,41 @@ public class ErnpRestClient implements IErnpClient { } } - private ErnpRegisterResult updatePersonInErnp(Person ernpPersonToKitt, - Collection eidasDocumentToAdd, String citizenCountryCode) - throws ServiceFault { + @Override + public ErnpRegisterResult add(SimpleEidasData eidData) throws EidasSAuthenticationException { // build generic request metadata - final GenericRequestParams generic = buildGenericRequestParameters("stepKittUpdate"); + final GenericRequestParams generic = buildGenericRequestParameters("stepNew"); // build update request - PersonAendern ernpReq = new PersonAendern(); - ernpReq.setBegruendung(PROCESS_KITT_IDENITIES_UPDATE); - - // set reference elements for person update - ernpReq.setEntityId(ernpPersonToKitt.getEntityId()); - ernpReq.setVersion(ernpPersonToKitt.getVersion()); - - // add new eIDAS attributes - eidasDocumentToAdd.stream().forEach(el -> ernpReq.getAnlegen().addEidasItem(el)); - - // TODO: should we update MDS also in that step? - + 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); - // request ZMR - log.trace("Requesting ERnP for '{}' operation", PROCESS_KITT_IDENITIES_UPDATE); - AendernResponse ernpResp = ernpClient.aendern(generic.getClientBehkz(), generic.clientName, + 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_KITT_IDENITIES_UPDATE); + log.trace("Receive response from ERnP for '{}' operation", PROCESS_ADD_IDENITY); return new ErnpRegisterResult(Arrays.asList( - mapErnpResponseToRegisterResult(ernpResp.getPerson(), citizenCountryCode))); - - } - - private Collection selectEidasDocumentsToAdd( - Person ernpPersonToKitt, SimpleEidasData eidData) { - - //TODO: maybe we should re-factor SimpleEidasData to a generic data-model to facilitate arbitrary eIDAS attributes - Set result = new HashSet<>(); - addEidasDocumentIfNotAvailable(result, ernpPersonToKitt, eidData.getCitizenCountryCode(), - Constants.eIDAS_ATTRURN_PERSONALIDENTIFIER, eidData.getPseudonym(), true); - addEidasDocumentIfNotAvailable(result, ernpPersonToKitt, eidData.getCitizenCountryCode(), - Constants.eIDAS_ATTRURN_PLACEOFBIRTH, eidData.getPlaceOfBirth(), false); - addEidasDocumentIfNotAvailable(result, ernpPersonToKitt, eidData.getCitizenCountryCode(), - Constants.eIDAS_ATTRURN_BIRTHNAME, eidData.getBirthName(), false); - - return result; + mapErnpResponseToRegisterResult(ernpResp.getPerson(), eidData.getCitizenCountryCode()))); } - private void addEidasDocumentIfNotAvailable(Set result, - Person ernpPersonToKitt, 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 = ernpPersonToKitt.getEidas().stream() - .filter(el -> el.getWert().equals(attrValue) - && el.getArt().equals(attrName) - && el.getStaatscode2().equals(citizenCountryCode)) - .findAny() - .isPresent(); - - if (!alreadyExist) { - // check eIDAS documents already contains a document with this pair of country-code and attribute-name - Optional oneDocWithNameExists = ernpPersonToKitt.getEidas().stream() - .filter(el -> el.getStaatscode2().equals(citizenCountryCode) - && el.getArt().equals(attrName)) - .findAny(); - - if (!allowMoreThanOneEntry && oneDocWithNameExists.isPresent() - && !oneDocWithNameExists.get().getWert().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 { - - Eidas eidasDocToAdd = new Eidas(); - eidasDocToAdd.setStaatscode2(citizenCountryCode); - eidasDocToAdd.setArt(attrName); - eidasDocToAdd.setWert(attrValue); - log.info("Add eIDAS document: {} for country: {} to ERnP person", attrName, citizenCountryCode); - result.add(eidasDocToAdd); - - } - - } else { - log.debug("eIDAS document: {} already exists for country: {}. Skip update process for this ... ", - attrName, citizenCountryCode); - - } - } - - private Person searchPersonForUpdate(RegisterResult registerResult) throws WorkflowException { - // build generic request metadata - final GenericRequestParams generic = buildGenericRequestParameters("stepKittSearch"); - - // build search request - final Suchdaten searchInfos = new Suchdaten(); - searchInfos.setFamilienname(registerResult.getFamilyName()); - searchInfos.setVorname(registerResult.getGivenName()); - searchInfos.setGeburtsdatum(buildErnpBirthday(registerResult.getDateOfBirth())); - - final PersonSuchen personSuchen = new PersonSuchen(); - personSuchen.setSuchoptionen(generateSearchParameters()); - personSuchen.setBegruendung(PROCESS_KITT_IDENITIES_GET); - personSuchen.setSuchdaten(searchInfos); - - // request ERnP - log.trace("Requesting ERnP for '{}' operation", PROCESS_KITT_IDENITIES_GET); - final SuchenResponse resp = ernpClient.suchen(generic.getClientBehkz(), generic.clientName, - generic.getClientRequestTime(), generic.getClientRequestId(), personSuchen); - - // perform shot validation of ERnP response - if (resp.getPerson() == null || resp.getPerson().size() != 1) { - log.error("ERnP result contains NO 'Person' or 'Person' is empty"); - throw new WorkflowException(PROCESS_KITT_IDENITIES_GET, - "Find NO data-set with already matchted eID during ERnP KITT process"); - - } else { - log.debug("Find person for '{}' operation", PROCESS_KITT_IDENITIES_GET); - return resp.getPerson().get(0); - - } - } - @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 { // validate additional Ernp communication parameters @@ -545,6 +449,161 @@ public class ErnpRestClient implements IErnpClient { } + private ErnpRegisterResult updatePersonInErnp(Person ernpPersonToKitt, + Collection eidasDocumentToAdd, String citizenCountryCode) + throws ServiceFault { + // build generic request metadata + final GenericRequestParams generic = buildGenericRequestParameters("stepKittUpdate"); + + // build update request + PersonAendern ernpReq = new PersonAendern(); + ernpReq.setBegruendung(PROCESS_KITT_IDENITIES_UPDATE); + + // set reference elements for person update + ernpReq.setEntityId(ernpPersonToKitt.getEntityId()); + ernpReq.setVersion(ernpPersonToKitt.getVersion()); + + // add new eIDAS attributes + eidasDocumentToAdd.stream().forEach(el -> ernpReq.getAnlegen().addEidasItem(el)); + + // TODO: should we update MDS also in that step? + + + // request ERnP + log.trace("Requesting ERnP for '{}' operation", PROCESS_KITT_IDENITIES_UPDATE); + AendernResponse ernpResp = ernpClient.aendern(generic.getClientBehkz(), generic.clientName, + generic.getClientRequestTime(), generic.getClientRequestId(), ernpReq); + log.trace("Receive response from ERnP for '{}' operation", PROCESS_KITT_IDENITIES_UPDATE); + + return new ErnpRegisterResult(Arrays.asList( + mapErnpResponseToRegisterResult(ernpResp.getPerson(), citizenCountryCode))); + + } + + private Collection selectEidasDocumentsToAdd( + Person ernpPersonToKitt, SimpleEidasData eidData) { + + //TODO: maybe we should re-factor SimpleEidasData to a generic data-model to facilitate arbitrary eIDAS attributes + Set result = new HashSet<>(); + addEidasDocumentIfNotAvailable(result, ernpPersonToKitt, eidData.getCitizenCountryCode(), + Constants.eIDAS_ATTRURN_PERSONALIDENTIFIER, eidData.getPseudonym(), true); + addEidasDocumentIfNotAvailable(result, ernpPersonToKitt, eidData.getCitizenCountryCode(), + Constants.eIDAS_ATTRURN_PLACEOFBIRTH, eidData.getPlaceOfBirth(), false); + addEidasDocumentIfNotAvailable(result, ernpPersonToKitt, eidData.getCitizenCountryCode(), + Constants.eIDAS_ATTRURN_BIRTHNAME, eidData.getBirthName(), false); + + return result; + + } + + private void addEidasDocumentIfNotAvailable(Set result, + Person ernpPersonToKitt, 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 = ernpPersonToKitt.getEidas().stream() + .filter(el -> el.getWert().equals(attrValue) + && el.getArt().equals(attrName) + && el.getStaatscode2().equals(citizenCountryCode)) + .findAny() + .isPresent(); + + if (!alreadyExist) { + // check eIDAS documents already contains a document with this pair of country-code and attribute-name + Optional oneDocWithNameExists = ernpPersonToKitt.getEidas().stream() + .filter(el -> el.getStaatscode2().equals(citizenCountryCode) + && el.getArt().equals(attrName)) + .findAny(); + + if (!allowMoreThanOneEntry && oneDocWithNameExists.isPresent() + && !oneDocWithNameExists.get().getWert().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 { + + Eidas eidasDocToAdd = new Eidas(); + eidasDocToAdd.setStaatscode2(citizenCountryCode); + eidasDocToAdd.setArt(attrName); + eidasDocToAdd.setWert(attrValue); + log.info("Add eIDAS document: {} for country: {} to ERnP person", attrName, citizenCountryCode); + result.add(eidasDocToAdd); + + } + + } else { + log.debug("eIDAS document: {} already exists for country: {}. Skip update process for this ... ", + attrName, citizenCountryCode); + + } + } + + private Person searchPersonForUpdate(RegisterResult registerResult) throws WorkflowException { + // build generic request metadata + final GenericRequestParams generic = buildGenericRequestParameters("stepKittSearch"); + + // build search request + final Suchdaten searchInfos = new Suchdaten(); + searchInfos.setFamilienname(registerResult.getFamilyName()); + searchInfos.setVorname(registerResult.getGivenName()); + searchInfos.setGeburtsdatum(buildErnpBirthday(registerResult.getDateOfBirth())); + + final PersonSuchen personSuchen = new PersonSuchen(); + personSuchen.setSuchoptionen(generateSearchParameters()); + personSuchen.setBegruendung(PROCESS_KITT_IDENITIES_GET); + personSuchen.setSuchdaten(searchInfos); + + // request ERnP + log.trace("Requesting ERnP for '{}' operation", PROCESS_KITT_IDENITIES_GET); + final SuchenResponse resp = ernpClient.suchen(generic.getClientBehkz(), generic.clientName, + generic.getClientRequestTime(), generic.getClientRequestId(), personSuchen); + + // perform shot validation of ERnP response + if (resp.getPerson() == null || resp.getPerson().size() != 1) { + log.error("ERnP result contains NO 'Person' or 'Person' is empty"); + throw new WorkflowException(PROCESS_KITT_IDENITIES_GET, + "Find NO data-set with already matchted eID during ERnP KITT process"); + + } else { + log.debug("Find person for '{}' operation", PROCESS_KITT_IDENITIES_GET); + return resp.getPerson().get(0); + + } + } + + private void buildNewEidasDocumens(PersonAnlegen ernpReq, SimpleEidasData eidData) { + ernpReq.addEidasItem(buildNewEidasDocument(eidData.getCitizenCountryCode(), + Constants.eIDAS_ATTRURN_PERSONALIDENTIFIER, eidData.getPseudonym())); + + if (StringUtils.isNotEmpty(eidData.getPlaceOfBirth())) { + ernpReq.addEidasItem(buildNewEidasDocument(eidData.getCitizenCountryCode(), + Constants.eIDAS_ATTRURN_PLACEOFBIRTH, eidData.getPlaceOfBirth())); + + } + + if (StringUtils.isNotEmpty(eidData.getBirthName())) { + ernpReq.addEidasItem(buildNewEidasDocument(eidData.getCitizenCountryCode(), + Constants.eIDAS_ATTRURN_BIRTHNAME, eidData.getBirthName())); + + } + } + + private Eidas buildNewEidasDocument(String citizenCountryCode, String eidasAttrName, + String eidasAddrValue) { + Eidas el = new Eidas(); + el.setArt(eidasAttrName); + el.setWert(eidasAddrValue); + el.setStaatscode2(citizenCountryCode); + return el; + } + /** * Map an AT specific Date String 'yyyy-MM-dd' to ERnP birthday representation. * diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/IErnpClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/IErnpClient.java index 4c8bcd3e..7a957531 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/IErnpClient.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/IErnpClient.java @@ -84,6 +84,18 @@ public interface IErnpClient { ErnpRegisterResult update(RegisterResult registerResult, SimpleEidasData eidData) throws EidasSAuthenticationException; + + /** + * Add new entry into ERnP by using identity from this eIDAS authentication. + * + * @param eidData eIDAS eID information from current authentication process + * @return Update result but never null + * @throws EidasSAuthenticationException In case of a communication error + */ + @Nonnull + ErnpRegisterResult add(SimpleEidasData eidData) throws EidasSAuthenticationException; + + /** * Search person based on address information. * 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 52703232..dabb73dc 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 @@ -73,4 +73,9 @@ public class DummyErnpClient implements IErnpClient { } + @Override + public ErnpRegisterResult add(SimpleEidasData eidData) throws EidasSAuthenticationException { + return buildEmptyResult(); + } + } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateNewErnpEntryTask.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateNewErnpEntryTask.java index 6fc6d499..b63b0ca0 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateNewErnpEntryTask.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateNewErnpEntryTask.java @@ -26,9 +26,16 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.ErnpRestClient; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.ErnpRestClient.ErnpRegisterResult; +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.exception.WorkflowException; +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.TaskExecutionException; import at.gv.egiz.eaaf.core.impl.idp.auth.modules.AbstractAuthServletTask; @@ -46,6 +53,7 @@ import lombok.extern.slf4j.Slf4j; *
  • TODO MDS, BPK of new entry
  • * * + * @author tlenz * @author amarsalek * @author ckollmann */ @@ -53,36 +61,40 @@ import lombok.extern.slf4j.Slf4j; @Component("CreateNewErnbEntryTask") public class CreateNewErnpEntryTask extends AbstractAuthServletTask { - //private final SzrClient szrClient; + private final ErnpRestClient ernpClient; - ///** - // * Constructor. - // * @param szrClient SZR client for creating a new ERnP entry - // */ - //public CreateNewErnpEntryTask(SzrClient szrClient) { - // this.szrClient = szrClient; - //} + /** + * Constructor. + * @param szrClient SZR client for creating a new ERnP entry + */ + public CreateNewErnpEntryTask(@Autowired ErnpRestClient client) { + this.ernpClient = client; + } @Override public void execute(ExecutionContext executionContext, HttpServletRequest request, HttpServletResponse response) throws TaskExecutionException { try { - //SimpleEidasData simpleEidasData = MatchingTaskUtils.getInitialEidasData(pendingReq); - - // insert person into ERnP - //TODO: should we insert it directly into ERnP? - //TODO: has to updated to new eIDAS document model in ERnP - //String vsz = szrClient.createNewErnpEntry(simpleEidasData); - - // finish matching process, because new user-entry uniquly matches - //log.info("User successfully registerred into ERnP and matching tasks are finished "); - //MatchingTaskUtils.storeFinalMatchingResult(pendingReq, - // MatchedPersonResult.builder() - // .vsz(vsz) - // .build()); - - log.warn("Skipping new insert ERnP task, because it's currently unknown who we should it"); + SimpleEidasData simpleEidasData = MatchingTaskUtils.getInitialEidasData(pendingReq); + if (simpleEidasData == null) { + throw new WorkflowException("step09", "No initial eIDAS authn data", true); + + } + //add person into ERnP + ErnpRegisterResult resp = ernpClient.add(simpleEidasData); + if (resp.getPersonResult().size() != 1) { + log.error("Receive {} from ERnP during 'add person' step", + resp.getPersonResult().isEmpty() ? "no result" : "more-than-one result"); + throw new WorkflowException("step09", "Add person into ERnP failed", true); + + } + + // finish matching process, because new user-entry uniquly matches + log.info("User successfully registerred into ERnP and matching tasks are finished "); + MatchingTaskUtils.storeFinalMatchingResult(pendingReq, + MatchedPersonResult.generateFormMatchingResult( + resp.getPersonResult().get(0), simpleEidasData.getCitizenCountryCode())); } catch (final Exception e) { log.error("Initial search FAILED.", e); diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ErnpRestClientProductionTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ErnpRestClientProductionTest.java new file mode 100644 index 00000000..6ebe4c8a --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ErnpRestClientProductionTest.java @@ -0,0 +1,87 @@ +package at.asitplus.eidas.specific.modules.auth.eidas.v2.test.clients; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThrows; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.IfProfileValue; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.ErnpRestClient.ErnpRegisterResult; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.IErnpClient; +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 lombok.SneakyThrows; + +@IfProfileValue(name = "spring.profiles.active", value = "devEnvironment") +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = { + "/SpringTest-context_tasks_test.xml", + "/SpringTest-context_basic_realConfig.xml"}) +@TestPropertySource(locations = { + //"classpath:/application.properties", + "file:/home/tlenz/Projekte/config/ms_connector/default_config.properties", + }) +public class ErnpRestClientProductionTest { + + @Autowired IErnpClient client; + + @Test + @SneakyThrows + public void searchWithPersonalIdentifierServerError() { + final String personalIdentifierFirst = "7cEYWithDEElementsasdfsafsaf4CDVzNT4E7cjkU4VqForjUnit"; + final String cc = "DE"; + final SimpleEidasData eidasDataFirst = SimpleEidasData.builder() + .citizenCountryCode(cc) + .familyName("XXXvon Brandenburg") + .givenName("XXXClaus - Maria") + .dateOfBirth("1994-12-31") + .personalIdentifier(cc + "/AT/" + personalIdentifierFirst) + .pseudonym(personalIdentifierFirst) + .build(); + + // execute operation + EidasSAuthenticationException error = assertThrows("wrong Exception", EidasSAuthenticationException.class, + () -> client.searchWithPersonIdentifier( + eidasDataFirst.getPseudonym(), eidasDataFirst.getCitizenCountryCode())); + + assertEquals("wrong errorCode", "module.eidasauth.matching.11", error.getErrorId()); + + } + + @Test + @SneakyThrows + public void searchWithPersonalIdentifierSuccess() { + final String personalIdentifierFirst = "7cEYWithDEElementsasdfsafsaf4CDVzNT4E7cjkU4VqForjUnit"; + final String cc = "DE"; + final SimpleEidasData eidasDataFirst = SimpleEidasData.builder() + .citizenCountryCode(cc) + .familyName("XXXvon Brandenburg") + .givenName("XXXClaus - Maria") + .dateOfBirth("1994-12-31") + .personalIdentifier(cc + "/AT/" + personalIdentifierFirst) + .pseudonym(personalIdentifierFirst) + .build(); + + // execute operation + ErnpRegisterResult resp = client.searchWithPersonIdentifier( + eidasDataFirst.getPseudonym(), eidasDataFirst.getCitizenCountryCode()); + + // validate state + assertNotNull("no ERnP response", resp); + assertEquals("wrong resp size", 1, resp.getPersonResult().size()); + + RegisterResult persInfo = resp.getPersonResult().get(0); + assertEquals("wrong familyname", "XXXSZR", persInfo.getFamilyName()); + + + } + + +} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateNewErnpEntryTaskTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateNewErnpEntryTaskTest.java new file mode 100644 index 00000000..985a5e14 --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateNewErnpEntryTaskTest.java @@ -0,0 +1,198 @@ +package at.asitplus.eidas.specific.modules.auth.eidas.v2.test.tasks; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; + +import java.net.URISyntaxException; +import java.util.Arrays; +import java.util.List; + +import org.apache.commons.lang3.RandomStringUtils; +import org.jetbrains.annotations.NotNull; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.mock.web.MockHttpServletResponse; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.ErnpRestClient; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.ErnpRestClient.ErnpRegisterResult; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.MatchedPersonResult; +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.WorkflowException; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.CreateNewErnpEntryTask; +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; +import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; +import at.gv.egiz.eaaf.core.impl.idp.module.test.TestRequestImpl; +import at.gv.egiz.eaaf.core.impl.idp.process.ExecutionContextImpl; +import lombok.SneakyThrows; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = { + "/SpringTest-context_tasks_test.xml", + "/SpringTest-context_basic_mapConfig.xml" +}) +@DirtiesContext(classMode = ClassMode.BEFORE_CLASS) +public class CreateNewErnpEntryTaskTest { + + CreateNewErnpEntryTask task; + + @Mock ErnpRestClient ernpClient; + + final ExecutionContext executionContext = new ExecutionContextImpl(); + private TestRequestImpl pendingReq; + + /** + * jUnit test set-up. + */ + @Before + public void setUp() throws URISyntaxException, EaafStorageException { + task = new CreateNewErnpEntryTask(ernpClient); + + MockHttpServletRequest httpReq = new MockHttpServletRequest("POST", "https://localhost/authhandler"); + MockHttpServletResponse httpResp = new MockHttpServletResponse(); + RequestContextHolder.resetRequestAttributes(); + RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(httpReq, httpResp)); + + pendingReq = new TestRequestImpl(); + pendingReq.setPendingReqId(RandomStringUtils.randomAlphanumeric(10)); + + } + + + @Test + @SneakyThrows + public void missingEidasData() { + Mockito.when(ernpClient.add(any())) + .thenThrow(new IllegalStateException("add ERnP entry should not be neccessary")); + + TaskExecutionException error = assertThrows("wrong exception", TaskExecutionException.class, + () -> task.execute(pendingReq, executionContext)); + + assertEquals("wrong pendingRequestId", pendingReq.getPendingRequestId(), error.getPendingRequestID()); + assertTrue("Wrong exception", (error.getOriginalException() instanceof WorkflowException)); + assertTrue("Wrong flag 'manualFixNeeded'", + ((WorkflowException) error.getOriginalException()).isRequiresManualFix()); + + } + + @Test + @SneakyThrows + public void noErnpResponse() { + SimpleEidasData input = buildInputData(); + Mockito.when(ernpClient.add(input)) + .thenReturn(ernpRegisterResult(Arrays.asList())); + + TaskExecutionException error = assertThrows("wrong exception", TaskExecutionException.class, + () -> task.execute(pendingReq, executionContext)); + + assertEquals("wrong pendingRequestId", pendingReq.getPendingRequestId(), error.getPendingRequestID()); + assertTrue("Wrong exception", (error.getOriginalException() instanceof WorkflowException)); + assertTrue("Wrong flag 'manualFixNeeded'", + ((WorkflowException) error.getOriginalException()).isRequiresManualFix()); + + } + + @Test + @SneakyThrows + public void moreThanOneErnpResponse() { + String bpk = RandomStringUtils.randomAlphabetic(5); + SimpleEidasData input = buildInputData(); + Mockito.when(ernpClient.add(input)) + .thenReturn(ernpRegisterResult(Arrays.asList(buildErnpResultEntry(input, bpk), buildRandomResultEntry()))); + + TaskExecutionException error = assertThrows("wrong exception", TaskExecutionException.class, + () -> task.execute(pendingReq, executionContext)); + + assertEquals("wrong pendingRequestId", pendingReq.getPendingRequestId(), error.getPendingRequestID()); + assertTrue("Wrong exception", (error.getOriginalException() instanceof WorkflowException)); + assertTrue("Wrong flag 'manualFixNeeded'", + ((WorkflowException) error.getOriginalException()).isRequiresManualFix()); + + } + + @Test + @SneakyThrows + public void insertErnpSuccess() { + String bpk = RandomStringUtils.randomAlphabetic(5); + SimpleEidasData input = buildInputData(); + Mockito.when(ernpClient.add(input)) + .thenReturn(ernpRegisterResult(Arrays.asList(buildErnpResultEntry(input, bpk)))); + + // perform test + task.execute(pendingReq, executionContext); + + // validate state + MatchedPersonResult result = MatchingTaskUtils.getFinalMatchingResult(pendingReq); + assertNotNull("no matching result", result); + assertEquals("familyname", input.getFamilyName(), result.getFamilyName()); + assertEquals("givenyname", input.getGivenName(), result.getGivenName()); + assertEquals("dateOfBirth", input.getDateOfBirth(), result.getDateOfBirth()); + assertEquals("bpk", bpk, result.getBpk()); + assertEquals("countryCode", input.getCitizenCountryCode(), result.getCountryCode()); + + } + + + @NotNull + private ErnpRegisterResult ernpRegisterResult(List registerResult) { + return new ErnpRegisterResult(registerResult); + + } + + private RegisterResult buildErnpResultEntry(SimpleEidasData input, String bpk) { + return buildErnpResultEntry(input.getFamilyName(), input.getGivenName(), input.getDateOfBirth(), bpk); + + } + + private RegisterResult buildRandomResultEntry() { + return buildErnpResultEntry(RandomStringUtils.randomAlphabetic(5), RandomStringUtils.randomAlphabetic(5), + RandomStringUtils.randomAlphabetic(5), RandomStringUtils.randomAlphabetic(5)); + + } + + private RegisterResult buildErnpResultEntry(String familyName, String givenName, String birthday, String bpk) { + return RegisterResult.builder() + .bpk(bpk) + .dateOfBirth(birthday) + .givenName(givenName) + .familyName(familyName) + .build(); + + } + + private SimpleEidasData buildInputData() throws EaafStorageException { + String cc = RandomStringUtils.randomAlphabetic(5).toUpperCase(); + String pseudonym = RandomStringUtils.randomAlphabetic(5); + String familyName = RandomStringUtils.randomAlphabetic(5); + String givenName = RandomStringUtils.randomAlphabetic(5); + String birthday = RandomStringUtils.randomNumeric(4) + "-" + + RandomStringUtils.randomNumeric(2) + "-" + RandomStringUtils.randomNumeric(2); + + SimpleEidasData input = SimpleEidasData.builder() + .familyName(familyName) + .givenName(givenName) + .dateOfBirth(birthday) + .personalIdentifier(cc + "/AT/" + pseudonym) + .pseudonym(pseudonym) + .citizenCountryCode(cc) + .build(); + MatchingTaskUtils.storeInitialEidasData(pendingReq, input); + return input; + + } +} -- cgit v1.2.3 From 1a442f77692a0438cc9d43be563b0ca965ff6c2b Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Mon, 7 Feb 2022 11:17:42 +0100 Subject: refactor(szr): remove 'insertErnp' functionality from SZR client. After this, the person is directly added into ERnP by using ErnpRestClient --- .../auth/eidas/v2/clients/szr/SzrClient.java | 49 ------------ .../eidas/v2/tasks/CreateIdentityLinkTask.java | 29 +------ .../v2/test/clients/SzrClientProductionTest.java | 75 +++--------------- .../auth/eidas/v2/test/clients/SzrClientTest.java | 91 ---------------------- .../tasks/CreateIdentityLinkTaskEidNewTest.java | 71 +++++++---------- .../v2/test/tasks/CreateIdentityLinkTaskTest.java | 10 ++- 6 files changed, 50 insertions(+), 275 deletions(-) diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/szr/SzrClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/szr/SzrClient.java index 397cbe46..bd1eb13e 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/szr/SzrClient.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/szr/SzrClient.java @@ -111,28 +111,6 @@ public class SzrClient extends AbstractSoapClient { final ObjectMapper mapper = new ObjectMapper(); - /** - * Get IdentityLink of a person. - * - * - * @param eidData minimum dataset of person - * @return IdentityLink - * @throws SzrCommunicationException In case of a SZR error - */ - public IdentityLinkType getIdentityLinkInRawMode(SimpleEidasData eidData) - throws SzrCommunicationException { - try { - final GetIdentityLinkEidas getIdl = new GetIdentityLinkEidas(); - getIdl.setPersonInfo(generateSzrRequest(eidData)); - - return getIdentityLinkGeneric(getIdl); - - } catch (final Exception e) { - log.warn("SZR communication FAILED. Reason: " + e.getMessage(), e); - throw new SzrCommunicationException("ernb.02", new Object[]{e.getMessage()}, e); - - } - } /** * Get IdentityLink of a person. @@ -206,33 +184,6 @@ public class SzrClient extends AbstractSoapClient { } return resp; } - - /** - * Request a encrypted baseId from SZR. - * - * Note: Previously, this method did create a new ERnP entry, if it did not exist. This is - * not the case any more. See {@link #createNewErnpEntry(SimpleEidasData)} for that functionality. - * - * @param eidData Minimum dataset of person - * @return encrypted baseId - * @throws SzrCommunicationException In case of a SZR error - */ - public String getEncryptedStammzahl(final SimpleEidasData eidData) - throws SzrCommunicationException { - final String resp; - try { - resp = this.szr.getStammzahlEncrypted(generateSzrRequest(eidData), false); - } catch (SZRException_Exception e) { - throw new SzrCommunicationException("ernb.02", new Object[]{e.getMessage()}, e); - } - - if (StringUtils.isEmpty(resp)) { - throw new SzrCommunicationException("ernb.01", new Object[]{"Stammzahl response empty"}); // TODO error handling - } - - return resp; - - } /** * Request a encrypted baseId from SZR. diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateIdentityLinkTask.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateIdentityLinkTask.java index c95c275e..740e5292 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateIdentityLinkTask.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateIdentityLinkTask.java @@ -86,9 +86,6 @@ import szrservices.IdentityLinkType; *
      *
    • {@link at.gv.egiz.eaaf.core.impl.idp.controller.tasks.FinalizeAuthenticationTask}
    • *
    - * TODO Take Constants#DATA_SIMPLE_EIDAS and Constants#DATA_RESULT_MATCHING_BPK - * TODO Only do VSZ Erstellung and eidasBind -- this is always the end of the whole process - * TODO Move Eintragung to separate Task, as it does not happen every time * @author tlenz */ @Slf4j @@ -192,16 +189,8 @@ public class CreateIdentityLinkTask extends AbstractAuthServletTask { private void executeEidMode(SimpleEidasData eidData, MatchedPersonResult matchedPersonData) throws JsonProcessingException, EaafException, JoseException { // get encrypted baseId - String vsz; - if (matchedPersonData != null) { - log.debug("Requesting encrypted baseId by already matched person information ... "); - vsz = szrClient.getEncryptedStammzahl(matchedPersonData); - - } else { - log.debug("Requesting encrypted baseId by using eIDAS information directly ... "); - vsz = szrClient.createNewErnpEntry(eidData); - - } + log.debug("Requesting encrypted baseId by already matched person information ... "); + String vsz = szrClient.getEncryptedStammzahl(matchedPersonData); //write revision-Log entry and extended infos personal-identifier mapping revisionsLogger.logEvent(pendingReq, MsConnectorEventCodes.SZR_VSZ_RECEIVED); @@ -252,18 +241,8 @@ public class CreateIdentityLinkTask extends AbstractAuthServletTask { private SzrResultHolder requestSzrForIdentityLink(SimpleEidasData eidData, MatchedPersonResult matchedPersonData) throws EaafException { //request IdentityLink from SZR - IdentityLinkType result; - - if (matchedPersonData != null) { - log.debug("Requesting encrypted baseId by already matched person information ... "); - result = szrClient.getIdentityLinkInRawMode(matchedPersonData); - - } else { - log.debug("Requesting encrypted baseId by using eIDAS information directly ... "); - result = szrClient.getIdentityLinkInRawMode(eidData); - - } - + log.debug("Requesting encrypted baseId by already matched person information ... "); + IdentityLinkType result = szrClient.getIdentityLinkInRawMode(matchedPersonData); final Element idlFromSzr = (Element) result.getAssertion(); final IIdentityLink identityLink = new SimpleIdentityLinkAssertionParser(idlFromSzr).parseIdentityLink(); diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/SzrClientProductionTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/SzrClientProductionTest.java index a5b83b13..fb52a729 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/SzrClientProductionTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/SzrClientProductionTest.java @@ -23,16 +23,8 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.test.clients; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.szr.SzrClient; -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.SzrCommunicationException; -import at.gv.egiz.eaaf.core.api.data.EaafConstants; -import at.gv.egiz.eaaf.core.api.idp.IConfiguration; -import at.gv.egiz.eaaf.core.api.idp.auth.data.IIdentityLink; -import at.gv.egiz.eaaf.core.exceptions.EaafParserException; -import at.gv.egiz.eaaf.core.impl.idp.auth.data.SimpleIdentityLinkAssertionParser; +import java.util.List; + import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.StringUtils; import org.bouncycastle.util.encoders.Base64; @@ -47,10 +39,14 @@ import org.springframework.test.annotation.IfProfileValue; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.w3c.dom.Element; -import szrservices.IdentityLinkType; -import java.util.List; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.szr.SzrClient; +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.SzrCommunicationException; +import at.gv.egiz.eaaf.core.api.data.EaafConstants; +import at.gv.egiz.eaaf.core.api.idp.IConfiguration; @IfProfileValue(name = "spring.profiles.active", value = "devEnvironment") @@ -77,13 +73,6 @@ public class SzrClientProductionTest { } - @Test - public void getVsz() throws EidasSAuthenticationException { - String vsz = szrClient.getEncryptedStammzahl(getEidData()); - Assert.assertNotNull("vsz", vsz); - - } - @Test public void getEidasBind() throws EidasSAuthenticationException { String vsz = RandomStringUtils.randomAlphanumeric(10); @@ -96,52 +85,6 @@ public class SzrClientProductionTest { } - - @Test - public void getIdentityLinkRawMode() throws EaafParserException, EidasSAuthenticationException { - log.debug("Starting connecting SZR Gateway"); - final IdentityLinkType result = szrClient.getIdentityLinkInRawMode(getEidData()); - - final Element idlFromSzr = (Element) result.getAssertion(); - final IIdentityLink identityLink = new SimpleIdentityLinkAssertionParser(idlFromSzr).parseIdentityLink(); - - if (identityLink == null) { - throw new SzrCommunicationException("ernb.00", new Object[] { "NO IDL object" }); - } - - System.out.println(identityLink.getSerializedSamlAssertion()); - - if (StringUtils.isEmpty(identityLink.getFamilyName())) { - throw new SzrCommunicationException("ernb.00", new Object[] { "NO FamilyName from IDL" }); - } - - if (StringUtils.isEmpty(identityLink.getGivenName())) { - throw new SzrCommunicationException("ernb.00", new Object[] { "NO GivenName from IDL" }); - } - - if (StringUtils.isEmpty(identityLink.getDateOfBirth())) { - throw new SzrCommunicationException("ernb.00", new Object[] { "NO DateOfBirthName from IDL" }); - } - - if (StringUtils.isEmpty(identityLink.getIdentificationType())) { - throw new SzrCommunicationException("ernb.00", new Object[] { "NO baseIdType from IDL" }); - } - - if (StringUtils.isEmpty(identityLink.getIdentificationValue())) { - throw new SzrCommunicationException("ernb.00", new Object[] { "NO baseId from IDL" }); - } - - if (StringUtils.isEmpty(identityLink.getSerializedSamlAssertion())) { - throw new SzrCommunicationException("ernb.00", new Object[] { "NO serialized IDL" }); - } - - if (identityLink.getSamlAssertion() == null) { - throw new SzrCommunicationException("ernb.00", new Object[] { "NO raw IDL" }); - } - - } - - @Ignore @Test public void getBpkTest() throws EidasSAuthenticationException { diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/SzrClientTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/SzrClientTest.java index ee1ecf9f..c47c4fb0 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/SzrClientTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/SzrClientTest.java @@ -34,7 +34,6 @@ import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import javax.xml.parsers.ParserConfigurationException; -import javax.xml.ws.soap.SOAPFaultException; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.RandomStringUtils; @@ -63,15 +62,9 @@ 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.SzrCommunicationException; import at.gv.egiz.eaaf.core.api.data.EaafConstants; -import at.gv.egiz.eaaf.core.api.idp.auth.data.IIdentityLink; -import at.gv.egiz.eaaf.core.exceptions.EaafParserException; -import at.gv.egiz.eaaf.core.impl.idp.auth.data.SimpleIdentityLinkAssertionParser; import at.gv.egiz.eaaf.core.impl.utils.DomUtils; import lombok.extern.slf4j.Slf4j; -import szrservices.GetBPKFromStammzahlEncryptedResponse; -import szrservices.GetBPKFromStammzahlEncryptedResponseType; import szrservices.GetIdentityLinkEidasResponse; -import szrservices.IdentityLinkType; import szrservices.PersonInfoType; import szrservices.SZR; import szrservices.SZRException_Exception; @@ -110,33 +103,6 @@ public class SzrClientTest { } - - - - @Test - public void getStammzahlenEcryptedTest() throws SZRException_Exception, SzrCommunicationException { - final GetBPKFromStammzahlEncryptedResponse szrResponse = new GetBPKFromStammzahlEncryptedResponse(); - final GetBPKFromStammzahlEncryptedResponseType result1 = new GetBPKFromStammzahlEncryptedResponseType(); - szrResponse.getOut().add(result1); - - result1.setKey(RandomStringUtils.randomAlphanumeric(20)); - - // when(szrMock.getBPKFromStammzahlEncrypted(anyList())) - // .thenReturn(Arrays.asList(result1)); - when(szrMock.getStammzahlEncrypted(any(), any())).thenReturn(result1.getKey()); - - String stammzahlEncrypted = szrClient.getEncryptedStammzahl(getEidData()); - - Assert.assertEquals("bcBind not match", result1.getKey(), stammzahlEncrypted); - - when(szrMock.getStammzahlEncrypted(any(), any())).thenReturn(null); - try { - szrClient.getEncryptedStammzahl(getEidData()); - } catch (SzrCommunicationException e) { - Assert.assertTrue("Not correct error", e.getMessage().contains("ernb.01")); - } - } - @Test public void getEidasBindRealSzrResponse() throws SZRException_Exception, SzrCommunicationException, IOException { final SignContentResponse szrResponse = new SignContentResponse(); @@ -254,63 +220,6 @@ public class SzrClientTest { } - @Test - public void getIdentityLinkRawModeValidResponse() - throws SZRException_Exception, EaafParserException, JAXBException { - setSzrResponseIdentityLink("/data/szr/szr_resp_valid_1.xml"); - - try { - log.debug("Starting connecting SZR Gateway"); - final IdentityLinkType result = szrClient.getIdentityLinkInRawMode(getEidData()); - - Assert.assertNotNull(result); - Assert.assertNotNull(result.getAssertion()); - - final IIdentityLink identityLink = new SimpleIdentityLinkAssertionParser((Element) result.getAssertion()) - .parseIdentityLink(); - Assert.assertNotNull(identityLink); - - System.out.println(identityLink.getSerializedSamlAssertion()); - - checkElement("Mustermann", identityLink.getFamilyName()); - checkElement("Hans", identityLink.getGivenName()); - checkElement("1989-05-05", identityLink.getDateOfBirth()); - checkElement("urn:publicid:gv.at:baseid", identityLink.getIdentificationType()); - checkElement("k+zDM1BVpN1WJO4x7ZQ3ng==", identityLink.getIdentificationValue()); - Assert.assertNotNull(identityLink.getSerializedSamlAssertion()); - Assert.assertNotNull(identityLink.getSamlAssertion()); - - } catch (final SzrCommunicationException e) { - Assert.fail(); - - } - - } - - @Test - public void getIdentityLinkRawModeErrorTravelerDocExists() - throws SZRException_Exception, IOException, ParserConfigurationException, SAXException { - setSzrExceptionIdentityLink("/data/szr/szr_resp_error_travelerdocexists.xml"); - - try { - log.debug("Starting connecting SZR Gateway"); - szrClient.getIdentityLinkInRawMode(getEidData()); - Assert.fail(); - - } catch (final SzrCommunicationException e) { - checkElement("ernb.02", e.getErrorId()); - Assert.assertNotNull(e.getCause()); - org.springframework.util.Assert.isInstanceOf(SOAPFaultException.class, e.getCause()); - Assert.assertNotNull(((SOAPFaultException) e.getCause()).getFault()); - checkElement("p344:F455", ((SOAPFaultException) e.getCause()).getFault().getFaultCode()); - checkElement( - "The travel document you sent to insert a person already exists for another person. " + "Either check the document or have the person altered accordingly", - ((SOAPFaultException) e.getCause()).getFault().getFaultString()); - - } - - } - @Ignore @Test public void getBpkTest() throws EidasSAuthenticationException { diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskEidNewTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskEidNewTest.java index e3757c0d..14ace0b8 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskEidNewTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskEidNewTest.java @@ -133,6 +133,7 @@ public class CreateIdentityLinkTaskEidNewTest { private static ObjectMapper mapper = new ObjectMapper(); private AuthenticationResponse response; + private MatchedPersonResult matchingInfos; @Rule public final SoapServiceRule soap = SoapServiceRule.newInstance(); @@ -168,7 +169,14 @@ public class CreateIdentityLinkTaskEidNewTest { final SimpleEidasData eidData = eidPostProcessor.postProcess(eidasAttributes); MatchingTaskUtils.storeInitialEidasData(pendingReq, eidData); - MatchingTaskUtils.storeFinalMatchingResult(pendingReq, null); + matchingInfos = MatchedPersonResult.builder() + .bpk(RandomStringUtils.randomAlphabetic(5)) + .givenName(eidData.getGivenName()) + .familyName(eidData.getFamilyName()) + .dateOfBirth(eidData.getDateOfBirth()) + .countryCode(eidData.getCitizenCountryCode()) + .build(); + MatchingTaskUtils.storeFinalMatchingResult(pendingReq, matchingInfos); pendingReq.setSpConfig(oaParam); pendingReq.setPendingReqId(at.gv.egiz.eaaf.core.impl.utils.Random.nextProcessReferenceValue()); @@ -187,9 +195,19 @@ public class CreateIdentityLinkTaskEidNewTest { //initialize test response = buildDummyAuthResponse(true); pendingReq.getSessionData(AuthProcessDataWrapper.class) - .setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response); - MatchingTaskUtils.storeInitialEidasData(pendingReq, eidPostProcessor.postProcess( - convertEidasAttrToSimpleMap(response.getAttributes().getAttributeMap()))); + .setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response); + SimpleEidasData eidData = eidPostProcessor.postProcess( + convertEidasAttrToSimpleMap(response.getAttributes().getAttributeMap())); + MatchingTaskUtils.storeInitialEidasData(pendingReq, eidData); + + matchingInfos = MatchedPersonResult.builder() + .bpk(RandomStringUtils.randomAlphabetic(5)) + .givenName(eidData.getGivenName()) + .familyName(eidData.getFamilyName()) + .dateOfBirth(eidData.getDateOfBirth()) + .countryCode(eidData.getCitizenCountryCode()) + .build(); + MatchingTaskUtils.storeFinalMatchingResult(pendingReq, matchingInfos); String vsz = RandomStringUtils.randomNumeric(10); when(szrMock.getStammzahlEncrypted(any(), any())).thenReturn(vsz); @@ -251,7 +269,7 @@ public class CreateIdentityLinkTaskEidNewTest { verify(szrMock, times(1)).getStammzahlEncrypted(argument4.capture(), argument5.capture()); Boolean param5 = argument5.getValue(); - Assert.assertTrue("insertERnP flag", param5); + Assert.assertFalse("insertERnP flag", param5); PersonInfoType person = argument4.getValue(); Assert.assertEquals("FamilyName", response.getAttributes().getAttributeValuesByFriendlyName("FamilyName").getFirstValue( @@ -267,23 +285,9 @@ public class CreateIdentityLinkTaskEidNewTest { .toString().split("T")[0], person.getPerson().getDateOfBirth()); - Assert.assertEquals("PlaceOfBirth", - response.getAttributes().getAttributeValuesByFriendlyName("PlaceOfBirth").getFirstValue( - response.getAttributes().getDefinitionsByFriendlyName("PlaceOfBirth").iterator().next()), - person.getPerson().getPlaceOfBirth()); - Assert.assertEquals("BirthName", - response.getAttributes().getAttributeValuesByFriendlyName("BirthName").getFirstValue( - response.getAttributes().getDefinitionsByFriendlyName("BirthName").iterator().next()), - person.getPerson().getAlternativeName().getFamilyName()); - - Assert.assertEquals("CitizenCountry", "LU", person.getTravelDocument().getIssuingCountry()); - Assert.assertEquals("DocumentType", "ELEKTR_DOKUMENT", person.getTravelDocument().getDocumentType()); - - Assert.assertEquals("Identifier", - response.getAttributes().getAttributeValuesByFriendlyName("PersonIdentifier").getFirstValue( - response.getAttributes().getDefinitionsByFriendlyName("PersonIdentifier").iterator().next()) - .toString().split("/")[2], - person.getTravelDocument().getDocumentNumber()); + Assert.assertNull("PlaceOfBirth", person.getPerson().getPlaceOfBirth()); + Assert.assertNull("BirthName", person.getPerson().getAlternativeName()); + Assert.assertNull("TravelDocument", person.getTravelDocument()); // check bcBind singing request ArgumentCaptor argument1 = ArgumentCaptor.forClass(Boolean.class); @@ -336,20 +340,9 @@ public class CreateIdentityLinkTaskEidNewTest { when(szrMock.signContent(any(), any(), any())).thenReturn(signContentResp); - String randomTestSp = RandomStringUtils.randomAlphabetic(10); String bindingPubKey = RandomStringUtils.randomAlphabetic(10); pendingReq.setRawDataToTransaction(MsEidasNodeConstants.DATA_REQUESTERID, randomTestSp); - - MatchedPersonResult matchingInfos = MatchedPersonResult.builder() - .bpk(RandomStringUtils.randomAlphabetic(5)) - .givenName(RandomStringUtils.randomAlphabetic(5)) - .familyName(RandomStringUtils.randomAlphabetic(5)) - .dateOfBirth(RandomStringUtils.randomAlphabetic(5)) - .countryCode(RandomStringUtils.randomAlphabetic(2).toUpperCase()) - .build(); - MatchingTaskUtils.storeFinalMatchingResult(pendingReq, matchingInfos); - pendingReq.setRawDataToTransaction(MsEidasNodeConstants.EID_BINDING_PUBLIC_KEY_NAME, bindingPubKey); @@ -467,7 +460,7 @@ public class CreateIdentityLinkTaskEidNewTest { verify(szrMock, times(1)).getStammzahlEncrypted(argument4.capture(), argument5.capture()); Boolean param5 = argument5.getValue(); - Assert.assertTrue("insertERnP flag", param5); + Assert.assertFalse("insertERnP flag", param5); PersonInfoType person = argument4.getValue(); Assert.assertEquals("FamilyName", response.getAttributes().getAttributeValuesByFriendlyName("FamilyName").getFirstValue( @@ -485,15 +478,7 @@ public class CreateIdentityLinkTaskEidNewTest { Assert.assertNull("PlaceOfBirth", person.getPerson().getPlaceOfBirth()); Assert.assertNull("BirthName", person.getPerson().getAlternativeName()); - - Assert.assertEquals("CitizenCountry", "LU", person.getTravelDocument().getIssuingCountry()); - Assert.assertEquals("DocumentType", "ELEKTR_DOKUMENT", person.getTravelDocument().getDocumentType()); - - Assert.assertEquals("Identifier", - response.getAttributes().getAttributeValuesByFriendlyName("PersonIdentifier").getFirstValue( - response.getAttributes().getDefinitionsByFriendlyName("PersonIdentifier").iterator().next()) - .toString().split("/")[2], - person.getTravelDocument().getDocumentNumber()); + Assert.assertNull("TravelDocument", person.getTravelDocument()); } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskTest.java index 7513501e..8dc106f2 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskTest.java @@ -105,6 +105,7 @@ public class CreateIdentityLinkTaskTest { private DummySpConfiguration oaParam; private SZR szrMock; + private MatchedPersonResult matchingInfos; private AuthenticationResponse response; private Map spConfig; @@ -143,7 +144,14 @@ public class CreateIdentityLinkTaskTest { pendingReq.getSessionData(AuthProcessDataWrapper.class) .setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response); - MatchingTaskUtils.storeFinalMatchingResult(pendingReq, null); + matchingInfos = MatchedPersonResult.builder() + .bpk(RandomStringUtils.randomAlphabetic(5)) + .givenName(eidData.getGivenName()) + .familyName(eidData.getFamilyName()) + .dateOfBirth(eidData.getDateOfBirth()) + .countryCode(eidData.getCitizenCountryCode()) + .build(); + MatchingTaskUtils.storeFinalMatchingResult(pendingReq, matchingInfos); pendingReq.setSpConfig(oaParam); pendingReq.setPendingReqId(at.gv.egiz.eaaf.core.impl.utils.Random.nextProcessReferenceValue()); -- cgit v1.2.3 From e9bb7aeaf5a9f7a445907ccb2abc96635e5b534c Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Mon, 7 Feb 2022 11:37:22 +0100 Subject: chore(szr): remove dummy code for SZR emulation --- .../eidas/v2/tasks/CreateIdentityLinkTask.java | 97 ++-------------------- .../v2/test/tasks/CreateIdentityLinkTaskTest.java | 35 -------- 2 files changed, 6 insertions(+), 126 deletions(-) diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateIdentityLinkTask.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateIdentityLinkTask.java index 740e5292..0aba70d1 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateIdentityLinkTask.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateIdentityLinkTask.java @@ -23,21 +23,16 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks; -import java.io.IOException; -import java.io.InputStream; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import javax.xml.parsers.ParserConfigurationException; import org.jetbrains.annotations.Nullable; import org.jose4j.lang.JoseException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.xml.sax.SAXException; import com.fasterxml.jackson.core.JsonProcessingException; @@ -64,8 +59,6 @@ import at.gv.egiz.eaaf.core.impl.data.Pair; import at.gv.egiz.eaaf.core.impl.idp.auth.data.AuthProcessDataWrapper; import at.gv.egiz.eaaf.core.impl.idp.auth.data.SimpleIdentityLinkAssertionParser; import at.gv.egiz.eaaf.core.impl.idp.auth.modules.AbstractAuthServletTask; -import at.gv.egiz.eaaf.core.impl.utils.DomUtils; -import at.gv.egiz.eaaf.core.impl.utils.XPathUtils; import lombok.Data; import lombok.extern.slf4j.Slf4j; import szrservices.IdentityLinkType; @@ -124,21 +117,17 @@ public class CreateIdentityLinkTask extends AbstractAuthServletTask { final SimpleEidasData eidData = MatchingTaskUtils.getInitialEidasData(pendingReq); MatchedPersonResult matchedPersonData = MatchingTaskUtils.getFinalMatchingResult(pendingReq); + // write log information based on current configuration writeMdsLogInformation(eidData); - if (basicConfig.getBasicConfigurationBoolean(Constants.CONIG_PROPS_EIDAS_SZRCLIENT_DEBUG_USEDUMMY, false)) { - buildDummyIdentityLink(eidData); + //request SZR based on IDL or E-ID mode + if (pendingReq.getServiceProviderConfiguration() + .isConfigurationValue(MsEidasNodeConstants.PROP_CONFIG_SP_NEW_EID_MODE, false)) { + executeEidMode(eidData, matchedPersonData); } else { - //request SZR based on IDL or E-ID mode - if (pendingReq.getServiceProviderConfiguration() - .isConfigurationValue(MsEidasNodeConstants.PROP_CONFIG_SP_NEW_EID_MODE, false)) { - executeEidMode(eidData, matchedPersonData); + executeIdlMode(eidData, matchedPersonData); - } else { - executeIdlMode(eidData, matchedPersonData); - - } } storeGenericInfoToSession(eidData); @@ -213,21 +202,6 @@ public class CreateIdentityLinkTask extends AbstractAuthServletTask { } - private void buildDummyIdentityLink(SimpleEidasData eidData) - throws ParserConfigurationException, SAXException, IOException, EaafException { - AuthProcessDataWrapper authProcessDataWrapper = MatchingTaskUtils.getAuthProcessDataWrapper(pendingReq); - SzrResultHolder idlResult = createDummyIdentityLinkForTestDeployment(eidData); - //inject personal-data into session - authProcessDataWrapper.setIdentityLink(idlResult.getIdentityLink()); - - // set bPK and bPKType into auth session - authProcessDataWrapper.setGenericDataToSession(PvpAttributeDefinitions.BPK_NAME, extendBpkByPrefix( - idlResult.getBpK(), pendingReq.getServiceProviderConfiguration().getAreaSpecificTargetIdentifier())); - authProcessDataWrapper.setGenericDataToSession(PvpAttributeDefinitions.EID_SECTOR_FOR_IDENTIFIER_NAME, - pendingReq.getServiceProviderConfiguration() - .getAreaSpecificTargetIdentifier()); - } - private void writeExtendedRevisionLogEntry(SimpleEidasData eidData, String personalIdentifier) { // write ERnP input-data into revision-log if (basicConfig.getBasicConfigurationBoolean( @@ -343,63 +317,4 @@ public class CreateIdentityLinkTask extends AbstractAuthServletTask { final String bpK; } - - /** - * Build a dummy IdentityLink and a dummy bPK based on eIDAS information. - * - *

    - * FOR LOCAL TESTING ONLY!!! - * - * @param eidData Information from eIDAS response - * @return IdentityLink and bPK - * @throws ParserConfigurationException In case of an IDL processing error - * @throws SAXException In case of an IDL processing error - * @throws IOException In case of an IDL processing error - * @throws EaafException In case of a bPK generation error - */ - private SzrResultHolder createDummyIdentityLinkForTestDeployment(SimpleEidasData eidData) - throws ParserConfigurationException, SAXException, IOException, EaafException { - log.warn("SZR-Dummy IS ACTIVE! IdentityLink is NOT VALID!!!!"); - // create fake IdL - // - fetch IdL template from resources - final InputStream s = CreateIdentityLinkTask.class - .getResourceAsStream("/resources/xmldata/fakeIdL_IdL_template.xml"); - final Element idlTemplate = DomUtils.parseXmlValidating(s); - - IIdentityLink identityLink = new SimpleIdentityLinkAssertionParser(idlTemplate).parseIdentityLink(); - - // replace data - final Element idlassertion = identityLink.getSamlAssertion(); - - // - set fake baseID; - final Node prIdentification = XPathUtils - .selectSingleNode(idlassertion, SimpleIdentityLinkAssertionParser.PERSON_IDENT_VALUE_XPATH); - prIdentification.getFirstChild().setNodeValue(eidData.getPseudonym()); - - // - set last name - final Node prFamilyName = XPathUtils - .selectSingleNode(idlassertion, SimpleIdentityLinkAssertionParser.PERSON_FAMILY_NAME_XPATH); - prFamilyName.getFirstChild().setNodeValue(eidData.getFamilyName()); - - // - set first name - final Node prGivenName = XPathUtils - .selectSingleNode(idlassertion, SimpleIdentityLinkAssertionParser.PERSON_GIVEN_NAME_XPATH); - prGivenName.getFirstChild().setNodeValue(eidData.getGivenName()); - - // - set date of birth - final Node prDateOfBirth = XPathUtils - .selectSingleNode(idlassertion, SimpleIdentityLinkAssertionParser.PERSON_DATE_OF_BIRTH_XPATH); - - prDateOfBirth.getFirstChild().setNodeValue(eidData.getDateOfBirth()); - - identityLink = new SimpleIdentityLinkAssertionParser(idlassertion).parseIdentityLink(); - - String idValue = identityLink.getIdentificationValue(); - String idType = identityLink.getIdentificationType(); - String targetId = pendingReq.getServiceProviderConfiguration().getAreaSpecificTargetIdentifier(); - final Pair bpkCalc = BpkBuilder.generateAreaSpecificPersonIdentifier(idValue, idType, targetId); - return new SzrResultHolder(identityLink, bpkCalc.getFirst()); - - } - } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskTest.java index 8dc106f2..4986d5a7 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskTest.java @@ -455,41 +455,6 @@ public class CreateIdentityLinkTaskTest { authProcessData.getGenericDataFromSession(PvpAttributeDefinitions.BPK_NAME)); } - @Test - public void buildDummyIdl() throws Exception { - //initialize test - String randomTestSp = RandomStringUtils.randomAlphabetic(10); - pendingReq.setRawDataToTransaction(MsEidasNodeConstants.DATA_REQUESTERID, randomTestSp); - - basicConfig.putConfigValue("eidas.ms.auth.eIDAS.szrclient.debug.useDummySolution", "true"); - - - //perform test - task.execute(pendingReq, executionContext); - - - //validate state - // check if pendingRequest was stored - IRequest storedPendingReq = requestStorage.getPendingRequest(pendingReq.getPendingRequestId()); - Assert.assertNotNull("pendingReq not stored", storedPendingReq); - - //check data in session - final AuthProcessDataWrapper authProcessData = storedPendingReq.getSessionData(AuthProcessDataWrapper.class); - Assert.assertNotNull("AuthProcessData", authProcessData); - Assert.assertNull("eidasBind", authProcessData.getGenericDataFromSession(Constants.EIDAS_BIND, String.class)); - - String authBlock = authProcessData.getGenericDataFromSession(Constants.SZR_AUTHBLOCK, String.class); - Assert.assertNull("AuthBlock", authBlock); - - Assert.assertFalse("EID process", authProcessData.isEidProcess()); - Assert.assertTrue("foreigner process", authProcessData.isForeigner()); - Assert.assertEquals("EID-ISSUING_NATION", "LU", - authProcessData.getGenericDataFromSession(PvpAttributeDefinitions.EID_ISSUING_NATION_NAME, String.class)); - - Assert.assertNotNull("IDL", authProcessData.getIdentityLink()); - - } - private void setSzrResponseIdentityLink(String responseXmlPath) throws JAXBException, SZRException_Exception { final JAXBContext jaxbContext = JAXBContext .newInstance(szrservices.ObjectFactory.class, org.w3._2001._04.xmldsig_more.ObjectFactory.class, -- cgit v1.2.3 From 160a5665b89b56dd141377233ff4ff0c10defb11 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Mon, 7 Feb 2022 11:40:27 +0100 Subject: test(ernp): exclude generated ERnP classes from PWD checks --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 7cc47323..15a126f4 100644 --- a/pom.xml +++ b/pom.xml @@ -786,6 +786,7 @@ target/generated/cxf + target/generated/swagger -- cgit v1.2.3 From d3daa7d11bf52c572375373089e0c48603ec14f3 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Mon, 7 Feb 2022 12:13:59 +0100 Subject: test(matching): fix broken tests and add some more edge cases --- .../eidas/v2/test/tasks/InitialSearchTaskTest.java | 142 ++++++++++++++++++++- .../tasks/InitialSearchTaskWithRegistersTest.java | 16 +++ 2 files changed, 151 insertions(+), 7 deletions(-) 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 d6d49370..b3ba8a9d 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 @@ -208,8 +208,7 @@ public class InitialSearchTaskTest { } /** - * TODO: include again if ERnP update is implementet. Maybe we can update MDS based on ERnP. - *

    + * * One match, but register update needed. * * @throws EidasSAuthenticationException @@ -343,11 +342,11 @@ public class InitialSearchTaskTest { public void singlePersonalIdMatchNoUpdate_Ernp() throws Exception { Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPseudonym, DE)) .thenReturn(emptyZmrRegisterResult()); - Mockito.when(zmrClient.update(any(), any(), any())) - .thenThrow(new IllegalStateException("ZMR update should not be neccessary")); - Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE)) - .thenReturn(ernpRegisterResult(randomRegisterResult())); + .thenReturn(ernpRegisterResult(randomRegisterResult())); + + Mockito.when(zmrClient.update(any(), any(), any())) + .thenThrow(new IllegalStateException("ZMR update should not be neccessary")); Mockito.when(ernpClient.update(any(), any())) .thenThrow(new IllegalStateException("ERnP update should not be neccessary")); @@ -368,8 +367,11 @@ public class InitialSearchTaskTest { .thenReturn(zmrRegisterResult(randomRegisterResult())); Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE)) .thenReturn(emptyErnpRegisterResult()); + Mockito.when(zmrClient.update(any(), any(), any())) .thenThrow(new IllegalStateException("ZMR update should not be neccessary")); + Mockito.when(ernpClient.update(any(), any())) + .thenThrow(new IllegalStateException("ERnP update should not be neccessary")); // execute test task.execute(pendingReq, executionContext); @@ -420,7 +422,15 @@ public class InitialSearchTaskTest { Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE)) .thenReturn(emptyErnpRegisterResult()); - + Mockito.when(ernpClient.searchCountrySpecific(any(), eq(DE))) + .thenReturn(emptyErnpRegisterResult()); + Mockito.when(ernpClient.searchWithMds(any(), any(), any(), eq(DE))) + .thenThrow(new IllegalStateException("ERnP MDS search should not be neccessary")); + Mockito.when(ernpClient.update(any(), any())) + .thenThrow(new IllegalStateException("ERnP update should not be neccessary")); + Mockito.when(ernpClient.add(any())) + .thenThrow(new IllegalStateException("ERnP add-entity should not be neccessary")); + // execute test task.execute(pendingReq1, executionContext); @@ -470,6 +480,10 @@ public class InitialSearchTaskTest { Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE)) .thenReturn(emptyErnpRegisterResult()); + Mockito.when(ernpClient.searchCountrySpecific(any(), eq(DE))) + .thenReturn(emptyErnpRegisterResult()); + Mockito.when(ernpClient.update(any(), any())) + .thenThrow(new IllegalStateException("ERnP update should not be neccessary")); // execute task TaskExecutionException exception = assertThrows(TaskExecutionException.class, @@ -482,6 +496,89 @@ public class InitialSearchTaskTest { } + /** + * Multiple matches found in ZMR and ERnP by country specifics. + */ + @Test + @DirtiesContext + public void multiplePersonFindWithCountySpecifics_ZmrAndErnp() throws Exception { + final AuthenticationResponse response = buildDummyAuthResponseDE(randomGivenName, randomFamilyName, + randomPersonalIdentifier_DE, + randomBirthDate, randomPlaceOfBirth, randomBirthName); + TestRequestImpl pendingReq1 = new TestRequestImpl(); + pendingReq1.getSessionData(AuthProcessDataWrapper.class) + .setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response); + + BigInteger zmrProcessId = generateRandomProcessId(); + Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPseudonym, DE)) + .thenReturn(new ZmrRegisterResult(Collections.emptyList(), zmrProcessId)); + RegisterResult randomResult1 = RegisterResult.builder() + .bpk(randomBpk) + .pseudonym(Collections.singletonList(randomPseudonym)) + .givenName(randomGivenName) + .familyName(randomFamilyName) + .dateOfBirth(randomBirthDate) + .placeOfBirth(randomPlaceOfBirth) + .birthName(randomBirthName) + .build(); + Mockito.when(zmrClient.searchCountrySpecific(eq(zmrProcessId), any(PersonSuchenRequest.class), eq(DE))) + .thenReturn(new ZmrRegisterResult(Arrays.asList(randomResult1), zmrProcessId)); + + Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE)) + .thenReturn(emptyErnpRegisterResult()); + Mockito.when(ernpClient.searchCountrySpecific(any(), eq(DE))) + .thenReturn(ernpRegisterResult(randomRegisterResult())); + Mockito.when(ernpClient.update(any(), any())) + .thenThrow(new IllegalStateException("ERnP update should not be neccessary")); + + // execute task + TaskExecutionException exception = assertThrows(TaskExecutionException.class, + () -> task.execute(pendingReq1, executionContext)); + + // validate state + assertTrue("Wrong exception", (exception.getOriginalException() instanceof WorkflowException)); + assertTrue("Wrong flag 'manualFixNeeded'", + ((WorkflowException) exception.getOriginalException()).isRequiresManualFix()); + + } + + /** + * Multiple matches found in ERnP by country specifics. + */ + @Test + @DirtiesContext + public void multiplePersonFindWithCountySpecifics_Ernp() throws Exception { + final AuthenticationResponse response = buildDummyAuthResponseDE(randomGivenName, randomFamilyName, + randomPersonalIdentifier_DE, + randomBirthDate, randomPlaceOfBirth, randomBirthName); + TestRequestImpl pendingReq1 = new TestRequestImpl(); + pendingReq1.getSessionData(AuthProcessDataWrapper.class) + .setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response); + + BigInteger zmrProcessId = generateRandomProcessId(); + Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPseudonym, DE)) + .thenReturn(new ZmrRegisterResult(Collections.emptyList(), zmrProcessId)); + Mockito.when(zmrClient.searchCountrySpecific(eq(zmrProcessId), any(PersonSuchenRequest.class), eq(DE))) + .thenReturn(new ZmrRegisterResult(Arrays.asList(), zmrProcessId)); + + Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE)) + .thenReturn(emptyErnpRegisterResult()); + Mockito.when(ernpClient.searchCountrySpecific(any(), eq(DE))) + .thenReturn(ernpRegisterResult(Arrays.asList(randomRegisterResult(), randomRegisterResult()))); + Mockito.when(ernpClient.update(any(), any())) + .thenThrow(new IllegalStateException("ERnP update should not be neccessary")); + + // execute task + TaskExecutionException exception = assertThrows(TaskExecutionException.class, + () -> task.execute(pendingReq1, executionContext)); + + // validate state + assertTrue("Wrong exception", (exception.getOriginalException() instanceof WorkflowException)); + assertTrue("Wrong flag 'manualFixNeeded'", + ((WorkflowException) exception.getOriginalException()).isRequiresManualFix()); + + } + /** * NO match found in ZMR and ErnP with Initial and MDS search * @@ -590,6 +687,37 @@ public class InitialSearchTaskTest { } + /** + * Find matches with MDS search in ZMR and ERnP. + */ + @Test + @DirtiesContext + public void resultByMdsSearch_ZmrAndErnp() throws TaskExecutionException, EidasSAuthenticationException { + BigInteger zmrProcessId = generateRandomProcessId(); + Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPseudonym, DE)) + .thenReturn(new ZmrRegisterResult(Collections.emptyList(), zmrProcessId)); + Mockito.when(zmrClient.searchWithMds(zmrProcessId, randomGivenName, randomFamilyName, randomBirthDate, DE)) + .thenReturn(zmrRegisterResult(randomRegisterResult(), zmrProcessId)); + Mockito.when(zmrClient.update(any(), any(), any())) + .thenThrow(new IllegalStateException("ZMR update should not be neccessary")); + + Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE)).thenReturn( + emptyErnpRegisterResult()); + Mockito.when(ernpClient.searchWithMds(randomGivenName, randomFamilyName, randomBirthDate, DE)) + .thenReturn(ernpRegisterResult(randomRegisterResult())); + Mockito.when(ernpClient.update(any(), any())) + .thenThrow(new IllegalStateException("ERnP update should not be neccessary")); + + + + // execute test + task.execute(pendingReq, executionContext); + + // validate state + checkIntermediateResult(2); + + } + /** * resultByMdsSearch */ diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java index 565efe09..0e95f718 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java @@ -283,6 +283,11 @@ public class InitialSearchTaskWithRegistersTest { .thenReturn(loadResponseFromFile("/data/zmr/seq_1-6_kitt_update_resp.xml")) //KITT update .thenThrow(new RuntimeException("This request is not needed any more")); + mockWebServer.enqueue(new MockResponse().setResponseCode(200) //CC specific search + .setBody("{}") + .setHeader("Content-Type", "application/json;charset=utf-8")); + + // execute test task.execute(pendingReq, executionContext); @@ -322,6 +327,9 @@ public class InitialSearchTaskWithRegistersTest { .thenReturn(loadResponseFromFile("/data/zmr/seq_1-2_search_with_mds_resp.xml")) //MDS specific search .thenThrow(new RuntimeException("This request is not needed any more")); + mockWebServer.enqueue(new MockResponse().setResponseCode(200) //MDS specific search + .setBody("{}") + .setHeader("Content-Type", "application/json;charset=utf-8")); // execute test task.execute(pendingReq, executionContext); @@ -361,6 +369,14 @@ public class InitialSearchTaskWithRegistersTest { .thenThrow(new RuntimeException("This request is not needed any more")); + mockWebServer.enqueue(new MockResponse().setResponseCode(200) //CC specific search + .setBody("{}") + .setHeader("Content-Type", "application/json;charset=utf-8")); + mockWebServer.enqueue(new MockResponse().setResponseCode(200) //MDS specific search + .setBody("{}") + .setHeader("Content-Type", "application/json;charset=utf-8")); + + // execute test task.execute(pendingReq, executionContext); -- cgit v1.2.3 From b430405209fb61d7de7dec19fe9b2da780a575ac Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Mon, 7 Feb 2022 15:11:55 +0100 Subject: feature(ernp): update MDS if register information does not match to information from eIDAS --- .../auth/eidas/v2/clients/ernp/ErnpRestClient.java | 111 ++++++++++++++++----- 1 file changed, 85 insertions(+), 26 deletions(-) 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 58b3ca45..15b7573c 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 @@ -38,8 +38,10 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include; 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.SimpleEidasData.SimpleEidasDataBuilder; 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.AnlegenResponse; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ernp.model.Eidas; @@ -49,6 +51,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ernp.model.PersonAen import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ernp.model.PersonAnlegen; 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.Personendaten; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ernp.model.PersonendatenErgebnis; 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; @@ -247,10 +250,11 @@ public class ErnpRestClient implements IErnpClient { // select elements that have to be updated Collection eidasDocumentToAdd = - selectEidasDocumentsToAdd(ernpPersonToKitt, eidData); + selectEidasDocumentsToAdd(ernpPersonToKitt, eidData); + SimpleEidasData mdsToUpdate = selectMdsInformationToUpdate(ernpPersonToKitt, eidData); - if (eidasDocumentToAdd.isEmpty()) { - log.info("Find no eIDAS document for update during: {}. Looks strange but nothing todo", + if (eidasDocumentToAdd.isEmpty() && mdsToUpdate == null) { + log.info("Find no eIDAS document or MDS for update during: {}. Nothing todo on ERnP side", PROCESS_KITT_GENERAL); return new ErnpRegisterResult(Arrays.asList(registerResult)); @@ -258,7 +262,7 @@ public class ErnpRestClient implements IErnpClient { 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 updatePersonInErnp(ernpPersonToKitt, eidasDocumentToAdd, eidData.getCitizenCountryCode()); + return updatePersonInErnp(ernpPersonToKitt, eidasDocumentToAdd, mdsToUpdate, eidData.getCitizenCountryCode()); } @@ -430,27 +434,8 @@ public class ErnpRestClient implements IErnpClient { } - /** - * Build AT specific Date String 'yyyy-MM-dd' from ERnP birthday representation. - * - *

    - * Info: {@link LocalDate} can not be used, because '1940-00-00' is also - * a valid birthday on ERnP site. - *

    - * - * @param geburtsdatum ERnP birthday representation - * @return birthday in 'yyyy-MM-dd' format - */ - private String getTextualBirthday(PartialDate geburtsdatum) { - return MessageFormat.format("{0}-{1}-{2}", - String.valueOf(geburtsdatum.getJahr()), - String.format("%02d", geburtsdatum.getMonat()), - String.format("%02d", geburtsdatum.getTag())); - - } - private ErnpRegisterResult updatePersonInErnp(Person ernpPersonToKitt, - Collection eidasDocumentToAdd, String citizenCountryCode) + Collection eidasDocumentToAdd, SimpleEidasData mdsToUpdate, String citizenCountryCode) throws ServiceFault { // build generic request metadata final GenericRequestParams generic = buildGenericRequestParameters("stepKittUpdate"); @@ -466,8 +451,12 @@ public class ErnpRestClient implements IErnpClient { // add new eIDAS attributes eidasDocumentToAdd.stream().forEach(el -> ernpReq.getAnlegen().addEidasItem(el)); - // TODO: should we update MDS also in that step? - + // update MDS if required + if (mdsToUpdate != null) { + log.debug("Find MDS to update. Injection update entries into ERnP request ... "); + ernpReq.setAendern(generateMdsChangeRequest(ernpPersonToKitt, mdsToUpdate)); + + } // request ERnP log.trace("Requesting ERnP for '{}' operation", PROCESS_KITT_IDENITIES_UPDATE); @@ -604,6 +593,56 @@ public class ErnpRestClient implements IErnpClient { return el; } + private SimpleEidasData selectMdsInformationToUpdate(Person ernpPersonToKitt, SimpleEidasData eidData) { + PersonendatenErgebnis person = ernpPersonToKitt.getPersonendaten(); + SimpleEidasDataBuilder builder = SimpleEidasData.builder(); + + 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()); + + } + + return findMismatch ? builder.build() : null; + } + + private Aendern generateMdsChangeRequest(Person ernpPersonToKitt, SimpleEidasData mdsToUpdate) { + Aendern el = new Aendern(); + 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())); + + } + return el; + + } + /** * Map an AT specific Date String 'yyyy-MM-dd' to ERnP birthday representation. * @@ -626,6 +665,26 @@ public class ErnpRestClient implements IErnpClient { return result; } + + /** + * Build AT specific Date String 'yyyy-MM-dd' from ERnP birthday representation. + * + *

    + * Info: {@link LocalDate} can not be used, because '1940-00-00' is also + * a valid birthday on ERnP site. + *

    + * + * @param geburtsdatum ERnP birthday representation + * @return birthday in 'yyyy-MM-dd' format + */ + private String getTextualBirthday(PartialDate geburtsdatum) { + return MessageFormat.format("{0}-{1}-{2}", + String.valueOf(geburtsdatum.getJahr()), + String.format("%02d", geburtsdatum.getMonat()), + String.format("%02d", geburtsdatum.getTag())); + + } + /** * Get all eIDAS document with the specified country code and document type. -- cgit v1.2.3 From 5b0a9142a0e00fa528f86f8fe432c0e44ed4ae8e Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Mon, 7 Feb 2022 15:19:56 +0100 Subject: refactor(matching): change 'kitt' and 'update' steps in 'InitialSearchTask' - Update MDS in case of changes eIDAS data and already existing ERnP entry - Add additional attributes in case of new eIDAS attributes outside of MDS --- .../modules/auth/eidas/v2/dao/SimpleEidasData.java | 22 +- .../eidas/v2/service/RegisterSearchService.java | 22 +- .../auth/eidas/v2/tasks/InitialSearchTask.java | 42 ++-- .../eidas/v2/test/tasks/InitialSearchTaskTest.java | 41 +++- .../tasks/InitialSearchTaskWithRegistersTest.java | 75 ++++++- ...rsonalId_only_resp_no_additional_attributes.xml | 221 +++++++++++++++++++++ 6 files changed, 386 insertions(+), 37 deletions(-) create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/zmr/seq_1-8_search_with_personalId_only_resp_no_additional_attributes.xml diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java index 5ad92507..e76768b6 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java @@ -23,10 +23,11 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.dao; +import org.apache.commons.lang3.builder.EqualsBuilder; + import at.gv.e_government.reference.namespace.persondata._20020228.PostalAddressType; import lombok.Builder; import lombok.Data; -import org.apache.commons.lang3.builder.EqualsBuilder; @Data @Builder @@ -68,8 +69,11 @@ public class SimpleEidasData { .append(result.getGivenName(), givenName) .append(result.getFamilyName(), familyName) .append(result.getDateOfBirth(), dateOfBirth) - .isEquals() - && result.getPseudonym().stream().anyMatch(el -> el.equals(pseudonym)); + .appendSuper(result.getPseudonym().stream().anyMatch(el -> el.equals(pseudonym))) + .appendSuper(checkOptionalAttributes(result.getPlaceOfBirth(), placeOfBirth)) + .appendSuper(checkOptionalAttributes(result.getBirthName(), birthName)) + .isEquals(); + } /** @@ -84,5 +88,17 @@ public class SimpleEidasData { .isEquals(); } + /** + * Check if eIDAS attribute is available. + * + * @param registerData Attribute value from register + * @param eidasData Attribute value from eIDAS + * @return true if eidasData is null or eidasData does not match to register value, + * otherwise false + */ + private static boolean checkOptionalAttributes(String registerData, String eidasData) { + return eidasData == null || eidasData.equals(registerData); + + } } 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 488b571b..85ea942c 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 @@ -7,6 +7,7 @@ import java.util.List; import javax.annotation.Nonnull; import org.jetbrains.annotations.Nullable; +import org.springframework.lang.NonNull; import org.springframework.stereotype.Service; import com.google.common.collect.Streams; @@ -186,34 +187,49 @@ public class RegisterSearchService { * @param initialEidasData Received eidas data from initial authn * @return */ + @NonNull public RegisterStatusResults step7aKittProcess(RegisterStatusResults registerResult, SimpleEidasData initialEidasData) throws WorkflowException { log.trace("Starting step7aKittProcess"); - // TODO verify with which data this method gets called + + // check if only one single result was found if (registerResult.getResultCount() != 1) { throw new WorkflowException("step7aKittProcess", "getResultCount() != 1"); + } + + // perform updated operation in respect to register results try { if (registerResult.getResultsZmr().size() == 1) { RegisterResult entryZmr = registerResult.getResultsZmr().get(0); ZmrRegisterResult updateZmr = zmrClient .update(registerResult.getOperationStatus().getZmrProcessId(), entryZmr, initialEidasData); return RegisterStatusResults.fromZmr(updateZmr); + } else { RegisterResult entryErnp = registerResult.getResultsErnp().get(0); ErnpRegisterResult updateErnp = ernpClient.update(entryErnp, initialEidasData); return RegisterStatusResults.fromErnp(registerResult.operationStatus, updateErnp); + } } catch (final EidasSAuthenticationException e) { throw new WorkflowException("kittMatchedIdentitiess", e.getMessage(), !(e instanceof ZmrCommunicationException), e); + } } - //TODO: check this method, because it's different to 'step7aKittProcess'??? /** * Automatic process to fix the register entries. * Called when the alternative eIDAS authn leads to a match in a register. + * + *

    This method perform two additional operations: + *

      + *
    • Use bPK to check if altSearchResult is part of initialSearchResult.
    • + *
    • Update register entry twice, be using information from alternative authentication altEidasData + * and from initial authentication initialEidasData.
    • + *
    + *

    * * @param initialSearchResult Register results from initial authentication * @param initialEidasData Received eIDAS data from initial authentication @@ -273,7 +289,7 @@ public class RegisterSearchService { // update ZMR entry by using eIDAS information from alternative authentication ErnpRegisterResult updateAlt = ernpClient.update(entryErnp, altEidasData); - return RegisterStatusResults.fromErnp(altSearchResult.operationStatus, updateAlt); + return RegisterStatusResults.fromErnp(altSearchResult.getOperationStatus(), updateAlt); } } catch (final EidasSAuthenticationException e) { throw new WorkflowException("kittMatchedIdentitiess", e.getMessage(), 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 c720cb7f..9564a8fc 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 @@ -122,8 +122,9 @@ public class InitialSearchTask extends AbstractAuthServletTask { if (resultCount == 0) { step6CountrySpecificSearch(executionContext, searchResult.getOperationStatus(), eidasData); - } else if (resultCount == 1) { - foundMatchFinalizeTask(searchResult, eidasData); + } else if (resultCount == 1) { + RegisterResult updatedResult = step3CheckRegisterUpdateNecessary(searchResult, eidasData); + foundMatchFinalizeTask(updatedResult, eidasData); } else { throw new WorkflowException("step2RegisterSearchWithPersonIdentifier", @@ -146,10 +147,12 @@ public class InitialSearchTask extends AbstractAuthServletTask { if (searchResult.getResultCount() == 0) { log.trace("'step6CountrySpecificSearch' ends with no result. Forward to next matching step ... "); step8RegisterSearchWithMds(executionContext, searchResult.getOperationStatus(), eidasData); + } else if (searchResult.getResultCount() == 1) { log.trace("'step6CountrySpecificSearch' finds a person. Forward to 'step7aKittProcess' step ... "); - registerSearchService.step7aKittProcess(searchResult, eidasData); - foundMatchFinalizeTask(searchResult, eidasData); + RegisterStatusResults updatedResult = registerSearchService.step7aKittProcess(searchResult, eidasData); + foundMatchFinalizeTask(updatedResult.getResult(), eidasData); + } else { throw new WorkflowException("step6CountrySpecificSearch", "More than one entry with unique country-specific information", true); @@ -172,29 +175,26 @@ public class InitialSearchTask extends AbstractAuthServletTask { } } - private void foundMatchFinalizeTask(RegisterStatusResults searchResult, SimpleEidasData eidasData) - throws WorkflowException, EaafStorageException { - RegisterResult updatedResult = step3CheckRegisterUpdateNecessary(searchResult.getResult(), eidasData); - MatchedPersonResult result = MatchedPersonResult.generateFormMatchingResult( - updatedResult, eidasData.getCitizenCountryCode()); - MatchingTaskUtils.storeFinalMatchingResult(pendingReq, result); - } - - private RegisterResult step3CheckRegisterUpdateNecessary(RegisterResult searchResult, - SimpleEidasData eidasData) { + private RegisterResult step3CheckRegisterUpdateNecessary( + RegisterStatusResults searchResult, SimpleEidasData eidasData) throws WorkflowException { log.trace("Starting step3CheckRegisterUpdateNecessary"); - if (!eidasData.equalsRegisterData(searchResult)) { - log.info("Skipping update-register-information step, because it's not supported yet"); - - //TODO: update of ERnP information are allowed. Add ERnP update-step. Maybe we can use regular KITT steps - + if (!eidasData.equalsRegisterData(searchResult.getResult())) { + log.debug("PersonalIdentifier match but MDS or other information changed. Starting update process ... "); + return registerSearchService.step7aKittProcess(searchResult, eidasData).getResult(); - return searchResult; } else { log.debug("Register information match to eIDAS information. No update required"); - return searchResult; + return searchResult.getResult(); } } + + private void foundMatchFinalizeTask(RegisterResult updatedResult, SimpleEidasData eidasData) + throws WorkflowException, EaafStorageException { + MatchedPersonResult result = + MatchedPersonResult.generateFormMatchingResult(updatedResult, eidasData.getCitizenCountryCode()); + MatchingTaskUtils.storeFinalMatchingResult(pendingReq, result); + + } @NotNull private SimpleEidasData convertEidasAttrToSimpleData() 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 b3ba8a9d..74ac065e 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 @@ -48,7 +48,6 @@ import org.apache.commons.lang3.RandomStringUtils; import org.jetbrains.annotations.NotNull; import org.junit.Assert; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; @@ -181,15 +180,17 @@ public class InitialSearchTaskTest { @DirtiesContext public void singlePersonalIdMatchUpdateNecessary_Zmr() throws Exception { String oldGivenName = randomAlphabetic(10); + String placeOfBirth = randomAlphabetic(10); + RegisterResult firstZmrResult = randomRegisterResult(oldGivenName, randomBpk, placeOfBirth); Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPseudonym, DE)) - .thenReturn(zmrRegisterResult(randomRegisterResult(oldGivenName, randomBpk))); + .thenReturn(zmrRegisterResult(firstZmrResult)); Mockito.when(zmrClient.searchCountrySpecific(any(), any(), any())) .thenThrow(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")); + .thenReturn(zmrRegisterResult(firstZmrResult)); Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE)) .thenReturn(emptyErnpRegisterResult()); @@ -213,17 +214,33 @@ public class InitialSearchTaskTest { * * @throws EidasSAuthenticationException */ - @Ignore @Test @DirtiesContext public void singlePersonalIdMatchUpdateNecessary_Ernp() throws TaskExecutionException, EidasSAuthenticationException { Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPseudonym, DE)) .thenReturn(emptyZmrRegisterResult()); - + Mockito.when(zmrClient.searchCountrySpecific(any(), any(), any())) + .thenThrow(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")); + String oldRandomGivenName = randomAlphabetic(10); Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE)) .thenReturn(ernpRegisterResult(randomRegisterResult(oldRandomGivenName, randomBpk))); - + Mockito.when(ernpClient.searchCountrySpecific(any(), any())) + .thenThrow(new IllegalStateException("CountrySpecific search search should not be neccessary")); + Mockito.when(ernpClient.searchWithMds(any(), any(), any(), any())) + .thenThrow(new IllegalStateException("MDS search should not be neccessary")); + Mockito.when(ernpClient.update(any(), any())) + .thenReturn(ernpRegisterResult(RegisterResult.builder() + .bpk(randomBpk) + .dateOfBirth(randomBirthDate) + .givenName(randomGivenName) + .familyName(randomFamilyName) + .build())); + // execute test task.execute(pendingReq, executionContext); @@ -798,6 +815,18 @@ public class InitialSearchTaskTest { .build(); } + @NotNull + private RegisterResult randomRegisterResult(String randomGivenName, String randomBpk, String placeOfBirth) { + return RegisterResult.builder() + .bpk(randomBpk) + .pseudonym(Collections.singletonList(randomPseudonym)) + .givenName(randomGivenName) + .familyName(randomFamilyName) + .dateOfBirth(randomBirthDate) + .placeOfBirth(placeOfBirth) + .build(); + } + @NotNull private AuthenticationResponse buildDummyAuthResponseRandomPerson() throws URISyntaxException { return buildDummyAuthResponse(randomGivenName, randomFamilyName, DE_ST + randomPseudonym, randomBirthDate); diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java index 0e95f718..7f27a17c 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java @@ -190,10 +190,13 @@ public class InitialSearchTaskWithRegistersTest { /** * One match, but register update needed + *

    + * Check if ZMR update request is NOT executed in case of MDS change! + *

    */ @Test @DirtiesContext - public void singlePersonalIdMatchUpdateNecessary_Zmr() throws Exception { + public void singlePersonalIdMatchUpdateNecessary_ZmrNotDone() throws Exception { String oldGivenName = "XXXClaus - Maria"; @@ -208,7 +211,12 @@ public class InitialSearchTaskWithRegistersTest { // inject response when(zmrMock.service(zmrReq.capture(), any())) .thenReturn(loadResponseFromFile("/data/zmr/seq_1-8_search_with_personalId_only_resp.xml")) - .thenThrow(new RuntimeException("This request is not needed any more")); + + //perform prepair-update request + .thenReturn(loadResponseFromFile("/data/zmr/seq_1-8_search_with_personalId_only_resp.xml")) + + //do not make an update because, MDS update is not allowed and no other data has been changed + .thenThrow(new RuntimeException("This request is not needed any more")); // execute test @@ -220,13 +228,72 @@ public class InitialSearchTaskWithRegistersTest { oldGivenName, "1994-12-31", DE); // validate request - assertEquals("wrong number of req.", 1, zmrReq.getAllValues().size()); + assertEquals("wrong number of req.", 2, zmrReq.getAllValues().size()); assertNotNull("Personensuche req.", zmrReq.getValue().getPersonSuchenRequest()); - checkBasicRequestParameters(zmrReq.getValue(), ZmrClientTest.PROCESS_TASK_SEARCH, null, "jUnit123456"); + checkBasicRequestParameters(zmrReq.getValue(), ZmrClientTest.PROCESS_TASK_SEARCH, + new BigInteger("367100000000079"), "jUnit123456"); } + /** + * One match, but register update needed + *

    + * Check if ZMR update request is executed in case of other data than MDS change! + *

    + */ + @Test + @DirtiesContext + public void singlePersonalIdMatchUpdateNecessary_ZmrDone() throws Exception { + + String oldGivenName = "XXXClaus - Maria"; + String placeOfBirth = RandomStringUtils.randomAlphabetic(5); + + //inject eIDAS data + pendingReq.getSessionData(AuthProcessDataWrapper.class).setGenericDataToSession( + Constants.DATA_FULL_EIDAS_RESPONSE, + buildDummyAuthResponse(oldGivenName, "XXXvon Brandenburg", + "DE/AT/7cEYWithDEElementsasdfsafsaf4CDVzNT4E7cjkU4VqForjUnit", "1994-12-31", null, placeOfBirth, null)); + + final ArgumentCaptor zmrReq = ArgumentCaptor.forClass(RequestType.class); + + // inject response + when(zmrMock.service(zmrReq.capture(), any())) + .thenReturn(loadResponseFromFile("/data/zmr/seq_1-8_search_with_personalId_only_resp_no_additional_attributes.xml")) + + //perform prepair-update request + .thenReturn(loadResponseFromFile("/data/zmr/seq_1-8_search_with_personalId_only_resp_no_additional_attributes.xml")) + + //do make an update because, MDS DOES NOT change, but additional attribute was available + .thenReturn(loadResponseFromFile("/data/zmr/seq_3-6_kitt_update_resp.xml")); + + + // execute test + task.execute(pendingReq, executionContext); + + // validate state + //INFO: has to be the old givenName because ZMR allows no update of MDS information + checkMatchingSuccessState(pendingReq, "UgeknNsc26lVuB7U/uYGVmWtnnA=", "XXXvon Brandenburg", + oldGivenName, "1994-12-31", DE); + + // validate request + assertEquals("wrong number of req.", 3, zmrReq.getAllValues().size()); + assertNotNull("Personensuche req.", zmrReq.getAllValues().get(0).getPersonSuchenRequest()); + checkBasicRequestParameters(zmrReq.getAllValues().get(0), ZmrClientTest.PROCESS_TASK_SEARCH, null, "jUnit123456"); + assertNotNull("Personenupdate req.", zmrReq.getAllValues().get(2).getPersonAendernRequest()); + checkBasicRequestParameters(zmrReq.getAllValues().get(2), ZmrClientTest.PROCESS_TASK_UPDATE, + new BigInteger("367100000000079"), "jUnit123456"); + assertEquals("eIDAS attribute to add", 1, + zmrReq.getAllValues().get(2).getPersonAendernRequest().getEidasIdentitaetAnlage().size()); + assertEquals("eIDAS attribute to add - Type", "http://eidas.europa.eu/attributes/naturalperson/PlaceOfBirth", + zmrReq.getAllValues().get(2).getPersonAendernRequest().getEidasIdentitaetAnlage().get(0).getEidasArt()); + assertEquals("eIDAS attribute to add - Value", placeOfBirth, + zmrReq.getAllValues().get(2).getPersonAendernRequest().getEidasIdentitaetAnlage().get(0).getEidasWert()); + assertNull("ZMR update MDS", zmrReq.getAllValues().get(2).getPersonAendernRequest().getPersonAenderung()); + + } + + /** * Two matches by PersonalId found in ZMR * diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/zmr/seq_1-8_search_with_personalId_only_resp_no_additional_attributes.xml b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/zmr/seq_1-8_search_with_personalId_only_resp_no_additional_attributes.xml new file mode 100644 index 00000000..6551cdd3 --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/zmr/seq_1-8_search_with_personalId_only_resp_no_additional_attributes.xml @@ -0,0 +1,221 @@ + + + + GP_EIDAS + 367100000000079 + 0 + + + ZMR-Server Version: 5.9.0.0-SNAPSHOT + 2021-11-12T08:24:40.985 + 1877300000000139 + + + + + Searching PersonIdentifier + + true + false + + + false + + 10 + + + + + 5020 + Person gefunden. + + + 1 + 0 + 0 + 1 + + + + + 2021-11-12T08:24:39.695 + + + + 44453600000000697 + 2020-02-05T13:07:06.311 + + 2020-02-05T13:07:06.311 + SONSTIGES + Sonstiges + Testerperson + + + 109091 + + + + 000430320173 + + + UgeknNsc26lVuB7U/uYGVmWtnnA= + urn:publicid:gv.at:cdid+ZP + + + XXXClaus - Maria + XXXvon Brandenburg + + unbekannt + männlich + 1994-12-31 + Wien + Wien + Österreich + + AUT + Österreich + + + 44453600000000727 + 2020-02-05T13:07:06.311 + + 2020-02-05T13:07:06.311 + STAATSANGEH_ANLEGEN + Staatsangehörigkeit anlegen + Testerperson + + + 109091 + + + + + + + + + 1879000000000001 + 2021-11-12T08:24:39.695 + + 2021-11-12T08:24:39.695 + EIDAS_ANLEGEN + KITT for eIDAS Matching + + + 101179 + + eidtapp@bmi.gv.at + + + http://eidas.europa.eu/attributes/naturalperson/BirthName + DE + + XXXvon Heuburg + 9999-12-31 + 9999-12-31 + + + + + 1879000000000005 + 2021-11-12T08:24:39.695 + + 2021-11-12T08:24:39.695 + EIDAS_ANLEGEN + KITT for eIDAS Matching + + + 101179 + + eidtapp@bmi.gv.at + + + http://eidas.europa.eu/attributes/naturalperson/PersonIdentifier + DE + + 7cEYWithDEElementsasdfsafsaf4CDVzNT4E7cjkU4VqForjUnit + 9999-12-31 + 9999-12-31 + + + + + + + 2020-02-05T13:07:06.311 + + + + 44453500000005242 + 2020-02-05T13:07:06.311 + + 2020-02-05T13:07:06.311 + WSANM + Wohnsitz anmelden + + + 109091 + + + + + + 0088 + Testgemeinde + 09988 + Testort A + + Testgasse + 1a-2b + Stg. 3c-4d + 5 + H + false + 0001 + + T800001 + 001 + T800001 + + + + HST111WWW + + T8001 + T80001 + T80000000001 + T80000000002 + + H + Testpostort + + 2020-02-05T13:07:06.311 + WSANM + Wohnsitz anmelden + + + + 44453500000005262 + 2020-02-05T13:07:06.311 + + 2020-02-05T13:07:06.311 + AUSK_SPERRE_SETZ + Auskunftssperre setzen + + + 109091 + + + + 2020-02-05T13:07:06.311 + 9999-12-31T23:59:59.000 + ASMG + Auskunftssperre nach § 18 / 2ff MeldeG + automatische Auskunftssperre + + + + + + + -- cgit v1.2.3 From 02e3d1b479234ac8d028f00263cfc1b311209a0c Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Mon, 7 Feb 2022 15:20:29 +0100 Subject: chore(mathing): change log level ZMRClient --- .../eidas/specific/modules/auth/eidas/v2/clients/zmr/ZmrSoapClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 432df9ef..18a80c33 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 @@ -269,7 +269,7 @@ public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient { selectEidasDocumentsToAdd(zmrPersonToKitt, eidData); if (eidasDocumentToAdd.isEmpty()) { - log.info("Find no eIDAS document for update during: {}. Looks strange but nothing todo", + log.info("Find no eIDAS document for update during: {}. Nothing todo on ZMR side", PROCESS_KITT_GENERAL); return new ZmrRegisterResult(Arrays.asList(registerResult), zmrProzessId); -- cgit v1.2.3 From 6f8bfc98e85e6c6ed819f39e878a44310674e178 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Mon, 7 Feb 2022 17:46:22 +0100 Subject: test(ernp): fix broken test after ERnP integration --- .../auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java index 028c0359..79b2532b 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java @@ -801,7 +801,7 @@ public class AlternativeSearchTaskWithRegisterTest { Mockito.when(ernpClient.searchWithPersonIdentifier("7cEYasdfsafsaf4CDVzNT4E7cjkU4VqForjUnit", "DE")) .thenReturn(emptyErnpRegisterResult()); - Mockito.when(ernpClient.searchWithMds("XXXKlaus - Maria", "XXXvon Brandenburg", "1994-12-31","DE")) + Mockito.when(ernpClient.searchCountrySpecific(any(), any())) .thenReturn(emptyErnpRegisterResult()); Mockito.when(ernpClient.update(any(), any())) .thenThrow(new IllegalStateException("ERnP update should not be neccessary")); -- cgit v1.2.3 From cc54421d99604cd2f2b01846f94bb11fb192028d Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Mon, 7 Feb 2022 18:22:27 +0100 Subject: chore(matching): fix some code-style and code-quality issues --- .../auth/eidas/v2/clients/ernp/ErnpRestClient.java | 20 ++++++++++---------- .../v2/exception/ErnpRestCommunicationException.java | 5 +++++ .../auth/eidas/v2/tasks/CreateNewErnpEntryTask.java | 2 +- .../test/tasks/CreateIdentityLinkTaskEidNewTest.java | 4 ++-- 4 files changed, 18 insertions(+), 13 deletions(-) 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 15b7573c..3c19e9c1 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 @@ -86,7 +86,7 @@ import lombok.extern.slf4j.Slf4j; public class ErnpRestClient implements IErnpClient { private static final String ERROR_MATCHING_11 = "module.eidasauth.matching.11"; - private static final String ERROR_MATCHING_12 = "module.eidasauth.matching.12"; + //private static final String ERROR_MATCHING_12 = "module.eidasauth.matching.12"; private static final String ERROR_MATCHING_99 = "module.eidasauth.matching.99"; private static final String LOGMSG_MISSING_CONFIG = "Missing configuration with key: {0}"; @@ -95,8 +95,8 @@ public class ErnpRestClient implements IErnpClient { private static final String LOGMSG_ERNP_RESP_PROCESS = "Proces ERnP response during '{}' operation failes with msg: {}"; - private static final String LOGMSG_ERNP_REST_ERROR = - "ERnP anwser for transaction: {0} with code: {1} and message: {2}"; + //private static final String LOGMSG_ERNP_REST_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; @@ -429,7 +429,7 @@ public class ErnpRestClient implements IErnpClient { //TODO: search eIDAS has to be a LIST!!!!!! SuchEidas eidasInfos = new SuchEidas(); - searchInfos.setEidas(eidasInfos ); + searchInfos.setEidas(eidasInfos); return searchInfos; } @@ -542,7 +542,7 @@ public class ErnpRestClient implements IErnpClient { final Suchdaten searchInfos = new Suchdaten(); 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()); @@ -572,8 +572,8 @@ public class ErnpRestClient implements IErnpClient { Constants.eIDAS_ATTRURN_PERSONALIDENTIFIER, eidData.getPseudonym())); if (StringUtils.isNotEmpty(eidData.getPlaceOfBirth())) { - ernpReq.addEidasItem(buildNewEidasDocument(eidData.getCitizenCountryCode(), - Constants.eIDAS_ATTRURN_PLACEOFBIRTH, eidData.getPlaceOfBirth())); + ernpReq.addEidasItem(buildNewEidasDocument(eidData.getCitizenCountryCode(), + Constants.eIDAS_ATTRURN_PLACEOFBIRTH, eidData.getPlaceOfBirth())); } @@ -773,9 +773,9 @@ public class ErnpRestClient implements IErnpClient { public void handleError(ClientHttpResponse response) throws IOException { // TODO: opimize errorHandling based on response info's from real ERnP - List serverId = response.getHeaders().getOrEmpty(ERNP_RESPONSE_HEADER_SERVER_ID); - log.warn("Receive http-error: {} from ERnP with serverTransactionId", - response.getRawStatusCode(), serverId.isEmpty() ? "'not set'" : serverId.get(0)); + List serverId = response.getHeaders().getOrEmpty(ERNP_RESPONSE_HEADER_SERVER_ID); + log.warn("Receive http-error: {} from ERnP with serverTransactionId", + response.getRawStatusCode(), serverId.isEmpty() ? "'not set'" : serverId.get(0)); throw new ErnpRestCommunicationException(response.getRawStatusCode()); diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/exception/ErnpRestCommunicationException.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/exception/ErnpRestCommunicationException.java index e3224c93..566a8fa4 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/exception/ErnpRestCommunicationException.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/exception/ErnpRestCommunicationException.java @@ -16,6 +16,11 @@ public class ErnpRestCommunicationException extends IOException { @Getter int httpStatusCode; + /** + * ERnP communication error on HTTP REST level. + * + * @param rawStatusCode HTTP statuscode + */ public ErnpRestCommunicationException(int rawStatusCode) { super("ERnP service answers with an error and HTTP status-code: " + rawStatusCode); this.httpStatusCode = rawStatusCode; diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateNewErnpEntryTask.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateNewErnpEntryTask.java index b63b0ca0..c7843be5 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateNewErnpEntryTask.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateNewErnpEntryTask.java @@ -65,7 +65,7 @@ public class CreateNewErnpEntryTask extends AbstractAuthServletTask { /** * Constructor. - * @param szrClient SZR client for creating a new ERnP entry + * @param client SZR client for creating a new ERnP entry */ public CreateNewErnpEntryTask(@Autowired ErnpRestClient client) { this.ernpClient = client; diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskEidNewTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskEidNewTest.java index 14ace0b8..dbcc62dc 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskEidNewTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskEidNewTest.java @@ -211,7 +211,7 @@ public class CreateIdentityLinkTaskEidNewTest { String vsz = RandomStringUtils.randomNumeric(10); when(szrMock.getStammzahlEncrypted(any(), any())).thenReturn(vsz); - val signContentResp = new SignContentResponseType(); + SignContentResponseType signContentResp = new SignContentResponseType(); final SignContentEntry signContentEntry = new SignContentEntry(); signContentEntry.setValue(RandomStringUtils.randomAlphanumeric(10)); signContentResp.getOut().add(signContentEntry); @@ -333,7 +333,7 @@ public class CreateIdentityLinkTaskEidNewTest { //initialize test String vsz = RandomStringUtils.randomNumeric(10); when(szrMock.getStammzahlEncrypted(any(), any())).thenReturn(vsz); - val signContentResp = new SignContentResponseType(); + SignContentResponseType signContentResp = new SignContentResponseType(); final SignContentEntry signContentEntry = new SignContentEntry(); signContentEntry.setValue(RandomStringUtils.randomAlphanumeric(10)); signContentResp.getOut().add(signContentEntry); -- cgit v1.2.3 From 6e7c333ec6e9a6fe33737ee3a67a23433854a55b Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Mon, 7 Feb 2022 18:37:05 +0100 Subject: fix(matching): make matching DTO's serializeable because the has to be stored into session --- .../specific/modules/auth/eidas/v2/dao/MatchedPersonResult.java | 6 +++++- .../eidas/specific/modules/auth/eidas/v2/dao/RegisterResult.java | 5 ++++- .../eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java | 6 +++++- .../modules/auth/eidas/v2/dao/SimpleMobileSignatureData.java | 6 +++++- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/MatchedPersonResult.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/MatchedPersonResult.java index 1e8fcecf..1dcea7fc 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/MatchedPersonResult.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/MatchedPersonResult.java @@ -1,5 +1,7 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.dao; +import java.io.Serializable; + import lombok.Builder; import lombok.Getter; @@ -11,7 +13,9 @@ import lombok.Getter; */ @Getter @Builder -public class MatchedPersonResult { +public class MatchedPersonResult implements Serializable { + + private static final long serialVersionUID = 9110998952621456281L; /** * Matched person result from matching result. diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/RegisterResult.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/RegisterResult.java index aa82d806..e5878ff3 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/RegisterResult.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/RegisterResult.java @@ -23,6 +23,7 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.dao; +import java.io.Serializable; import java.util.List; import at.gv.e_government.reference.namespace.persondata._20020228.PostalAddressType; @@ -31,8 +32,10 @@ import lombok.Getter; @Builder @Getter -public class RegisterResult { +public class RegisterResult implements Serializable { + private static final long serialVersionUID = 762728480185716130L; + // MDS private final List pseudonym; private final String givenName; diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java index e76768b6..f9301505 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java @@ -23,6 +23,8 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.dao; +import java.io.Serializable; + import org.apache.commons.lang3.builder.EqualsBuilder; import at.gv.e_government.reference.namespace.persondata._20020228.PostalAddressType; @@ -31,7 +33,9 @@ import lombok.Data; @Data @Builder -public class SimpleEidasData { +public class SimpleEidasData implements Serializable { + + private static final long serialVersionUID = 2848914124372968418L; /** * Full eIDAS personal identifier with prefix. diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleMobileSignatureData.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleMobileSignatureData.java index 92e727ea..54cb3f31 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleMobileSignatureData.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleMobileSignatureData.java @@ -23,6 +23,8 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.dao; +import java.io.Serializable; + import org.apache.commons.lang3.builder.EqualsBuilder; import lombok.Builder; @@ -30,7 +32,9 @@ import lombok.Data; @Data @Builder -public class SimpleMobileSignatureData { +public class SimpleMobileSignatureData implements Serializable { + + private static final long serialVersionUID = 7775305733438275312L; private final String bpk; private final String givenName; -- cgit v1.2.3 From 10a890cefbec754f927d3adf63d56956c426b45d Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Mon, 7 Feb 2022 18:55:46 +0100 Subject: test(core): fix broken integration tests after ERnP client integration --- .../connector/test/FullStartUpAndProcessTest.java | 34 ++++++++++++++++++---- .../config/junit_config_1_springboot.properties | 9 ++++++ .../config/junit_config_2_springboot.properties | 9 ++++++ 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/FullStartUpAndProcessTest.java b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/FullStartUpAndProcessTest.java index 09d11a78..890d4b19 100644 --- a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/FullStartUpAndProcessTest.java +++ b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/FullStartUpAndProcessTest.java @@ -97,9 +97,12 @@ import eu.eidas.auth.commons.tx.BinaryLightToken; import eu.eidas.specificcommunication.SpecificCommunicationDefinitionBeanNames; import eu.eidas.specificcommunication.exception.SpecificCommunicationException; import eu.eidas.specificcommunication.protocol.SpecificCommunicationService; +import lombok.SneakyThrows; import lombok.val; import net.shibboleth.utilities.java.support.component.ComponentInitializationException; import net.shibboleth.utilities.java.support.xml.XMLParserException; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; import szrservices.SZR; import szrservices.SignContentEntry; import szrservices.SignContentResponseType; @@ -136,15 +139,20 @@ public class FullStartUpAndProcessTest { private SZR szrMock; private ServicePort zmrClient; + private static MockWebServer mockWebServer; + private String cc; private String givenName; private String familyName; private String dateOfBirth; private String personalId; + private String pseudonym; private String vsz; private String eidasBind; + + /** * jUnit class initializer. * @throws InterruptedException In case of an error @@ -153,7 +161,8 @@ public class FullStartUpAndProcessTest { * */ @BeforeClass - public static void classInitializer() throws InterruptedException, InitializationException, ComponentInitializationException { + @SneakyThrows + public static void classInitializer() { final String current = new java.io.File(".").toURI().toString(); System.clearProperty("eidas.ms.configuration"); @@ -167,6 +176,10 @@ public class FullStartUpAndProcessTest { EaafOpenSaml3xInitializer.eaafInitialize(); + // start ERnP mockup WebServer + mockWebServer = new MockWebServer(); + mockWebServer.start(1718); + } /** @@ -175,7 +188,8 @@ public class FullStartUpAndProcessTest { * @throws Exception In case of an error */ @AfterClass - public static void closeIgniteNode() throws Exception { + @SneakyThrows + public static void closeIgniteNode() { System.out.println("Closiong Ignite Node ... "); Ignition.stopAll(true); @@ -183,6 +197,9 @@ public class FullStartUpAndProcessTest { final Field field = IgniteInstanceInitializerSpecificCommunication.class.getDeclaredField("instance"); field.setAccessible(true); field.set(null, null); + + // shut-down ERnP mock-up WebServer + mockWebServer.shutdown(); } @@ -210,7 +227,8 @@ public class FullStartUpAndProcessTest { cc = RandomStringUtils.randomAlphabetic(2).toUpperCase(); - personalId = cc + "/AT/" + RandomStringUtils.randomNumeric(64); + pseudonym = RandomStringUtils.randomNumeric(64); + personalId = cc + "/AT/" + pseudonym; familyName = RandomStringUtils.randomAlphabetic(10); givenName = RandomStringUtils.randomAlphabetic(10); dateOfBirth = "2015-10-12"; @@ -357,9 +375,13 @@ public class FullStartUpAndProcessTest { RequestContextHolder.resetRequestAttributes(); RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(eidasNodeRespReq, finalizeResp)); + // inject ZMR, ERnP and SZR responses for matching injectZmrResponse(); - injectSzrResponse(); - + injectSzrResponse(); + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody("{}") // empty response because we simulate result from ZMR + .setHeader("Content-Type", "application/json;charset=utf-8")); + //excute eIDAS node response eidasSignal.restoreEidasAuthProcess(eidasNodeRespReq, finalizeResp); @@ -454,7 +476,7 @@ public class FullStartUpAndProcessTest { EidasIdentitaetErgebnisType eidasPersonalIdentifier = new EidasIdentitaetErgebnisType(); personInfo.getEidasIdentitaet().add(eidasPersonalIdentifier); - eidasPersonalIdentifier.setEidasWert(personalId); + eidasPersonalIdentifier.setEidasWert(pseudonym); eidasPersonalIdentifier.setEidasArt(Constants.eIDAS_ATTRURN_PERSONALIDENTIFIER); eidasPersonalIdentifier.setStaatscode2(cc); diff --git a/connector/src/test/resources/config/junit_config_1_springboot.properties b/connector/src/test/resources/config/junit_config_1_springboot.properties index 3544c3a9..d3f0d136 100644 --- a/connector/src/test/resources/config/junit_config_1_springboot.properties +++ b/connector/src/test/resources/config/junit_config_1_springboot.properties @@ -55,6 +55,15 @@ 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 +# ERnP communication +eidas.ms.auth.eIDAS.ernpclient.endpoint=http://localhost:1718/demoernp +eidas.ms.auth.eIDAS.ernpclient.req.organisation.behoerdennr=jUnit123456 +eidas.ms.auth.eIDAS.client.common.ssl.keyStore.type=jks +eidas.ms.auth.eIDAS.client.common.ssl.keyStore.path=keys/junit.jks +eidas.ms.auth.eIDAS.client.common.ssl.keyStore.password=password +eidas.ms.auth.eIDAS.client.common.ssl.key.alias=meta +eidas.ms.auth.eIDAS.client.common.ssl.key.password=password + ## PVP2 S-Profile end-point configuration diff --git a/connector/src/test/resources/config/junit_config_2_springboot.properties b/connector/src/test/resources/config/junit_config_2_springboot.properties index a67e387f..71a573e0 100644 --- a/connector/src/test/resources/config/junit_config_2_springboot.properties +++ b/connector/src/test/resources/config/junit_config_2_springboot.properties @@ -55,6 +55,15 @@ 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 +# ERnP communication +eidas.ms.auth.eIDAS.ernpclient.endpoint=http://localhost:1718/demoernp +eidas.ms.auth.eIDAS.ernpclient.req.organisation.behoerdennr=jUnit123456 +eidas.ms.auth.eIDAS.client.common.ssl.keyStore.type=jks +eidas.ms.auth.eIDAS.client.common.ssl.keyStore.path=keys/junit.jks +eidas.ms.auth.eIDAS.client.common.ssl.keyStore.password=password +eidas.ms.auth.eIDAS.client.common.ssl.key.alias=meta +eidas.ms.auth.eIDAS.client.common.ssl.key.password=password + ## PVP2 S-Profile end-point configuration eidas.ms.pvp2.keystore.type=jks -- cgit v1.2.3 From 1a5d7bd12b0028b7cdb4e1b5e99d6162a323dce8 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Tue, 8 Feb 2022 08:07:48 +0100 Subject: chore(ernp): ignore search requests with residence information. ERnP search is not used here, because we only search for people with Austrian residence and they are in ZMR only. --- .../specific/modules/auth/eidas/v2/clients/ernp/ErnpRestClient.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 3c19e9c1..3822da01 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 @@ -311,8 +311,10 @@ public class ErnpRestClient implements IErnpClient { @Override public ErnpRegisterResult searchWithResidenceData(String givenName, String familyName, String dateOfBirth, - String zipcode, String city, String street) { + String zipcode, String city, String street) { + log.warn("Matching with residence information is prohibited by design! This requests will be ignored"); return new ErnpRegisterResult(Collections.emptyList()); + } @PostConstruct -- cgit v1.2.3 From a2baf085fcd3a1940585beb3f4a8acb2e4e5a461 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Tue, 8 Feb 2022 11:40:01 +0100 Subject: refactor(matching): move AddresssucheController into eIDAS module to reuse data-model for tasks --- .../controller/AdresssucheController.java | 248 -------------------- .../eidas/v2/controller/AdresssucheController.java | 258 +++++++++++++++++++++ 2 files changed, 258 insertions(+), 248 deletions(-) delete mode 100644 connector/src/main/java/at/asitplus/eidas/specific/connector/controller/AdresssucheController.java create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/controller/AdresssucheController.java diff --git a/connector/src/main/java/at/asitplus/eidas/specific/connector/controller/AdresssucheController.java b/connector/src/main/java/at/asitplus/eidas/specific/connector/controller/AdresssucheController.java deleted file mode 100644 index b044e95e..00000000 --- a/connector/src/main/java/at/asitplus/eidas/specific/connector/controller/AdresssucheController.java +++ /dev/null @@ -1,248 +0,0 @@ -/* - * Copyright 2018 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.connector.controller; - -import at.asitplus.eidas.specific.connector.MsEidasNodeConstants; -import at.asitplus.eidas.specific.connector.gui.StaticGuiBuilderConfiguration; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.zmr.ZmrAddressSoapClient; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasSAuthenticationException; -import at.gv.bmi.namespace.zmr_su.zrm._20040201_.address.Adressdaten; -import at.gv.e_government.reference.namespace.persondata.de._20040201.PostAdresseTyp; -import at.gv.e_government.reference.namespace.persondata.de._20040201.ZustelladresseTyp; -import at.gv.egiz.eaaf.core.api.gui.ISpringMvcGuiFormBuilder; -import at.gv.egiz.eaaf.core.api.idp.IConfiguration; -import at.gv.egiz.eaaf.core.api.utils.IPendingRequestIdGenerationStrategy; -import at.gv.egiz.eaaf.core.exceptions.EaafException; -import at.gv.egiz.eaaf.core.exceptions.GuiBuildException; -import at.gv.egiz.eaaf.core.exceptions.PendingReqIdValidationException; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.builder.CompareToBuilder; -import org.jetbrains.annotations.NotNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.io.ResourceLoader; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -/** - * Default process-engine signaling controller. - * - * @author tlenz - */ -@Controller -@Slf4j -public class AdresssucheController { - - @Autowired - private ISpringMvcGuiFormBuilder guiBuilder; - - @Autowired - private IConfiguration basicConfig; - - @Autowired - private ResourceLoader resourceLoader; - - @Autowired - private ZmrAddressSoapClient client; - - @Autowired - private IPendingRequestIdGenerationStrategy pendingReqGeneration; - - /** - * Show the "residency.html" directly. - * TODO Remove this after testing. - */ - @RequestMapping(value = {"/test"}, method = {RequestMethod.GET}) - public void test(HttpServletRequest request, HttpServletResponse response) throws GuiBuildException, EaafException { - final StaticGuiBuilderConfiguration config = new StaticGuiBuilderConfiguration( - basicConfig, - "http://localhost:8080/ms_connector/", - basicConfig.getBasicConfiguration(//TODO - MsEidasNodeConstants.PROP_CONFIG_WEBCONTENT_TEMPLATES_RESIDENCY, - MsEidasNodeConstants.TEMPLATE_HTML_RESIDENCY), - MsEidasNodeConstants.ENDPOINT_RESIDENCY_INPUT, - resourceLoader); - config.putCustomParameter(null, "pendingid", pendingReqGeneration.generateExternalPendingRequestId()); - guiBuilder.build(request, response, config, "Query Austrian residency"); - } - - /** - * Show the "other_login_method.html" directly. - * TODO Remove this after testing. - */ - @RequestMapping(value = {"/olm"}, method = {RequestMethod.GET}) - public void otherloginmethod(HttpServletRequest request, HttpServletResponse response) throws GuiBuildException, - EaafException { - final StaticGuiBuilderConfiguration config = new StaticGuiBuilderConfiguration( - basicConfig, - "http://localhost:8080/ms_connector/", - basicConfig.getBasicConfiguration(//TODO - MsEidasNodeConstants.PROP_CONFIG_WEBCONTENT_TEMPLATES_OTHER_LOGIN_METHOD_SELECTION, - MsEidasNodeConstants.TEMPLATE_HTML_OTHERLOGINMETHODS), - MsEidasNodeConstants.ENDPOINT_OTHER_LOGIN_METHOD_SELECTION, - resourceLoader); - config.putCustomParameter(null, "pendingid", pendingReqGeneration.generateExternalPendingRequestId()); - guiBuilder.build(request, response, config, "Other Login Method"); - } - - /** - * Show the "country_selection.html" directly. - * TODO Remove this after testing. - */ - @RequestMapping(value = {"/country"}, method = {RequestMethod.GET}) - public void countryselection(HttpServletRequest request, HttpServletResponse response) throws GuiBuildException, - EaafException { - final StaticGuiBuilderConfiguration config = new StaticGuiBuilderConfiguration( - basicConfig, - "http://localhost:8080/ms_connector/", - basicConfig.getBasicConfiguration(//TODO - MsEidasNodeConstants.PROP_CONFIG_WEBCONTENT_TEMPLATES_CCSELECTION, - MsEidasNodeConstants.TEMPLATE_HTML_COUNTRYSELECTION), - MsEidasNodeConstants.ENDPOINT_COUNTRYSELECTION, - resourceLoader); - config.putCustomParameter(null, "pendingid", pendingReqGeneration.generateExternalPendingRequestId()); - guiBuilder.build(request, response, config, "Country Selection"); - } - - /** - * Performs search for addresses in ZMR. - */ - @RequestMapping(value = {"/residency/search"}, method = {RequestMethod.POST}) - public ResponseEntity search(@RequestParam("postleitzahl") String postleitzahl, - @RequestParam("municipality") String municipality, - @RequestParam("village") String village, - @RequestParam("street") String street, - @RequestParam("number") String number, - @RequestParam("pendingid") String pendingId) { - log.info("Search with '{}', '{}', '{}', '{}', '{}'", - postleitzahl.replaceAll("[\r\n]", ""), - municipality.replaceAll("[\r\n]", ""), - village.replaceAll("[\r\n]", ""), - street.replaceAll("[\r\n]", ""), - number.replaceAll("[\r\n]", "")); - try { - pendingReqGeneration.validateAndGetPendingRequestId(pendingId); - } catch (PendingReqIdValidationException e) { - log.warn("Search with pendingId '{}' is not valid", pendingId.replaceAll("[\r\n]", "")); - return ResponseEntity.badRequest().build(); - } - try { - Adressdaten searchInput = buildSearchInput(postleitzahl, municipality, village, street, number); - ZmrAddressSoapClient.AddressInfo searchOutput = client.searchAddress(searchInput); - AdresssucheResult output = buildResponse(searchOutput); - return ResponseEntity.ok(output); - } catch (EidasSAuthenticationException e) { - log.warn("Search failed", e); - return ResponseEntity.badRequest().build(); - } - } - - private AdresssucheResult buildResponse(ZmrAddressSoapClient.AddressInfo searchOutput) { - if (searchOutput.getPersonResult().isEmpty()) { - log.warn("No result from ZMR"); - return new AdresssucheResult(Collections.emptyList(), 0); - } - log.info("Result level is {}", searchOutput.getLevel()); - Set result = searchOutput.getPersonResult().stream() - .map(Adressdaten::getPostAdresse) - .map(it -> new AdresssucheOutput(it.getPostleitzahl(), it.getGemeinde(), it.getOrtschaft(), - it.getZustelladresse().getStrassenname(), it.getZustelladresse().getOrientierungsnummer())) - .collect(Collectors.toSet()); - // TODO Add configuration option for the limit of 30 - List sorted = result.stream().sorted().limit(30).collect(Collectors.toList()); - return new AdresssucheResult(sorted, result.size()); - } - - private Adressdaten buildSearchInput(String postleitzahl, - String municipality, - String village, - String street, - String number) { - PostAdresseTyp postAdresse = new PostAdresseTyp(); - if (StringUtils.isNotBlank(postleitzahl)) { - postAdresse.setPostleitzahl(postleitzahl); - } - if (StringUtils.isNotBlank(municipality)) { - postAdresse.setGemeinde(municipality); - } - if (StringUtils.isNotBlank(village)) { - postAdresse.setOrtschaft(village); - } - if (StringUtils.isNotBlank(street) || StringUtils.isNotBlank(number)) { - ZustelladresseTyp zustelladresse = new ZustelladresseTyp(); - if (StringUtils.isNotBlank(street)) { - zustelladresse.setStrassenname(street); - } - if (StringUtils.isNotBlank(number)) { - zustelladresse.setOrientierungsnummer(number); - } - postAdresse.setZustelladresse(zustelladresse); - } - Adressdaten searchInput = new Adressdaten(); - searchInput.setPostAdresse(postAdresse); - return searchInput; - } - - @Data - @AllArgsConstructor - public static class AdresssucheResult { - private final Collection results; - private final int resultCount; - } - - @Data - @AllArgsConstructor - public static class AdresssucheOutput implements Comparable { - private final String postleitzahl; - private final String municipality; - private final String village; - private final String street; - private final String number; - - @Override - public int compareTo(@NotNull AdresssucheOutput o) { - return new CompareToBuilder() - .append(this.postleitzahl, o.postleitzahl) - .append(this.municipality, o.municipality) - .append(this.village, o.village) - .append(this.street, o.street) - .append(this.number, o.number) - .toComparison(); - } - } - -} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/controller/AdresssucheController.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/controller/AdresssucheController.java new file mode 100644 index 00000000..8505f5d5 --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/controller/AdresssucheController.java @@ -0,0 +1,258 @@ +/* + * Copyright 2018 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.controller; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.builder.CompareToBuilder; +import org.jetbrains.annotations.NotNull; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.io.ResourceLoader; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; + +import at.asitplus.eidas.specific.connector.MsEidasNodeConstants; +import at.asitplus.eidas.specific.connector.gui.StaticGuiBuilderConfiguration; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.zmr.ZmrAddressSoapClient; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasSAuthenticationException; +import at.gv.bmi.namespace.zmr_su.zrm._20040201_.address.Adressdaten; +import at.gv.e_government.reference.namespace.persondata.de._20040201.PostAdresseTyp; +import at.gv.e_government.reference.namespace.persondata.de._20040201.ZustelladresseTyp; +import at.gv.egiz.eaaf.core.api.data.EaafConstants; +import at.gv.egiz.eaaf.core.api.gui.ISpringMvcGuiFormBuilder; +import at.gv.egiz.eaaf.core.api.idp.IConfiguration; +import at.gv.egiz.eaaf.core.api.utils.IPendingRequestIdGenerationStrategy; +import at.gv.egiz.eaaf.core.exceptions.EaafException; +import at.gv.egiz.eaaf.core.exceptions.GuiBuildException; +import at.gv.egiz.eaaf.core.exceptions.PendingReqIdValidationException; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; + +/** + * Default process-engine signaling controller. + * + * @author tlenz + */ +@Controller +@Slf4j +public class AdresssucheController { + + public static final String PARAM_POSTLEITZAHL = "postleitzahl"; + public static final String PARAM_MUNIPICALITY = "municipality"; + public static final String PARAM_VILLAGE = "village"; + public static final String PARAM_STREET = "street"; + public static final String PARAM_NUMBER = "number"; + + @Autowired + private ISpringMvcGuiFormBuilder guiBuilder; + + @Autowired + private IConfiguration basicConfig; + + @Autowired + private ResourceLoader resourceLoader; + + @Autowired + private ZmrAddressSoapClient client; + + @Autowired + private IPendingRequestIdGenerationStrategy pendingReqGeneration; + + /** + * Show the "residency.html" directly. + * TODO Remove this after testing. + */ + @RequestMapping(value = {"/test"}, method = {RequestMethod.GET}) + public void test(HttpServletRequest request, HttpServletResponse response) throws GuiBuildException, EaafException { + final StaticGuiBuilderConfiguration config = new StaticGuiBuilderConfiguration( + basicConfig, + "http://localhost:8080/ms_connector/", + basicConfig.getBasicConfiguration(//TODO + MsEidasNodeConstants.PROP_CONFIG_WEBCONTENT_TEMPLATES_RESIDENCY, + MsEidasNodeConstants.TEMPLATE_HTML_RESIDENCY), + MsEidasNodeConstants.ENDPOINT_RESIDENCY_INPUT, + resourceLoader); + config.putCustomParameter(null, "pendingid", pendingReqGeneration.generateExternalPendingRequestId()); + guiBuilder.build(request, response, config, "Query Austrian residency"); + } + + /** + * Show the "other_login_method.html" directly. + * TODO Remove this after testing. + */ + @RequestMapping(value = {"/olm"}, method = {RequestMethod.GET}) + public void otherloginmethod(HttpServletRequest request, HttpServletResponse response) throws GuiBuildException, + EaafException { + final StaticGuiBuilderConfiguration config = new StaticGuiBuilderConfiguration( + basicConfig, + "http://localhost:8080/ms_connector/", + basicConfig.getBasicConfiguration(//TODO + MsEidasNodeConstants.PROP_CONFIG_WEBCONTENT_TEMPLATES_OTHER_LOGIN_METHOD_SELECTION, + MsEidasNodeConstants.TEMPLATE_HTML_OTHERLOGINMETHODS), + MsEidasNodeConstants.ENDPOINT_OTHER_LOGIN_METHOD_SELECTION, + resourceLoader); + config.putCustomParameter(null, "pendingid", pendingReqGeneration.generateExternalPendingRequestId()); + guiBuilder.build(request, response, config, "Other Login Method"); + } + + /** + * Show the "country_selection.html" directly. + * TODO Remove this after testing. + */ + @RequestMapping(value = {"/country"}, method = {RequestMethod.GET}) + public void countryselection(HttpServletRequest request, HttpServletResponse response) throws GuiBuildException, + EaafException { + final StaticGuiBuilderConfiguration config = new StaticGuiBuilderConfiguration( + basicConfig, + "http://localhost:8080/ms_connector/", + basicConfig.getBasicConfiguration(//TODO + MsEidasNodeConstants.PROP_CONFIG_WEBCONTENT_TEMPLATES_CCSELECTION, + MsEidasNodeConstants.TEMPLATE_HTML_COUNTRYSELECTION), + MsEidasNodeConstants.ENDPOINT_COUNTRYSELECTION, + resourceLoader); + config.putCustomParameter(null, "pendingid", pendingReqGeneration.generateExternalPendingRequestId()); + guiBuilder.build(request, response, config, "Country Selection"); + } + + /** + * Performs search for addresses in ZMR. + */ + @RequestMapping(value = {"/residency/search"}, method = {RequestMethod.POST}) + public ResponseEntity search( + @RequestParam(PARAM_POSTLEITZAHL) String postleitzahl, + @RequestParam(PARAM_MUNIPICALITY) String municipality, + @RequestParam(PARAM_VILLAGE) String village, + @RequestParam(PARAM_STREET) String street, + @RequestParam(PARAM_NUMBER) String number, + @RequestParam(EaafConstants.PARAM_HTTP_TARGET_PENDINGREQUESTID) String pendingId) { + log.info("Search with '{}', '{}', '{}', '{}', '{}'", + postleitzahl.replaceAll("[\r\n]", ""), + municipality.replaceAll("[\r\n]", ""), + village.replaceAll("[\r\n]", ""), + street.replaceAll("[\r\n]", ""), + number.replaceAll("[\r\n]", "")); + try { + pendingReqGeneration.validateAndGetPendingRequestId(pendingId); + } catch (PendingReqIdValidationException e) { + log.warn("Search with pendingId '{}' is not valid", pendingId.replaceAll("[\r\n]", "")); + return ResponseEntity.badRequest().build(); + } + try { + Adressdaten searchInput = buildSearchInput(postleitzahl, municipality, village, street, number); + ZmrAddressSoapClient.AddressInfo searchOutput = client.searchAddress(searchInput); + AdresssucheResult output = buildResponse(searchOutput); + return ResponseEntity.ok(output); + } catch (EidasSAuthenticationException e) { + log.warn("Search failed", e); + return ResponseEntity.badRequest().build(); + } + } + + private AdresssucheResult buildResponse(ZmrAddressSoapClient.AddressInfo searchOutput) { + if (searchOutput.getPersonResult().isEmpty()) { + log.warn("No result from ZMR"); + return new AdresssucheResult(Collections.emptyList(), 0); + } + log.info("Result level is {}", searchOutput.getLevel()); + Set result = searchOutput.getPersonResult().stream() + .map(Adressdaten::getPostAdresse) + .map(it -> new AdresssucheOutput(it.getPostleitzahl(), it.getGemeinde(), it.getOrtschaft(), + it.getZustelladresse().getStrassenname(), it.getZustelladresse().getOrientierungsnummer())) + .collect(Collectors.toSet()); + // TODO Add configuration option for the limit of 30 + List sorted = result.stream().sorted().limit(30).collect(Collectors.toList()); + return new AdresssucheResult(sorted, result.size()); + } + + private Adressdaten buildSearchInput(String postleitzahl, + String municipality, + String village, + String street, + String number) { + PostAdresseTyp postAdresse = new PostAdresseTyp(); + if (StringUtils.isNotBlank(postleitzahl)) { + postAdresse.setPostleitzahl(postleitzahl); + } + if (StringUtils.isNotBlank(municipality)) { + postAdresse.setGemeinde(municipality); + } + if (StringUtils.isNotBlank(village)) { + postAdresse.setOrtschaft(village); + } + if (StringUtils.isNotBlank(street) || StringUtils.isNotBlank(number)) { + ZustelladresseTyp zustelladresse = new ZustelladresseTyp(); + if (StringUtils.isNotBlank(street)) { + zustelladresse.setStrassenname(street); + } + if (StringUtils.isNotBlank(number)) { + zustelladresse.setOrientierungsnummer(number); + } + postAdresse.setZustelladresse(zustelladresse); + } + Adressdaten searchInput = new Adressdaten(); + searchInput.setPostAdresse(postAdresse); + return searchInput; + } + + @Data + @AllArgsConstructor + public static class AdresssucheResult { + private final Collection results; + private final int resultCount; + } + + @Data + @AllArgsConstructor + public static class AdresssucheOutput implements Comparable { + private final String postleitzahl; + private final String municipality; + private final String village; + private final String street; + private final String number; + + @Override + public int compareTo(@NotNull AdresssucheOutput o) { + return new CompareToBuilder() + .append(this.postleitzahl, o.postleitzahl) + .append(this.municipality, o.municipality) + .append(this.village, o.village) + .append(this.street, o.street) + .append(this.number, o.number) + .toComparison(); + } + } + +} -- cgit v1.2.3 From 33404685b1d8de14229f61ea5dfa1fbee6229916 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Tue, 8 Feb 2022 14:50:03 +0100 Subject: feature(matching): finalize matching by residence search Add ZMR communication and state validation for match-by-residence operation --- .../specific/modules/auth/eidas/v2/Constants.java | 4 +- .../auth/eidas/v2/clients/zmr/IZmrClient.java | 21 ++- .../auth/eidas/v2/clients/zmr/ZmrSoapClient.java | 96 +++++++++-- .../eidas/v2/controller/AdresssucheController.java | 11 ++ .../eidas/v2/service/RegisterSearchService.java | 28 ++-- .../ReceiveAustrianResidenceGuiResponseTask.java | 175 +++++++++++---------- .../messages/eidas_connector_message.properties | 4 + ...eceiveAustrianResidenceGuiResponseTaskTest.java | 127 ++++++++++----- 8 files changed, 323 insertions(+), 143 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 6da30299..40bcd27a 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 @@ -314,10 +314,12 @@ public class Constants { // UI options public static final String HTML_FORM_ADVANCED_MATCHING_FAILED = "advancedMatchingFailed"; - + // ProcessEngine context public static final String CONTEXT_FLAG_ADVANCED_MATCHING_FAILED = HTML_FORM_ADVANCED_MATCHING_FAILED; + public static final String CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON = + HTML_FORM_ADVANCED_MATCHING_FAILED + "Reason"; /** * {@link at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.CreateNewErnpEntryTask}. 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 c4e8ece0..f3c32c96 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 @@ -29,6 +29,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.zmr.ZmrSoapClient.ZmrRegisterResult; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.controller.AdresssucheController.AdresssucheOutput; 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; @@ -79,6 +80,23 @@ public interface IZmrClient { @Nonnull PersonSuchenRequest personSearchDao, @Nonnull String citizenCountryCode) throws EidasSAuthenticationException; + /** + * Search person based on MDS information and Austrian residence. + * + * @param zmrProzessId zmrProzessId zmrProzessId ProcessId from ZMR or null if no processId exists + * @param givenName eIDAS given name + * @param familyName eIDAS principle name + * @param dateOfBirth eIDAS date-of-birth + * @param citizenCountryCode citizenCountryCode CountryCode of the eIDAS proxy-service + * @param address Address information for searching + * @return Search result but never null + * @throws EidasSAuthenticationException In case of a communication error + */ + @Nonnull + ZmrRegisterResult searchWithResidenceData(@Nullable BigInteger zmrProzessId, @Nonnull String givenName, + @Nonnull String familyName, @Nonnull String dateOfBirth, @Nonnull String citizenCountryCode, + @Nonnull AdresssucheOutput address) throws EidasSAuthenticationException; + /** * Update ZMR entry to KITT existing ZMR identity with this eIDAS authentication. * @@ -92,7 +110,4 @@ public interface IZmrClient { 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 18a80c33..0f2f94cc 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 @@ -24,6 +24,7 @@ import org.springframework.lang.Nullable; import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.AbstractSoapClient; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.controller.AdresssucheController.AdresssucheOutput; 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; @@ -56,6 +57,8 @@ 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.e_government.reference.namespace.persondata.de._20040201.PostAdresseTyp; +import at.gv.e_government.reference.namespace.persondata.de._20040201.ZustelladresseTyp; 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; @@ -95,6 +98,7 @@ 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 {0} specific"; + private static final String PROCESS_SEARCH_BY_RESIDENCE = "Searching by residence"; private static final String PROCESS_KITT_GENERAL = "KITT general-processing"; private static final String PROCESS_KITT_IDENITIES_GET = "KITT get-latest-version"; @@ -173,15 +177,7 @@ public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient { // set eIDAS person information final PersonSuchenRequest searchPersonReq = new PersonSuchenRequest(); req.setPersonSuchenRequest(searchPersonReq); - - final NatuerlichePersonTyp searchNatPerson = new NatuerlichePersonTyp(); - searchPersonReq.setNatuerlichePerson(searchNatPerson); - final PersonenNameTyp searchNatPersonName = new PersonenNameTyp(); - searchNatPerson.setPersonenName(searchNatPersonName); - - searchNatPersonName.setFamilienname(familyName); - searchNatPersonName.setVorname(givenName); - searchNatPerson.setGeburtsdatum(dateOfBirth); + searchPersonReq.setNatuerlichePerson(buildSearchNatPerson(givenName, familyName, dateOfBirth)); // set work-flow client information req.setWorkflowInfoClient(generateWorkFlowInfos(PROCESS_TASK_SEARCH, zmrProzessId)); @@ -296,12 +292,49 @@ public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient { } } - + @Override public ZmrRegisterResult searchWithResidenceData(BigInteger zmrProzessId, String givenName, String familyName, - String dateOfBirth, String zipcode, String city, String street) { - // TODO Auto-generated method stub - return null; + String dateOfBirth, String citizenCountryCode, AdresssucheOutput address) + throws EidasSAuthenticationException { + try { + // build search request + final RequestType req = new RequestType(); + + // set person information + final PersonSuchenRequest searchPersonReq = new PersonSuchenRequest(); + req.setPersonSuchenRequest(searchPersonReq); + searchPersonReq.setNatuerlichePerson(buildSearchNatPerson(givenName, familyName, dateOfBirth)); + searchPersonReq.setPostAdresse(buildSearchAddress(address)); + + // set work-flow client information + req.setWorkflowInfoClient(generateWorkFlowInfos(PROCESS_SEARCH_BY_RESIDENCE, zmrProzessId)); + req.setClientInfo(generateClientInfos()); + + // set additionl search parameters + searchPersonReq.setPersonensucheInfo(generateSearchCriteria( + PROCESS_SEARCH_BY_RESIDENCE, false, true, false)); + + // request ZMR + log.trace("Requesting ZMR for '{}' operation", PROCESS_SEARCH_BY_RESIDENCE); + final ResponseType resp = zmrClient.service(req, null); + + // parse ZMR response + return processZmrResponse(resp, citizenCountryCode, false, PROCESS_SEARCH_BY_RESIDENCE); + + } catch (final ServiceFault e) { + final String errorMsg = extractReasonFromError(e); + log.warn(LOGMSG_ZMR_ERROR, PROCESS_SEARCH_BY_RESIDENCE, 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_SEARCH_BY_RESIDENCE, e.getMessage()); + throw new EidasSAuthenticationException(ERROR_MATCHING_99, new Object[] { e.getMessage() }, e); + + } } @PostConstruct @@ -685,6 +718,43 @@ public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient { } } + private NatuerlichePersonTyp buildSearchNatPerson(String givenName, String familyName, String dateOfBirth) { + final NatuerlichePersonTyp searchNatPerson = new NatuerlichePersonTyp(); + final PersonenNameTyp searchNatPersonName = new PersonenNameTyp(); + searchNatPerson.setPersonenName(searchNatPersonName); + searchNatPersonName.setFamilienname(familyName); + searchNatPersonName.setVorname(givenName); + searchNatPerson.setGeburtsdatum(dateOfBirth); + return searchNatPerson; + + } + + private PostAdresseTyp buildSearchAddress(AdresssucheOutput address) { + PostAdresseTyp postAdresse = new PostAdresseTyp(); + if (StringUtils.isNotBlank(address.getPostleitzahl())){ + postAdresse.setPostleitzahl(address.getPostleitzahl()); + } + if (StringUtils.isNotBlank(address.getMunicipality())) { + postAdresse.setGemeinde(address.getMunicipality()); + } + if (StringUtils.isNotBlank(address.getVillage())) { + postAdresse.setOrtschaft(address.getVillage()); + } + if (StringUtils.isNotBlank(address.getStreet()) || StringUtils.isNotBlank(address.getNumber())) { + ZustelladresseTyp zustelladresse = new ZustelladresseTyp(); + if (StringUtils.isNotBlank(address.getStreet())) { + zustelladresse.setStrassenname(address.getStreet()); + } + if (StringUtils.isNotBlank(address.getNumber())) { + zustelladresse.setOrientierungsnummer(address.getNumber()); + } + postAdresse.setZustelladresse(zustelladresse); + } + + return postAdresse; + + } + private Collection selectEidasDocumentsToAdd( PersonErgebnisType zmrPersonToKitt, SimpleEidasData eidData) { diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/controller/AdresssucheController.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/controller/AdresssucheController.java index 8505f5d5..6dcd4879 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/controller/AdresssucheController.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/controller/AdresssucheController.java @@ -58,6 +58,7 @@ import at.gv.egiz.eaaf.core.exceptions.EaafException; import at.gv.egiz.eaaf.core.exceptions.GuiBuildException; import at.gv.egiz.eaaf.core.exceptions.PendingReqIdValidationException; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; import lombok.extern.slf4j.Slf4j; @@ -166,18 +167,23 @@ public class AdresssucheController { number.replaceAll("[\r\n]", "")); try { pendingReqGeneration.validateAndGetPendingRequestId(pendingId); + } catch (PendingReqIdValidationException e) { log.warn("Search with pendingId '{}' is not valid", pendingId.replaceAll("[\r\n]", "")); return ResponseEntity.badRequest().build(); + } + try { Adressdaten searchInput = buildSearchInput(postleitzahl, municipality, village, street, number); ZmrAddressSoapClient.AddressInfo searchOutput = client.searchAddress(searchInput); AdresssucheResult output = buildResponse(searchOutput); return ResponseEntity.ok(output); + } catch (EidasSAuthenticationException e) { log.warn("Search failed", e); return ResponseEntity.badRequest().build(); + } } @@ -185,7 +191,9 @@ public class AdresssucheController { if (searchOutput.getPersonResult().isEmpty()) { log.warn("No result from ZMR"); return new AdresssucheResult(Collections.emptyList(), 0); + } + log.info("Result level is {}", searchOutput.getLevel()); Set result = searchOutput.getPersonResult().stream() .map(Adressdaten::getPostAdresse) @@ -195,6 +203,7 @@ public class AdresssucheController { // TODO Add configuration option for the limit of 30 List sorted = result.stream().sorted().limit(30).collect(Collectors.toList()); return new AdresssucheResult(sorted, result.size()); + } private Adressdaten buildSearchInput(String postleitzahl, @@ -225,6 +234,7 @@ public class AdresssucheController { Adressdaten searchInput = new Adressdaten(); searchInput.setPostAdresse(postAdresse); return searchInput; + } @Data @@ -236,6 +246,7 @@ public class AdresssucheController { @Data @AllArgsConstructor + @Builder public static class AdresssucheOutput implements Comparable { private final String postleitzahl; private final String municipality; 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 85ea942c..d95aadda 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 @@ -16,6 +16,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.ErnpRestCli import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.IErnpClient; 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.controller.AdresssucheController.AdresssucheOutput; 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; @@ -165,18 +166,27 @@ public class RegisterSearchService { * Search with residence infos. * * @param operationStatus Current register-operation status that contains processing informations - * @param zipcode Provided Zipcode - * @param city Provided City - * @param street Provided street + * @param eidasData Receive eIDAS eID information + * @param address Address information provided by user * @return Results from ZMR or ERnP search + * @throws WorkflowException In case of a register interaction error */ - 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 RegisterStatusResults.fromZmr(resultsZmr); + public RegisterStatusResults searchWithResidence(RegisterOperationStatus operationStatus, SimpleEidasData eidasData, + AdresssucheOutput address) throws WorkflowException { + try { + final ZmrRegisterResult resultsZmr = zmrClient.searchWithResidenceData( + operationStatus.getZmrProcessId(), eidasData.getGivenName(), eidasData.getFamilyName(), + eidasData.getDateOfBirth(), eidasData.getCitizenCountryCode(), address); + + // ERnP search is not used here, because we only search for people with Austrian residence and they are in ZMR only + + return RegisterStatusResults.fromZmr(resultsZmr); + + } catch (final EidasSAuthenticationException e) { + throw new WorkflowException("searchWithResidenceInformation", e.getMessage(), + !(e instanceof ZmrCommunicationException), e); + } } /** 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 acf469d3..67addf94 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 @@ -23,16 +23,24 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks; +import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED; +import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON; +import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK; + import java.util.Enumeration; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.StringEscapeUtils; +import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; import org.springframework.stereotype.Component; import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.controller.AdresssucheController; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.controller.AdresssucheController.AdresssucheOutput; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.controller.AdresssucheController.AdresssucheOutput.AdresssucheOutputBuilder; 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.exception.ManualFixNecessaryException; @@ -43,15 +51,9 @@ 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; import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; -import at.gv.egiz.eaaf.core.impl.idp.auth.modules.AbstractAuthServletTask; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; +import at.gv.egiz.eaaf.core.impl.idp.controller.tasks.AbstractLocaleAuthServletTask; import lombok.extern.slf4j.Slf4j; -import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED; -import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK; - /** * Task receives the response of {@link GenerateAustrianResidenceGuiTask} and handles it. @@ -67,7 +69,7 @@ import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.TRANSIT * * Transitions: *
      - *
    • {@link CreateNewErnpEntryTask} if no results from search with residency data in registers
    • + *
    • {@link GenerateOtherLoginMethodGuiTask} if no results from search with residency data in registers
    • *
    • {@link CreateIdentityLinkTask} if one exact match between initial register search (with MDS) and results * from search with residency data in registers exists
    • *
    • {@link GenerateOtherLoginMethodGuiTask} if a user input error has happened
    • @@ -79,71 +81,77 @@ import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.TRANSIT */ @Slf4j @Component("ReceiveAustrianResidenceGuiResponseTask") -public class ReceiveAustrianResidenceGuiResponseTask extends AbstractAuthServletTask { +public class ReceiveAustrianResidenceGuiResponseTask extends AbstractLocaleAuthServletTask { - public static final String PARAM_FORMER_RESIDENCE_AVAILABLE = "formerResidenceAvailable"; - public static final String PARAM_STREET = "street"; - public static final String PARAM_CITY = "city"; - public static final String PARAM_ZIPCODE = "zipcode"; + private static final String MSG_PROP_20 = "module.eidasauth.matching.20"; + private static final String MSG_PROP_21 = "module.eidasauth.matching.21"; + private static final String MSG_PROP_22 = "module.eidasauth.matching.22"; + + public static final String HTTP_PARAM_NO_RESIDENCE = "noResidence"; private final RegisterSearchService registerSearchService; public ReceiveAustrianResidenceGuiResponseTask(RegisterSearchService registerSearchService) { this.registerSearchService = registerSearchService; + } - - @Data - @AllArgsConstructor - @NoArgsConstructor - public static class UserInput { - private boolean formerResidenceAvailable; - private String zipcode; - private String city; - private String street; - } - + @Override - public void execute(ExecutionContext executionContext, HttpServletRequest request, HttpServletResponse response) - throws TaskExecutionException { + protected void executeWithLocale(ExecutionContext executionContext, HttpServletRequest request, + HttpServletResponse response) throws TaskExecutionException { log.trace("Starting ReceiveAustrianResidenceGuiResponseTask"); - UserInput input = parseHtmlInput(request); - if (!input.isFormerResidenceAvailable()) { - moveToNextTask(executionContext); - return; - - } - - if (input.getStreet().isEmpty() || input.getCity().isEmpty() || input.getZipcode().isEmpty()) { - // HTML form should ensure that mandatory fields are set => this should never happen - executionContext.put(CONTEXT_FLAG_ADVANCED_MATCHING_FAILED, true); - executionContext.put(TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK, true); - return; - - } + try { + //return to AuswahlScreen if HTTP_PARAM_NO_RESIDENCE was selected + final boolean forwardWithOutMandate = parseFlagFromHttpRequest(request, HTTP_PARAM_NO_RESIDENCE, false); + if (forwardWithOutMandate) { + log.debug("User selects 'no residence' button. Switch back to 'other matching' selection ... "); + executionContext.put(TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK, true); + + executionContext.put(CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON, MSG_PROP_20); + executionContext.put(CONTEXT_FLAG_ADVANCED_MATCHING_FAILED, true); + return; + + } + + //load search parameters from HTML form + AdresssucheOutput input = parseHtmlInput(request); + if (validateHtmlInput(input)) { + // HTML form should ensure that mandatory fields are set => this should never happen + log.warn("HTML form contains no residence information. Switch back to 'other matching' selection ... "); + executionContext.put(TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK, true); + + executionContext.put(CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON, MSG_PROP_20); + executionContext.put(CONTEXT_FLAG_ADVANCED_MATCHING_FAILED, true); + return; - try { + } + + // get pre-processed information SimpleEidasData eidasData = MatchingTaskUtils.getInitialEidasData(pendingReq); RegisterStatusResults initialSearchResult = MatchingTaskUtils.getIntermediateMatchingResult(pendingReq); + // search in register RegisterStatusResults residencyResult = - registerSearchService.searchWithResidence(initialSearchResult.getOperationStatus(), - eidasData, input.zipcode, input.city, input.street); - if (residencyResult.getResultCount() == 0) { - //TODO: her we should add a GUI step of result is zero to inform user an forward process by click - moveToNextTask(executionContext); - - } else if (residencyResult.getResultCount() == 1) { - compareSearchResultWithInitialData(executionContext, residencyResult, eidasData); + registerSearchService.searchWithResidence(initialSearchResult.getOperationStatus(), eidasData, input); + + // validate matching response from registers + if (residencyResult.getResultCount() != 1) { + log.info("Find {} match by using residence information. Forward user to 'other matching' selection ... ", + residencyResult.getResultCount() == 0 ? "no" : "more-than-one"); + executionContext.put(TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK, true); + + executionContext.put(CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON, MSG_PROP_22); + executionContext.put(CONTEXT_FLAG_ADVANCED_MATCHING_FAILED, true); } else { - /*TODO: align with form generation task and to better error handling in case of more-than-one result. - * Maybe the user has to provide more information. - */ - throw new TaskExecutionException(pendingReq, - "Manual Fix necessary", new ManualFixNecessaryException(eidasData)); + log.debug("Find single match by using residence information. Starting data validation ... "); + compareSearchResultWithInitialData(executionContext, residencyResult, eidasData); } + } catch (WorkflowException e) { + throw new TaskExecutionException(pendingReq, "Search with residency data failed", e); + } catch (EaafStorageException e) { log.error("Search with residency data failed", e); throw new TaskExecutionException(pendingReq, "Search with residency data failed", e); @@ -151,58 +159,67 @@ public class ReceiveAustrianResidenceGuiResponseTask extends AbstractAuthServlet } } + private boolean validateHtmlInput(AdresssucheOutput input) { + return StringUtils.isEmpty(input.getMunicipality()) + && StringUtils.isEmpty(input.getNumber()) + && StringUtils.isEmpty(input.getPostleitzahl()) + && StringUtils.isEmpty(input.getStreet()) + && StringUtils.isEmpty(input.getVillage()); + } + private void compareSearchResultWithInitialData(ExecutionContext executionContext, RegisterStatusResults residencyResult, SimpleEidasData eidasData) throws TaskExecutionException, EaafStorageException { try { - if (eidasData.equalsRegisterData(residencyResult.getResult())) { + if (!eidasData.equalsRegisterData(residencyResult.getResult())) { // update register information - registerSearchService.step7aKittProcess(residencyResult, eidasData); + RegisterStatusResults updateResult = registerSearchService.step7aKittProcess(residencyResult, eidasData); - // store search result to re-used in CreateIdentityLink step, because there we need bPK and MDS + // store updated result to re-used in CreateIdentityLink step, because there we need bPK and MDS MatchingTaskUtils.storeFinalMatchingResult(pendingReq, MatchedPersonResult.generateFormMatchingResult( - residencyResult.getResult(), eidasData.getCitizenCountryCode())); + updateResult.getResult(), eidasData.getCitizenCountryCode())); } else { - moveToNextTask(executionContext); - + log.warn("Suspect state FOUND. Matching by residence was neccessary but NO register-update are required!"); + // no update required. Data can be used as it is. + MatchingTaskUtils.storeFinalMatchingResult(pendingReq, + MatchedPersonResult.generateFormMatchingResult( + residencyResult.getResult(), eidasData.getCitizenCountryCode())); + } - + } catch (WorkflowException e) { throw new TaskExecutionException(pendingReq, "Search failed", new ManualFixNecessaryException(eidasData)); } } - private void moveToNextTask(ExecutionContext executionContext) { - // Later on, this should transition to Step 20 - executionContext.put(Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_TASK, true); - - } - - private @NotNull UserInput parseHtmlInput(HttpServletRequest request) { + private @NotNull AdresssucheOutput parseHtmlInput(HttpServletRequest request) { Enumeration reqParamNames = request.getParameterNames(); - UserInput result = new UserInput(); + AdresssucheOutputBuilder resultBuilder = AdresssucheOutput.builder(); while (reqParamNames.hasMoreElements()) { final String paramName = reqParamNames.nextElement(); String escaped = StringEscapeUtils.escapeHtml(request.getParameter(paramName)); - if (PARAM_FORMER_RESIDENCE_AVAILABLE.equalsIgnoreCase(paramName)) { - result.setFormerResidenceAvailable(Boolean.parseBoolean(escaped)); + if (AdresssucheController.PARAM_MUNIPICALITY.equalsIgnoreCase(paramName)) { + resultBuilder.municipality(escaped); - } else if (PARAM_STREET.equalsIgnoreCase(paramName)) { - result.setStreet(escaped); + } else if (AdresssucheController.PARAM_NUMBER.equalsIgnoreCase(paramName)) { + resultBuilder.number(escaped); - } else if (PARAM_CITY.equalsIgnoreCase(paramName)) { - result.setCity(escaped); + } else if (AdresssucheController.PARAM_POSTLEITZAHL.equalsIgnoreCase(paramName)) { + resultBuilder.postleitzahl(escaped); - } else if (PARAM_ZIPCODE.equalsIgnoreCase(paramName)) { - result.setZipcode(escaped); + } else if (AdresssucheController.PARAM_STREET.equalsIgnoreCase(paramName)) { + resultBuilder.street(escaped); + + } else if (AdresssucheController.PARAM_VILLAGE.equalsIgnoreCase(paramName)) { + resultBuilder.village(escaped); } } - return result; - + + return resultBuilder.build(); } } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/resources/messages/eidas_connector_message.properties b/eidas_modules/authmodule-eIDAS-v2/src/main/resources/messages/eidas_connector_message.properties index 188c5a8f..f1bf2128 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/resources/messages/eidas_connector_message.properties +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/resources/messages/eidas_connector_message.properties @@ -23,5 +23,9 @@ module.eidasauth.matching.04=An error occurred while loading your data from offi module.eidasauth.matching.11=Matching failed, because of an ERnP communication error. Reason: {0} module.eidasauth.matching.12=Matching failed, because ERnP response contains historic information which is not supported. +module.eidasauth.matching.20=Matching be using residence information was canceled. Use another method for matching or create a new Austrian identity. +module.eidasauth.matching.21=Matching be using residence information failed by missing input information. Use another method for matching or create a new Austrian identity. +module.eidasauth.matching.22=Can not find an unique match by using residence information. Provide more or other data, use another method for matching, or create a new Austrian identity. + module.eidasauth.matching.99=Matching failed, because of an unexpected processing error. Reason: {0} 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 64bb0d48..15edce07 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 @@ -1,14 +1,9 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.test.tasks; -import static at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.ReceiveAustrianResidenceGuiResponseTask.PARAM_CITY; -import static at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.ReceiveAustrianResidenceGuiResponseTask.PARAM_FORMER_RESIDENCE_AVAILABLE; -import static at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.ReceiveAustrianResidenceGuiResponseTask.PARAM_STREET; -import static at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.ReceiveAustrianResidenceGuiResponseTask.PARAM_ZIPCODE; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThrows; import static org.mockito.ArgumentMatchers.eq; -import static org.springframework.util.Assert.isInstanceOf; import java.math.BigInteger; import java.util.Arrays; @@ -21,7 +16,6 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.i18n.LocaleContextHolder; @@ -36,21 +30,22 @@ import com.google.common.collect.Lists; import at.asitplus.eidas.specific.connector.test.config.dummy.MsConnectorDummyConfigMap; import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.controller.AdresssucheController; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.controller.AdresssucheController.AdresssucheOutput; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.MatchedPersonResult; 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.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.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; import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; import at.gv.egiz.eaaf.core.exceptions.EaafStorageException; -import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; import at.gv.egiz.eaaf.core.impl.idp.auth.data.AuthProcessDataWrapper; import at.gv.egiz.eaaf.core.impl.idp.module.test.TestRequestImpl; import at.gv.egiz.eaaf.core.impl.idp.process.ExecutionContextImpl; +import lombok.SneakyThrows; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { @@ -67,7 +62,7 @@ public class ReceiveAustrianResidenceGuiResponseTaskTest { private ReceiveAustrianResidenceGuiResponseTask task; - private final ExecutionContext executionContext = new ExecutionContextImpl(); + private ExecutionContext executionContext; private MockHttpServletRequest httpReq; private MockHttpServletResponse httpResp; private TestRequestImpl pendingReq; @@ -79,8 +74,9 @@ public class ReceiveAustrianResidenceGuiResponseTaskTest { */ @Before public void setUp() throws Exception { + executionContext = new ExecutionContextImpl(); task = new ReceiveAustrianResidenceGuiResponseTask(registerSearchService); - + httpReq = new MockHttpServletRequest("POST", "https://localhost/ms_connector"); httpResp = new MockHttpServletResponse(); RequestContextHolder.resetRequestAttributes(); @@ -93,9 +89,27 @@ public class ReceiveAustrianResidenceGuiResponseTaskTest { LocaleContextHolder.resetLocaleContext(); } + @Test + public void canceledByUser() throws Exception { + AdresssucheOutput userInput = setupUserInput(); + SimpleEidasData eidasData = setupEidasData(); + RegisterStatusResults registerSearchResult = buildEmptyResult(); + mockRegisterSearch(userInput, registerSearchResult, eidasData); + MatchingTaskUtils.storeIntermediateMatchingResult(pendingReq, registerSearchResult); + httpReq.setParameter(ReceiveAustrianResidenceGuiResponseTask.HTTP_PARAM_NO_RESIDENCE, "true"); + + task.execute(pendingReq, executionContext); + + assertEquals("Transition To S9", true, executionContext.get(Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK)); + assertEquals("matching failed flag", true, executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED)); + assertEquals("failed reason", "module.eidasauth.matching.20", executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON)); + assertNull("no final matching result", MatchingTaskUtils.getFinalMatchingResult(pendingReq)); + + } + @Test public void noRegisterResult() throws Exception { - UserInput userInput = setupUserInput(); + AdresssucheOutput userInput = setupUserInput(); SimpleEidasData eidasData = setupEidasData(); RegisterStatusResults registerSearchResult = buildEmptyResult(); mockRegisterSearch(userInput, registerSearchResult, eidasData); @@ -103,56 +117,86 @@ public class ReceiveAustrianResidenceGuiResponseTaskTest { task.execute(pendingReq, executionContext); - assertEquals("Transition To S9", true, executionContext.get(Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_TASK)); + assertEquals("Transition To S9", true, executionContext.get(Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK)); + assertEquals("matching failed flag", true, executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED)); + assertEquals("failed reason", "module.eidasauth.matching.22", executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON)); + assertNull("no final matching result", MatchingTaskUtils.getFinalMatchingResult(pendingReq)); + } @Test - public void exactlyOneRegisterResult_Matching() throws Exception { - UserInput userInput = setupUserInput(); + public void exactlyOneRegisterResult_NoUpdate() throws Exception { + AdresssucheOutput userInput = setupUserInput(); SimpleEidasData eidasData = setupEidasData(); RegisterStatusResults registerSearchResult = buildResultWithOneMatch(buildMatchingRegisterResult(eidasData)); MatchingTaskUtils.storeIntermediateMatchingResult(pendingReq, registerSearchResult); mockRegisterSearch(userInput, registerSearchResult, eidasData); task.execute(pendingReq, executionContext); - + + // validate state assertNull("Transition To S9", executionContext.get(Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_TASK)); - Mockito.verify(registerSearchService).step7aKittProcess(eq(registerSearchResult), eq(eidasData)); - + MatchedPersonResult matchingResult = MatchingTaskUtils.getFinalMatchingResult(pendingReq); + assertNotNull("no final matching result", matchingResult); + validateMatchedPerson(matchingResult, registerSearchResult); + } @Test - public void exactlyOneRegisterResult_NotMatching() throws Exception { - UserInput userInput = setupUserInput(); + public void exactlyOneRegisterResult_UpdateRequired() throws Exception { + AdresssucheOutput userInput = setupUserInput(); SimpleEidasData eidasData = setupEidasData(); RegisterStatusResults registerSearchResult = buildResultWithOneMatch(buildNotMatchingRegisterResult(eidasData)); + RegisterStatusResults registerUpdateResult = buildResultWithOneMatch(buildRandomRegisterResult()); MatchingTaskUtils.storeIntermediateMatchingResult(pendingReq, registerSearchResult); mockRegisterSearch(userInput, registerSearchResult, eidasData); - + Mockito.when(registerSearchService.step7aKittProcess(eq(registerSearchResult), eq(eidasData))) + .thenReturn(registerUpdateResult); + + // perform test task.execute(pendingReq, executionContext); - assertEquals("Transition To S9", true, executionContext.get(Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_TASK)); + // validate state + assertNull("Transition To S9", executionContext.get(Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_TASK)); + + MatchedPersonResult matchingResult = MatchingTaskUtils.getFinalMatchingResult(pendingReq); + assertNotNull("no final matching result", matchingResult); + validateMatchedPerson(matchingResult, registerUpdateResult); + } @Test public void moreThanOneRegisterResult() throws Exception { - UserInput userInput = setupUserInput(); + AdresssucheOutput userInput = setupUserInput(); SimpleEidasData eidasData = setupEidasData(); RegisterStatusResults registerSearchResult = buildResultWithTwoMatches(); MatchingTaskUtils.storeIntermediateMatchingResult(pendingReq, registerSearchResult); mockRegisterSearch(userInput, registerSearchResult, eidasData); - TaskExecutionException e = assertThrows(TaskExecutionException.class, - () -> task.execute(pendingReq, executionContext)); + task.execute(pendingReq, executionContext); - assertEquals(pendingReq.getPendingRequestId(), e.getPendingRequestID()); - isInstanceOf(ManualFixNecessaryException.class, e.getOriginalException()); - assertNull("Transition To S16", executionContext.get(Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_TASK)); + assertEquals("Transition To S9", true, executionContext.get(Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK)); + assertEquals("matching failed flag", true, executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED)); + assertEquals("failed reason", "module.eidasauth.matching.22", executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON)); + assertNull("no final matching result", MatchingTaskUtils.getFinalMatchingResult(pendingReq)); + } - private void mockRegisterSearch(UserInput userInput, RegisterStatusResults registerSearchResult, SimpleEidasData eidasData ) { + @SneakyThrows + private void validateMatchedPerson(MatchedPersonResult current, + RegisterStatusResults registerUpdateResult) { + RegisterResult expected = registerUpdateResult.getResult(); + assertEquals("familyName", expected.getFamilyName(), current.getFamilyName()); + assertEquals("givenName", expected.getGivenName(), current.getGivenName()); + assertEquals("birthday", expected.getDateOfBirth(), current.getDateOfBirth()); + assertEquals("bpk", expected.getBpk(), current.getBpk()); + + } + + @SneakyThrows + private void mockRegisterSearch(AdresssucheOutput 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); + eq(userInput))).thenReturn(registerSearchResult); } @NotNull @@ -216,11 +260,13 @@ public class ReceiveAustrianResidenceGuiResponseTaskTest { } - private void setHttpParameters(UserInput input) { - httpReq.setParameter(PARAM_FORMER_RESIDENCE_AVAILABLE, String.valueOf(input.isFormerResidenceAvailable())); - httpReq.setParameter(PARAM_STREET, input.getStreet()); - httpReq.setParameter(PARAM_CITY, input.getCity()); - httpReq.setParameter(PARAM_ZIPCODE, input.getZipcode()); + private void setHttpParameters(AdresssucheOutput input) { + httpReq.setParameter(AdresssucheController.PARAM_STREET, input.getStreet()); + httpReq.setParameter(AdresssucheController.PARAM_MUNIPICALITY, input.getMunicipality()); + httpReq.setParameter(AdresssucheController.PARAM_NUMBER, input.getNumber()); + httpReq.setParameter(AdresssucheController.PARAM_VILLAGE, input.getVillage()); + httpReq.setParameter(AdresssucheController.PARAM_POSTLEITZAHL, input.getPostleitzahl()); + } @NotNull @@ -237,8 +283,13 @@ public class ReceiveAustrianResidenceGuiResponseTaskTest { } @NotNull - private UserInput setupUserInput() { - UserInput result = new UserInput(true, RandomStringUtils.randomAlphabetic(8), RandomStringUtils.randomAlphabetic(8), RandomStringUtils.randomAlphabetic(8)); + private AdresssucheOutput setupUserInput() { + AdresssucheOutput result = new AdresssucheOutput( + RandomStringUtils.randomAlphabetic(8), + RandomStringUtils.randomAlphabetic(8), + RandomStringUtils.randomAlphabetic(8), + RandomStringUtils.randomAlphabetic(8), + RandomStringUtils.randomAlphabetic(8)); setHttpParameters(result); return result; } -- cgit v1.2.3 From 00d30953a4da41d7c41e21ccffd5dc8db5e7bd79 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Tue, 8 Feb 2022 14:52:32 +0100 Subject: feature(matching): update process-definition for matching to optimize interaction between manual matching steps - return to 'otherLoginMethod' screen in any matching error case. - add change-language functionality --- .../src/main/resources/eIDAS.Authentication.process.xml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/resources/eIDAS.Authentication.process.xml b/eidas_modules/authmodule-eIDAS-v2/src/main/resources/eIDAS.Authentication.process.xml index c9bdad94..05c42fce 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/resources/eIDAS.Authentication.process.xml +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/resources/eIDAS.Authentication.process.xml @@ -35,6 +35,8 @@ + - + + - + from="receiveAustrianResidenceGuiResponseTask" to="generateOtherLoginMethodGuiTask" /> -- cgit v1.2.3 From 31871e30e30c869ab297b6a1751a7daddf777087 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Tue, 8 Feb 2022 15:23:05 +0100 Subject: test(matching): add test for 'search-residence' operation that uses mocked ZMR --- ...strianResidenceGuiResponseTaskRegisterTest.java | 337 +++++++++++++++++++++ 1 file changed, 337 insertions(+) create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskRegisterTest.java diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskRegisterTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskRegisterTest.java new file mode 100644 index 00000000..4f1ff61b --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskRegisterTest.java @@ -0,0 +1,337 @@ +package at.asitplus.eidas.specific.modules.auth.eidas.v2.test.tasks; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThrows; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +import java.math.BigInteger; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; + +import org.apache.commons.lang3.RandomStringUtils; +import org.jetbrains.annotations.NotNull; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.mock.web.MockHttpServletResponse; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import com.github.skjolber.mockito.soap.SoapServiceRule; +import com.google.common.collect.Lists; + +import at.asitplus.eidas.specific.connector.test.config.dummy.MsConnectorDummyConfigMap; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.controller.AdresssucheController; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.controller.AdresssucheController.AdresssucheOutput; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.MatchedPersonResult; +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.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.RegisterStatusResults; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.ReceiveAustrianResidenceGuiResponseTask; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.test.clients.ZmrClientTest; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.MatchingTaskUtils; +import at.gv.bmi.namespace.zmr_su.base._20040201.ResponseType; +import at.gv.bmi.namespace.zmr_su.base._20040201_.ServicePort; +import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; +import at.gv.egiz.eaaf.core.exceptions.EaafException; +import at.gv.egiz.eaaf.core.exceptions.EaafStorageException; +import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; +import at.gv.egiz.eaaf.core.impl.idp.auth.data.AuthProcessDataWrapper; +import at.gv.egiz.eaaf.core.impl.idp.module.test.TestRequestImpl; +import at.gv.egiz.eaaf.core.impl.idp.process.ExecutionContextImpl; +import lombok.SneakyThrows; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = { + "/SpringTest-context_tasks_test.xml", + "/SpringTest-context_basic_mapConfig.xml" +}) +public class ReceiveAustrianResidenceGuiResponseTaskRegisterTest { + + @Autowired + protected MsConnectorDummyConfigMap authConfig; + + @Autowired + private RegisterSearchService registerSearchService; + + @Rule + public SoapServiceRule soap = SoapServiceRule.newInstance(); + private ServicePort zmrMock = null; + private static JAXBContext jaxbContext; + + private ReceiveAustrianResidenceGuiResponseTask task; + private ExecutionContext executionContext; + private MockHttpServletRequest httpReq; + private MockHttpServletResponse httpResp; + private TestRequestImpl pendingReq; + + + /** + * Initialize jUnit class. + */ + @BeforeClass + @SneakyThrows + public static void classInitializer() { + jaxbContext = JAXBContext.newInstance( + at.gv.bmi.namespace.zmr_su.zmr._20040201.ObjectFactory.class, + at.gv.bmi.namespace.zmr_su.gis._20070725.ObjectFactory.class, + at.gv.bmi.namespace.zmr_su.base._20040201.ObjectFactory.class); + + } + + /** + * jUnit test set-up. + * + * @throws Exception In case of an set-up error + */ + @Before + public void setUp() throws Exception { + if (zmrMock == null) { + zmrMock = soap.mock(ServicePort.class, "http://localhost:1234/demozmr"); + + } + + executionContext = new ExecutionContextImpl(); + task = new ReceiveAustrianResidenceGuiResponseTask(registerSearchService); + + httpReq = new MockHttpServletRequest("POST", "https://localhost/ms_connector"); + httpResp = new MockHttpServletResponse(); + RequestContextHolder.resetRequestAttributes(); + RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(httpReq, httpResp)); + + pendingReq = new TestRequestImpl(); + pendingReq.setAuthUrl("https://localhost/ms_connector"); + pendingReq.setPendingReqId(RandomStringUtils.randomAlphanumeric(10)); + + LocaleContextHolder.resetLocaleContext(); + } + + @Test + public void canceledByUser() throws Exception { + AdresssucheOutput userInput = setupUserInput(); + SimpleEidasData eidasData = setupEidasData(); + RegisterStatusResults registerSearchResult = buildEmptyResult(); + MatchingTaskUtils.storeIntermediateMatchingResult(pendingReq, registerSearchResult); + httpReq.setParameter(ReceiveAustrianResidenceGuiResponseTask.HTTP_PARAM_NO_RESIDENCE, "true"); + + task.execute(pendingReq, executionContext); + + assertEquals("Transition To S9", true, executionContext.get(Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK)); + assertEquals("matching failed flag", true, executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED)); + assertEquals("failed reason", "module.eidasauth.matching.20", executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON)); + assertNull("no final matching result", MatchingTaskUtils.getFinalMatchingResult(pendingReq)); + + } + + @Test + public void noRegisterResult() throws Exception { + setupUserInput(); + setupEidasData(); + RegisterStatusResults registerSearchResult = buildEmptyResult(); + MatchingTaskUtils.storeIntermediateMatchingResult(pendingReq, registerSearchResult); + + // inject ZMR response + when(zmrMock.service(any(), any())) + .thenReturn(loadResponseFromFile("/data/zmr/empty_zmr_result.xml")); + + // execute task + task.execute(pendingReq, executionContext); + + // validate state + assertEquals("Transition To S9", true, executionContext.get(Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK)); + assertEquals("matching failed flag", true, executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED)); + assertEquals("failed reason", "module.eidasauth.matching.22", executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON)); + assertNull("no final matching result", MatchingTaskUtils.getFinalMatchingResult(pendingReq)); + + } + + @Test + public void exactlyOneRegisterResult_Update() throws Exception { + setupUserInput(); + SimpleEidasData eidasData = setupEidasData(); + RegisterStatusResults registerSearchResult = buildResultWithOneMatch(buildMatchingRegisterResult(eidasData)); + MatchingTaskUtils.storeIntermediateMatchingResult(pendingReq, registerSearchResult); + + // inject ZMR response + when(zmrMock.service(any(), any())) + .thenReturn(loadResponseFromFile("/data/zmr/search_with_personalId_only_resp.xml")) + .thenReturn(loadResponseFromFile("/data/zmr/seq_3-4_kitt_get_latest_version_resp.xml")) + .thenReturn(loadResponseFromFile("/data/zmr/seq_3-6_kitt_update_resp.xml")); + + task.execute(pendingReq, executionContext); + + // validate state + assertNull("Transition To S9", executionContext.get(Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_TASK)); + MatchedPersonResult matchingResult = MatchingTaskUtils.getFinalMatchingResult(pendingReq); + assertNotNull("no final matching result", matchingResult); + + } + + @Test + public void exactlyOneRegisterResult_UpdateFailedByZmrError() throws Exception { + setupUserInput(); + SimpleEidasData eidasData = setupEidasData(); + RegisterStatusResults registerSearchResult = buildResultWithOneMatch(buildMatchingRegisterResult(eidasData)); + MatchingTaskUtils.storeIntermediateMatchingResult(pendingReq, registerSearchResult); + + // inject ZMR response + when(zmrMock.service(any(), any())) + .thenReturn(loadResponseFromFile("/data/zmr/search_with_personalId_only_resp.xml")) + .thenReturn(loadResponseFromFile("/data/zmr/seq_3-4_kitt_get_latest_version_resp.xml")) + .thenThrow(new RuntimeException("ZMR update should fail for that test")); + + TaskExecutionException error = assertThrows("wrong exception", TaskExecutionException.class, + () -> task.execute(pendingReq, executionContext)); + + assertEquals("wrong errorId", "module.eidasauth.matching.04", ((EaafException) error.getOriginalException()).getErrorId()); + + } + + @Test + public void zmrError() throws Exception { + setupUserInput(); + setupEidasData(); + RegisterStatusResults registerSearchResult = buildResultWithTwoMatches(); + MatchingTaskUtils.storeIntermediateMatchingResult(pendingReq, registerSearchResult); + + TaskExecutionException error = assertThrows("wrong exception", TaskExecutionException.class, + () -> task.execute(pendingReq, executionContext)); + + assertEquals("wrong errorId", "module.eidasauth.matching.03", ((EaafException) error.getOriginalException()).getErrorId()); + + } + + @SneakyThrows + private void validateMatchedPerson(MatchedPersonResult current, + RegisterStatusResults registerUpdateResult) { + RegisterResult expected = registerUpdateResult.getResult(); + assertEquals("familyName", expected.getFamilyName(), current.getFamilyName()); + assertEquals("givenName", expected.getGivenName(), current.getGivenName()); + assertEquals("birthday", expected.getDateOfBirth(), current.getDateOfBirth()); + assertEquals("bpk", expected.getBpk(), current.getBpk()); + + } + + @NotNull + private RegisterStatusResults buildEmptyResult() { + return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId()), + Collections.emptyList(), Collections.emptyList()); + + } + + private BigInteger generateRandomProcessId() { + return new BigInteger(RandomStringUtils.randomNumeric(10)); + + } + + @NotNull + private RegisterStatusResults buildResultWithOneMatch(RegisterResult registerResult) { + return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId()), + Collections.singletonList(registerResult), Collections.emptyList()); + + } + + @NotNull + private RegisterStatusResults buildResultWithTwoMatches() { + List results = Lists.newArrayList(buildRandomRegisterResult(), buildRandomRegisterResult()); + return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId()), + results, Collections.emptyList()); + + } + + @NotNull + private RegisterResult buildRandomRegisterResult() { + return RegisterResult.builder() + .pseudonym(Arrays.asList(RandomStringUtils.randomAlphabetic(8))) + .givenName(RandomStringUtils.randomAlphabetic(8)) + .familyName(RandomStringUtils.randomAlphabetic(8)) + .dateOfBirth(RandomStringUtils.randomAlphabetic(8)) + .bpk(RandomStringUtils.randomAlphabetic(8)) + .build(); + + } + + private RegisterResult buildMatchingRegisterResult(SimpleEidasData eidData) { + return RegisterResult.builder() + .pseudonym(Arrays.asList(eidData.getPseudonym())) + .givenName(eidData.getGivenName()) + .familyName(eidData.getFamilyName()) + .dateOfBirth(eidData.getDateOfBirth()) + .bpk(RandomStringUtils.randomAlphabetic(8)) + .build(); + + } + + private RegisterResult buildNotMatchingRegisterResult(SimpleEidasData eidData) { + return RegisterResult.builder() + .pseudonym(Arrays.asList(eidData.getPseudonym() + RandomStringUtils.randomAlphabetic(8))) + .givenName(eidData.getGivenName()) + .familyName(eidData.getFamilyName()) + .dateOfBirth(eidData.getDateOfBirth()) + .bpk(RandomStringUtils.randomAlphabetic(8)) + .build(); + + } + + private void setHttpParameters(AdresssucheOutput input) { + httpReq.setParameter(AdresssucheController.PARAM_STREET, input.getStreet()); + httpReq.setParameter(AdresssucheController.PARAM_MUNIPICALITY, input.getMunicipality()); + httpReq.setParameter(AdresssucheController.PARAM_NUMBER, input.getNumber()); + httpReq.setParameter(AdresssucheController.PARAM_VILLAGE, input.getVillage()); + httpReq.setParameter(AdresssucheController.PARAM_POSTLEITZAHL, input.getPostleitzahl()); + + } + + @NotNull + private SimpleEidasData setupEidasData() throws EaafStorageException { + SimpleEidasData result = SimpleEidasData.builder() + .pseudonym(RandomStringUtils.randomAlphabetic(8)) + .familyName(RandomStringUtils.randomAlphabetic(8)) + .givenName(RandomStringUtils.randomAlphabetic(8)) + .dateOfBirth("1970-01-01") + .build(); + AuthProcessDataWrapper authProcessDataWrapper = pendingReq.getSessionData(AuthProcessDataWrapper.class); + authProcessDataWrapper.setGenericDataToSession(Constants.DATA_SIMPLE_EIDAS, result); + return result; + } + + @NotNull + private AdresssucheOutput setupUserInput() { + AdresssucheOutput result = new AdresssucheOutput( + RandomStringUtils.randomAlphabetic(8), + RandomStringUtils.randomAlphabetic(8), + RandomStringUtils.randomAlphabetic(8), + RandomStringUtils.randomAlphabetic(8), + RandomStringUtils.randomAlphabetic(8)); + setHttpParameters(result); + return result; + } + + private ResponseType loadResponseFromFile(String filepath) throws JAXBException { + final Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); + JAXBElement resp = (JAXBElement) unmarshaller.unmarshal(ZmrClientTest.class.getResourceAsStream( + filepath)); + return (ResponseType) resp.getValue(); + + } + +} -- cgit v1.2.3 From d4027bf1ac134e50a1b8f1a59f862cf8abaa6c8c Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Tue, 8 Feb 2022 15:43:39 +0100 Subject: fix(zmr): update wrong workflow identifier in ZMR request in case of match-by-residence step --- .../eidas/specific/modules/auth/eidas/v2/clients/zmr/ZmrSoapClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 0f2f94cc..11c7cffe 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 @@ -308,7 +308,7 @@ public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient { searchPersonReq.setPostAdresse(buildSearchAddress(address)); // set work-flow client information - req.setWorkflowInfoClient(generateWorkFlowInfos(PROCESS_SEARCH_BY_RESIDENCE, zmrProzessId)); + req.setWorkflowInfoClient(generateWorkFlowInfos(PROCESS_TASK_SEARCH, zmrProzessId)); req.setClientInfo(generateClientInfos()); // set additionl search parameters -- cgit v1.2.3 From 1d0bed25b6edf315c6a05573629d727f54ef85ac Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Tue, 8 Feb 2022 15:44:09 +0100 Subject: test(zmr): add tests to check search-by-residence operations --- .../auth/eidas/v2/test/clients/ZmrClientTest.java | 165 ++++++++++++++++++++- 1 file changed, 164 insertions(+), 1 deletion(-) diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientTest.java index beedfda0..290eefe4 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientTest.java @@ -41,6 +41,7 @@ import at.asitplus.eidas.specific.connector.test.config.dummy.MsConnectorDummyCo import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.zmr.ZmrSoapClient; import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.zmr.ZmrSoapClient.ZmrRegisterResult; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.controller.AdresssucheController.AdresssucheOutput; 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; @@ -603,6 +604,168 @@ public class ZmrClientTest { } + @Test + @SneakyThrows + public void searchResidenceEmpty() { + BigInteger processId = new BigInteger(RandomStringUtils.randomNumeric(6)); + + final String cc = "DE"; + String familyName = RandomStringUtils.randomAlphabetic(10); + String givenName = RandomStringUtils.randomAlphabetic(10); + String dateOfBirth = RandomStringUtils.randomAlphabetic(10); + AdresssucheOutput addressInfo = AdresssucheOutput.builder() + .municipality(RandomStringUtils.randomAlphabetic(10)) + .number(RandomStringUtils.randomAlphabetic(10)) + .postleitzahl(RandomStringUtils.randomAlphabetic(10)) + .street(RandomStringUtils.randomAlphabetic(10)) + .village(RandomStringUtils.randomAlphabetic(10)) + .build(); + + + final ArgumentCaptor zmrReq = ArgumentCaptor.forClass(RequestType.class); + + // inject response + when(zmrMock.service(zmrReq.capture(), any())).thenReturn( + loadResponseFromFile("/data/zmr/empty_zmr_result.xml")); + + // execute operation + ZmrRegisterResult resp = client.searchWithResidenceData(processId, + givenName, familyName, dateOfBirth, cc, addressInfo); + + // validate state + assertNotNull("no ZMR response", resp); + assertEquals("wrong processId", "367100000000079", resp.getProcessId().toString()); + assertEquals("wrong resp size", 0, resp.getPersonResult().size()); + + // validate request + assertEquals("wrong number of req.", 1, zmrReq.getAllValues().size()); + assertNotNull("Personensuche req.", zmrReq.getValue().getPersonSuchenRequest()); + checkBasicRequestParameters(zmrReq.getValue(), PROCESS_TASK_SEARCH, processId, "jUnit123456"); + PersonSuchenRequest pSuche = zmrReq.getValue().getPersonSuchenRequest(); + checkSearchParameters(pSuche.getPersonensucheInfo()); + + assertNotNull("mds", pSuche.getNatuerlichePerson()); + assertEquals("req. givenName", givenName, pSuche.getNatuerlichePerson().getPersonenName().getVorname()); + assertEquals("req. familyName", familyName, pSuche.getNatuerlichePerson().getPersonenName().getFamilienname()); + assertEquals("req. dateOfBirth", dateOfBirth, pSuche.getNatuerlichePerson().getGeburtsdatum()); + + assertEquals("req. Municipality", addressInfo.getMunicipality(), pSuche.getPostAdresse().getGemeinde()); + assertEquals("req. Postleitzahl", addressInfo.getPostleitzahl(), pSuche.getPostAdresse().getPostleitzahl()); + assertEquals("req. Village", addressInfo.getVillage(), pSuche.getPostAdresse().getOrtschaft()); + assertEquals("req. Street", addressInfo.getStreet(), pSuche.getPostAdresse().getZustelladresse().getStrassenname()); + assertEquals("req. Number", addressInfo.getNumber(), pSuche.getPostAdresse().getZustelladresse().getOrientierungsnummer()); + + } + + @Test + @SneakyThrows + public void searchResidenceMoreThanOneResult() { + BigInteger processId = new BigInteger(RandomStringUtils.randomNumeric(6)); + + final String cc = "DE"; + String familyName = RandomStringUtils.randomAlphabetic(10); + String givenName = RandomStringUtils.randomAlphabetic(10); + String dateOfBirth = RandomStringUtils.randomAlphabetic(10); + AdresssucheOutput addressInfo = AdresssucheOutput.builder() + .municipality(RandomStringUtils.randomAlphabetic(10)) + .postleitzahl(RandomStringUtils.randomAlphabetic(10)) + .street(RandomStringUtils.randomAlphabetic(10)) + .build(); + + final ArgumentCaptor zmrReq = ArgumentCaptor.forClass(RequestType.class); + + // inject response + when(zmrMock.service(zmrReq.capture(), any())).thenReturn( + loadResponseFromFile("/data/zmr/search_with_personalId_only_resp_moreThanOne.xml")); + + // execute operation + ZmrRegisterResult resp = client.searchWithResidenceData(processId, + givenName, familyName, dateOfBirth, cc, addressInfo); + + // validate state + assertNotNull("no ZMR response", resp); + assertEquals("wrong processId", "367100000000079", resp.getProcessId().toString()); + assertEquals("wrong resp size", 2, resp.getPersonResult().size()); + + // validate request + assertEquals("wrong number of req.", 1, zmrReq.getAllValues().size()); + assertNotNull("Personensuche req.", zmrReq.getValue().getPersonSuchenRequest()); + checkBasicRequestParameters(zmrReq.getValue(), PROCESS_TASK_SEARCH, processId, "jUnit123456"); + PersonSuchenRequest pSuche = zmrReq.getValue().getPersonSuchenRequest(); + assertEquals("req. Municipality", addressInfo.getMunicipality(), pSuche.getPostAdresse().getGemeinde()); + assertEquals("req. Postleitzahl", addressInfo.getPostleitzahl(), pSuche.getPostAdresse().getPostleitzahl()); + assertNull("req. Village", pSuche.getPostAdresse().getOrtschaft()); + assertEquals("req. Street", addressInfo.getStreet(), pSuche.getPostAdresse().getZustelladresse().getStrassenname()); + assertNull("req. Number", pSuche.getPostAdresse().getZustelladresse().getOrientierungsnummer()); + + } + + @Test + @SneakyThrows + public void searchResidenceSuccess() { + final String personalIdentifierFirst = "7cEYWithDEElementsasdfsafsaf4CDVzNT4E7cjkU4VqForjUnit"; + final String cc = "DE"; + final SimpleEidasData eidasDataFirst = SimpleEidasData.builder() + .citizenCountryCode(cc) + .familyName("XXXvon Brandenburg") + .givenName("XXXClaus - Maria") + .dateOfBirth("1994-12-31") + .personalIdentifier(cc + "/AT/" + personalIdentifierFirst) + .pseudonym(personalIdentifierFirst) + .build(); + + BigInteger processId = new BigInteger(RandomStringUtils.randomNumeric(6)); + + String familyName = RandomStringUtils.randomAlphabetic(10); + String givenName = RandomStringUtils.randomAlphabetic(10); + String dateOfBirth = RandomStringUtils.randomAlphabetic(10); + AdresssucheOutput addressInfo = AdresssucheOutput.builder() + .municipality(RandomStringUtils.randomAlphabetic(10)) + .postleitzahl(RandomStringUtils.randomAlphabetic(10)) + .build(); + + final ArgumentCaptor zmrReq = ArgumentCaptor.forClass(RequestType.class); + + // inject response + when(zmrMock.service(zmrReq.capture(), any())).thenReturn( + loadResponseFromFile("/data/zmr/search_with_personalId_only_resp.xml")); + + // execute operation + ZmrRegisterResult resp = client.searchWithResidenceData(processId, + givenName, familyName, dateOfBirth, cc, addressInfo); + + // validate state + assertNotNull("no ZMR response", resp); + assertEquals("wrong processId", "367100000000079", resp.getProcessId().toString()); + assertEquals("wrong resp size", 1, resp.getPersonResult().size()); + + RegisterResult persInfo = resp.getPersonResult().get(0); + assertEquals("bPK", "UgeknNsc26lVuB7U/uYGVmWtnnA=", persInfo.getBpk()); + assertEquals("dateOfBirth", eidasDataFirst.getDateOfBirth(), persInfo.getDateOfBirth()); + assertEquals("familyName", eidasDataFirst.getFamilyName(), persInfo.getFamilyName()); + assertEquals("givenName", eidasDataFirst.getGivenName(), persInfo.getGivenName()); + assertEquals("placeOfBirth", "Hintergigritzpotschn", persInfo.getPlaceOfBirth()); + assertEquals("birthName", "XXXvon Heuburg", persInfo.getBirthName()); + assertEquals("num. stored eIDAS identifiers", 2, persInfo.getPseudonym().size()); + assertEquals("stored eIDAS identifiers", "7cEYWithDEElementsasdfsafsaf4CDVzNT4E7cjkU4VqForjUnit", + persInfo.getPseudonym().get(0)); + assertEquals("stored eIDAS identifiers", + "7cEYWithDEElementsasdfsafsaf4CDVzNT4E7cjkU4VqForjUnit_second_one", + persInfo.getPseudonym().get(1)); + + // validate request + assertEquals("wrong number of req.", 1, zmrReq.getAllValues().size()); + assertNotNull("Personensuche req.", zmrReq.getValue().getPersonSuchenRequest()); + checkBasicRequestParameters(zmrReq.getValue(), PROCESS_TASK_SEARCH, processId, "jUnit123456"); + PersonSuchenRequest pSuche = zmrReq.getValue().getPersonSuchenRequest(); + assertEquals("req. Municipality", addressInfo.getMunicipality(), pSuche.getPostAdresse().getGemeinde()); + assertEquals("req. Postleitzahl", addressInfo.getPostleitzahl(), pSuche.getPostAdresse().getPostleitzahl()); + assertNull("req. Village", pSuche.getPostAdresse().getOrtschaft()); + assertNull("req. Number", pSuche.getPostAdresse().getZustelladresse()); + + } + + @Test @SneakyThrows public void updateProcessNoLatestVersionResult() { @@ -978,7 +1141,7 @@ public class ZmrClientTest { return req; } - + private void addIfAvailable(List eidasSuchdaten, String cc, String attrName, String attrValue) { if (StringUtils.isNotEmpty(attrValue)) { -- cgit v1.2.3 From e3eae0a6f822d66f33c1a32459dd4ba3cfc76852 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Tue, 8 Feb 2022 16:31:08 +0100 Subject: chore(matching): update matching by 'ID Austria login' to forward user to 'otherLoginMethod' GUI in case of an error --- .../v2/tasks/ReceiveMobilePhoneSignatureResponseTask.java | 11 +++++++++-- .../src/main/resources/eIDAS.Authentication.process.xml | 2 +- .../resources/messages/eidas_connector_message.properties | 2 ++ .../tasks/ReceiveMobilePhoneSignatureResponseTaskTest.java | 10 ++++++++-- 4 files changed, 20 insertions(+), 5 deletions(-) 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 3e57ea24..2d28709b 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 @@ -24,6 +24,7 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks; import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED; +import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON; import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK; import static at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient.IdAustriaClientAuthConstants.MODULE_NAME_FOR_LOGGING; @@ -127,6 +128,9 @@ public class ReceiveMobilePhoneSignatureResponseTask extends AbstractAuthServlet private static final String ERROR_MSG_02 = "PVP response decryption FAILED. No credential found."; private static final String ERROR_MSG_03 = "PVP response validation FAILED."; + private static final String MSG_PROP_23 = "module.eidasauth.matching.23"; + private static final String MSG_PROP_24 = "module.eidasauth.matching.24"; + /** * Creates the new task, with autowired dependencies from Spring. */ @@ -152,7 +156,9 @@ public class ReceiveMobilePhoneSignatureResponseTask extends AbstractAuthServlet Pair processedMsg = validateAssertion((PvpSProfileResponse) inboundMessage); if (processedMsg.getSecond()) { // forward to next matching step in case of ID Autria authentication was stopped by user - executionContext.put(Constants.TRANSITION_TO_GENERATE_GUI_QUERY_AUSTRIAN_RESIDENCE_TASK, true); + executionContext.put(Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK, true); + executionContext.put(CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON, MSG_PROP_23); + executionContext.put(CONTEXT_FLAG_ADVANCED_MATCHING_FAILED, true); return; } @@ -171,8 +177,9 @@ public class ReceiveMobilePhoneSignatureResponseTask extends AbstractAuthServlet // check if MDS from ID Austria authentication matchs to eIDAS authentication if (!simpleMobileSignatureData.equalsSimpleEidasData(eidasData)) { - executionContext.put(CONTEXT_FLAG_ADVANCED_MATCHING_FAILED, true); executionContext.put(TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK, true); + executionContext.put(CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON, MSG_PROP_24); + executionContext.put(CONTEXT_FLAG_ADVANCED_MATCHING_FAILED, true); return; } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/resources/eIDAS.Authentication.process.xml b/eidas_modules/authmodule-eIDAS-v2/src/main/resources/eIDAS.Authentication.process.xml index 05c42fce..6ca21550 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/resources/eIDAS.Authentication.process.xml +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/resources/eIDAS.Authentication.process.xml @@ -56,7 +56,7 @@ - diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/resources/messages/eidas_connector_message.properties b/eidas_modules/authmodule-eIDAS-v2/src/main/resources/messages/eidas_connector_message.properties index f1bf2128..8d65d63f 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/resources/messages/eidas_connector_message.properties +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/resources/messages/eidas_connector_message.properties @@ -26,6 +26,8 @@ module.eidasauth.matching.12=Matching failed, because ERnP response contains his module.eidasauth.matching.20=Matching be using residence information was canceled. Use another method for matching or create a new Austrian identity. module.eidasauth.matching.21=Matching be using residence information failed by missing input information. Use another method for matching or create a new Austrian identity. module.eidasauth.matching.22=Can not find an unique match by using residence information. Provide more or other data, use another method for matching, or create a new Austrian identity. +module.eidasauth.matching.23=Matching be using Austrian Identity was canceled. Use another method for matching or create a new Austrian identity. +module.eidasauth.matching.24=Matching be using Austrian Identity not possible. Use another method for matching or create a new Austrian identity. module.eidasauth.matching.99=Matching failed, because of an unexpected processing error. Reason: {0} 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 d5400695..b9133392 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 @@ -282,7 +282,10 @@ public class ReceiveMobilePhoneSignatureResponseTaskTest { task.execute(pendingReq, executionContext); - assertEquals("Transition To S16", true, executionContext.get(Constants.TRANSITION_TO_GENERATE_GUI_QUERY_AUSTRIAN_RESIDENCE_TASK)); + assertEquals("Transition To S16", true, executionContext.get(Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK)); + assertEquals("matching failed flag", true, executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED)); + assertEquals("failed reason", "module.eidasauth.matching.23", executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON)); + assertNull("no final matching result", MatchingTaskUtils.getFinalMatchingResult(pendingReq)); } @@ -326,7 +329,10 @@ public class ReceiveMobilePhoneSignatureResponseTaskTest { task.execute(pendingReq, executionContext); assertEquals("Next task", true, executionContext.get(Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK)); - assertEquals("advancedMatchingError flag", true, executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED)); + assertEquals("matching failed flag", true, executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED)); + assertEquals("failed reason", "module.eidasauth.matching.24", executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON)); + assertNull("no final matching result", MatchingTaskUtils.getFinalMatchingResult(pendingReq)); + } //TODO: implement new test that this test makes no sense any more -- cgit v1.2.3 From 6936c9a9350ad5d83f6c84d649df63d5de1c188a Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Tue, 8 Feb 2022 16:37:50 +0100 Subject: chore(matching): update matching by 'alternative eIDAS Login' to forward user to 'otherLoginMethod' GUI in case of an error and show specific error message --- .../specific/modules/auth/eidas/v2/tasks/AlternativeSearchTask.java | 6 ++++++ .../src/main/resources/messages/eidas_connector_message.properties | 1 + .../eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java | 3 +++ 3 files changed, 10 insertions(+) diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/AlternativeSearchTask.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/AlternativeSearchTask.java index f021fae9..96aa9c51 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/AlternativeSearchTask.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/AlternativeSearchTask.java @@ -23,6 +23,8 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks; +import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED; +import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON; import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK; import java.util.Map; @@ -78,6 +80,8 @@ import lombok.extern.slf4j.Slf4j; @SuppressWarnings("PMD.TooManyStaticImports") public class AlternativeSearchTask extends AbstractAuthServletTask { + private static final String MSG_PROP_25 = "module.eidasauth.matching.25"; + private final RegisterSearchService registerSearchService; private final ICcSpecificEidProcessingService eidPostProcessor; @@ -200,6 +204,8 @@ public class AlternativeSearchTask extends AbstractAuthServletTask { log.trace("'step12CountrySpecificSearch' ends with no result. Forward to GUI based matching step ... "); log.debug("Forward to GUI based matching steps ... "); executionContext.put(TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK, true); + executionContext.put(CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON, MSG_PROP_25); + executionContext.put(CONTEXT_FLAG_ADVANCED_MATCHING_FAILED, true); } else if (ccAltSearchResult.getResultCount() == 1) { log.debug("'step12CountrySpecificSearch' find single result. Starting KITT operation ... "); diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/resources/messages/eidas_connector_message.properties b/eidas_modules/authmodule-eIDAS-v2/src/main/resources/messages/eidas_connector_message.properties index 8d65d63f..3942f30a 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/resources/messages/eidas_connector_message.properties +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/resources/messages/eidas_connector_message.properties @@ -28,6 +28,7 @@ module.eidasauth.matching.21=Matching be using residence information failed by m module.eidasauth.matching.22=Can not find an unique match by using residence information. Provide more or other data, use another method for matching, or create a new Austrian identity. module.eidasauth.matching.23=Matching be using Austrian Identity was canceled. Use another method for matching or create a new Austrian identity. module.eidasauth.matching.24=Matching be using Austrian Identity not possible. Use another method for matching or create a new Austrian identity. +module.eidasauth.matching.25=Matching be using alternative eIDAS authentication not possible. Provide more or other data, use another method for matching, or create a new Austrian identity. module.eidasauth.matching.99=Matching failed, because of an unexpected processing error. Reason: {0} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java index 79b2532b..66807ee0 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java @@ -815,6 +815,9 @@ public class AlternativeSearchTaskWithRegisterTest { assertNull("final matching result", MatchingTaskUtils.getFinalMatchingResult(pendingReq)); assertEquals("wrong executionContextFlag 'alternative eIDAS result'", true, executionContext.get(Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK)); + assertEquals("matching failed flag", true, executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED)); + assertEquals("failed reason", "module.eidasauth.matching.25", executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON)); + // validate request -- cgit v1.2.3 From 71d94fdd4435187c13321322893cd9b1bf273402 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Tue, 8 Feb 2022 17:16:42 +0100 Subject: chore(matching): update 'other-login-method' GUI steps to use it as common starting-point for any other alternative matching method --- basicConfig/properties/messages.properties | 17 ++++- basicConfig/properties/messages_de.properties | 17 ++++- basicConfig/templates/other_login_method.html | 36 ++++++++-- .../specific/modules/auth/eidas/v2/Constants.java | 4 +- .../v2/tasks/GenerateOtherLoginMethodGuiTask.java | 7 ++ .../ReceiveOtherLoginMethodGuiResponseTask.java | 17 +++-- .../tasks/GenerateOtherLoginMethodGuiTaskTest.java | 76 +++++++++++++++------- 7 files changed, 134 insertions(+), 40 deletions(-) diff --git a/basicConfig/properties/messages.properties b/basicConfig/properties/messages.properties index 6674d0bd..fcb85bee 100644 --- a/basicConfig/properties/messages.properties +++ b/basicConfig/properties/messages.properties @@ -113,11 +113,22 @@ gui.countryselection.mode.dev=Development ##Other Login Methods page gui.otherlogin.title=eIDAS-Login Other Login Methods gui.otherlogin.header.selection=Select an alternative login method -gui.otherlogin.hs=Mobile Signature ("Handy-Signatur") -gui.otherlogin.eidas=Alternative eIDAS ID -gui.otherlogin.none=No alternative login methods +gui.otherlogin.button.hs=ID Austria +gui.otherlogin.button.eidas=Alternative eIDAS ID +gui.otherlogin.button.none=No alternative login methods +gui.otherlogin.button.inserternp=Use my eIDAS data to create a new Austrian identity gui.otherlogin.cancel=Cancel +gui.otherlogin.inserternp.infotext=You can create a new Austrian Identity by using your identity information provided by eIDAS. During these, you get a new Austrian identifier. + +module.eidasauth.matching.20=Matching be using residence information was canceled. Use another method for matching or create a new Austrian identity. +module.eidasauth.matching.21=Matching be using residence information failed by missing input information. Use another method for matching or create a new Austrian identity. +module.eidasauth.matching.22=Can not find an unique match by using residence information. Provide more or other data, use another method for matching, or create a new Austrian identity. +module.eidasauth.matching.23=Matching be using ID Austria was canceled. Use another method for matching or create a new Austrian identity. +module.eidasauth.matching.24=Matching be using ID Austria not possible. Use another method for matching or create a new Austrian identity. +module.eidasauth.matching.25=Matching be using alternative eIDAS authentication not possible. Provide more or other data, use another method for matching, or create a new Austrian identity. +module.eidasauth.matching.29=Matching be using other information failed. Provide more or other data, use another method for matching, or create a new Austrian identity. + ##Austrian Residency page gui.residency.title=Austrian Residency diff --git a/basicConfig/properties/messages_de.properties b/basicConfig/properties/messages_de.properties index 9c496903..613bead6 100644 --- a/basicConfig/properties/messages_de.properties +++ b/basicConfig/properties/messages_de.properties @@ -112,11 +112,22 @@ gui.countryselection.mode.dev=Development ##Other Login Methods page gui.otherlogin.title=eIDAS-Login Alternative Anmeldemethoden gui.otherlogin.header.selection=Wählen Sie eine alternative Anmeldemethode -gui.otherlogin.hs=Handy-Signatur -gui.otherlogin.eidas=Alternativer eIDAS Login -gui.otherlogin.none=Keine +gui.otherlogin.button.hs=Handy-Signatur +gui.otherlogin.button.eidas=Alternativer eIDAS Login +gui.otherlogin.button.none=Keine +gui.otherlogin.button.inserternp=Eine neue österreichische Identity auf Basis meiner eIDAS Daten erzeugen gui.otherlogin.cancel=Abbrechen +gui.otherlogin.inserternp.infotext=Falls Sie sich noch nie mit eIDAS in Österreich angemeldet haben und Sie auch noch keinen anderen Kontakt zur österreichischen Verwaltung hatten können Sie eine neue österreichischen Identifikatior erzeugen. + +module.eidasauth.matching.20=Matching auf Basis eine Wohnanschrift in Österreich wurde abgebrochen. Nutzen Sie eine andere Matchingmethode oder Erzeugen Sie einen neuen österreichischen Identifikator. +module.eidasauth.matching.21=Das Matching auf Basis eine Wohnanschrift in Österreich schlug fehl. Nutzen Sie eine andere Matchingmethode oder Erzeugen Sie einen neuen österreichischen Identifikator. +module.eidasauth.matching.22=Das Matching auf Basis eine Wohnanschrift in Österreich schlug fehl. Stellen Sie weitere Informationen bereit, nutzen Sie eine andere Matchingmethode oder Erzeugen Sie einen neuen österreichischen Identifikator. +module.eidasauth.matching.23=Matching auf Basis eines ID Autria wurde abgebrochen. Nutzen Sie eine andere Matchingmethode oder Erzeugen Sie einen neuen österreichischen Identifikator. +module.eidasauth.matching.24=Matching auf Basis eines ID Autria schlug fehl. Nutzen Sie eine andere Matchingmethode oder Erzeugen Sie einen neuen österreichischen Identifikator. +module.eidasauth.matching.25=Matching auf Basis einer alternativen eIDAS Anmeldung schlug fehl. Stellen Sie weitere Informationen bereit, nutzen Sie eine andere Matchingmethode oder Erzeugen Sie einen neuen österreichischen Identifikator. + + ##Austrian Residency page gui.residency.title=Österreichischer Wohnsitz gui.residency.header.selection=Suche nach Österreichischem Wohnsitz diff --git a/basicConfig/templates/other_login_method.html b/basicConfig/templates/other_login_method.html index 8f846f84..4fc061c0 100644 --- a/basicConfig/templates/other_login_method.html +++ b/basicConfig/templates/other_login_method.html @@ -49,29 +49,57 @@

      Betrieben durch das Bundesministerium für Inneres

      +
      +

      Detailed

      +

      Generell

      + + + +
      + +

      Select an alternative login method

      -
      -
      + +
      + +

      + +
      + + + +
      +
      +
      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 40bcd27a..e642c5ec 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 @@ -314,12 +314,14 @@ public class Constants { // UI options public static final String HTML_FORM_ADVANCED_MATCHING_FAILED = "advancedMatchingFailed"; + public static final String HTML_FORM_ADVANCED_MATCHING_FAILED_REASON = + HTML_FORM_ADVANCED_MATCHING_FAILED + "Reason"; // ProcessEngine context public static final String CONTEXT_FLAG_ADVANCED_MATCHING_FAILED = HTML_FORM_ADVANCED_MATCHING_FAILED; public static final String CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON = - HTML_FORM_ADVANCED_MATCHING_FAILED + "Reason"; + HTML_FORM_ADVANCED_MATCHING_FAILED_REASON; /** * {@link at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.CreateNewErnpEntryTask}. diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/GenerateOtherLoginMethodGuiTask.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/GenerateOtherLoginMethodGuiTask.java index 7107709f..d29519be 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/GenerateOtherLoginMethodGuiTask.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/GenerateOtherLoginMethodGuiTask.java @@ -79,6 +79,13 @@ public class GenerateOtherLoginMethodGuiTask extends AbstractAuthServletTask { config.putCustomParameter(AbstractGuiFormBuilderConfiguration.PARAM_GROUP_UIOPTIONS, Constants.HTML_FORM_ADVANCED_MATCHING_FAILED, String.valueOf(true)); + //set detailed error-code + if (executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON) != null) { + config.putCustomParameter(AbstractGuiFormBuilderConfiguration.PARAM_GROUP_UIOPTIONS, + Constants.HTML_FORM_ADVANCED_MATCHING_FAILED_REASON, + executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON).toString()); + } + } guiBuilder.build(request, response, config, "Other login methods selection form"); diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveOtherLoginMethodGuiResponseTask.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveOtherLoginMethodGuiResponseTask.java index f4419c1c..c9f043b5 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveOtherLoginMethodGuiResponseTask.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveOtherLoginMethodGuiResponseTask.java @@ -23,17 +23,19 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks; +import java.util.Enumeration; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang.StringEscapeUtils; +import org.springframework.stereotype.Component; + import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SelectedLoginMethod; import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; import at.gv.egiz.eaaf.core.impl.idp.controller.tasks.AbstractLocaleAuthServletTask; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang.StringEscapeUtils; -import org.springframework.stereotype.Component; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.Enumeration; /** * Handles user's selection from {@link GenerateOtherLoginMethodGuiTask}. @@ -65,12 +67,13 @@ public class ReceiveOtherLoginMethodGuiResponseTask extends AbstractLocaleAuthSe SelectedLoginMethod selection = SelectedLoginMethod.valueOf(extractUserSelection(request)); executionContext.put(Constants.REQ_SELECTED_LOGIN_METHOD_PARAMETER, selection); executionContext.remove(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED); + executionContext.remove(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON); transitionToNextTask(executionContext, selection); } catch (final Exception e) { log.error("Parsing selected login method FAILED.", e); executionContext.put(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED, true); - executionContext.put(Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK, true); + executionContext.put(Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK, true); } } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/GenerateOtherLoginMethodGuiTaskTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/GenerateOtherLoginMethodGuiTaskTest.java index f17f69c3..ff994061 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/GenerateOtherLoginMethodGuiTaskTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/GenerateOtherLoginMethodGuiTaskTest.java @@ -1,15 +1,13 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.test.tasks; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SelectedLoginMethod; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.GenerateOtherLoginMethodGuiTask; -import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; -import at.gv.egiz.eaaf.core.impl.idp.module.test.TestRequestImpl; -import at.gv.egiz.eaaf.core.impl.idp.process.ExecutionContextImpl; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.json.JsonMapper; -import lombok.SneakyThrows; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.io.UnsupportedEncodingException; +import java.text.MessageFormat; +import java.util.Locale; + import org.apache.commons.lang3.RandomStringUtils; import org.junit.Assert; import org.junit.Before; @@ -26,12 +24,17 @@ import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; -import java.io.UnsupportedEncodingException; -import java.text.MessageFormat; -import java.util.Locale; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.json.JsonMapper; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SelectedLoginMethod; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.GenerateOtherLoginMethodGuiTask; +import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; +import at.gv.egiz.eaaf.core.impl.idp.module.test.TestRequestImpl; +import at.gv.egiz.eaaf.core.impl.idp.process.ExecutionContextImpl; +import lombok.SneakyThrows; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { @@ -82,8 +85,9 @@ public class GenerateOtherLoginMethodGuiTaskTest { @Test @SneakyThrows public void jsonResponse() throws TaskExecutionException, UnsupportedEncodingException { - + String reason = RandomStringUtils.randomAlphabetic(5); executionContext.put(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED, true); + executionContext.put(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON, reason); httpReq.addHeader("Accept", "application/json"); task.execute(pendingReq, executionContext); @@ -98,20 +102,44 @@ public class GenerateOtherLoginMethodGuiTaskTest { assertNotNull("response body is null", json); assertNotNull("advancedMatchFailed", json.get(Constants.HTML_FORM_ADVANCED_MATCHING_FAILED)); assertTrue("advancedMatchFailed", json.get(Constants.HTML_FORM_ADVANCED_MATCHING_FAILED).asBoolean()); - + assertNotNull("advancedMatchingFailedReason", json.get(Constants.HTML_FORM_ADVANCED_MATCHING_FAILED_REASON)); + assertEquals("advancedMatchingFailedReason", reason, + json.get(Constants.HTML_FORM_ADVANCED_MATCHING_FAILED_REASON).asText()); + } @Test public void advancedMatchingFailedMsg() throws TaskExecutionException, UnsupportedEncodingException { - executionContext.put(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED, true); task.execute(pendingReq, executionContext); + + String html = doBasicValidation(); + Assert.assertTrue("Missing eIDAS infos", + html.contains(MessageFormat.format(TEST_PATTER_REQ_PARAM, SelectedLoginMethod.ADD_ME_AS_NEW))); + Assert.assertTrue("missing errorfield", + html.contains("
      ")); + + return html; } } -- cgit v1.2.3 From a16e5ba2c6030788524e6dc49f6bb5ae4f0cabe0 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Tue, 8 Feb 2022 17:17:52 +0100 Subject: chore(core): add log message and add empty lines for better reading --- .../eidas/specific/modules/auth/eidas/v2/tasks/InitialSearchTask.java | 2 ++ .../auth/eidas/v2/tasks/ReceiveAustrianResidenceGuiResponseTask.java | 1 + 2 files changed, 3 insertions(+) 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 9564a8fc..3a775837 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 @@ -167,11 +167,13 @@ public class InitialSearchTask extends AbstractAuthServletTask { if (registerData.getResultCount() == 0) { log.debug("Matching step: 'step8RegisterSearchWithMds' has no result. Forward to create new ERnP entry ... "); executionContext.put(TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_TASK, true); + } else { log.debug("Matching step: 'step8RegisterSearchWithMds' has #{} results. " + "Forward to GUI based matching steps ... ", registerData.getResultCount()); MatchingTaskUtils.storeIntermediateMatchingResult(pendingReq, registerData); executionContext.put(TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK, true); + } } 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 67addf94..08d2bfa1 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 @@ -190,6 +190,7 @@ public class ReceiveAustrianResidenceGuiResponseTask extends AbstractLocaleAuthS } } catch (WorkflowException e) { + log.warn("Kitt operation after successful residence matching FAILED.", e); throw new TaskExecutionException(pendingReq, "Search failed", new ManualFixNecessaryException(eidasData)); } -- cgit v1.2.3 From 0fb02a267d231ce130f7ea419cade9a0cc79bb6e Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Tue, 8 Feb 2022 17:35:24 +0100 Subject: fix(matching): update wrong error-reason and remove an unused method parameter --- .../v2/tasks/ReceiveAustrianResidenceGuiResponseTask.java | 13 ++++++------- .../tasks/ReceiveAustrianResidenceGuiResponseTaskTest.java | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 7 deletions(-) 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 08d2bfa1..89a3f350 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 @@ -117,11 +117,11 @@ public class ReceiveAustrianResidenceGuiResponseTask extends AbstractLocaleAuthS AdresssucheOutput input = parseHtmlInput(request); if (validateHtmlInput(input)) { // HTML form should ensure that mandatory fields are set => this should never happen - log.warn("HTML form contains no residence information. Switch back to 'other matching' selection ... "); + log.warn("HTML form contains no residence information. Switch back to 'other matching' selection ... "); executionContext.put(TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK, true); - - executionContext.put(CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON, MSG_PROP_20); - executionContext.put(CONTEXT_FLAG_ADVANCED_MATCHING_FAILED, true); + + executionContext.put(CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON, MSG_PROP_21); + executionContext.put(CONTEXT_FLAG_ADVANCED_MATCHING_FAILED, true); return; } @@ -145,7 +145,7 @@ public class ReceiveAustrianResidenceGuiResponseTask extends AbstractLocaleAuthS } else { log.debug("Find single match by using residence information. Starting data validation ... "); - compareSearchResultWithInitialData(executionContext, residencyResult, eidasData); + compareSearchResultWithInitialData(residencyResult, eidasData); } @@ -167,8 +167,7 @@ public class ReceiveAustrianResidenceGuiResponseTask extends AbstractLocaleAuthS && StringUtils.isEmpty(input.getVillage()); } - private void compareSearchResultWithInitialData(ExecutionContext executionContext, - RegisterStatusResults residencyResult, SimpleEidasData eidasData) + private void compareSearchResultWithInitialData(RegisterStatusResults residencyResult, SimpleEidasData eidasData) throws TaskExecutionException, EaafStorageException { try { if (!eidasData.equalsRegisterData(residencyResult.getResult())) { 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 15edce07..7758e021 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 @@ -107,6 +107,20 @@ public class ReceiveAustrianResidenceGuiResponseTaskTest { } + @Test + public void noInputData() throws Exception { + RegisterStatusResults registerSearchResult = buildEmptyResult(); + MatchingTaskUtils.storeIntermediateMatchingResult(pendingReq, registerSearchResult); + + task.execute(pendingReq, executionContext); + + assertEquals("Transition To S9", true, executionContext.get(Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK)); + assertEquals("matching failed flag", true, executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED)); + assertEquals("failed reason", "module.eidasauth.matching.21", executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON)); + assertNull("no final matching result", MatchingTaskUtils.getFinalMatchingResult(pendingReq)); + + } + @Test public void noRegisterResult() throws Exception { AdresssucheOutput userInput = setupUserInput(); -- cgit v1.2.3 From 474fc2b1c7645672e3ed60039177c3c04ba85dc9 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Tue, 8 Feb 2022 17:41:14 +0100 Subject: chore(core): fix some code-quality and code-style issues --- .../specific/modules/auth/eidas/v2/clients/zmr/ZmrSoapClient.java | 2 +- .../modules/auth/eidas/v2/service/RegisterSearchService.java | 6 ++++-- .../eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseTask.java | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) 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 11c7cffe..f24c75eb 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 @@ -731,7 +731,7 @@ public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient { private PostAdresseTyp buildSearchAddress(AdresssucheOutput address) { PostAdresseTyp postAdresse = new PostAdresseTyp(); - if (StringUtils.isNotBlank(address.getPostleitzahl())){ + if (StringUtils.isNotBlank(address.getPostleitzahl())) { postAdresse.setPostleitzahl(address.getPostleitzahl()); } if (StringUtils.isNotBlank(address.getMunicipality())) { 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 d95aadda..c3bf4309 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 @@ -174,11 +174,13 @@ public class RegisterSearchService { public RegisterStatusResults searchWithResidence(RegisterOperationStatus operationStatus, SimpleEidasData eidasData, AdresssucheOutput address) throws WorkflowException { try { - final ZmrRegisterResult resultsZmr = zmrClient.searchWithResidenceData( + final ZmrRegisterResult resultsZmr = zmrClient.searchWithResidenceData( operationStatus.getZmrProcessId(), eidasData.getGivenName(), eidasData.getFamilyName(), eidasData.getDateOfBirth(), eidasData.getCitizenCountryCode(), address); - // ERnP search is not used here, because we only search for people with Austrian residence and they are in ZMR only + /* ERnP search is not used here, + * because we only search for people with Austrian residence and they are in ZMR only + */ return RegisterStatusResults.fromZmr(resultsZmr); 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 2d28709b..514e38ba 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 @@ -156,7 +156,7 @@ public class ReceiveMobilePhoneSignatureResponseTask extends AbstractAuthServlet Pair processedMsg = validateAssertion((PvpSProfileResponse) inboundMessage); if (processedMsg.getSecond()) { // forward to next matching step in case of ID Autria authentication was stopped by user - executionContext.put(Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK, true); + executionContext.put(TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK, true); executionContext.put(CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON, MSG_PROP_23); executionContext.put(CONTEXT_FLAG_ADVANCED_MATCHING_FAILED, true); return; -- cgit v1.2.3 From 01a4c718c21573b0d149ca182a02d9355eb61170 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Tue, 8 Feb 2022 18:03:07 +0100 Subject: feature(matching): add 'Back to previous step' button into 'search-by-residence' GUI --- basicConfig/properties/messages.properties | 1 + basicConfig/properties/messages_de.properties | 1 + basicConfig/templates/residency.html | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/basicConfig/properties/messages.properties b/basicConfig/properties/messages.properties index fcb85bee..e5558c76 100644 --- a/basicConfig/properties/messages.properties +++ b/basicConfig/properties/messages.properties @@ -137,6 +137,7 @@ gui.residency.header.help=You can search for the address that you have been regi postcode, municipality or village first to start the search. gui.residency.header.inputinvalid=Be sure to enter a value for Municipality or Village gui.residency.cancel=Cancel +gui.residency.back=Back to previous step gui.residency.search=Search gui.residency.clear=Clear gui.residency.proceed=Proceed diff --git a/basicConfig/properties/messages_de.properties b/basicConfig/properties/messages_de.properties index 613bead6..b26646aa 100644 --- a/basicConfig/properties/messages_de.properties +++ b/basicConfig/properties/messages_de.properties @@ -135,6 +135,7 @@ gui.residency.header.help=Hier können Sie nach einem Wohnsitze in Österreich s Postleitzahl, Gemeinde oder Ortschaft ein um die Suche zu starten. gui.residency.header.inputinvalid=Bitte geben Sie einen Wert für Gemeinde oder Ortschaft ein gui.residency.cancel=Abbrechen +gui.residency.back=Zurück zum vorangegangenen Schritt gui.residency.search=Suche gui.residency.clear=Löschen gui.residency.proceed=Fortfahren diff --git a/basicConfig/templates/residency.html b/basicConfig/templates/residency.html index 4600a26f..df3c10b7 100644 --- a/basicConfig/templates/residency.html +++ b/basicConfig/templates/residency.html @@ -211,6 +211,12 @@
      +
      + + + +
      +
      -- cgit v1.2.3 From 63e7e29f8d2a367c32f0151e9ad93eb86abeb404 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Wed, 9 Feb 2022 08:30:22 +0100 Subject: build: exclude generated classes from test-coverage validation --- build_reporting/pom.xml | 9 +++++++++ eidas_modules/authmodule-eIDAS-v2/pom.xml | 1 + 2 files changed, 10 insertions(+) diff --git a/build_reporting/pom.xml b/build_reporting/pom.xml index ef3f735f..b0897aad 100644 --- a/build_reporting/pom.xml +++ b/build_reporting/pom.xml @@ -48,6 +48,15 @@ **/target/jacoco-it.exec + + **/at/gv/e_government/reference/namespace/persondata/_20020228/* + **/org/w3/_2000/_09/* + **/org/w3/_2001/_04/* + **/szrservices/* + **/generated/cxf/* + **at/gv/bmi/namespace/* + **at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/ernp/* + diff --git a/eidas_modules/authmodule-eIDAS-v2/pom.xml b/eidas_modules/authmodule-eIDAS-v2/pom.xml index 3ee16b0c..a3d855bd 100644 --- a/eidas_modules/authmodule-eIDAS-v2/pom.xml +++ b/eidas_modules/authmodule-eIDAS-v2/pom.xml @@ -377,6 +377,7 @@ **/szrservices/* **/generated/cxf/* **at/gv/bmi/namespace/* + **at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/ernp/* -- cgit v1.2.3 From e4ccd3df84e7ea509e66f2f832719529fe408839 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Wed, 9 Feb 2022 08:34:26 +0100 Subject: feature(zmr): add MDS attributes as 'eIdAS-Documents' too ZMR does not allow MDS update on regular places. Therefore, we add it as 'eIDAS-Documents' for later usage. --- .../specific/modules/auth/eidas/v2/Constants.java | 8 ++- .../auth/eidas/v2/clients/zmr/ZmrSoapClient.java | 12 ++++ .../auth/eidas/v2/test/clients/ZmrClientTest.java | 13 ++-- .../AlternativeSearchTaskWithRegisterTest.java | 24 +++++++- .../tasks/InitialSearchTaskWithRegistersTest.java | 8 +-- .../seq_1-8_search_with_personalId_only_resp.xml | 71 +++++++++++++++++++++- .../zmr/seq_3-8_kitt_get_latest_version_resp.xml | 71 +++++++++++++++++++++- 7 files changed, 193 insertions(+), 14 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 e642c5ec..272d79c4 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 @@ -268,7 +268,13 @@ public class Constants { public static final String eIDAS_ATTRURN_PREFIX_NATURAL = eIDAS_ATTRURN_PREFIX + "naturalperson/"; public static final String eIDAS_ATTRURN_PERSONALIDENTIFIER = - eIDAS_ATTRURN_PREFIX_NATURAL + eIDAS_ATTR_PERSONALIDENTIFIER; + eIDAS_ATTRURN_PREFIX_NATURAL + eIDAS_ATTR_PERSONALIDENTIFIER; + public static final String eIDAS_ATTRURN_CURRENTGIVENNAME = + eIDAS_ATTRURN_PREFIX_NATURAL + "CurrentGivenName"; + public static final String eIDAS_ATTRURN_CURRENTFAMILYNAME = + eIDAS_ATTRURN_PREFIX_NATURAL + "CurrentFamilyName"; + public static final String eIDAS_ATTRURN_DATEOFBIRTH = + eIDAS_ATTRURN_PREFIX_NATURAL + eIDAS_ATTR_DATEOFBIRTH; public static final String eIDAS_ATTRURN_PLACEOFBIRTH = eIDAS_ATTRURN_PREFIX_NATURAL + eIDAS_ATTR_PLACEOFBIRTH; public static final String eIDAS_ATTRURN_BIRTHNAME = 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 f24c75eb..8dbd0632 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 @@ -264,6 +264,10 @@ public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient { Collection eidasDocumentToAdd = selectEidasDocumentsToAdd(zmrPersonToKitt, eidData); + /*TODO: Is there a requirement to change 'eIDAS-Documents'? + * We add MDS information as 'eIDAS-Documents' too. Maybe, we should update that in a later version. + */ + if (eidasDocumentToAdd.isEmpty()) { log.info("Find no eIDAS document for update during: {}. Nothing todo on ZMR side", PROCESS_KITT_GENERAL); @@ -766,6 +770,14 @@ public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient { Constants.eIDAS_ATTRURN_PLACEOFBIRTH, eidData.getPlaceOfBirth(), false); addEidasDocumentIfNotAvailable(result, zmrPersonToKitt, eidData.getCitizenCountryCode(), Constants.eIDAS_ATTRURN_BIRTHNAME, eidData.getBirthName(), false); + + // add MDS attributes as 'eIDAS-Documents' too, because ZMR does not allow a MDS update on regular places. + addEidasDocumentIfNotAvailable(result, zmrPersonToKitt, eidData.getCitizenCountryCode(), + Constants.eIDAS_ATTRURN_CURRENTGIVENNAME, eidData.getGivenName(), false); + addEidasDocumentIfNotAvailable(result, zmrPersonToKitt, eidData.getCitizenCountryCode(), + Constants.eIDAS_ATTRURN_CURRENTFAMILYNAME, eidData.getFamilyName(), false); + addEidasDocumentIfNotAvailable(result, zmrPersonToKitt, eidData.getCitizenCountryCode(), + Constants.eIDAS_ATTRURN_DATEOFBIRTH, eidData.getDateOfBirth(), false); return result; diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientTest.java index 290eefe4..2ff9f0cb 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientTest.java @@ -940,13 +940,19 @@ public class ZmrClientTest { assertEquals("2 req. tech. Ref. date", "2020-02-05T13:07:06.311", secondpSuche.getPersonReferenz().getTechnisch().getLetzteAenderung().toString()); - assertEquals("eidas Docs. size", 3, secondpSuche.getEidasIdentitaetAnlage().size()); + assertEquals("eidas Docs. size", 6, secondpSuche.getEidasIdentitaetAnlage().size()); checkEidasDocumentAdd(secondpSuche.getEidasIdentitaetAnlage(), "http://eidas.europa.eu/attributes/naturalperson/PlaceOfBirth", cc, eidasData.getPlaceOfBirth()); checkEidasDocumentAdd(secondpSuche.getEidasIdentitaetAnlage(), "http://eidas.europa.eu/attributes/naturalperson/BirthName", cc, eidasData.getBirthName()); checkEidasDocumentAdd(secondpSuche.getEidasIdentitaetAnlage(), - "http://eidas.europa.eu/attributes/naturalperson/PersonIdentifier", cc, eidasData.getPseudonym()); + "http://eidas.europa.eu/attributes/naturalperson/PersonIdentifier", cc, eidasData.getPseudonym()); + checkEidasDocumentAdd(secondpSuche.getEidasIdentitaetAnlage(), + "http://eidas.europa.eu/attributes/naturalperson/CurrentGivenName", cc, eidasData.getGivenName()); + checkEidasDocumentAdd(secondpSuche.getEidasIdentitaetAnlage(), + "http://eidas.europa.eu/attributes/naturalperson/CurrentFamilyName", cc, eidasData.getFamilyName()); + checkEidasDocumentAdd(secondpSuche.getEidasIdentitaetAnlage(), + "http://eidas.europa.eu/attributes/naturalperson/DateOfBirth", cc, eidasData.getDateOfBirth()); // validate state @@ -1110,8 +1116,7 @@ public class ZmrClientTest { assertEquals("eidas Docs. size", 1, secondpSuche.getEidasIdentitaetAnlage().size()); checkEidasDocumentAdd(secondpSuche.getEidasIdentitaetAnlage(), "http://eidas.europa.eu/attributes/naturalperson/PersonIdentifier", cc, eidasData.getPseudonym()); - - + // validate state assertNotNull("no ZMR response", resp); assertEquals("wrong processId", "366200000000082", resp.getProcessId().toString()); diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java index 66807ee0..3814c632 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java @@ -71,6 +71,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.MatchingTaskUtils; import at.gv.bmi.namespace.zmr_su.base._20040201.RequestType; import at.gv.bmi.namespace.zmr_su.base._20040201.ResponseType; 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.EidasSuchdatenType; import at.gv.egiz.eaaf.core.api.IRequest; import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; @@ -509,7 +510,16 @@ public class AlternativeSearchTaskWithRegisterTest { assertNotNull("PersonAender KITT req.", zmrReq.getAllValues().get(2).getPersonAendernRequest()); checkBasicRequestParameters(zmrReq.getAllValues().get(2), ZmrClientTest.PROCESS_TASK_UPDATE, new BigInteger("367100000000079"), "jUnit123456"); - + + assertEquals("wrong number of eIDAS Docs to Add", 4, + zmrReq.getAllValues().get(2).getPersonAendernRequest().getEidasIdentitaetAnlage().size()); + checkEidasDocumentAdd(zmrReq.getAllValues().get(2).getPersonAendernRequest().getEidasIdentitaetAnlage(), + "http://eidas.europa.eu/attributes/naturalperson/DateOfBirth", "DE", "1994-12-31"); + checkEidasDocumentAdd(zmrReq.getAllValues().get(2).getPersonAendernRequest().getEidasIdentitaetAnlage(), + "http://eidas.europa.eu/attributes/naturalperson/CurrentGivenName", "DE", "XXXKlaus - Maria"); + checkEidasDocumentAdd(zmrReq.getAllValues().get(2).getPersonAendernRequest().getEidasIdentitaetAnlage(), + "http://eidas.europa.eu/attributes/naturalperson/CurrentFamilyName", "DE", "XXXvon Brandenburg"); + assertNotNull("Personensuche KITT req.", zmrReq.getAllValues().get(3).getPersonSuchenRequest()); checkBasicRequestParameters(zmrReq.getAllValues().get(3), ZmrClientTest.PROCESS_TASK_SEARCH, new BigInteger("367100000000079"), "jUnit123456"); @@ -1011,6 +1021,18 @@ public class AlternativeSearchTaskWithRegisterTest { } + + private void checkEidasDocumentAdd(List list, String type, String cc, String value) { + Optional eidasDoc = list.stream() + .filter(el -> type.equals(el.getEidasArt())) + .findFirst(); + + assertTrue("eidas doc: " + type, eidasDoc.isPresent()); + assertEquals("eIDAS docType", type, eidasDoc.get().getEidasArt()); + assertEquals("eIDAS docValue", value, eidasDoc.get().getEidasWert()); + assertEquals("eIDAS docCC", cc, eidasDoc.get().getStaatscode2()); + } + @NotNull private ErnpRegisterResult emptyErnpRegisterResult() { return new ErnpRegisterResult(Collections.emptyList()); diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java index 7f27a17c..18d76264 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java @@ -283,12 +283,8 @@ public class InitialSearchTaskWithRegistersTest { assertNotNull("Personenupdate req.", zmrReq.getAllValues().get(2).getPersonAendernRequest()); checkBasicRequestParameters(zmrReq.getAllValues().get(2), ZmrClientTest.PROCESS_TASK_UPDATE, new BigInteger("367100000000079"), "jUnit123456"); - assertEquals("eIDAS attribute to add", 1, - zmrReq.getAllValues().get(2).getPersonAendernRequest().getEidasIdentitaetAnlage().size()); - assertEquals("eIDAS attribute to add - Type", "http://eidas.europa.eu/attributes/naturalperson/PlaceOfBirth", - zmrReq.getAllValues().get(2).getPersonAendernRequest().getEidasIdentitaetAnlage().get(0).getEidasArt()); - assertEquals("eIDAS attribute to add - Value", placeOfBirth, - zmrReq.getAllValues().get(2).getPersonAendernRequest().getEidasIdentitaetAnlage().get(0).getEidasWert()); + assertEquals("eIDAS attribute to add", 4, + zmrReq.getAllValues().get(2).getPersonAendernRequest().getEidasIdentitaetAnlage().size()); assertNull("ZMR update MDS", zmrReq.getAllValues().get(2).getPersonAendernRequest().getPersonAenderung()); } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/zmr/seq_1-8_search_with_personalId_only_resp.xml b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/zmr/seq_1-8_search_with_personalId_only_resp.xml index 3fd477ee..f21c3698 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/zmr/seq_1-8_search_with_personalId_only_resp.xml +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/zmr/seq_1-8_search_with_personalId_only_resp.xml @@ -182,7 +182,76 @@ 7cEYWithDEElementsasdfsafsaf4CDVzNT4E7cjkU4VqForjUnit 9999-12-31 9999-12-31 - + + + + + 1879000000000005 + 2021-11-12T08:24:39.695 + + 2021-11-12T08:24:39.695 + EIDAS_ANLEGEN + KITT for eIDAS Matching + + + 101179 + + eidtapp@bmi.gv.at + + + http://eidas.europa.eu/attributes/naturalperson/CurrentFamilyName + DE + + XXXvon Brandenburg + 9999-12-31 + 9999-12-31 + + + + + 1879000000000005 + 2021-11-12T08:24:39.695 + + 2021-11-12T08:24:39.695 + EIDAS_ANLEGEN + KITT for eIDAS Matching + + + 101179 + + eidtapp@bmi.gv.at + + + http://eidas.europa.eu/attributes/naturalperson/CurrentGivenName + DE + + XXXClaus - Maria + 9999-12-31 + 9999-12-31 + + + + + 1879000000000005 + 2021-11-12T08:24:39.695 + + 2021-11-12T08:24:39.695 + EIDAS_ANLEGEN + KITT for eIDAS Matching + + + 101179 + + eidtapp@bmi.gv.at + + + http://eidas.europa.eu/attributes/naturalperson/DateOfBirth + DE + + 1994-12-31 + 9999-12-31 + 9999-12-31 + diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/zmr/seq_3-8_kitt_get_latest_version_resp.xml b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/zmr/seq_3-8_kitt_get_latest_version_resp.xml index 447d2b55..656164f2 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/zmr/seq_3-8_kitt_get_latest_version_resp.xml +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/zmr/seq_3-8_kitt_get_latest_version_resp.xml @@ -146,7 +146,76 @@ 7cEYasdfsafsaf4CDVzNT4E7cjkU4VqForjUnit 9999-12-31 9999-12-31 - + + + + + 1879000000000005 + 2021-11-12T08:24:39.695 + + 2021-11-12T08:24:39.695 + EIDAS_ANLEGEN + KITT for eIDAS Matching + + + 101179 + + eidtapp@bmi.gv.at + + + http://eidas.europa.eu/attributes/naturalperson/CurrentFamilyName + DE + + XXXvon Brandenburg + 9999-12-31 + 9999-12-31 + + + + + 1879000000000005 + 2021-11-12T08:24:39.695 + + 2021-11-12T08:24:39.695 + EIDAS_ANLEGEN + KITT for eIDAS Matching + + + 101179 + + eidtapp@bmi.gv.at + + + http://eidas.europa.eu/attributes/naturalperson/CurrentGivenName + DE + + XXXClaus - Maria + 9999-12-31 + 9999-12-31 + + + + + 1879000000000005 + 2021-11-12T08:24:39.695 + + 2021-11-12T08:24:39.695 + EIDAS_ANLEGEN + KITT for eIDAS Matching + + + 101179 + + eidtapp@bmi.gv.at + + + http://eidas.europa.eu/attributes/naturalperson/DateOfBirth + DE + + 1994-12-31 + 9999-12-31 + 9999-12-31 + -- cgit v1.2.3 From be411ba3e668eb86f87c0d8a021989d97b63c7a3 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Wed, 2 Mar 2022 13:10:39 +0100 Subject: chore(ernp): update ERnP REST API to v1.5.1 --- .../auth/eidas/v2/clients/ernp/ErnpRestClient.java | 25 +++++-- .../main/resources/wsdl/ernp_client/openapi.json | 82 ++++++++++++++++++---- 2 files changed, 89 insertions(+), 18 deletions(-) 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 3822da01..45a4010b 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 @@ -62,6 +62,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.ErnpRestCommun 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.base._20040201_.ServiceFault; +import at.gv.bmi.namespace.zmr_su.zmr._20040201.EidasSuchdatenType; 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; @@ -142,7 +143,7 @@ public class ErnpRestClient implements IErnpClient { personSuchen.setSuchoptionen(generateSearchParameters()); personSuchen.setBegruendung(PROCESS_SEARCH_PERSONAL_IDENTIFIER); final Suchdaten searchInfos = new Suchdaten(); - searchInfos.setEidas(eidasInfos); + searchInfos.setEidas(Arrays.asList(eidasInfos)); personSuchen.setSuchdaten(searchInfos); // request ERnP @@ -429,9 +430,11 @@ public class ErnpRestClient implements IErnpClient { searchInfos.setVorname(personSearchDao.getNatuerlichePerson().getPersonenName().getVorname()); searchInfos.setGeburtsdatum(buildErnpBirthday(personSearchDao.getNatuerlichePerson().getGeburtsdatum())); - //TODO: search eIDAS has to be a LIST!!!!!! - SuchEidas eidasInfos = new SuchEidas(); - searchInfos.setEidas(eidasInfos); + // map all eIDAS documents into ERnP format + searchInfos.setEidas(personSearchDao.getEidasSuchdaten().stream() + .map(el -> buildErnpEidasDocument(el)) + .collect(Collectors.toList())); + return searchInfos; } @@ -668,6 +671,20 @@ public class ErnpRestClient implements IErnpClient { } + /** + * Map eIDAS search-data from ZMR model into ERnP model. + * + * @param daten eIDAS document as ZMR model + * @return the same eIDAS document as an ERnP model + */ + private SuchEidas buildErnpEidasDocument(EidasSuchdatenType daten) { + return new SuchEidas() + .art(daten.getEidasArt()) + .wert(daten.getEidasWert()) + .staatscode2(daten.getStaatscode2()); + } + + /** * Build AT specific Date String 'yyyy-MM-dd' from ERnP birthday representation. * diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/resources/wsdl/ernp_client/openapi.json b/eidas_modules/authmodule-eIDAS-v2/src/main/resources/wsdl/ernp_client/openapi.json index fef86c1b..9e09240f 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/resources/wsdl/ernp_client/openapi.json +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/resources/wsdl/ernp_client/openapi.json @@ -87,6 +87,11 @@ "schema" : { "$ref" : "#/components/schemas/PersonAendern" } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/PersonAendern" + } } } }, @@ -98,6 +103,11 @@ "schema" : { "$ref" : "#/components/schemas/AendernResponse" } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/AendernResponse" + } } } }, @@ -108,6 +118,11 @@ "schema" : { "$ref" : "#/components/schemas/Fault" } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Fault" + } } } }, @@ -118,6 +133,11 @@ "schema" : { "$ref" : "#/components/schemas/Fault" } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Fault" + } } } } @@ -165,6 +185,11 @@ "schema" : { "$ref" : "#/components/schemas/PersonAnlegen" } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/PersonAnlegen" + } } } }, @@ -176,6 +201,11 @@ "schema" : { "$ref" : "#/components/schemas/AnlegenResponse" } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/AnlegenResponse" + } } } }, @@ -186,6 +216,11 @@ "schema" : { "$ref" : "#/components/schemas/Fault" } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Fault" + } } } }, @@ -196,6 +231,11 @@ "schema" : { "$ref" : "#/components/schemas/Fault" } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Fault" + } } } } @@ -243,6 +283,11 @@ "schema" : { "$ref" : "#/components/schemas/PersonSuchen" } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/PersonSuchen" + } } } }, @@ -254,6 +299,11 @@ "schema" : { "$ref" : "#/components/schemas/SuchenResponse" } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/SuchenResponse" + } } } }, @@ -264,6 +314,11 @@ "schema" : { "$ref" : "#/components/schemas/Fault" } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Fault" + } } } }, @@ -274,6 +329,11 @@ "schema" : { "$ref" : "#/components/schemas/Fault" } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Fault" + } } } } @@ -716,6 +776,7 @@ } }, "Eidas" : { + "required" : [ "art", "staatscode2", "wert" ], "type" : "object", "properties" : { "entityId" : { @@ -775,19 +836,6 @@ "xml" : { "name" : "Staatscode2" } - }, - "image" : { - "type" : "array", - "xml" : { - "name" : "Image" - }, - "items" : { - "type" : "string", - "format" : "byte", - "xml" : { - "name" : "Image" - } - } } } }, @@ -1836,7 +1884,13 @@ "$ref" : "#/components/schemas/SuchStaatsangehoerigkeit" }, "eidas" : { - "$ref" : "#/components/schemas/SuchEidas" + "type" : "array", + "xml" : { + "name" : "Eidas" + }, + "items" : { + "$ref" : "#/components/schemas/SuchEidas" + } } } }, -- cgit v1.2.3 From df894a4076abbcb4357509eb453f4c447a8856d5 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Thu, 3 Mar 2022 11:42:53 +0100 Subject: chore(ernp): optimize ERnP client based on results from integration test --- eidas_modules/authmodule-eIDAS-v2/pom.xml | 3 - .../auth/eidas/v2/clients/ernp/ErnpRestClient.java | 74 +++++++++++----------- pom.xml | 17 ++++- 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 @@ com.fasterxml.jackson.datatype jackson-datatype-jsr310 - com.fasterxml.jackson.core jackson-databind - 2.11.2 - compile org.openapitools 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 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()); } diff --git a/pom.xml b/pom.xml index 15a126f4..6e936130 100644 --- a/pom.xml +++ b/pom.xml @@ -43,8 +43,8 @@ 1.7.32 2.17.1 1.2.10 - - 2.13.1 + + 2.13.1 0.2.2 2.0.29 @@ -373,11 +373,22 @@ commons-collections4 ${commons-collections4.version} + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + ${jackson.version} + com.fasterxml.jackson.datatype jackson-datatype-jsr310 - ${jackson-datatype-jsr310.version} + ${jackson.version} + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + org.openapitools jackson-databind-nullable -- cgit v1.2.3 From 0020b5d6084501b6ee6b6b07fdc40ab47dc30dc7 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Thu, 3 Mar 2022 11:43:59 +0100 Subject: test(ernp): add all ERnP integration tests into test that operates in real test ERnP --- .../modules/auth/eidas/v2/dao/SimpleEidasData.java | 2 +- .../test/clients/ErnpRestClientProductionTest.java | 389 ++++++++++++++++++++- 2 files changed, 382 insertions(+), 9 deletions(-) diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java index f9301505..094b2a9f 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java @@ -32,7 +32,7 @@ import lombok.Builder; import lombok.Data; @Data -@Builder +@Builder(toBuilder=true) public class SimpleEidasData implements Serializable { private static final long serialVersionUID = 2848914124372968418L; diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ErnpRestClientProductionTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ErnpRestClientProductionTest.java index 6ebe4c8a..66a426a1 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ErnpRestClientProductionTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ErnpRestClientProductionTest.java @@ -1,9 +1,14 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.test.clients; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; +import org.apache.commons.lang3.RandomStringUtils; +import org.apache.commons.lang3.StringUtils; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -17,6 +22,8 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.IErnpClient 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.handler.DeSpecificDetailSearchProcessor; +import at.gv.bmi.namespace.zmr_su.zmr._20040201.PersonSuchenRequest; import lombok.SneakyThrows; @IfProfileValue(name = "spring.profiles.active", value = "devEnvironment") @@ -30,18 +37,22 @@ import lombok.SneakyThrows; }) public class ErnpRestClientProductionTest { + //private static final String TEST_PREFIX = "XXX_"; + private static final String TEST_PREFIX = ""; + @Autowired IErnpClient client; @Test @SneakyThrows public void searchWithPersonalIdentifierServerError() { - final String personalIdentifierFirst = "7cEYWithDEElementsasdfsafsaf4CDVzNT4E7cjkU4VqForjUnit"; + String personalIdentifierFirst = "7cEYWithDEElementsasdfsafsaf4CDVzNT4E7cjkU4VqForjUnit"; + personalIdentifierFirst = ""; final String cc = "DE"; final SimpleEidasData eidasDataFirst = SimpleEidasData.builder() .citizenCountryCode(cc) .familyName("XXXvon Brandenburg") .givenName("XXXClaus - Maria") - .dateOfBirth("1994-12-31") + .dateOfBirth("1994-12-00") .personalIdentifier(cc + "/AT/" + personalIdentifierFirst) .pseudonym(personalIdentifierFirst) .build(); @@ -59,12 +70,39 @@ public class ErnpRestClientProductionTest { @SneakyThrows public void searchWithPersonalIdentifierSuccess() { final String personalIdentifierFirst = "7cEYWithDEElementsasdfsafsaf4CDVzNT4E7cjkU4VqForjUnit"; - final String cc = "DE"; + final String cc = "CZ"; final SimpleEidasData eidasDataFirst = SimpleEidasData.builder() .citizenCountryCode(cc) - .familyName("XXXvon Brandenburg") - .givenName("XXXClaus - Maria") - .dateOfBirth("1994-12-31") + .familyName("DOPISNÍ") + .givenName("DANA") + .dateOfBirth("1996-01-01") + .personalIdentifier(cc + "/AT/" + personalIdentifierFirst) + .pseudonym(personalIdentifierFirst) + .build(); + + // execute operation + ErnpRegisterResult resp = client.searchWithPersonIdentifier( + eidasDataFirst.getPseudonym(), eidasDataFirst.getCitizenCountryCode()); + + // validate state + assertNotNull("no ERnP response", resp); + assertEquals("wrong resp size", 1, resp.getPersonResult().size()); + checkErnpResult(resp.getPersonResult().get(0), eidasDataFirst, 1); + assertEquals("wrong bpk", "vypyCkyczK7i+cgPWlJasuJphIA=", + resp.getPersonResult().get(0).getBpk()); + + } + + @Test + @SneakyThrows + public void searchWithPersonalIdentifierNoResult() { + final String personalIdentifierFirst = RandomStringUtils.randomAlphanumeric(10); + final String cc = "CZ"; + final SimpleEidasData eidasDataFirst = SimpleEidasData.builder() + .citizenCountryCode(cc) + .familyName("DOPISNÍ") + .givenName("DANA") + .dateOfBirth("1996-01-01") .personalIdentifier(cc + "/AT/" + personalIdentifierFirst) .pseudonym(personalIdentifierFirst) .build(); @@ -73,15 +111,350 @@ public class ErnpRestClientProductionTest { ErnpRegisterResult resp = client.searchWithPersonIdentifier( eidasDataFirst.getPseudonym(), eidasDataFirst.getCitizenCountryCode()); + // validate state + assertNotNull("no ERnP response", resp); + assertEquals("wrong resp size", 0, resp.getPersonResult().size()); + + } + + + @Test + @SneakyThrows + public void searchWithMdsSuccess() { + final String personalIdentifierFirst = "7cEYWithDEElementsasdfsafsaf4CDVzNT4E7cjkU4VqForjUnit"; + final String cc = "CZ"; + final SimpleEidasData eidasDataFirst = SimpleEidasData.builder() + .citizenCountryCode(cc) + .familyName("DOPISNÍ") + .givenName("DANA") + .dateOfBirth("1996-01-01") + .personalIdentifier(cc + "/AT/" + personalIdentifierFirst) + .pseudonym(personalIdentifierFirst) + .build(); + + // execute operation + ErnpRegisterResult resp = client.searchWithMds(eidasDataFirst.getGivenName(), eidasDataFirst.getFamilyName(), + eidasDataFirst.getDateOfBirth(), eidasDataFirst.getCitizenCountryCode()); + // validate state assertNotNull("no ERnP response", resp); assertEquals("wrong resp size", 1, resp.getPersonResult().size()); + checkErnpResult(resp.getPersonResult().get(0), eidasDataFirst, 1); + assertEquals("wrong bpk", "vypyCkyczK7i+cgPWlJasuJphIA=", + resp.getPersonResult().get(0).getBpk()); + + } + + @Test + @SneakyThrows + public void searchWithMdsNoResult() { + final String personalIdentifierFirst = RandomStringUtils.randomAlphanumeric(10); + final String cc = "CZ"; + final SimpleEidasData eidasDataFirst = SimpleEidasData.builder() + .citizenCountryCode(cc) + .familyName(RandomStringUtils.randomAlphanumeric(10)) + .givenName(RandomStringUtils.randomAlphanumeric(10)) + .dateOfBirth("1996-10-15") + .personalIdentifier(cc + "/AT/" + personalIdentifierFirst) + .pseudonym(personalIdentifierFirst) + .build(); + + // execute operation + ErnpRegisterResult resp = client.searchWithMds(eidasDataFirst.getGivenName(), eidasDataFirst.getFamilyName(), + eidasDataFirst.getDateOfBirth(), eidasDataFirst.getCitizenCountryCode()); + + // validate state + assertNotNull("no ERnP response", resp); + assertEquals("wrong resp size", 0, resp.getPersonResult().size()); + + } + + @Test + @SneakyThrows + public void addTwiceSameMdsAndMdsSearch() { + // *** add new random first person *** + final String addFirstPersonPersonalIdentifier = RandomStringUtils.randomAlphanumeric(10); + final String cc = "XZ"; + final SimpleEidasData addFirstPersonData = SimpleEidasData.builder() + .citizenCountryCode(cc) + .familyName(TEST_PREFIX + RandomStringUtils.randomAlphabetic(8)) + .givenName(TEST_PREFIX + RandomStringUtils.randomAlphabetic(8)) + .dateOfBirth("1996-01-01") + .personalIdentifier(cc + "/AT/" + addFirstPersonPersonalIdentifier) + .pseudonym(addFirstPersonPersonalIdentifier) + .build(); + + // add entry + ErnpRegisterResult addFirstPersonResponse = client.add(addFirstPersonData); + + // verify added entry + assertNotNull("no ERnP response", addFirstPersonResponse); + assertEquals("wrong resp size", 1, addFirstPersonResponse.getPersonResult().size()); + checkErnpResult(addFirstPersonResponse.getPersonResult().get(0), addFirstPersonData, 1); + + + // *** add new random second person with same MDS *** + final String addSecondPersonPersonalIdentifier = RandomStringUtils.randomAlphanumeric(10); + final SimpleEidasData addSecondPersonData = addFirstPersonData.toBuilder() + .personalIdentifier(cc + "/AT/" + addSecondPersonPersonalIdentifier) + .pseudonym(addSecondPersonPersonalIdentifier) + .build(); + + // add entry + ErnpRegisterResult addSecondPersonResponse = client.add(addSecondPersonData); + + // verify added entry + assertNotNull("no ERnP response", addSecondPersonResponse); + assertEquals("wrong resp size", 1, addSecondPersonResponse.getPersonResult().size()); + checkErnpResult(addSecondPersonResponse.getPersonResult().get(0), addSecondPersonData, 1); - RegisterResult persInfo = resp.getPersonResult().get(0); - assertEquals("wrong familyname", "XXXSZR", persInfo.getFamilyName()); + // search with MDS + ErnpRegisterResult resp = client.searchWithMds(addFirstPersonData.getGivenName(), addFirstPersonData.getFamilyName(), + addFirstPersonData.getDateOfBirth(), cc); + + // validate state + assertNotNull("no ERnP response", resp); + assertEquals("wrong resp size", 2, resp.getPersonResult().size()); + } + + @Test + @SneakyThrows + public void addSearchAndPersonalIdUpdate() { + // *** add new random entry *** + + final String addPersonPersonalIdentifier = RandomStringUtils.randomAlphanumeric(10); + final String cc = "DE"; + final SimpleEidasData addPersonData = SimpleEidasData.builder() + .citizenCountryCode(cc) + .familyName(TEST_PREFIX + RandomStringUtils.randomAlphabetic(8)) + .givenName(TEST_PREFIX + RandomStringUtils.randomAlphabetic(8)) + .dateOfBirth("1996-01-01") + .personalIdentifier(cc + "/AT/" + addPersonPersonalIdentifier) + .pseudonym(addPersonPersonalIdentifier) + .birthName(RandomStringUtils.randomAlphabetic(8)) + .placeOfBirth(RandomStringUtils.randomAlphabetic(8)) + .build(); + + // add entry + ErnpRegisterResult addPersonResponse = client.add(addPersonData); + + // verify added entry + assertNotNull("no ERnP response", addPersonResponse); + assertEquals("wrong resp size", 1, addPersonResponse.getPersonResult().size()); + checkErnpResult(addPersonResponse.getPersonResult().get(0), addPersonData, 1); + + + // *** search entry by countrySpecifics *** + final String ccPersonPersonalIdentifier = RandomStringUtils.randomAlphanumeric(10); + SimpleEidasData ccSpecificData = addPersonData.toBuilder() + .personalIdentifier(cc + "/AT/" + ccPersonPersonalIdentifier) + .pseudonym(ccPersonPersonalIdentifier) + .build(); + PersonSuchenRequest ccSearchReq = + new DeSpecificDetailSearchProcessor().generateSearchRequest(ccSpecificData); + + // search CC specific + ErnpRegisterResult ccSearchResponse = client.searchCountrySpecific(ccSearchReq, cc); + + // verify cc specific result + assertNotNull("no ERnP response", ccSearchResponse); + assertEquals("wrong resp size", 1, ccSearchResponse.getPersonResult().size()); + RegisterResult ccSearchPersResult = ccSearchResponse.getPersonResult().get(0); + checkErnpResult(ccSearchResponse.getPersonResult().get(0), addPersonData, 1); + assertEquals("wrong bPK", addPersonResponse.getPersonResult().get(0).getBpk(), + ccSearchPersResult.getBpk()); + assertFalse("no PersonalId change detected", ccSpecificData.equalsRegisterData(ccSearchPersResult)); + + + // *** update entry because PersonalId has changed *** + // update ERnP entry + ErnpRegisterResult updateResponse = client.update(ccSearchPersResult, ccSpecificData); + assertNotNull("no ERnP response", updateResponse); + assertEquals("wrong resp size", 1, updateResponse.getPersonResult().size()); + checkErnpResult(updateResponse.getPersonResult().get(0), addPersonData, 2); + assertEquals("wrong bPK", addPersonResponse.getPersonResult().get(0).getBpk(), ccSearchPersResult.getBpk()); + checkPersonalIdentifier(updateResponse.getPersonResult().get(0), addPersonPersonalIdentifier); + checkPersonalIdentifier(updateResponse.getPersonResult().get(0), ccPersonPersonalIdentifier); + + + + // *** search by first personalIdentifier + ErnpRegisterResult persIdSearchFirstResp = client.searchWithPersonIdentifier( + addPersonPersonalIdentifier, cc); + assertNotNull("no ERnP response", persIdSearchFirstResp); + assertEquals("wrong resp size", 1, persIdSearchFirstResp.getPersonResult().size()); + assertEquals("wrong bPK", addPersonResponse.getPersonResult().get(0).getBpk(), ccSearchPersResult.getBpk()); + checkPersonalIdentifier(updateResponse.getPersonResult().get(0), addPersonPersonalIdentifier); + checkPersonalIdentifier(updateResponse.getPersonResult().get(0), ccPersonPersonalIdentifier); + checkErnpResult(updateResponse.getPersonResult().get(0), addPersonData, 2); + + + + // *** search by second personalIdentifier + ErnpRegisterResult persIdSearchSecondResp = client.searchWithPersonIdentifier( + ccPersonPersonalIdentifier, cc); + assertNotNull("no ERnP response", persIdSearchSecondResp); + assertEquals("wrong resp size", 1, persIdSearchSecondResp.getPersonResult().size()); + assertEquals("wrong bPK", addPersonResponse.getPersonResult().get(0).getBpk(), ccSearchPersResult.getBpk()); + checkPersonalIdentifier(updateResponse.getPersonResult().get(0), addPersonPersonalIdentifier); + checkPersonalIdentifier(updateResponse.getPersonResult().get(0), ccPersonPersonalIdentifier); + checkErnpResult(updateResponse.getPersonResult().get(0), addPersonData, 2); + + } + + @Test + @SneakyThrows + public void addSearchAndMdsUpdate() { + // *** add new random entry *** + + final String addPersonPersonalIdentifier = RandomStringUtils.randomAlphanumeric(10); + final String cc = "DE"; + final SimpleEidasData addPersonData = SimpleEidasData.builder() + .citizenCountryCode(cc) + .familyName(TEST_PREFIX + RandomStringUtils.randomAlphabetic(8)) + .givenName(TEST_PREFIX + RandomStringUtils.randomAlphabetic(8)) + .dateOfBirth("1985-05-05") + .personalIdentifier(cc + "/AT/" + addPersonPersonalIdentifier) + .pseudonym(addPersonPersonalIdentifier) + .birthName(RandomStringUtils.randomAlphabetic(8)) + .placeOfBirth(RandomStringUtils.randomAlphabetic(8)) + .build(); + + // add entry + ErnpRegisterResult addPersonResponse = client.add(addPersonData); + + // verify added entry + assertNotNull("no ERnP response", addPersonResponse); + assertEquals("wrong resp size", 1, addPersonResponse.getPersonResult().size()); + checkErnpResult(addPersonResponse.getPersonResult().get(0), addPersonData, 1); + + + // *** search entry by personalId *** + SimpleEidasData mdsHasChanged = addPersonData.toBuilder() + .givenName(RandomStringUtils.randomAlphanumeric(10)) + .familyName(RandomStringUtils.randomAlphanumeric(10)) + .build(); + + // search by personalId + ErnpRegisterResult personalIdResponse = client.searchWithPersonIdentifier(addPersonPersonalIdentifier, cc); + + // verify personalId result + assertNotNull("no ERnP response", personalIdResponse); + assertEquals("wrong resp size", 1, personalIdResponse.getPersonResult().size()); + RegisterResult persIdSearchResult = personalIdResponse.getPersonResult().get(0); + checkErnpResult(personalIdResponse.getPersonResult().get(0), addPersonData, 1); + assertEquals("wrong bPK", addPersonResponse.getPersonResult().get(0).getBpk(), + persIdSearchResult.getBpk()); + assertFalse("no MDS change detected", mdsHasChanged.equalsRegisterData(persIdSearchResult)); + + + // *** update entry because MDS has changed *** + // update ERnP entry + ErnpRegisterResult updateResponse = client.update(persIdSearchResult, mdsHasChanged); + assertNotNull("no ERnP response", updateResponse); + assertEquals("wrong resp size", 1, updateResponse.getPersonResult().size()); + checkErnpResult(updateResponse.getPersonResult().get(0), mdsHasChanged, 1); + assertEquals("wrong bPK", addPersonResponse.getPersonResult().get(0).getBpk(), persIdSearchResult.getBpk()); + checkPersonalIdentifier(updateResponse.getPersonResult().get(0), addPersonPersonalIdentifier); + + + // *** search by first personalIdentifier + ErnpRegisterResult persIdSearchFirstResp = client.searchWithPersonIdentifier( + addPersonPersonalIdentifier, cc); + assertNotNull("no ERnP response", persIdSearchFirstResp); + assertEquals("wrong resp size", 1, persIdSearchFirstResp.getPersonResult().size()); + assertEquals("wrong bPK", addPersonResponse.getPersonResult().get(0).getBpk(), persIdSearchResult.getBpk()); + checkPersonalIdentifier(updateResponse.getPersonResult().get(0), addPersonPersonalIdentifier); + checkErnpResult(updateResponse.getPersonResult().get(0), mdsHasChanged, 1); + + // *** search by first personalIdentifier + ErnpRegisterResult mdsSearchResp = client.searchWithMds( + mdsHasChanged.getGivenName(), mdsHasChanged.getFamilyName(), mdsHasChanged.getDateOfBirth(), cc); + assertNotNull("no ERnP response", mdsSearchResp); + assertEquals("wrong resp size", 1, mdsSearchResp.getPersonResult().size()); + assertEquals("wrong bPK", addPersonResponse.getPersonResult().get(0).getBpk(), persIdSearchResult.getBpk()); + checkPersonalIdentifier(updateResponse.getPersonResult().get(0), addPersonPersonalIdentifier); + checkErnpResult(updateResponse.getPersonResult().get(0), mdsHasChanged, 1); + + + + } + + + @Ignore + @Test + @SneakyThrows + public void addErnpEntry() { + final String personalIdentifierFirst = "7cEYWithDEElementsasdfsafsaf4CDVzNT4E7cjkU4VqForjUnit"; + final String cc = "CZ"; + final SimpleEidasData eidasDataFirst = SimpleEidasData.builder() + .citizenCountryCode(cc) + .familyName("DOPISNÍ") + .givenName("DANA") + .dateOfBirth("1996-01-01") + .personalIdentifier(cc + "/AT/" + personalIdentifierFirst) + .pseudonym(personalIdentifierFirst) + .build(); + + // execute operation + ErnpRegisterResult resp = client.add(eidasDataFirst); + + // validate state + assertNotNull("no ERnP response", resp); + assertEquals("wrong resp size", 1, resp.getPersonResult().size()); + checkErnpResult(resp.getPersonResult().get(0), eidasDataFirst, 1); + + } + + @Test + @SneakyThrows + public void addRandomErnpEntry() { + final String addPersonPersonalIdentifier = RandomStringUtils.randomAlphanumeric(10); + final String cc = "XZ"; + final SimpleEidasData addPersonData = SimpleEidasData.builder() + .citizenCountryCode(cc) + .familyName(TEST_PREFIX + RandomStringUtils.randomAlphabetic(8)) + .givenName(TEST_PREFIX + RandomStringUtils.randomAlphabetic(8)) + .dateOfBirth("1985-05-05") + .personalIdentifier(cc + "/AT/" + addPersonPersonalIdentifier) + .pseudonym(addPersonPersonalIdentifier) + .birthName(RandomStringUtils.randomAlphabetic(8)) + .placeOfBirth(RandomStringUtils.randomAlphabetic(8)) + .build(); + + // add entry + ErnpRegisterResult addPersonResponse = client.add(addPersonData); + + // verify added entry + assertNotNull("no ERnP response", addPersonResponse); + assertEquals("wrong resp size", 1, addPersonResponse.getPersonResult().size()); + checkErnpResult(addPersonResponse.getPersonResult().get(0), addPersonData, 1); + + } + + + private void checkErnpResult(RegisterResult registerResult, final SimpleEidasData eidasData, int numOfPseudonyms) { + assertEquals("wrong familyname", eidasData.getFamilyName(), registerResult.getFamilyName()); + assertEquals("wrong givenname", eidasData.getGivenName(), registerResult.getGivenName()); + assertEquals("wrong birthday", eidasData.getDateOfBirth(), registerResult.getDateOfBirth()); + assertEquals("wrong personalId size", numOfPseudonyms, registerResult.getPseudonym().size()); + assertEquals("wrong placeOfBirth", eidasData.getPlaceOfBirth(), registerResult.getPlaceOfBirth()); + assertEquals("wrong birthName", eidasData.getBirthName(), registerResult.getBirthName()); + assertTrue("no bPK", StringUtils.isNotEmpty(registerResult.getBpk())); + checkPersonalIdentifier(registerResult, eidasData.getPseudonym()); + + } + + private void checkPersonalIdentifier(RegisterResult registerResult, String pseudonym) { + assertTrue("wrong or no personalId", registerResult.getPseudonym().stream() + .filter(el -> pseudonym.equals(el)) + .findFirst() + .isPresent()); + + } } -- cgit v1.2.3 From 0d7caf5c248a53610c2133e5cc1755a76d690b40 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Thu, 3 Mar 2022 11:44:29 +0100 Subject: test(ernp): add ERnP client detail tests --- .../src/test/resources/data/ernp/1_add_req.json | 30 ++++++++ .../src/test/resources/data/ernp/1_add_resp.json | 60 ++++++++++++++++ .../data/ernp/1_kitt_search_latest_req.json | 19 +++++ .../data/ernp/1_kitt_search_latest_resp.json | 62 ++++++++++++++++ .../resources/data/ernp/1_kitt_update_req.json | 17 +++++ .../resources/data/ernp/1_kitt_update_resp.json | 60 ++++++++++++++++ .../data/ernp/1_search_with_personalId_req.json | 20 ++++++ .../data/ernp/1_search_with_personalId_resp.json | 62 ++++++++++++++++ .../src/test/resources/data/ernp/2_add_req.json | 30 ++++++++ .../src/test/resources/data/ernp/2_add_resp.json | 60 ++++++++++++++++ .../data/ernp/2_kitt_search_latest_req.json | 19 +++++ .../data/ernp/2_kitt_search_latest_resp.json | 62 ++++++++++++++++ .../resources/data/ernp/2_kitt_update_req.json | 14 ++++ .../resources/data/ernp/2_kitt_update_resp.json | 69 ++++++++++++++++++ .../data/ernp/2_search_with_cc_specific_req.json | 30 ++++++++ .../data/ernp/2_search_with_cc_specific_resp.json | 62 ++++++++++++++++ .../resources/data/ernp/3_search_with_mds_req.json | 18 +++++ .../data/ernp/3_search_with_mds_resp.json | 44 ++++++++++++ .../data/ernp/4_search_with_mds_multi_resp.json | 84 ++++++++++++++++++++++ .../resources/data/ernp/4_search_with_mds_req.json | 18 +++++ .../test/resources/data/ernp/ernp_empty_resp.json | 1 + .../src/test/resources/data/ernp/error_resp.json | 12 ++++ 22 files changed, 853 insertions(+) create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_add_req.json create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_add_resp.json create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_kitt_search_latest_req.json create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_kitt_search_latest_resp.json create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_kitt_update_req.json create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_kitt_update_resp.json create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_search_with_personalId_req.json create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_search_with_personalId_resp.json create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_add_req.json create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_add_resp.json create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_kitt_search_latest_req.json create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_kitt_search_latest_resp.json create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_kitt_update_req.json create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_kitt_update_resp.json create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_search_with_cc_specific_req.json create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_search_with_cc_specific_resp.json create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/3_search_with_mds_req.json create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/3_search_with_mds_resp.json create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/4_search_with_mds_multi_resp.json create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/4_search_with_mds_req.json create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/ernp_empty_resp.json create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/error_resp.json diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_add_req.json b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_add_req.json new file mode 100644 index 00000000..4f823c60 --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_add_req.json @@ -0,0 +1,30 @@ +{ + "begruendung": "Add new person", + "personendaten": { + "familienname": "CtKKrtUe", + "vorname": "dUeYzUFg", + "geburtsdatum": { + "jahr": 1985, + "monat": 5, + "tag": 5 + } + }, + "anschrift": null, + "eidas": [ + { + "art": "http://eidas.europa.eu/attributes/naturalperson/PersonIdentifier", + "wert": "Y8ADWaeh0h", + "staatscode2": "DE" + }, + { + "art": "http://eidas.europa.eu/attributes/naturalperson/PlaceOfBirth", + "wert": "hrFevCfP", + "staatscode2": "DE" + }, + { + "art": "http://eidas.europa.eu/attributes/naturalperson/BirthName", + "wert": "sNUEAhEr", + "staatscode2": "DE" + } + ] +} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_add_resp.json b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_add_resp.json new file mode 100644 index 00000000..139483cf --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_add_resp.json @@ -0,0 +1,60 @@ +{ + "person": { + "type": "Person", + "eidas": [ + { + "ablaufDatum": "9999-12-31T00:00:00.000+01:00", + "art": "http://eidas.europa.eu/attributes/naturalperson/PersonIdentifier", + "ausstellDatum": "9999-12-31T00:00:00.000+01:00", + "entityId": "1933000000000486", + "gueltigAb": "2022-03-03T11:07:28.885+01:00", + "staatscode2": "DE", + "wert": "Y8ADWaeh0h" + }, + { + "ablaufDatum": "9999-12-31T00:00:00.000+01:00", + "art": "http://eidas.europa.eu/attributes/naturalperson/PlaceOfBirth", + "ausstellDatum": "9999-12-31T00:00:00.000+01:00", + "entityId": "1933000000000488", + "gueltigAb": "2022-03-03T11:07:28.885+01:00", + "staatscode2": "DE", + "wert": "hrFevCfP" + }, + { + "ablaufDatum": "9999-12-31T00:00:00.000+01:00", + "art": "http://eidas.europa.eu/attributes/naturalperson/BirthName", + "ausstellDatum": "9999-12-31T00:00:00.000+01:00", + "entityId": "1933000000000490", + "gueltigAb": "2022-03-03T11:07:28.885+01:00", + "staatscode2": "DE", + "wert": "sNUEAhEr" + } + ], + "entityId": "1933000000000475", + "gueltigAb": "2022-03-03T11:07:28.885+01:00", + "letzteOperation": { + "begruendung": "Add new person", + "durchgefuehrtVon": { + "behoerdenkennzeichen": "380630", + "benutzer": "eidtapp@bmi.gv.at" + }, + "vorgang": "PersonAnlegen", + "zeitpunkt": "2022-03-03T11:07:28.885+01:00" + }, + "personendaten": { + "basiszahl": "000482591530", + "bpkZp": "+OQnljn0Son1W2rkM73nP/VMsvc=", + "entityId": "1933000000000475", + "familienname": "CtKKrtUe", + "geburtsdatum": { + "jahr": 1985, + "monat": 5, + "tag": 5 + }, + "geprueft": false, + "gueltigAb": "2022-03-03T11:07:28.885+01:00", + "vorname": "dUeYzUFg" + }, + "version": "2022-03-03T11:07:28.885+01:00" + } +} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_kitt_search_latest_req.json b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_kitt_search_latest_req.json new file mode 100644 index 00000000..2538ebac --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_kitt_search_latest_req.json @@ -0,0 +1,19 @@ +{ + "begruendung": "KITT get-latest-version", + "suchoptionen": { + "historisch": "AktuellUndHistorisch", + "sucheMitNamensteilen": false, + "suchwizard": false, + "zmr": false + }, + "suchdaten": { + "bpkZp": "+OQnljn0Son1W2rkM73nP/VMsvc=", + "familienname": "CtKKrtUe", + "vorname": "dUeYzUFg", + "geburtsdatum": { + "jahr": 1985, + "monat": 5, + "tag": 5 + } + } +} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_kitt_search_latest_resp.json b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_kitt_search_latest_resp.json new file mode 100644 index 00000000..588153cd --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_kitt_search_latest_resp.json @@ -0,0 +1,62 @@ +{ + "person": [ + { + "type": "Person", + "eidas": [ + { + "ablaufDatum": "9999-12-31T00:00:00.000+01:00", + "art": "http://eidas.europa.eu/attributes/naturalperson/PersonIdentifier", + "ausstellDatum": "9999-12-31T00:00:00.000+01:00", + "entityId": "1933000000000486", + "gueltigAb": "2022-03-03T11:07:28.885+01:00", + "staatscode2": "DE", + "wert": "Y8ADWaeh0h" + }, + { + "ablaufDatum": "9999-12-31T00:00:00.000+01:00", + "art": "http://eidas.europa.eu/attributes/naturalperson/PlaceOfBirth", + "ausstellDatum": "9999-12-31T00:00:00.000+01:00", + "entityId": "1933000000000488", + "gueltigAb": "2022-03-03T11:07:28.885+01:00", + "staatscode2": "DE", + "wert": "hrFevCfP" + }, + { + "ablaufDatum": "9999-12-31T00:00:00.000+01:00", + "art": "http://eidas.europa.eu/attributes/naturalperson/BirthName", + "ausstellDatum": "9999-12-31T00:00:00.000+01:00", + "entityId": "1933000000000490", + "gueltigAb": "2022-03-03T11:07:28.885+01:00", + "staatscode2": "DE", + "wert": "sNUEAhEr" + } + ], + "entityId": "1933000000000475", + "gueltigAb": "2022-03-03T11:07:28.885+01:00", + "letzteOperation": { + "begruendung": "Add new person", + "durchgefuehrtVon": { + "behoerdenkennzeichen": "380630", + "benutzer": "eidtapp@bmi.gv.at" + }, + "vorgang": "PersonAnlegen", + "zeitpunkt": "2022-03-03T11:07:28.885+01:00" + }, + "personendaten": { + "basiszahl": "000482591530", + "bpkZp": "+OQnljn0Son1W2rkM73nP/VMsvc=", + "entityId": "1933000000000475", + "familienname": "CtKKrtUe", + "geburtsdatum": { + "jahr": 1985, + "monat": 5, + "tag": 5 + }, + "geprueft": false, + "gueltigAb": "2022-03-03T11:07:28.885+01:00", + "vorname": "dUeYzUFg" + }, + "version": "2022-03-03T11:07:28.885+01:00" + } + ] +} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_kitt_update_req.json b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_kitt_update_req.json new file mode 100644 index 00000000..194fba1d --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_kitt_update_req.json @@ -0,0 +1,17 @@ +{ + "begruendung": "KITT update dataset", + "aendern": { + "personendaten": { + "entityId": "1933000000000475", + "familienname": "mVzTMpig6r", + "vorname": "Jb2vj1Xpql", + "geburtsdatum": { + "jahr": 1985, + "monat": 5, + "tag": 5 + } + } + }, + "entityId": "1933000000000475", + "version": "2022-03-03T10:07:28.885Z" +} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_kitt_update_resp.json b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_kitt_update_resp.json new file mode 100644 index 00000000..7fe9210a --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_kitt_update_resp.json @@ -0,0 +1,60 @@ +{ + "person": { + "type": "Person", + "eidas": [ + { + "ablaufDatum": "9999-12-31T00:00:00.000+01:00", + "art": "http://eidas.europa.eu/attributes/naturalperson/PersonIdentifier", + "ausstellDatum": "9999-12-31T00:00:00.000+01:00", + "entityId": "1933000000000486", + "gueltigAb": "2022-03-03T11:07:28.885+01:00", + "staatscode2": "DE", + "wert": "Y8ADWaeh0h" + }, + { + "ablaufDatum": "9999-12-31T00:00:00.000+01:00", + "art": "http://eidas.europa.eu/attributes/naturalperson/PlaceOfBirth", + "ausstellDatum": "9999-12-31T00:00:00.000+01:00", + "entityId": "1933000000000488", + "gueltigAb": "2022-03-03T11:07:28.885+01:00", + "staatscode2": "DE", + "wert": "hrFevCfP" + }, + { + "ablaufDatum": "9999-12-31T00:00:00.000+01:00", + "art": "http://eidas.europa.eu/attributes/naturalperson/BirthName", + "ausstellDatum": "9999-12-31T00:00:00.000+01:00", + "entityId": "1933000000000490", + "gueltigAb": "2022-03-03T11:07:28.885+01:00", + "staatscode2": "DE", + "wert": "sNUEAhEr" + } + ], + "entityId": "1933000000000475", + "gueltigAb": "2022-03-03T11:07:29.751+01:00", + "letzteOperation": { + "begruendung": "KITT update dataset", + "durchgefuehrtVon": { + "behoerdenkennzeichen": "380630", + "benutzer": "eidtapp@bmi.gv.at" + }, + "vorgang": "PersonAendern", + "zeitpunkt": "2022-03-03T11:07:29.751+01:00" + }, + "personendaten": { + "basiszahl": "000482591530", + "bpkZp": "+OQnljn0Son1W2rkM73nP/VMsvc=", + "entityId": "1933000000000475", + "familienname": "mVzTMpig6r", + "geburtsdatum": { + "jahr": 1985, + "monat": 5, + "tag": 5 + }, + "geprueft": false, + "gueltigAb": "2022-03-03T11:07:29.751+01:00", + "vorname": "Jb2vj1Xpql" + }, + "version": "2022-03-03T11:07:29.751+01:00" + } +} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_search_with_personalId_req.json b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_search_with_personalId_req.json new file mode 100644 index 00000000..d7344f08 --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_search_with_personalId_req.json @@ -0,0 +1,20 @@ +{ + "begruendung": "Searching PersonIdentifier", + "suchoptionen": { + "historisch": "AktuellUndHistorisch", + "sucheMitNamensteilen": false, + "suchwizard": false, + "zmr": false + }, + "suchdaten": { + "familienname": null, + "vorname": null, + "eidas": [ + { + "art": "http://eidas.europa.eu/attributes/naturalperson/PersonIdentifier", + "wert": "Y8ADWaeh0h", + "staatscode2": "DE" + } + ] + } +} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_search_with_personalId_resp.json b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_search_with_personalId_resp.json new file mode 100644 index 00000000..588153cd --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/1_search_with_personalId_resp.json @@ -0,0 +1,62 @@ +{ + "person": [ + { + "type": "Person", + "eidas": [ + { + "ablaufDatum": "9999-12-31T00:00:00.000+01:00", + "art": "http://eidas.europa.eu/attributes/naturalperson/PersonIdentifier", + "ausstellDatum": "9999-12-31T00:00:00.000+01:00", + "entityId": "1933000000000486", + "gueltigAb": "2022-03-03T11:07:28.885+01:00", + "staatscode2": "DE", + "wert": "Y8ADWaeh0h" + }, + { + "ablaufDatum": "9999-12-31T00:00:00.000+01:00", + "art": "http://eidas.europa.eu/attributes/naturalperson/PlaceOfBirth", + "ausstellDatum": "9999-12-31T00:00:00.000+01:00", + "entityId": "1933000000000488", + "gueltigAb": "2022-03-03T11:07:28.885+01:00", + "staatscode2": "DE", + "wert": "hrFevCfP" + }, + { + "ablaufDatum": "9999-12-31T00:00:00.000+01:00", + "art": "http://eidas.europa.eu/attributes/naturalperson/BirthName", + "ausstellDatum": "9999-12-31T00:00:00.000+01:00", + "entityId": "1933000000000490", + "gueltigAb": "2022-03-03T11:07:28.885+01:00", + "staatscode2": "DE", + "wert": "sNUEAhEr" + } + ], + "entityId": "1933000000000475", + "gueltigAb": "2022-03-03T11:07:28.885+01:00", + "letzteOperation": { + "begruendung": "Add new person", + "durchgefuehrtVon": { + "behoerdenkennzeichen": "380630", + "benutzer": "eidtapp@bmi.gv.at" + }, + "vorgang": "PersonAnlegen", + "zeitpunkt": "2022-03-03T11:07:28.885+01:00" + }, + "personendaten": { + "basiszahl": "000482591530", + "bpkZp": "+OQnljn0Son1W2rkM73nP/VMsvc=", + "entityId": "1933000000000475", + "familienname": "CtKKrtUe", + "geburtsdatum": { + "jahr": 1985, + "monat": 5, + "tag": 5 + }, + "geprueft": false, + "gueltigAb": "2022-03-03T11:07:28.885+01:00", + "vorname": "dUeYzUFg" + }, + "version": "2022-03-03T11:07:28.885+01:00" + } + ] +} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_add_req.json b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_add_req.json new file mode 100644 index 00000000..35e52c10 --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_add_req.json @@ -0,0 +1,30 @@ +{ + "begruendung": "Add new person", + "personendaten": { + "familienname": "mRjMKAQc", + "vorname": "vdqZZIaA", + "geburtsdatum": { + "jahr": 1996, + "monat": 1, + "tag": 1 + } + }, + "anschrift": null, + "eidas": [ + { + "art": "http://eidas.europa.eu/attributes/naturalperson/PersonIdentifier", + "wert": "88hvWzUaIX", + "staatscode2": "DE" + }, + { + "art": "http://eidas.europa.eu/attributes/naturalperson/PlaceOfBirth", + "wert": "VRNCAylF", + "staatscode2": "DE" + }, + { + "art": "http://eidas.europa.eu/attributes/naturalperson/BirthName", + "wert": "miEklFHC", + "staatscode2": "DE" + } + ] +} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_add_resp.json b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_add_resp.json new file mode 100644 index 00000000..7f85a143 --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_add_resp.json @@ -0,0 +1,60 @@ +{ + "person": { + "type": "Person", + "eidas": [ + { + "ablaufDatum": "9999-12-31T00:00:00.000+01:00", + "art": "http://eidas.europa.eu/attributes/naturalperson/PersonIdentifier", + "ausstellDatum": "9999-12-31T00:00:00.000+01:00", + "entityId": "1933000000000509", + "gueltigAb": "2022-03-03T11:14:59.712+01:00", + "staatscode2": "DE", + "wert": "88hvWzUaIX" + }, + { + "ablaufDatum": "9999-12-31T00:00:00.000+01:00", + "art": "http://eidas.europa.eu/attributes/naturalperson/PlaceOfBirth", + "ausstellDatum": "9999-12-31T00:00:00.000+01:00", + "entityId": "1933000000000511", + "gueltigAb": "2022-03-03T11:14:59.712+01:00", + "staatscode2": "DE", + "wert": "VRNCAylF" + }, + { + "ablaufDatum": "9999-12-31T00:00:00.000+01:00", + "art": "http://eidas.europa.eu/attributes/naturalperson/BirthName", + "ausstellDatum": "9999-12-31T00:00:00.000+01:00", + "entityId": "1933000000000513", + "gueltigAb": "2022-03-03T11:14:59.712+01:00", + "staatscode2": "DE", + "wert": "miEklFHC" + } + ], + "entityId": "1933000000000498", + "gueltigAb": "2022-03-03T11:14:59.712+01:00", + "letzteOperation": { + "begruendung": "Add new person", + "durchgefuehrtVon": { + "behoerdenkennzeichen": "380630", + "benutzer": "eidtapp@bmi.gv.at" + }, + "vorgang": "PersonAnlegen", + "zeitpunkt": "2022-03-03T11:14:59.712+01:00" + }, + "personendaten": { + "basiszahl": "000951265372", + "bpkZp": "TBGoMlirU881e2jMGETa9WLx1+A=", + "entityId": "1933000000000498", + "familienname": "mRjMKAQc", + "geburtsdatum": { + "jahr": 1996, + "monat": 1, + "tag": 1 + }, + "geprueft": false, + "gueltigAb": "2022-03-03T11:14:59.712+01:00", + "vorname": "vdqZZIaA" + }, + "version": "2022-03-03T11:14:59.712+01:00" + } +} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_kitt_search_latest_req.json b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_kitt_search_latest_req.json new file mode 100644 index 00000000..d3dd0658 --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_kitt_search_latest_req.json @@ -0,0 +1,19 @@ +{ + "begruendung": "KITT get-latest-version", + "suchoptionen": { + "historisch": "AktuellUndHistorisch", + "sucheMitNamensteilen": false, + "suchwizard": false, + "zmr": false + }, + "suchdaten": { + "bpkZp": "TBGoMlirU881e2jMGETa9WLx1+A=", + "familienname": "mRjMKAQc", + "vorname": "vdqZZIaA", + "geburtsdatum": { + "jahr": 1996, + "monat": 1, + "tag": 1 + } + } +} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_kitt_search_latest_resp.json b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_kitt_search_latest_resp.json new file mode 100644 index 00000000..24009e64 --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_kitt_search_latest_resp.json @@ -0,0 +1,62 @@ +{ + "person": [ + { + "type": "Person", + "eidas": [ + { + "ablaufDatum": "9999-12-31T00:00:00.000+01:00", + "art": "http://eidas.europa.eu/attributes/naturalperson/PersonIdentifier", + "ausstellDatum": "9999-12-31T00:00:00.000+01:00", + "entityId": "1933000000000509", + "gueltigAb": "2022-03-03T11:14:59.712+01:00", + "staatscode2": "DE", + "wert": "88hvWzUaIX" + }, + { + "ablaufDatum": "9999-12-31T00:00:00.000+01:00", + "art": "http://eidas.europa.eu/attributes/naturalperson/PlaceOfBirth", + "ausstellDatum": "9999-12-31T00:00:00.000+01:00", + "entityId": "1933000000000511", + "gueltigAb": "2022-03-03T11:14:59.712+01:00", + "staatscode2": "DE", + "wert": "VRNCAylF" + }, + { + "ablaufDatum": "9999-12-31T00:00:00.000+01:00", + "art": "http://eidas.europa.eu/attributes/naturalperson/BirthName", + "ausstellDatum": "9999-12-31T00:00:00.000+01:00", + "entityId": "1933000000000513", + "gueltigAb": "2022-03-03T11:14:59.712+01:00", + "staatscode2": "DE", + "wert": "miEklFHC" + } + ], + "entityId": "1933000000000498", + "gueltigAb": "2022-03-03T11:14:59.712+01:00", + "letzteOperation": { + "begruendung": "Add new person", + "durchgefuehrtVon": { + "behoerdenkennzeichen": "380630", + "benutzer": "eidtapp@bmi.gv.at" + }, + "vorgang": "PersonAnlegen", + "zeitpunkt": "2022-03-03T11:14:59.712+01:00" + }, + "personendaten": { + "basiszahl": "000951265372", + "bpkZp": "TBGoMlirU881e2jMGETa9WLx1+A=", + "entityId": "1933000000000498", + "familienname": "mRjMKAQc", + "geburtsdatum": { + "jahr": 1996, + "monat": 1, + "tag": 1 + }, + "geprueft": false, + "gueltigAb": "2022-03-03T11:14:59.712+01:00", + "vorname": "vdqZZIaA" + }, + "version": "2022-03-03T11:14:59.712+01:00" + } + ] +} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_kitt_update_req.json b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_kitt_update_req.json new file mode 100644 index 00000000..0e4a9b21 --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_kitt_update_req.json @@ -0,0 +1,14 @@ +{ + "begruendung": "KITT update dataset", + "anlegen": { + "eidas": [ + { + "art": "http://eidas.europa.eu/attributes/naturalperson/PersonIdentifier", + "wert": "nj1m79jm9z", + "staatscode2": "DE" + } + ] + }, + "entityId": "1933000000000498", + "version": "2022-03-03T10:14:59.712Z" +} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_kitt_update_resp.json b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_kitt_update_resp.json new file mode 100644 index 00000000..23dc74f3 --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_kitt_update_resp.json @@ -0,0 +1,69 @@ +{ + "person": { + "type": "Person", + "eidas": [ + { + "ablaufDatum": "9999-12-31T00:00:00.000+01:00", + "art": "http://eidas.europa.eu/attributes/naturalperson/PersonIdentifier", + "ausstellDatum": "9999-12-31T00:00:00.000+01:00", + "entityId": "1933000000000509", + "gueltigAb": "2022-03-03T11:14:59.712+01:00", + "staatscode2": "DE", + "wert": "88hvWzUaIX" + }, + { + "ablaufDatum": "9999-12-31T00:00:00.000+01:00", + "art": "http://eidas.europa.eu/attributes/naturalperson/PlaceOfBirth", + "ausstellDatum": "9999-12-31T00:00:00.000+01:00", + "entityId": "1933000000000511", + "gueltigAb": "2022-03-03T11:14:59.712+01:00", + "staatscode2": "DE", + "wert": "VRNCAylF" + }, + { + "ablaufDatum": "9999-12-31T00:00:00.000+01:00", + "art": "http://eidas.europa.eu/attributes/naturalperson/BirthName", + "ausstellDatum": "9999-12-31T00:00:00.000+01:00", + "entityId": "1933000000000513", + "gueltigAb": "2022-03-03T11:14:59.712+01:00", + "staatscode2": "DE", + "wert": "miEklFHC" + }, + { + "ablaufDatum": "9999-12-31T00:00:00.000+01:00", + "art": "http://eidas.europa.eu/attributes/naturalperson/PersonIdentifier", + "ausstellDatum": "9999-12-31T00:00:00.000+01:00", + "entityId": "1933100000000607", + "gueltigAb": "2022-03-03T11:15:00.762+01:00", + "staatscode2": "DE", + "wert": "nj1m79jm9z" + } + ], + "entityId": "1933000000000498", + "gueltigAb": "2022-03-03T11:15:00.762+01:00", + "letzteOperation": { + "begruendung": "KITT update dataset", + "durchgefuehrtVon": { + "behoerdenkennzeichen": "380630", + "benutzer": "eidtapp@bmi.gv.at" + }, + "vorgang": "PersonAendern", + "zeitpunkt": "2022-03-03T11:15:00.762+01:00" + }, + "personendaten": { + "basiszahl": "000951265372", + "bpkZp": "TBGoMlirU881e2jMGETa9WLx1+A=", + "entityId": "1933000000000498", + "familienname": "mRjMKAQc", + "geburtsdatum": { + "jahr": 1996, + "monat": 1, + "tag": 1 + }, + "geprueft": false, + "gueltigAb": "2022-03-03T11:14:59.712+01:00", + "vorname": "vdqZZIaA" + }, + "version": "2022-03-03T11:15:00.762+01:00" + } +} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_search_with_cc_specific_req.json b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_search_with_cc_specific_req.json new file mode 100644 index 00000000..d80b0d2e --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_search_with_cc_specific_req.json @@ -0,0 +1,30 @@ +{ + "begruendung": "Searching DE specific", + "suchoptionen": { + "historisch": "AktuellUndHistorisch", + "sucheMitNamensteilen": false, + "suchwizard": false, + "zmr": false + }, + "suchdaten": { + "familienname": "mRjMKAQc", + "vorname": "vdqZZIaA", + "geburtsdatum": { + "jahr": 1996, + "monat": 1, + "tag": 1 + }, + "eidas": [ + { + "art": "http://eidas.europa.eu/attributes/naturalperson/PlaceOfBirth", + "wert": "VRNCAylF", + "staatscode2": "DE" + }, + { + "art": "http://eidas.europa.eu/attributes/naturalperson/BirthName", + "wert": "miEklFHC", + "staatscode2": "DE" + } + ] + } +} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_search_with_cc_specific_resp.json b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_search_with_cc_specific_resp.json new file mode 100644 index 00000000..24009e64 --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_search_with_cc_specific_resp.json @@ -0,0 +1,62 @@ +{ + "person": [ + { + "type": "Person", + "eidas": [ + { + "ablaufDatum": "9999-12-31T00:00:00.000+01:00", + "art": "http://eidas.europa.eu/attributes/naturalperson/PersonIdentifier", + "ausstellDatum": "9999-12-31T00:00:00.000+01:00", + "entityId": "1933000000000509", + "gueltigAb": "2022-03-03T11:14:59.712+01:00", + "staatscode2": "DE", + "wert": "88hvWzUaIX" + }, + { + "ablaufDatum": "9999-12-31T00:00:00.000+01:00", + "art": "http://eidas.europa.eu/attributes/naturalperson/PlaceOfBirth", + "ausstellDatum": "9999-12-31T00:00:00.000+01:00", + "entityId": "1933000000000511", + "gueltigAb": "2022-03-03T11:14:59.712+01:00", + "staatscode2": "DE", + "wert": "VRNCAylF" + }, + { + "ablaufDatum": "9999-12-31T00:00:00.000+01:00", + "art": "http://eidas.europa.eu/attributes/naturalperson/BirthName", + "ausstellDatum": "9999-12-31T00:00:00.000+01:00", + "entityId": "1933000000000513", + "gueltigAb": "2022-03-03T11:14:59.712+01:00", + "staatscode2": "DE", + "wert": "miEklFHC" + } + ], + "entityId": "1933000000000498", + "gueltigAb": "2022-03-03T11:14:59.712+01:00", + "letzteOperation": { + "begruendung": "Add new person", + "durchgefuehrtVon": { + "behoerdenkennzeichen": "380630", + "benutzer": "eidtapp@bmi.gv.at" + }, + "vorgang": "PersonAnlegen", + "zeitpunkt": "2022-03-03T11:14:59.712+01:00" + }, + "personendaten": { + "basiszahl": "000951265372", + "bpkZp": "TBGoMlirU881e2jMGETa9WLx1+A=", + "entityId": "1933000000000498", + "familienname": "mRjMKAQc", + "geburtsdatum": { + "jahr": 1996, + "monat": 1, + "tag": 1 + }, + "geprueft": false, + "gueltigAb": "2022-03-03T11:14:59.712+01:00", + "vorname": "vdqZZIaA" + }, + "version": "2022-03-03T11:14:59.712+01:00" + } + ] +} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/3_search_with_mds_req.json b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/3_search_with_mds_req.json new file mode 100644 index 00000000..eb382bc0 --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/3_search_with_mds_req.json @@ -0,0 +1,18 @@ +{ + "begruendung": "Searching with MDS only", + "suchoptionen": { + "historisch": "AktuellUndHistorisch", + "sucheMitNamensteilen": false, + "suchwizard": false, + "zmr": false + }, + "suchdaten": { + "familienname": "DOPISN[0xc3][0x8d]", + "vorname": "DANA", + "geburtsdatum": { + "jahr": 1996, + "monat": 1, + "tag": 1 + } + } +} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/3_search_with_mds_resp.json b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/3_search_with_mds_resp.json new file mode 100644 index 00000000..50735f23 --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/3_search_with_mds_resp.json @@ -0,0 +1,44 @@ +{ + "person": [ + { + "type": "Person", + "eidas": [ + { + "ablaufDatum": "9999-12-31T00:00:00.000+01:00", + "art": "http://eidas.europa.eu/attributes/naturalperson/PersonIdentifier", + "ausstellDatum": "9999-12-31T00:00:00.000+01:00", + "entityId": "1933000000000058", + "gueltigAb": "2022-03-02T16:23:32.743+01:00", + "staatscode2": "CZ", + "wert": "7cEYWithDEElementsasdfsafsaf4CDVzNT4E7cjkU4VqForjUnit" + } + ], + "entityId": "1933000000000047", + "gueltigAb": "2022-03-02T16:23:32.743+01:00", + "letzteOperation": { + "begruendung": "Add new person", + "durchgefuehrtVon": { + "behoerdenkennzeichen": "380630", + "benutzer": "eidtapp@bmi.gv.at" + }, + "vorgang": "PersonAnlegen", + "zeitpunkt": "2022-03-02T16:23:32.743+01:00" + }, + "personendaten": { + "basiszahl": "000501189333", + "bpkZp": "vypyCkyczK7i+cgPWlJasuJphIA=", + "entityId": "1933000000000047", + "familienname": "DOPISN[0xc3][0x8d]", + "geburtsdatum": { + "jahr": 1996, + "monat": 1, + "tag": 1 + }, + "geprueft": false, + "gueltigAb": "2022-03-02T16:23:32.743+01:00", + "vorname": "DANA" + }, + "version": "2022-03-02T16:23:32.743+01:00" + } + ] +} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/4_search_with_mds_multi_resp.json b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/4_search_with_mds_multi_resp.json new file mode 100644 index 00000000..87a23647 --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/4_search_with_mds_multi_resp.json @@ -0,0 +1,84 @@ +{ + "person": [ + { + "type": "Person", + "eidas": [ + { + "ablaufDatum": "9999-12-31T00:00:00.000+01:00", + "art": "http://eidas.europa.eu/attributes/naturalperson/PersonIdentifier", + "ausstellDatum": "9999-12-31T00:00:00.000+01:00", + "entityId": "1933000000000653", + "gueltigAb": "2022-03-03T11:27:57.651+01:00", + "staatscode2": "XZ", + "wert": "ybgLmbYGxU" + } + ], + "entityId": "1933000000000642", + "gueltigAb": "2022-03-03T11:27:57.651+01:00", + "letzteOperation": { + "begruendung": "Add new person", + "durchgefuehrtVon": { + "behoerdenkennzeichen": "380630", + "benutzer": "eidtapp@bmi.gv.at" + }, + "vorgang": "PersonAnlegen", + "zeitpunkt": "2022-03-03T11:27:57.651+01:00" + }, + "personendaten": { + "basiszahl": "000693812023", + "bpkZp": "QJ/5YLEbOCfRhG5R0KKHNnmeMYo=", + "entityId": "1933000000000642", + "familienname": "HjecFKGu", + "geburtsdatum": { + "jahr": 1996, + "monat": 1, + "tag": 1 + }, + "geprueft": false, + "gueltigAb": "2022-03-03T11:27:57.651+01:00", + "vorname": "QwnAMXsJ" + }, + "version": "2022-03-03T11:27:57.651+01:00" + }, + { + "type": "Person", + "eidas": [ + { + "ablaufDatum": "9999-12-31T00:00:00.000+01:00", + "art": "http://eidas.europa.eu/attributes/naturalperson/PersonIdentifier", + "ausstellDatum": "9999-12-31T00:00:00.000+01:00", + "entityId": "1933100000000762", + "gueltigAb": "2022-03-03T11:27:57.885+01:00", + "staatscode2": "XZ", + "wert": "rEhBYWgiSx" + } + ], + "entityId": "1933100000000751", + "gueltigAb": "2022-03-03T11:27:57.885+01:00", + "letzteOperation": { + "begruendung": "Add new person", + "durchgefuehrtVon": { + "behoerdenkennzeichen": "380630", + "benutzer": "eidtapp@bmi.gv.at" + }, + "vorgang": "PersonAnlegen", + "zeitpunkt": "2022-03-03T11:27:57.885+01:00" + }, + "personendaten": { + "basiszahl": "000803465934", + "bpkZp": "ZaJ2Yvx0u/z8VqNyCJ8zKT8XQa0=", + "entityId": "1933100000000751", + "familienname": "HjecFKGu", + "geburtsdatum": { + "jahr": 1996, + "monat": 1, + "tag": 1 + }, + "geprueft": false, + "gueltigAb": "2022-03-03T11:27:57.885+01:00", + "vorname": "QwnAMXsJ" + }, + "version": "2022-03-03T11:27:57.885+01:00" + } + ] +} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/4_search_with_mds_req.json b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/4_search_with_mds_req.json new file mode 100644 index 00000000..01c3c3f9 --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/4_search_with_mds_req.json @@ -0,0 +1,18 @@ +{ + "begruendung": "Searching with MDS only", + "suchoptionen": { + "historisch": "AktuellUndHistorisch", + "sucheMitNamensteilen": false, + "suchwizard": false, + "zmr": false + }, + "suchdaten": { + "familienname": "HjecFKGu", + "vorname": "QwnAMXsJ", + "geburtsdatum": { + "jahr": 1996, + "monat": 1, + "tag": 1 + } + } +} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/ernp_empty_resp.json b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/ernp_empty_resp.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/ernp_empty_resp.json @@ -0,0 +1 @@ +{} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/error_resp.json b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/error_resp.json new file mode 100644 index 00000000..76e3e7ba --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/error_resp.json @@ -0,0 +1,12 @@ +{ + "faultDetails": { + "fault": [ + { + "key": "suchdaten", + "message": "Mindestsuchkriterien sind: Vorname & Familienname & Geburtsdatum (statt Familienname kann auch Name vor Ehe angegeben werden) oder mindestens ein Eidas Attribut (Art & Wert & Staat)" + } + ], + "faultNumber": 100 + }, + "message": "Validierungsfehler" +} -- cgit v1.2.3 From 576344a004328d12aa293ff33fb7a392b825e0bd Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Thu, 3 Mar 2022 15:05:46 +0100 Subject: test(ernp): add ERnP client test with mocked ERnP responses --- .../eidas/v2/test/clients/ErnpRestClientTest.java | 957 ++++++++++++++++++++- .../data/ernp/3_search_with_mds_resp.json | 2 +- 2 files changed, 956 insertions(+), 3 deletions(-) diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ErnpRestClientTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ErnpRestClientTest.java index 9eb574fd..ab1a502c 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ErnpRestClientTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ErnpRestClientTest.java @@ -3,10 +3,20 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.test.clients; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; + +import java.net.HttpURLConnection; +import java.util.Arrays; +import java.util.Iterator; +import java.util.UUID; +import java.util.concurrent.TimeUnit; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.RandomStringUtils; import org.junit.AfterClass; +import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -16,16 +26,22 @@ import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + import at.asitplus.eidas.specific.connector.test.config.dummy.MsConnectorDummyConfigMap; import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.ErnpRestClient.ErnpRegisterResult; import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.IErnpClient; 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.handler.DeSpecificDetailSearchProcessor; +import at.gv.egiz.eaaf.core.impl.utils.TransactionIdUtils; import lombok.SneakyThrows; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; +import okhttp3.mockwebserver.SocketPolicy; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { @@ -36,7 +52,8 @@ public class ErnpRestClientTest { @Autowired MsConnectorDummyConfigMap basicConfig; @Autowired IErnpClient client; - + + private static ObjectMapper mapper = new ObjectMapper(); private static MockWebServer mockWebServer; /** @@ -59,6 +76,19 @@ public class ErnpRestClientTest { } + /** + * jUnit test initializer. + * + * @throws InterruptedException in case of an error + */ + @Before + public void initialize() throws InterruptedException { + mockWebServer.takeRequest(2, TimeUnit.MILLISECONDS); + TransactionIdUtils.setTransactionId(UUID.randomUUID().toString()); + + } + + @Test @SneakyThrows public void searchWithPersonalIdentifierServerError() { @@ -82,6 +112,7 @@ public class ErnpRestClientTest { () -> client.searchWithPersonIdentifier( eidasDataFirst.getPseudonym(), eidasDataFirst.getCitizenCountryCode())); + mockWebServer.takeRequest(); assertEquals("wrong errorCode", "module.eidasauth.matching.11", error.getErrorId()); } @@ -122,9 +153,931 @@ public class ErnpRestClientTest { assertNotNull("no ERnP response", resp); assertEquals("wrong resp size", 1, resp.getPersonResult().size()); + + } + + @Test + @SneakyThrows + public void searchResidence() { + // execute operation + ErnpRegisterResult resp = client.searchWithResidenceData(null, null, null, null, null, null); + assertNotNull("no ERnP response", resp); + assertEquals("wrong resp size", 0, resp.getPersonResult().size()); + + } + + @Test + @SneakyThrows + public void searchWithMdsNoResponse() { + final String cc = "CZ"; + final SimpleEidasData eidasDataFirst = generateRandomEidasData(cc); + + mockWebServer.enqueue(new MockResponse() + .setSocketPolicy(SocketPolicy.NO_RESPONSE) + .setResponseCode(HttpURLConnection.HTTP_NO_CONTENT)); + + // execute operation + EidasSAuthenticationException error = assertThrows("wrong Exception", EidasSAuthenticationException.class, + () -> client.searchWithMds(eidasDataFirst.getGivenName(), eidasDataFirst.getFamilyName(), eidasDataFirst.getDateOfBirth(), cc)); + assertEquals("wrong errorCode", "module.eidasauth.matching.11", error.getErrorId()); + mockWebServer.takeRequest(); + + + } + + @Test + @SneakyThrows + public void searchWithMdsErrorResponse() { + final String cc = "CZ"; + final SimpleEidasData eidasDataFirst = generateRandomEidasData(cc); + + // set ERnP response + mockWebServer.enqueue(new MockResponse().setResponseCode(400) + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/error_resp.json"), + "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + + // execute operation + EidasSAuthenticationException error = assertThrows("wrong Exception", EidasSAuthenticationException.class, + () -> client.searchWithMds(eidasDataFirst.getGivenName(), eidasDataFirst.getFamilyName(), eidasDataFirst.getDateOfBirth(), cc)); + assertEquals("wrong errorCode", "module.eidasauth.matching.11", error.getErrorId()); + mockWebServer.takeRequest(); + + } + + @Test + @SneakyThrows + public void searchWithMdsNoResult() { + final String cc = "CZ"; + final SimpleEidasData eidasDataFirst = generateRandomEidasData(cc); + + // set ERnP response + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/ernp_empty_resp.json"), + "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + + // execute operation + ErnpRegisterResult resp = client.searchWithMds(eidasDataFirst.getGivenName(), eidasDataFirst.getFamilyName(), eidasDataFirst.getDateOfBirth(), cc); + + // validate request + final RecordedRequest request = mockWebServer.takeRequest(); + String reqBody = request.getBody().readUtf8(); + assertFalse("no request body", reqBody.isEmpty()); + JsonNode reqJson = mapper.readTree(reqBody); + checkSearchOptions(reqJson, "Searching with MDS only"); + JsonNode person = getJsonObject(reqJson, "suchdaten"); + checkJsonElement(person, "familienname", eidasDataFirst.getFamilyName()); + checkJsonElement(person, "vorname", eidasDataFirst.getGivenName()); + checkPersonDateOfBirth(person, eidasDataFirst.getDateOfBirth()); + + // validate state + assertNotNull("no ERnP response", resp); + assertEquals("wrong resp size", 0, resp.getPersonResult().size()); + + } + + @Test + @SneakyThrows + public void searchWithMdsSingleResult() { + final String cc = "CZ"; + final SimpleEidasData eidasDataFirst = generateRandomEidasData(cc); + + // set ERnP response + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/3_search_with_mds_resp.json"), + "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + + // execute operation + ErnpRegisterResult resp = client.searchWithMds(eidasDataFirst.getGivenName(), eidasDataFirst.getFamilyName(), eidasDataFirst.getDateOfBirth(), cc); + + // validate state + mockWebServer.takeRequest(); + assertNotNull("no ERnP response", resp); + assertEquals("wrong resp size", 1, resp.getPersonResult().size()); RegisterResult persInfo = resp.getPersonResult().get(0); - assertEquals("wrong familyname", "XXXSZR", persInfo.getFamilyName()); + assertEquals("wrong familyname", "DOPISNÍ", persInfo.getFamilyName()); + assertEquals("wrong givenName", "DANA", persInfo.getGivenName()); + assertEquals("wrong dateOfBirth", "1996-01-01", persInfo.getDateOfBirth()); + assertEquals("wrong bpk", "vypyCkyczK7i+cgPWlJasuJphIA=", persInfo.getBpk()); + assertEquals("wrong pseudonym", "7cEYWithDEElementsasdfsafsaf4CDVzNT4E7cjkU4VqForjUnit", persInfo.getPseudonym().get(0)); + assertNull("placeOfBirth", persInfo.getPlaceOfBirth()); + assertNull("birthName", persInfo.getBirthName()); + } + + @Test + @SneakyThrows + public void searchWithMdsMultiResult() { + final String cc = "CZ"; + final SimpleEidasData eidasDataFirst = generateRandomEidasData(cc); + + // set ERnP response + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/4_search_with_mds_multi_resp.json"), + "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + + // execute operation + ErnpRegisterResult resp = client.searchWithMds(eidasDataFirst.getGivenName(), eidasDataFirst.getFamilyName(), eidasDataFirst.getDateOfBirth(), cc); + + // validate state + mockWebServer.takeRequest(); + assertNotNull("no ERnP response", resp); + assertEquals("wrong resp size", 2, resp.getPersonResult().size()); + + } + + + @Test + @SneakyThrows + public void searchWithPersonalIdNoResponse() { + final String cc = "CZ"; + final SimpleEidasData eidasDataFirst = generateRandomEidasData(cc); + + mockWebServer.enqueue(new MockResponse() + .setSocketPolicy(SocketPolicy.NO_RESPONSE) + .setResponseCode(HttpURLConnection.HTTP_NO_CONTENT)); + + // execute operation + EidasSAuthenticationException error = assertThrows("wrong Exception", EidasSAuthenticationException.class, + () -> client.searchWithPersonIdentifier(eidasDataFirst.getPseudonym(), cc)); + assertEquals("wrong errorCode", "module.eidasauth.matching.11", error.getErrorId()); + mockWebServer.takeRequest(); + + } + + @Test + @SneakyThrows + public void searchWithPersonalIdErrorResponse() { + final String cc = "CZ"; + final SimpleEidasData eidasDataFirst = generateRandomEidasData(cc); + + // set ERnP response + mockWebServer.enqueue(new MockResponse().setResponseCode(400) + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/error_resp.json"), + "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + + // execute operation + EidasSAuthenticationException error = assertThrows("wrong Exception", EidasSAuthenticationException.class, + () -> client.searchWithPersonIdentifier(eidasDataFirst.getPseudonym(), cc)); + assertEquals("wrong errorCode", "module.eidasauth.matching.11", error.getErrorId()); + mockWebServer.takeRequest(); + + } + + @Test + @SneakyThrows + public void searchWithPersonalIdNoResult() { + final String cc = "CZ"; + final SimpleEidasData eidasDataFirst = generateRandomEidasData(cc); + + // set ERnP response + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/ernp_empty_resp.json"), + "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + + // execute operation + ErnpRegisterResult resp = client.searchWithPersonIdentifier(eidasDataFirst.getPseudonym(), cc); + + // validate request + final RecordedRequest request = mockWebServer.takeRequest(); + String reqBody = request.getBody().readUtf8(); + assertFalse("no request body", reqBody.isEmpty()); + JsonNode reqJson = mapper.readTree(reqBody); + checkSearchOptions(reqJson, "Searching PersonIdentifier"); + JsonNode person = getJsonObject(reqJson, "suchdaten"); + checkEidasDocument(person, "http://eidas.europa.eu/attributes/naturalperson/PersonIdentifier", cc, eidasDataFirst.getPseudonym()); + + // validate state + assertNotNull("no ERnP response", resp); + assertEquals("wrong resp size", 0, resp.getPersonResult().size()); + + } + + @Test + @SneakyThrows + public void searchWithPersonalIdSingleResult() { + final String cc = "DE"; + final SimpleEidasData eidasDataFirst = generateRandomEidasData(cc); + + // set ERnP response + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/1_search_with_personalId_resp.json"), + "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + + // execute operation + ErnpRegisterResult resp = client.searchWithPersonIdentifier(eidasDataFirst.getPseudonym(), cc); + + // validate state + mockWebServer.takeRequest(); + assertNotNull("no ERnP response", resp); + assertEquals("wrong resp size", 1, resp.getPersonResult().size()); + RegisterResult persInfo = resp.getPersonResult().get(0); + assertEquals("wrong familyname", "CtKKrtUe", persInfo.getFamilyName()); + assertEquals("wrong givenName", "dUeYzUFg", persInfo.getGivenName()); + assertEquals("wrong dateOfBirth", "1985-05-05", persInfo.getDateOfBirth()); + assertEquals("wrong bpk", "+OQnljn0Son1W2rkM73nP/VMsvc=", persInfo.getBpk()); + assertEquals("wrong pseudonym", "Y8ADWaeh0h", persInfo.getPseudonym().get(0)); + assertEquals("wrong placeOfBirth", "hrFevCfP", persInfo.getPlaceOfBirth()); + assertEquals("wrong birthName", "sNUEAhEr", persInfo.getBirthName()); + + } + + @Test + @SneakyThrows + public void searchWithPersonalIdSingleResultCountryNoMatch() { + final String cc = "CZ"; + final SimpleEidasData eidasDataFirst = generateRandomEidasData(cc); + + // set ERnP response + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/1_search_with_personalId_resp.json"), + "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + + // execute operation + ErnpRegisterResult resp = client.searchWithPersonIdentifier(eidasDataFirst.getPseudonym(), cc); + + // validate state + mockWebServer.takeRequest(); + assertNotNull("no ERnP response", resp); + assertEquals("wrong resp size", 1, resp.getPersonResult().size()); + RegisterResult persInfo = resp.getPersonResult().get(0); + assertEquals("wrong familyname", "CtKKrtUe", persInfo.getFamilyName()); + assertEquals("wrong givenName", "dUeYzUFg", persInfo.getGivenName()); + assertEquals("wrong dateOfBirth", "1985-05-05", persInfo.getDateOfBirth()); + assertEquals("wrong bpk", "+OQnljn0Son1W2rkM73nP/VMsvc=", persInfo.getBpk()); + assertTrue("pseudonym", persInfo.getPseudonym().isEmpty()); + assertNull("placeOfBirth", persInfo.getPlaceOfBirth()); + assertNull("birthName", persInfo.getBirthName()); + + } + + + @Test + @SneakyThrows + public void searchWithPersonalIdMultiResult() { + final String cc = "CZ"; + final SimpleEidasData eidasDataFirst = generateRandomEidasData(cc); + + // set ERnP response + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/4_search_with_mds_multi_resp.json"), + "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + + // execute operation + EidasSAuthenticationException error = assertThrows("wrong Exception", EidasSAuthenticationException.class, + () -> client.searchWithPersonIdentifier(eidasDataFirst.getPseudonym(), cc)); + assertEquals("wrong errorCode", "module.eidasauth.matching.03", error.getErrorId()); + mockWebServer.takeRequest(); + + } + + + @Test + @SneakyThrows + public void searchWithCcspecificsNoResponse() { + final String cc = "CZ"; + final SimpleEidasData eidasDataFirst = generateRandomEidasData(cc); + + mockWebServer.enqueue(new MockResponse() + .setSocketPolicy(SocketPolicy.NO_RESPONSE) + .setResponseCode(HttpURLConnection.HTTP_NO_CONTENT)); + + // execute operation + EidasSAuthenticationException error = assertThrows("wrong Exception", EidasSAuthenticationException.class, + () -> client.searchCountrySpecific(new DeSpecificDetailSearchProcessor().generateSearchRequest(eidasDataFirst), cc)); + assertEquals("wrong errorCode", "module.eidasauth.matching.11", error.getErrorId()); + mockWebServer.takeRequest(); + + } + + @Test + @SneakyThrows + public void searchWithCcspecificsErrorResponse() { + final String cc = "CZ"; + final SimpleEidasData eidasDataFirst = generateRandomEidasData(cc); + + // set ERnP response + mockWebServer.enqueue(new MockResponse().setResponseCode(400) + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/error_resp.json"), + "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + + // execute operation + EidasSAuthenticationException error = assertThrows("wrong Exception", EidasSAuthenticationException.class, + () -> client.searchCountrySpecific(new DeSpecificDetailSearchProcessor().generateSearchRequest(eidasDataFirst), cc)); + assertEquals("wrong errorCode", "module.eidasauth.matching.11", error.getErrorId()); + mockWebServer.takeRequest(); + + } + + @Test + @SneakyThrows + public void searchWithCcspecificsNoResult() { + final String cc = "DE"; + final SimpleEidasData eidasDataFirst = generateRandomEidasData(cc).toBuilder() + .birthName(RandomStringUtils.randomAlphabetic(5)) + .placeOfBirth(RandomStringUtils.randomAlphabetic(5)) + .build(); + + // set ERnP response + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/ernp_empty_resp.json"), + "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + + // execute operation + ErnpRegisterResult resp = client.searchCountrySpecific( + new DeSpecificDetailSearchProcessor().generateSearchRequest(eidasDataFirst), cc); + + // validate request + final RecordedRequest request = mockWebServer.takeRequest(); + String reqBody = request.getBody().readUtf8(); + assertFalse("no request body", reqBody.isEmpty()); + JsonNode reqJson = mapper.readTree(reqBody); + checkSearchOptions(reqJson, "Searching DE specific"); + JsonNode person = getJsonObject(reqJson, "suchdaten"); + checkJsonElement(person, "familienname", eidasDataFirst.getFamilyName()); + checkJsonElement(person, "vorname", eidasDataFirst.getGivenName()); + checkPersonDateOfBirth(person, eidasDataFirst.getDateOfBirth()); + checkEidasDocument(person, "http://eidas.europa.eu/attributes/naturalperson/PlaceOfBirth", cc, eidasDataFirst.getPlaceOfBirth()); + checkEidasDocument(person, "http://eidas.europa.eu/attributes/naturalperson/BirthName", cc, eidasDataFirst.getBirthName()); + + // validate state + assertNotNull("no ERnP response", resp); + assertEquals("wrong resp size", 0, resp.getPersonResult().size()); + + } + + @Test + @SneakyThrows + public void searchWithCcspecificsSingleResult() { + final String cc = "DE"; + final SimpleEidasData eidasDataFirst = generateRandomEidasData(cc); + + // set ERnP response + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/1_search_with_personalId_resp.json"), + "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + + // execute operation + ErnpRegisterResult resp = client.searchCountrySpecific( + new DeSpecificDetailSearchProcessor().generateSearchRequest(eidasDataFirst), cc); + + // validate state + mockWebServer.takeRequest(); + assertNotNull("no ERnP response", resp); + assertEquals("wrong resp size", 1, resp.getPersonResult().size()); + RegisterResult persInfo = resp.getPersonResult().get(0); + assertEquals("wrong familyname", "CtKKrtUe", persInfo.getFamilyName()); + assertEquals("wrong givenName", "dUeYzUFg", persInfo.getGivenName()); + assertEquals("wrong dateOfBirth", "1985-05-05", persInfo.getDateOfBirth()); + assertEquals("wrong bpk", "+OQnljn0Son1W2rkM73nP/VMsvc=", persInfo.getBpk()); + assertEquals("wrong pseudonym", "Y8ADWaeh0h", persInfo.getPseudonym().get(0)); + assertEquals("wrong placeOfBirth", "hrFevCfP", persInfo.getPlaceOfBirth()); + assertEquals("wrong birthName", "sNUEAhEr", persInfo.getBirthName()); + + } + + @Test + @SneakyThrows + public void searchWithCcspecificsSingleResultCountryNoMatch() { + final String cc = "CZ"; + final SimpleEidasData eidasDataFirst = generateRandomEidasData(cc); + + // set ERnP response + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/1_search_with_personalId_resp.json"), + "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + + // execute operation + ErnpRegisterResult resp = client.searchCountrySpecific( + new DeSpecificDetailSearchProcessor().generateSearchRequest(eidasDataFirst), cc); + + // validate state + mockWebServer.takeRequest(); + assertNotNull("no ERnP response", resp); + assertEquals("wrong resp size", 1, resp.getPersonResult().size()); + RegisterResult persInfo = resp.getPersonResult().get(0); + assertEquals("wrong familyname", "CtKKrtUe", persInfo.getFamilyName()); + assertEquals("wrong givenName", "dUeYzUFg", persInfo.getGivenName()); + assertEquals("wrong dateOfBirth", "1985-05-05", persInfo.getDateOfBirth()); + assertEquals("wrong bpk", "+OQnljn0Son1W2rkM73nP/VMsvc=", persInfo.getBpk()); + assertTrue("pseudonym", persInfo.getPseudonym().isEmpty()); + assertNull("placeOfBirth", persInfo.getPlaceOfBirth()); + assertNull("birthName", persInfo.getBirthName()); + + } + + + @Test + @SneakyThrows + public void searchWithCcspecificsMultiResult() { + final String cc = "CZ"; + final SimpleEidasData eidasDataFirst = generateRandomEidasData(cc); + + // set ERnP response + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/4_search_with_mds_multi_resp.json"), + "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + + // execute operation + EidasSAuthenticationException error = assertThrows("wrong Exception", EidasSAuthenticationException.class, + () -> client.searchCountrySpecific(new DeSpecificDetailSearchProcessor().generateSearchRequest(eidasDataFirst), cc)); + assertEquals("wrong errorCode", "module.eidasauth.matching.03", error.getErrorId()); + mockWebServer.takeRequest(); + + } + + + @Test + @SneakyThrows + public void addPersonNoResponse() { + final String cc = "CZ"; + final SimpleEidasData eidasDataFirst = generateRandomEidasData(cc); + + mockWebServer.enqueue(new MockResponse() + .setSocketPolicy(SocketPolicy.NO_RESPONSE) + .setResponseCode(HttpURLConnection.HTTP_NO_CONTENT)); + + // execute operation + EidasSAuthenticationException error = assertThrows("wrong Exception", EidasSAuthenticationException.class, + () -> client.add(eidasDataFirst)); + assertEquals("wrong errorCode", "module.eidasauth.matching.11", error.getErrorId()); + mockWebServer.takeRequest(); + + } + + @Test + @SneakyThrows + public void addPersonSimpleSuccess() { + final String cc = "CZ"; + final SimpleEidasData eidasDataFirst = generateRandomEidasData(cc); + + // set ERnP response + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/2_add_resp.json"), + "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + + // execute operation + // execute operation + ErnpRegisterResult resp = client.add(eidasDataFirst); + + // validate request + final RecordedRequest request = mockWebServer.takeRequest(); + String reqBody = request.getBody().readUtf8(); + assertFalse("no request body", reqBody.isEmpty()); + JsonNode reqJson = mapper.readTree(reqBody); + checkJsonElement(reqJson, "begruendung", "Add new person"); + JsonNode person = getJsonObject(reqJson, "personendaten"); + checkJsonElement(person, "familienname", eidasDataFirst.getFamilyName()); + checkJsonElement(person, "vorname", eidasDataFirst.getGivenName()); + checkPersonDateOfBirth(person, eidasDataFirst.getDateOfBirth()); + checkEidasDocument(reqJson, "http://eidas.europa.eu/attributes/naturalperson/PersonIdentifier", cc, eidasDataFirst.getPseudonym()); + checkEidasDocument(reqJson, "http://eidas.europa.eu/attributes/naturalperson/PlaceOfBirth", cc); + checkEidasDocument(reqJson, "http://eidas.europa.eu/attributes/naturalperson/BirthName", cc); + + + // validate state + assertNotNull("no ERnP response", resp); + assertEquals("wrong resp size", 1, resp.getPersonResult().size()); + RegisterResult persInfo = resp.getPersonResult().get(0); + assertEquals("wrong familyname", "mRjMKAQc", persInfo.getFamilyName()); + assertEquals("wrong givenName", "vdqZZIaA", persInfo.getGivenName()); + assertEquals("wrong dateOfBirth", "1996-01-01", persInfo.getDateOfBirth()); + assertEquals("wrong bpk", "TBGoMlirU881e2jMGETa9WLx1+A=", persInfo.getBpk()); + + } + + @Test + @SneakyThrows + public void addPersonSimpleComplexe() { + final String cc = "DE"; + final SimpleEidasData eidasDataFirst = generateRandomEidasData(cc).toBuilder() + .birthName(RandomStringUtils.randomAlphabetic(5)) + .placeOfBirth(RandomStringUtils.randomAlphabetic(5)) + .build(); + + // set ERnP response + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/2_add_resp.json"), + "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + + // execute operation + // execute operation + ErnpRegisterResult resp = client.add(eidasDataFirst); + + // validate request + final RecordedRequest request = mockWebServer.takeRequest(); + String reqBody = request.getBody().readUtf8(); + assertFalse("no request body", reqBody.isEmpty()); + JsonNode reqJson = mapper.readTree(reqBody); + checkJsonElement(reqJson, "begruendung", "Add new person"); + JsonNode person = getJsonObject(reqJson, "personendaten"); + checkJsonElement(person, "familienname", eidasDataFirst.getFamilyName()); + checkJsonElement(person, "vorname", eidasDataFirst.getGivenName()); + checkPersonDateOfBirth(person, eidasDataFirst.getDateOfBirth()); + checkEidasDocument(reqJson, "http://eidas.europa.eu/attributes/naturalperson/PersonIdentifier", cc, eidasDataFirst.getPseudonym()); + checkEidasDocument(reqJson, "http://eidas.europa.eu/attributes/naturalperson/PlaceOfBirth", cc, eidasDataFirst.getPlaceOfBirth()); + checkEidasDocument(reqJson, "http://eidas.europa.eu/attributes/naturalperson/BirthName", cc, eidasDataFirst.getBirthName()); + + // validate state + assertNotNull("no ERnP response", resp); + assertEquals("wrong resp size", 1, resp.getPersonResult().size()); + RegisterResult persInfo = resp.getPersonResult().get(0); + assertEquals("wrong familyname", "mRjMKAQc", persInfo.getFamilyName()); + assertEquals("wrong givenName", "vdqZZIaA", persInfo.getGivenName()); + assertEquals("wrong dateOfBirth", "1996-01-01", persInfo.getDateOfBirth()); + assertEquals("wrong bpk", "TBGoMlirU881e2jMGETa9WLx1+A=", persInfo.getBpk()); + assertEquals("wrong pseudonym", "88hvWzUaIX", persInfo.getPseudonym().get(0)); + assertEquals("wrong placeOfBirth", "VRNCAylF", persInfo.getPlaceOfBirth()); + assertEquals("wrong birthName", "miEklFHC", persInfo.getBirthName()); + + } + + @Test + @SneakyThrows + public void updateNoLatestVersion() { + final String cc = "DE"; + final SimpleEidasData eidasDataFirst = generateRandomEidasData(cc).toBuilder() + .birthName(RandomStringUtils.randomAlphabetic(5)) + .placeOfBirth(RandomStringUtils.randomAlphabetic(5)) + .build(); + + // set ERnP response + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/ernp_empty_resp.json"), + "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + + RegisterResult ernpResult = RegisterResult.builder() + .familyName(eidasDataFirst.getFamilyName()) + .givenName(eidasDataFirst.getGivenName()) + .dateOfBirth(eidasDataFirst.getDateOfBirth()) + .bpk("") + .pseudonym(Arrays.asList(eidasDataFirst.getPseudonym())) + .build(); + + // execute operation + EidasSAuthenticationException error = assertThrows("wrong Exception", EidasSAuthenticationException.class, + () -> client.update(ernpResult, eidasDataFirst)); + assertEquals("wrong errorCode", "module.eidasauth.matching.03", error.getErrorId()); + mockWebServer.takeRequest(); + + + } + + + @Test + @SneakyThrows + public void updateNoUpdateRequired() { + final String cc = "DE"; + final String personalIdentifierFirst = "Y8ADWaeh0h"; + final SimpleEidasData eidasDataFirst = SimpleEidasData.builder() + .citizenCountryCode(cc) + .familyName("CtKKrtUe") + .givenName("dUeYzUFg") + .dateOfBirth("1985-05-05") + .personalIdentifier(cc + "/AT/" + personalIdentifierFirst) + .pseudonym(personalIdentifierFirst) + .build(); + + // set ERnP response + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/1_kitt_search_latest_resp.json"), + "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + + RegisterResult ernpResult = RegisterResult.builder() + .familyName(eidasDataFirst.getFamilyName()) + .givenName(eidasDataFirst.getGivenName()) + .dateOfBirth(eidasDataFirst.getDateOfBirth()) + .bpk("+OQnljn0Son1W2rkM73nP/VMsvc=") + .pseudonym(Arrays.asList(eidasDataFirst.getPseudonym())) + .birthName("sNUEAhEr") + .placeOfBirth("hrFevCfP") + .build(); + + // execute operation + ErnpRegisterResult resp = client.update(ernpResult, eidasDataFirst); + + // validate request + final RecordedRequest request = mockWebServer.takeRequest(); + String reqBody = request.getBody().readUtf8(); + assertFalse("no request body", reqBody.isEmpty()); + JsonNode reqJson = mapper.readTree(reqBody); + checkSearchOptions(reqJson, "KITT get-latest-version"); + JsonNode person = getJsonObject(reqJson, "suchdaten"); + checkJsonElement(person, "familienname", ernpResult.getFamilyName()); + checkJsonElement(person, "vorname", ernpResult.getGivenName()); + checkJsonElement(person, "bpkZp", ernpResult.getBpk()); + checkPersonDateOfBirth(person, ernpResult.getDateOfBirth()); + + //validate state + assertNotNull("no ERnP response", resp); + assertEquals("wrong resp size", 1, resp.getPersonResult().size()); + RegisterResult persInfo = resp.getPersonResult().get(0); + assertEquals("wrong familyname", ernpResult.getFamilyName(), persInfo.getFamilyName()); + assertEquals("wrong givenName", ernpResult.getGivenName(), persInfo.getGivenName()); + assertEquals("wrong dateOfBirth", ernpResult.getDateOfBirth(), persInfo.getDateOfBirth()); + assertEquals("wrong bpk", ernpResult.getBpk(), persInfo.getBpk()); + assertEquals("wrong pseudonym", ernpResult.getPseudonym().get(0), persInfo.getPseudonym().get(0)); + assertEquals("wrong placeOfBirth", "hrFevCfP", persInfo.getPlaceOfBirth()); + assertEquals("wrong birthName", "sNUEAhEr", persInfo.getBirthName()); + + } + + @Test + @SneakyThrows + public void updateUpdateRequiredMds() { + final String cc = "DE"; + final String personalIdentifierFirst = "Y8ADWaeh0h"; + final SimpleEidasData eidasDataFirst = SimpleEidasData.builder() + .citizenCountryCode(cc) + .familyName("mVzTMpig6r") + .givenName("Jb2vj1Xpql") + .dateOfBirth("1985-05-05") + .personalIdentifier(cc + "/AT/" + personalIdentifierFirst) + .pseudonym(personalIdentifierFirst) + .placeOfBirth("hrFevCfP") + .birthName("sNUEAhEr") + .build(); + + // set ERnP response + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/1_kitt_search_latest_resp.json"), + "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/1_kitt_update_resp.json"), + "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + + RegisterResult ernpResult = RegisterResult.builder() + .familyName("CtKKrtUe") + .givenName("dUeYzUFg") + .dateOfBirth("1985-05-05") + .bpk("+OQnljn0Son1W2rkM73nP/VMsvc=") + .pseudonym(Arrays.asList("Y8ADWaeh0h")) + .birthName("sNUEAhEr") + .placeOfBirth("hrFevCfP") + .build(); + + // execute operation + ErnpRegisterResult resp = client.update(ernpResult, eidasDataFirst); + + // validate request + // check get-latest-version request + final RecordedRequest request = mockWebServer.takeRequest(); + String reqBody = request.getBody().readUtf8(); + assertFalse("no request body", reqBody.isEmpty()); + JsonNode reqJson = mapper.readTree(reqBody); + checkSearchOptions(reqJson, "KITT get-latest-version"); + JsonNode person = getJsonObject(reqJson, "suchdaten"); + checkJsonElement(person, "familienname", ernpResult.getFamilyName()); + checkJsonElement(person, "vorname", ernpResult.getGivenName()); + checkJsonElement(person, "bpkZp", ernpResult.getBpk()); + checkPersonDateOfBirth(person, ernpResult.getDateOfBirth()); + + // check update request + final RecordedRequest requestKitt = mockWebServer.takeRequest(); + String reqBodyKitt = requestKitt.getBody().readUtf8(); + assertFalse("no request body", reqBodyKitt.isEmpty()); + JsonNode reqJsonKitt = mapper.readTree(reqBodyKitt); + checkJsonElement(reqJsonKitt, "begruendung", "KITT update dataset"); + checkJsonElement(reqJsonKitt, "entityId", "1933000000000475"); + checkJsonElement(reqJsonKitt, "version", "2022-03-03T10:07:28.885Z"); + JsonNode personChange = getJsonObject(reqJsonKitt, "aendern"); + JsonNode personKitt = getJsonObject(personChange, "personendaten"); + checkJsonElement(personKitt, "familienname", eidasDataFirst.getFamilyName()); + checkJsonElement(personKitt, "vorname", eidasDataFirst.getGivenName()); + checkPersonDateOfBirth(personKitt, eidasDataFirst.getDateOfBirth()); + + assertFalse("find 'aendern' element", reqJsonKitt.has("anlegen")); + assertFalse("find 'aendern' element", personChange.has("eidas")); + + + //validate state + assertNotNull("no ERnP response", resp); + assertEquals("wrong resp size", 1, resp.getPersonResult().size()); + RegisterResult persInfo = resp.getPersonResult().get(0); + assertEquals("wrong familyname", eidasDataFirst.getFamilyName(), persInfo.getFamilyName()); + assertEquals("wrong givenName", eidasDataFirst.getGivenName(), persInfo.getGivenName()); + assertEquals("wrong dateOfBirth", ernpResult.getDateOfBirth(), persInfo.getDateOfBirth()); + assertEquals("wrong bpk", ernpResult.getBpk(), persInfo.getBpk()); + assertEquals("wrong pseudonym", ernpResult.getPseudonym().get(0), persInfo.getPseudonym().get(0)); + assertEquals("wrong placeOfBirth", "hrFevCfP", persInfo.getPlaceOfBirth()); + assertEquals("wrong birthName", "sNUEAhEr", persInfo.getBirthName()); + + } + + @Test + @SneakyThrows + public void updateUpdateRequiredEidasDocs() { + final String cc = "DE"; + final String personalIdentifierFirst = "nj1m79jm9z"; + final SimpleEidasData eidasDataFirst = SimpleEidasData.builder() + .citizenCountryCode(cc) + .familyName("mRjMKAQc") + .givenName("vdqZZIaA") + .dateOfBirth("1996-01-01") + .personalIdentifier(cc + "/AT/" + personalIdentifierFirst) + .pseudonym(personalIdentifierFirst) + .birthName(RandomStringUtils.randomAlphabetic(10)) + .build(); + + // set ERnP response + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/2_kitt_search_latest_resp.json"), + "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/2_kitt_update_resp.json"), + "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + + RegisterResult ernpResult = RegisterResult.builder() + .familyName("mRjMKAQc") + .givenName("vdqZZIaA") + .dateOfBirth("1996-01-01") + .bpk("TBGoMlirU881e2jMGETa9WLx1+A=") + .pseudonym(Arrays.asList("88hvWzUaIX")) + .birthName("VRNCAylF") + .placeOfBirth("miEklFHC") + .build(); + + // execute operation + ErnpRegisterResult resp = client.update(ernpResult, eidasDataFirst); + + // validate request + // check get-latest-version request + final RecordedRequest request = mockWebServer.takeRequest(); + String reqBody = request.getBody().readUtf8(); + assertFalse("no request body", reqBody.isEmpty()); + JsonNode reqJson = mapper.readTree(reqBody); + checkSearchOptions(reqJson, "KITT get-latest-version"); + JsonNode person = getJsonObject(reqJson, "suchdaten"); + checkJsonElement(person, "familienname", ernpResult.getFamilyName()); + checkJsonElement(person, "vorname", ernpResult.getGivenName()); + checkJsonElement(person, "bpkZp", ernpResult.getBpk()); + checkPersonDateOfBirth(person, ernpResult.getDateOfBirth()); + + // check update request + final RecordedRequest requestKitt = mockWebServer.takeRequest(); + String reqBodyKitt = requestKitt.getBody().readUtf8(); + assertFalse("no request body", reqBodyKitt.isEmpty()); + JsonNode reqJsonKitt = mapper.readTree(reqBodyKitt); + checkJsonElement(reqJsonKitt, "begruendung", "KITT update dataset"); + checkJsonElement(reqJsonKitt, "entityId", "1933000000000498"); + checkJsonElement(reqJsonKitt, "version", "2022-03-03T10:14:59.712Z"); + JsonNode personChange = getJsonObject(reqJsonKitt, "anlegen"); + checkEidasDocument(personChange, "http://eidas.europa.eu/attributes/naturalperson/PersonIdentifier", cc, eidasDataFirst.getPseudonym()); + assertFalse("find 'aendern' element", reqJsonKitt.has("aendern")); + + //validate state + assertNotNull("no ERnP response", resp); + assertEquals("wrong resp size", 1, resp.getPersonResult().size()); + RegisterResult persInfo = resp.getPersonResult().get(0); + assertEquals("wrong familyname", eidasDataFirst.getFamilyName(), persInfo.getFamilyName()); + assertEquals("wrong givenName", eidasDataFirst.getGivenName(), persInfo.getGivenName()); + assertEquals("wrong dateOfBirth", ernpResult.getDateOfBirth(), persInfo.getDateOfBirth()); + assertEquals("wrong bpk", ernpResult.getBpk(), persInfo.getBpk()); + assertEquals("wrong pseudonym", ernpResult.getPseudonym().get(0), persInfo.getPseudonym().get(0)); + assertEquals("wrong pseudonym", eidasDataFirst.getPseudonym(), persInfo.getPseudonym().get(1)); + assertEquals("wrong placeOfBirth", "VRNCAylF", persInfo.getPlaceOfBirth()); + assertEquals("wrong birthName", "miEklFHC", persInfo.getBirthName()); + + } + + + private SimpleEidasData generateRandomEidasData(String cc) { + final String personalIdentifierFirst = RandomStringUtils.randomAlphanumeric(10); + return SimpleEidasData.builder() + .citizenCountryCode(cc) + .familyName(RandomStringUtils.randomAlphanumeric(10)) + .givenName(RandomStringUtils.randomAlphanumeric(10)) + .dateOfBirth("1996-10-15") + .personalIdentifier(cc + "/AT/" + personalIdentifierFirst) + .pseudonym(personalIdentifierFirst) + .build(); + + } + + private void checkEidasDocument(JsonNode person, String art, String cc, String expected) { + assertTrue("no element: eidas", person.has("eidas")); + assertTrue("wrong type element: eidas", person.get("eidas").isArray()); + + boolean found = false; + Iterator docs = person.get("eidas").elements(); + while (docs.hasNext() && !found) { + JsonNode el = docs.next(); + assertTrue("art", el.has("art")); + assertTrue("wert", el.has("wert")); + assertTrue("cc", el.has("staatscode2")); + found = art.equals(el.get("art").asText()) && cc.equals(el.get("staatscode2").asText()) + && expected.equals(el.get("wert").asText()); + + } + assertTrue("Missing eidas document", found); + + } + + private void checkEidasDocument(JsonNode person, String art, String cc) { + assertTrue("no element: eidas", person.has("eidas")); + assertTrue("wrong type element: eidas", person.get("eidas").isArray()); + + boolean found = false; + Iterator docs = person.get("eidas").elements(); + while (docs.hasNext() && !found) { + JsonNode el = docs.next(); + assertTrue("art", el.has("art")); + assertTrue("wert", el.has("wert")); + assertTrue("cc", el.has("staatscode2")); + found = art.equals(el.get("art").asText()) && cc.equals(el.get("staatscode2").asText()); + + } + assertFalse("Missing eidas document", found); + + } + + private void checkPersonDateOfBirth(JsonNode person, String dateOfBirth) { + JsonNode birthDay = getJsonObject(person, "geburtsdatum"); + String[] el = dateOfBirth.split("-"); + checkJsonElement(birthDay, "jahr", Integer.parseInt(el[0])); + checkJsonElement(birthDay, "monat", Integer.parseInt(el[1])); + checkJsonElement(birthDay, "tag", Integer.parseInt(el[2])); + + } + + private void checkSearchOptions(JsonNode json, String reason) { + checkJsonElement(json, "begruendung", reason); + JsonNode options = getJsonObject(json, "suchoptionen"); + checkJsonElement(options, "historisch", "AktuellUndHistorisch"); + checkJsonElement(options, "sucheMitNamensteilen", false); + checkJsonElement(options, "suchwizard", false); + checkJsonElement(options, "zmr", false); + + } + + private JsonNode getJsonObject(JsonNode json, String key) { + assertTrue("no element: " + key, json.has(key)); + assertTrue("wrong type element: " + key, json.get(key).isObject()); + return json.get(key); + + } + + private void checkJsonElement(JsonNode json, String key, int expected) { + assertTrue("no element: " + key, json.has(key)); + assertTrue("wong element-type: " + key, json.get(key).isInt()); + assertEquals("wong element-value: " + key, expected, json.get(key).asInt()); + + } + + private void checkJsonElement(JsonNode json, String key, String expected) { + assertTrue("no element: " + key, json.has(key)); + assertTrue("wong element-type: " + key, json.get(key).isTextual()); + assertEquals("wong element-value: " + key, expected, json.get(key).asText()); + + } + + private void checkJsonElement(JsonNode json, String key, boolean expected) { + assertTrue("no element: " + key, json.has(key)); + assertTrue("wong element-type: " + key, json.get(key).isBoolean()); + assertEquals("wong element-value: " + key, expected, json.get(key).asBoolean()); } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/3_search_with_mds_resp.json b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/3_search_with_mds_resp.json index 50735f23..87be362d 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/3_search_with_mds_resp.json +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/3_search_with_mds_resp.json @@ -28,7 +28,7 @@ "basiszahl": "000501189333", "bpkZp": "vypyCkyczK7i+cgPWlJasuJphIA=", "entityId": "1933000000000047", - "familienname": "DOPISN[0xc3][0x8d]", + "familienname": "DOPISNÍ", "geburtsdatum": { "jahr": 1996, "monat": 1, -- cgit v1.2.3 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(-) 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 From af4facf80c9a8661dc8aba109219757cff26af98 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Thu, 3 Mar 2022 15:30:54 +0100 Subject: test(ernp): add some ERnP releated tests into InitialSearchTask --- .../tasks/InitialSearchTaskWithRegistersTest.java | 83 +++++++++++++++++++--- 1 file changed, 75 insertions(+), 8 deletions(-) diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java index 18d76264..6d0e7c31 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java @@ -45,6 +45,7 @@ import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import javax.xml.namespace.QName; +import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.RandomStringUtils; import org.jetbrains.annotations.NotNull; import org.junit.AfterClass; @@ -84,6 +85,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.ICcSpecificEidPr import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService; 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.test.clients.ErnpRestClientTest; import at.asitplus.eidas.specific.modules.auth.eidas.v2.test.clients.ZmrClientTest; import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.MatchingTaskUtils; import at.gv.bmi.namespace.zmr_su.base._20040201.RequestType; @@ -180,11 +182,6 @@ public class InitialSearchTaskWithRegistersTest { RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(httpReq, httpResp)); pendingReq = new TestRequestImpl(); - - - mockWebServer.enqueue(new MockResponse().setResponseCode(200) - .setBody("{}") - .setHeader("Content-Type", "application/json;charset=utf-8")); } @@ -218,6 +215,10 @@ public class InitialSearchTaskWithRegistersTest { //do not make an update because, MDS update is not allowed and no other data has been changed .thenThrow(new RuntimeException("This request is not needed any more")); + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody("{}") + .setHeader("Content-Type", "application/json;charset=utf-8")); + // execute test task.execute(pendingReq, executionContext); @@ -266,6 +267,9 @@ public class InitialSearchTaskWithRegistersTest { //do make an update because, MDS DOES NOT change, but additional attribute was available .thenReturn(loadResponseFromFile("/data/zmr/seq_3-6_kitt_update_resp.xml")); + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody("{}") + .setHeader("Content-Type", "application/json;charset=utf-8")); // execute test task.execute(pendingReq, executionContext); @@ -321,6 +325,58 @@ public class InitialSearchTaskWithRegistersTest { } + /** + * Find single person in ZMR by country specifics. + */ + @Test + @DirtiesContext + public void singlePersonFindWithCountySpecifics_Ernp() throws Exception { + //inject eIDAS data + pendingReq.getSessionData(AuthProcessDataWrapper.class).setGenericDataToSession( + Constants.DATA_FULL_EIDAS_RESPONSE, + buildDummyAuthResponse("vdqZZIaA", "mRjMKAQc", + "DE/AT/nj1m79jm9z", "1996-01-01", + null, "VRNCAylF", "miEklFHC")); + + final ArgumentCaptor zmrReq = ArgumentCaptor.forClass(RequestType.class); + BigInteger processId = new BigInteger("367100000000079"); + + // inject response + when(zmrMock.service(zmrReq.capture(), any())) + .thenReturn(loadResponseFromFile("/data/zmr/empty_zmr_result.xml")) //personalId search + .thenReturn(loadResponseFromFile("/data/zmr/empty_zmr_result.xml")) //CC specific search + .thenThrow(new RuntimeException("This request is not needed any more")); + + mockWebServer.enqueue(new MockResponse().setResponseCode(200) //personalId search + .setBody("{}") + .setHeader("Content-Type", "application/json;charset=utf-8")); + mockWebServer.enqueue(new MockResponse().setResponseCode(200) //CC specific search + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/2_search_with_cc_specific_resp.json"), "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + mockWebServer.enqueue(new MockResponse().setResponseCode(200) //KITT search + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/2_kitt_search_latest_resp.json"), "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + mockWebServer.enqueue(new MockResponse().setResponseCode(200) //KITT update + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/2_kitt_update_resp.json"), "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + + // execute test + task.execute(pendingReq, executionContext); + + // validate state + checkMatchingSuccessState(pendingReq, "TBGoMlirU881e2jMGETa9WLx1+A=", "mRjMKAQc", + "vdqZZIaA", "1996-01-01", DE); + + // validate request + assertEquals("wrong number of req.", 2, zmrReq.getAllValues().size()); + checkBasicRequestParameters(zmrReq.getAllValues().get(0), ZmrClientTest.PROCESS_TASK_SEARCH, null, "jUnit123456"); + checkBasicRequestParameters(zmrReq.getAllValues().get(1), ZmrClientTest.PROCESS_TASK_SEARCH, processId, "jUnit123456"); + + } + /** * Find single person in ZMR by country specifics. @@ -346,6 +402,10 @@ public class InitialSearchTaskWithRegistersTest { .thenReturn(loadResponseFromFile("/data/zmr/seq_1-6_kitt_update_resp.xml")) //KITT update .thenThrow(new RuntimeException("This request is not needed any more")); + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody("{}") + .setHeader("Content-Type", "application/json;charset=utf-8")); + mockWebServer.enqueue(new MockResponse().setResponseCode(200) //CC specific search .setBody("{}") .setHeader("Content-Type", "application/json;charset=utf-8")); @@ -389,7 +449,10 @@ public class InitialSearchTaskWithRegistersTest { //CC-specific will be ignored because CC is DE but BirthName and PlaceOfBirth is 'null' .thenReturn(loadResponseFromFile("/data/zmr/seq_1-2_search_with_mds_resp.xml")) //MDS specific search .thenThrow(new RuntimeException("This request is not needed any more")); - + + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody("{}") + .setHeader("Content-Type", "application/json;charset=utf-8")); mockWebServer.enqueue(new MockResponse().setResponseCode(200) //MDS specific search .setBody("{}") .setHeader("Content-Type", "application/json;charset=utf-8")); @@ -432,11 +495,15 @@ public class InitialSearchTaskWithRegistersTest { .thenThrow(new RuntimeException("This request is not needed any more")); + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody("{}") + .setHeader("Content-Type", "application/json;charset=utf-8")); mockWebServer.enqueue(new MockResponse().setResponseCode(200) //CC specific search .setBody("{}") .setHeader("Content-Type", "application/json;charset=utf-8")); mockWebServer.enqueue(new MockResponse().setResponseCode(200) //MDS specific search - .setBody("{}") + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/3_search_with_mds_resp.json"), "UTF-8")) .setHeader("Content-Type", "application/json;charset=utf-8")); @@ -444,7 +511,7 @@ public class InitialSearchTaskWithRegistersTest { task.execute(pendingReq, executionContext); // validate state - checkIntermediateResult(2); + checkIntermediateResult(3); // validate request assertEquals("wrong number of req.", 3, zmrReq.getAllValues().size()); -- cgit v1.2.3 From c3bba97c9093eca911f6edd9cbb9742d5f32583c Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Thu, 3 Mar 2022 15:40:39 +0100 Subject: fix(core): solve code-style issue --- .../eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java index 094b2a9f..aca5025f 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java @@ -32,7 +32,7 @@ import lombok.Builder; import lombok.Data; @Data -@Builder(toBuilder=true) +@Builder(toBuilder = true) public class SimpleEidasData implements Serializable { private static final long serialVersionUID = 2848914124372968418L; -- cgit v1.2.3