diff options
author | Thomas <> | 2022-04-05 09:14:17 +0200 |
---|---|---|
committer | Thomas <> | 2022-04-05 09:14:17 +0200 |
commit | 9d1e1294c2825c6f9a422c9f9c51f9965258d19e (patch) | |
tree | 489c11343c4911cfda0a78974bdb51724c264f47 /modules/authmodule-eIDAS-v2/src | |
parent | ecc1dd834c5af467a5aa0f77e5dc6d986c6af418 (diff) | |
parent | 791dc8acd7edbf22b98c2be111d420e61ebb39e6 (diff) | |
download | National_eIDAS_Gateway-9d1e1294c2825c6f9a422c9f9c51f9965258d19e.tar.gz National_eIDAS_Gateway-9d1e1294c2825c6f9a422c9f9c51f9965258d19e.tar.bz2 National_eIDAS_Gateway-9d1e1294c2825c6f9a422c9f9c51f9965258d19e.zip |
Merge branch 'master' into nightlybuild
# Conflicts:
# build_reporting/pom.xml
# connector/pom.xml
# infos/history.txt
# infos/readme_1.2.4.md
# modules/authmodule-eIDAS-v2/pom.xml
# modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/szr/SzrClient.java
# modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateIdentityLinkTask.java
# modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTestProduction.java
# modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskEidNewTest.java
# modules/core_common_lib/pom.xml
# modules/pom.xml
# pom.xml
Diffstat (limited to 'modules/authmodule-eIDAS-v2/src')
5 files changed, 146 insertions, 44 deletions
diff --git a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/Constants.java b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/Constants.java index be20e632..40b953b1 100644 --- a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/Constants.java +++ b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/Constants.java @@ -138,6 +138,10 @@ public class Constants { public static final String CONIG_PROPS_EIDAS_SZRCLIENT_WORKAROUND_SQLLITEDATASTORE_ACTIVE = CONIG_PROPS_EIDAS_SZRCLIENT + ".workarounds.datastore.sqlite.active"; + public static final String CONIG_PROPS_EIDAS_SZRCLIENT_WORKAROUND_IDA_VSZ_IDL = + CONIG_PROPS_EIDAS_SZRCLIENT + ".workarounds.use.getidentitylink.for.ida"; + + // http endpoint descriptions public static final String eIDAS_HTTP_ENDPOINT_SP_POST = "/eidas/light/sp/post"; public static final String eIDAS_HTTP_ENDPOINT_SP_REDIRECT = "/eidas/light/sp/redirect"; diff --git a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/szr/SzrClient.java b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/szr/SzrClient.java index 5558fdfd..11ea2843 100644 --- a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/szr/SzrClient.java +++ b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/szr/SzrClient.java @@ -226,15 +226,15 @@ public class SzrClient { * Request a encryped baseId from SRZ. * * @param personInfo Minimum dataset of person + * @param insertErnp insertErnp flag on SZR request * @return encrypted baseId * @throws SzrCommunicationException In case of a SZR error */ - public String getEncryptedStammzahl(final PersonInfoType personInfo) + public String getEncryptedStammzahl(final PersonInfoType personInfo, boolean insertErnp) throws SzrCommunicationException { - final String resp; try { - resp = this.szr.getStammzahlEncrypted(personInfo, false); + resp = this.szr.getStammzahlEncrypted(personInfo, insertErnp); } catch (SZRException_Exception e) { throw new SzrCommunicationException("ernb.02", new Object[]{e.getMessage()}, e); } @@ -243,7 +243,19 @@ public class SzrClient { throw new SzrCommunicationException("ernb.01", new Object[]{"Stammzahl response empty"}); // TODO error handling } - return resp; + return resp; + } + + /** + * Request a encrypted baseId from SRZ without insertErnp. + * + * @param personInfo Minimum dataset of person + * @return encrypted baseId + * @throws SzrCommunicationException In case of a SZR error + */ + public String getEncryptedStammzahl(final PersonInfoType personInfo) + throws SzrCommunicationException { + return getEncryptedStammzahl(personInfo, false); } diff --git a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateIdentityLinkTask.java b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateIdentityLinkTask.java index 18ddab42..ce737526 100644 --- a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateIdentityLinkTask.java +++ b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateIdentityLinkTask.java @@ -150,12 +150,9 @@ public class CreateIdentityLinkTask extends AbstractAuthServletTask { if (pendingReq.getServiceProviderConfiguration() .isConfigurationValue(MsEidasNodeConstants.PROP_CONFIG_SP_NEW_EID_MODE, false)) { - // work-around, because getEncryptedStammzahl does not support insertERnP for eIDAS entities - SzrResultHolder idlResult = requestSzrForIdentityLink(personInfo); - - // get encrypted baseId - String vsz = szrClient.getEncryptedStammzahl(buildGetEncryptedBaseIdReq(idlResult.identityLink)); - + // get VSZ + String vsz = getVszForPerson(personInfo); + //write revision-Log entry and extended infos personal-identifier mapping revisionsLogger.logEvent(pendingReq, MsConnectorEventCodes.SZR_VSZ_RECEIVED); writeExtendedRevisionLogEntry(simpleAttrMap, eidData); @@ -224,6 +221,25 @@ public class CreateIdentityLinkTask extends AbstractAuthServletTask { } } + + private String getVszForPerson(PersonInfoType personInfo) throws SzrCommunicationException, EaafException { + if (basicConfig.getBasicConfigurationBoolean( + Constants.CONIG_PROPS_EIDAS_SZRCLIENT_WORKAROUND_IDA_VSZ_IDL, true)) { + log.debug("IDA workaround is active. Requesting IDL to insert person into ERnP .... "); + + // work-around, because getEncryptedStammzahl does not support insertERnP for eIDAS entities + SzrResultHolder idlResult = requestSzrForIdentityLink(personInfo); + + // get encrypted baseId + return szrClient.getEncryptedStammzahl(buildGetEncryptedBaseIdReq(idlResult.identityLink)); + + + } else { + return szrClient.getEncryptedStammzahl(personInfo, true); + + } + } + private PersonInfoType buildGetEncryptedBaseIdReq(IIdentityLink identityLink) throws EaafBuilderException { log.debug("Generating getVsz request from identityLink information ... "); final PersonInfoType personInfo = new PersonInfoType(); diff --git a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTestProduction.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTestProduction.java index 83d7866e..5b8bd8fd 100644 --- a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTestProduction.java +++ b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTestProduction.java @@ -139,7 +139,7 @@ public class SzrClientTestProduction { Assert.assertNotNull("vsz", vsz); } - + @Test public void getEidasBind() throws SzrCommunicationException, EidasSAuthenticationException { String vsz = RandomStringUtils.randomAlphanumeric(10); @@ -246,7 +246,6 @@ public class SzrClientTestProduction { private PersonInfoType getPersonInfo(String familyName, String givenName, String dateOfBirth, String eIDASeID) throws EidasSAuthenticationException { - final PersonInfoType personInfo = new PersonInfoType(); final PersonNameType personName = new PersonNameType(); final PhysicalPersonType naturalPerson = new PhysicalPersonType(); diff --git a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskEidNewTest.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskEidNewTest.java index fd2e589b..10595402 100644 --- a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskEidNewTest.java +++ b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskEidNewTest.java @@ -141,6 +141,7 @@ public class CreateIdentityLinkTaskEidNewTest { RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(httpReq, httpResp)); basicConfig.putConfigValue("eidas.ms.auth.eIDAS.szrclient.debug.useDummySolution", "false"); + basicConfig.putConfigValue("eidas.ms.auth.eIDAS.szrclient.workarounds.use.getidentitylink.for.ida", "true"); final Map<String, String> spConfig = new HashMap<>(); spConfig.put(EaafConfigConstants.SERVICE_UNIQUEIDENTIFIER, "testSp"); @@ -302,6 +303,106 @@ public class CreateIdentityLinkTaskEidNewTest { } + + + @Test + public void successfulProcessWithStandardInfosWithoutIdl() throws Exception { + //initialize test + basicConfig.putConfigValue("eidas.ms.auth.eIDAS.szrclient.workarounds.use.getidentitylink.for.ida", "false"); + + String vsz = RandomStringUtils.randomNumeric(10); + when(szrMock, "getStammzahlEncrypted", any(), any()).thenReturn(vsz); + val signContentResp = new SignContentResponseType(); + final SignContentEntry signContentEntry = new SignContentEntry(); + signContentEntry.setValue(RandomStringUtils.randomAlphanumeric(10)); + signContentResp.getOut().add(signContentEntry); + when(szrMock, "signContent", any(), any(), any()).thenReturn(signContentResp); + + String randomTestSp = RandomStringUtils.randomAlphabetic(10); + String bindingPubKey = RandomStringUtils.randomAlphabetic(10); + pendingReq.setRawDataToTransaction(MsEidasNodeConstants.DATA_REQUESTERID, randomTestSp); + pendingReq.setRawDataToTransaction(MsEidasNodeConstants.EID_BINDING_PUBLIC_KEY_NAME, bindingPubKey); + + //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.assertNotNull("eidasBind", authProcessData.getGenericDataFromSession(MsEidasNodeConstants.AUTH_DATA_EIDAS_BIND, String.class)); + + // check authblock signature + String authBlock = authProcessData.getGenericDataFromSession(MsEidasNodeConstants.AUTH_DATA_SZR_AUTHBLOCK, String.class); + Assert.assertNotNull("AuthBlock", authBlock); + final AlgorithmConstraints constraints = new AlgorithmConstraints(ConstraintType.PERMIT, + BINDING_AUTH_ALGORITHM_WHITELIST_SIGNING.toArray(new String[BINDING_AUTH_ALGORITHM_WHITELIST_SIGNING.size()])); + Pair<KeyStore, Provider> keyStore = getKeyStore(); + X509Certificate[] trustedCerts = EaafKeyStoreUtils + .getPrivateKeyAndCertificates(keyStore.getFirst(), ALIAS, PW.toCharArray(), true, "junit").getSecond(); + JwsResult result = JoseUtils.validateSignature(authBlock, Arrays.asList(trustedCerts), constraints); + Assert.assertTrue("AuthBlock not valid", result.isValid()); + JsonNode authBlockJson = mapper.readTree(result.getPayLoad()); + Assert.assertNotNull("deserialized AuthBlock", authBlockJson); + + Assert.assertNotNull("no piiTransactionId in pendingRequesdt", + storedPendingReq.getUniquePiiTransactionIdentifier()); + Assert.assertEquals("piiTransactionId", storedPendingReq.getUniquePiiTransactionIdentifier(), + authBlockJson.get("piiTransactionId").asText()); + Assert.assertEquals("appId", randomTestSp, authBlockJson.get("appId").asText()); + Assert.assertFalse("'challenge' is null", authBlockJson.get("challenge").asText().isEmpty()); + Assert.assertFalse("'timestamp' is null", authBlockJson.get("timestamp").asText().isEmpty()); + Assert.assertTrue("binding pubKey", authBlockJson.has("bindingPublicKey")); + Assert.assertEquals("binding PubKey", bindingPubKey, authBlockJson.get("bindingPublicKey").asText()); + + Assert.assertTrue("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("LoA is null", authProcessData.getQaaLevel()); + Assert.assertEquals("LoA", response.getLevelOfAssurance(), + authProcessData.getQaaLevel()); + + // check vsz request + ArgumentCaptor<PersonInfoType> argument4 = ArgumentCaptor.forClass(PersonInfoType.class); + ArgumentCaptor<Boolean> argument5 = ArgumentCaptor.forClass(Boolean.class); + verify(szrMock, times(1)).getStammzahlEncrypted(argument4.capture(), argument5.capture()); + + Boolean param5 = argument5.getValue(); + Assert.assertTrue("insertERnP flag", param5); + PersonInfoType person = argument4.getValue(); + Assert.assertEquals("FamilyName", + response.getAttributes().getAttributeValuesByFriendlyName("FamilyName").getFirstValue( + response.getAttributes().getDefinitionsByFriendlyName("FamilyName").iterator().next()), + person.getPerson().getName().getFamilyName()); + Assert.assertEquals("GivenName", + response.getAttributes().getAttributeValuesByFriendlyName("FirstName").getFirstValue( + response.getAttributes().getDefinitionsByFriendlyName("FirstName").iterator().next()), + person.getPerson().getName().getGivenName()); + Assert.assertEquals("DateOfBirth", + response.getAttributes().getAttributeValuesByFriendlyName("DateOfBirth").getFirstValue( + response.getAttributes().getDefinitionsByFriendlyName("DateOfBirth").iterator().next()) + .toString().split("T")[0], + person.getPerson().getDateOfBirth()); + + 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()); + + } + @Test public void successfulProcessWithStandardInfos() throws Exception { //initialize test @@ -367,37 +468,7 @@ public class CreateIdentityLinkTaskEidNewTest { ArgumentCaptor<PersonInfoType> argument4 = ArgumentCaptor.forClass(PersonInfoType.class); ArgumentCaptor<Boolean> argument5 = ArgumentCaptor.forClass(Boolean.class); verify(szrMock, times(1)).getStammzahlEncrypted(argument4.capture(), argument5.capture()); - -// Boolean param5 = argument5.getValue(); -// Assert.assertTrue("insertERnP flag", param5); -// PersonInfoType person = argument4.getValue(); -// Assert.assertEquals("FamilyName", -// response.getAttributes().getAttributeValuesByFriendlyName("FamilyName").getFirstValue( -// response.getAttributes().getDefinitionsByFriendlyName("FamilyName").iterator().next()), -// person.getPerson().getName().getFamilyName()); -// Assert.assertEquals("GivenName", -// response.getAttributes().getAttributeValuesByFriendlyName("FirstName").getFirstValue( -// response.getAttributes().getDefinitionsByFriendlyName("FirstName").iterator().next()), -// person.getPerson().getName().getGivenName()); -// Assert.assertEquals("DateOfBirth", -// response.getAttributes().getAttributeValuesByFriendlyName("DateOfBirth").getFirstValue( -// response.getAttributes().getDefinitionsByFriendlyName("DateOfBirth").iterator().next()) -// .toString().split("T")[0], -// person.getPerson().getDateOfBirth()); -// -// 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()); - - + } @Test @@ -453,7 +524,6 @@ public class CreateIdentityLinkTaskEidNewTest { } - @Nonnull private void setSzrResponseIdentityLink(String responseXmlPath) throws JAXBException, SZRException_Exception { final JAXBContext jaxbContext = JAXBContext @@ -467,6 +537,7 @@ public class CreateIdentityLinkTaskEidNewTest { } + @Nonnull private AuthenticationResponse buildDummyAuthResponse(boolean withAll) throws URISyntaxException { final AttributeDefinition attributeDef = attrRegistry.getCoreAttributeRegistry().getByFriendlyName( |