aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/szr/SzrClient.java34
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateIdentityLinkTask.java76
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTest.java162
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTestProduction.java110
4 files changed, 105 insertions, 277 deletions
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/szr/SzrClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/szr/SzrClient.java
index 6040e0b3..22f38c2a 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/szr/SzrClient.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/szr/SzrClient.java
@@ -138,15 +138,16 @@ public class SzrClient {
/**
* Get IdentityLink of a person.
*
- * @param personInfo Person identification information
+ *
+ * @param eidData minimum dataset of person
* @return IdentityLink
* @throws SzrCommunicationException In case of a SZR error
*/
- public IdentityLinkType getIdentityLinkInRawMode(PersonInfoType personInfo)
+ public IdentityLinkType getIdentityLinkInRawMode(ErnpEidData eidData)
throws SzrCommunicationException {
try {
final GetIdentityLinkEidas getIdl = new GetIdentityLinkEidas();
- getIdl.setPersonInfo(personInfo);
+ getIdl.setPersonInfo(generateSzrRequest(convertTemp(eidData)));
final JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class);
final Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
@@ -200,17 +201,18 @@ public class SzrClient {
/**
* Get bPK of person.
*
- * @param personInfo Person identification information
+ *
+ * @param eidData Minimum dataset of person
* @param target requested bPK target
* @param vkz Verfahrenskennzeichen
* @return bPK for this person
* @throws SzrCommunicationException In case of a SZR error
*/
- public List<String> getBpk(PersonInfoType personInfo, String target, String vkz)
+ public List<String> getBpk(ErnpEidData eidData, String target, String vkz)
throws SzrCommunicationException {
try {
final GetBPK parameters = new GetBPK();
- parameters.setPersonInfo(personInfo);
+ parameters.setPersonInfo(generateSzrRequest(convertTemp(eidData)));
parameters.getBereichsKennung().add(target);
parameters.setVKZ(vkz);
final GetBPKResponse result = this.szr.getBPK(parameters);
@@ -253,15 +255,15 @@ public class SzrClient {
* <b>Note</b>: Previously, this method did create a new ERnP entry, if it did not exist. This is
* <b>not</b> the case any more. See {@link #createNewErnpEntry(SimpleEidasData)} for that functionality.
*
- * @param personInfo Minimum dataset of person
+ * @param eidData Minimum dataset of person
* @return encrypted baseId
* @throws SzrCommunicationException In case of a SZR error
*/
- public String getEncryptedStammzahl(final PersonInfoType personInfo)
+ public String getEncryptedStammzahl(final ErnpEidData eidData)
throws SzrCommunicationException {
final String resp;
try {
- resp = this.szr.getStammzahlEncrypted(personInfo, false);
+ resp = this.szr.getStammzahlEncrypted(generateSzrRequest(convertTemp(eidData)), false);
} catch (SZRException_Exception e) {
throw new SzrCommunicationException("ernb.02", new Object[]{e.getMessage()}, e);
}
@@ -274,6 +276,20 @@ public class SzrClient {
}
+ private SimpleEidasData convertTemp(ErnpEidData eidData) {
+ return SimpleEidasData.builder()
+ .citizenCountryCode(eidData.getCitizenCountryCode())
+ .pseudonym(eidData.getPseudonym())
+ .givenName(eidData.getGivenName())
+ .familyName(eidData.getFamilyName())
+ .dateOfBirth(eidData.getFormatedDateOfBirth())
+ .placeOfBirth(eidData.getPlaceOfBirth())
+ .birthName(eidData.getBirthName())
+ .address(eidData.getAddress())
+ //TODO not available.taxNumber()
+ .build();
+ }
+
/**
* Sign an eidasBind data-structure that combines vsz with user's pubKey and E-ID status.
*
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 c22dc4ba..0287fe35 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
@@ -33,9 +33,6 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.AuthBlockSigning
import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.ICcSpecificEidProcessingService;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.szr.SzrClient;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasResponseUtils;
-import at.gv.e_government.reference.namespace.persondata._20020228.AlternativeNameType;
-import at.gv.e_government.reference.namespace.persondata._20020228.PersonNameType;
-import at.gv.e_government.reference.namespace.persondata._20020228.PhysicalPersonType;
import at.gv.egiz.eaaf.core.api.data.EaafConstants;
import at.gv.egiz.eaaf.core.api.data.PvpAttributeDefinitions;
import at.gv.egiz.eaaf.core.api.idp.IConfiguration;
@@ -72,8 +69,6 @@ import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
import szrservices.IdentityLinkType;
-import szrservices.PersonInfoType;
-import szrservices.TravelDocumentType;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -147,14 +142,12 @@ public class CreateIdentityLinkTask extends AbstractAuthServletTask {
if (basicConfig.getBasicConfigurationBoolean(Constants.CONIG_PROPS_EIDAS_SZRCLIENT_DEBUG_USEDUMMY, false)) {
buildDummyIdentityLink(eidData);
} else {
- //build SZR request from eIDAS data
- final PersonInfoType personInfo = generateSzrRequest(eidData);
//request SZR based on IDL or E-ID mode
if (pendingReq.getServiceProviderConfiguration()
.isConfigurationValue(MsEidasNodeConstants.PROP_CONFIG_SP_NEW_EID_MODE, false)) {
- executeEidMode(eidasAttributes, eidData, personInfo);
+ executeEidMode(eidasAttributes, eidData);
} else {
- executeIdlMode(eidasAttributes, eidData, personInfo);
+ executeIdlMode(eidasAttributes, eidData);
}
}
storeGenericInfoToSession(eidasAttributes);
@@ -178,9 +171,9 @@ public class CreateIdentityLinkTask extends AbstractAuthServletTask {
Objects.requireNonNull(eidasPersonalIdentifier).getFirst());
}
- private void executeIdlMode(Map<String, Object> simpleAttrMap, ErnpEidData eidData, PersonInfoType personInfo) throws EaafException {
+ private void executeIdlMode(Map<String, Object> simpleAttrMap, ErnpEidData eidData) throws EaafException {
//request SZR
- SzrResultHolder idlResult = requestSzrForIdentityLink(personInfo);
+ SzrResultHolder idlResult = requestSzrForIdentityLink(eidData);
//write revision-Log entry for personal-identifier mapping
writeExtendedRevisionLogEntry(simpleAttrMap, eidData);
@@ -201,9 +194,9 @@ public class CreateIdentityLinkTask extends AbstractAuthServletTask {
.getAreaSpecificTargetIdentifier());
}
- private void executeEidMode(Map<String, Object> simpleAttrMap, ErnpEidData eidData, PersonInfoType personInfo) throws JsonProcessingException, EaafException, JoseException {
+ private void executeEidMode(Map<String, Object> simpleAttrMap, ErnpEidData eidData) throws JsonProcessingException, EaafException, JoseException {
// get encrypted baseId
- String vsz = szrClient.getEncryptedStammzahl(personInfo);
+ String vsz = szrClient.getEncryptedStammzahl(eidData);
//write revision-Log entry and extended infos personal-identifier mapping
revisionsLogger.logEvent(pendingReq, MsConnectorEventCodes.SZR_VSZ_RECEIVED);
@@ -250,60 +243,9 @@ public class CreateIdentityLinkTask extends AbstractAuthServletTask {
}
}
- private PersonInfoType generateSzrRequest(ErnpEidData eidData) {
- log.debug("Starting connecting SZR Gateway");
- final PersonInfoType personInfo = new PersonInfoType();
- final PersonNameType personName = new PersonNameType();
- final PhysicalPersonType naturalPerson = new PhysicalPersonType();
- final TravelDocumentType eDocument = new TravelDocumentType();
-
- naturalPerson.setName(personName);
- personInfo.setPerson(naturalPerson);
- personInfo.setTravelDocument(eDocument);
-
- // person information
- personName.setFamilyName(eidData.getFamilyName());
- personName.setGivenName(eidData.getGivenName());
- naturalPerson.setDateOfBirth(eidData.getFormatedDateOfBirth());
- eDocument.setIssuingCountry(eidData.getCitizenCountryCode());
- eDocument.setDocumentNumber(eidData.getPseudonym());
-
- // eID document information
- String documentType = basicConfig
- .getBasicConfiguration(Constants.CONIG_PROPS_EIDAS_SZRCLIENT_PARAMS_EDOCUMENTTYPE,
- Constants.SZR_CONSTANTS_DEFAULT_DOCUMENT_TYPE);
- eDocument.setDocumentType(documentType);
-
- // set PlaceOfBirth if available
- if (eidData.getPlaceOfBirth() != null) {
- log.trace("Find 'PlaceOfBirth' attribute: " + eidData.getPlaceOfBirth());
- boolean setPlaceOfBirth = basicConfig
- .getBasicConfigurationBoolean(Constants.CONIG_PROPS_EIDAS_SZRCLIENT_PARAMS_SETPLACEOFBIRTHIFAVAILABLE, true);
- if (setPlaceOfBirth) {
- naturalPerson.setPlaceOfBirth(eidData.getPlaceOfBirth());
- log.trace("Adding 'PlaceOfBirth' to ERnB request ... ");
- }
- }
-
- // set BirthName if available
- if (eidData.getBirthName() != null) {
- log.trace("Find 'BirthName' attribute: " + eidData.getBirthName());
- boolean setBirthName = basicConfig
- .getBasicConfigurationBoolean(Constants.CONIG_PROPS_EIDAS_SZRCLIENT_PARAMS_SETBIRTHNAMEIFAVAILABLE, true);
- if (setBirthName) {
- final AlternativeNameType alternativeName = new AlternativeNameType();
- naturalPerson.setAlternativeName(alternativeName);
- alternativeName.setFamilyName(eidData.getBirthName());
- log.trace("Adding 'BirthName' to ERnB request ... ");
- }
- }
-
- return personInfo;
- }
-
- private SzrResultHolder requestSzrForIdentityLink(PersonInfoType personInfo) throws EaafException {
+ private SzrResultHolder requestSzrForIdentityLink(ErnpEidData eidData) throws EaafException {
//request IdentityLink from SZR
- final IdentityLinkType result = szrClient.getIdentityLinkInRawMode(personInfo);
+ final IdentityLinkType result = szrClient.getIdentityLinkInRawMode(eidData);
final Element idlFromSzr = (Element) result.getAssertion();
final IIdentityLink identityLink = new SimpleIdentityLinkAssertionParser(idlFromSzr).parseIdentityLink();
@@ -316,7 +258,7 @@ public class CreateIdentityLinkTask extends AbstractAuthServletTask {
if (debugUseSzrForBpk) {
String no_vkz_defined = basicConfig
.getBasicConfiguration(Constants.CONIG_PROPS_EIDAS_SZRCLIENT_PARAMS_VKZ, "no VKZ defined");
- List<String> bpkList = szrClient.getBpk(personInfo, targetId, no_vkz_defined);
+ List<String> bpkList = szrClient.getBpk(eidData, targetId, no_vkz_defined);
if (!bpkList.isEmpty()) {
bpk = bpkList.get(0);
}
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTest.java
index 5deb5f31..d8f2e47f 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTest.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTest.java
@@ -23,70 +23,45 @@
package at.asitplus.eidas.specific.modules.auth.eidas.v2.test;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyList;
-import static org.mockito.Mockito.when;
-
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.security.MessageDigest;
-import java.util.List;
-import java.util.Objects;
-
-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 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.dao.ErnpEidData;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasSAuthenticationException;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.SzrCommunicationException;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.szr.SzrClient;
+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 com.skjolberg.mockito.soap.SoapServiceRule;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.cxf.binding.soap.SoapFault;
import org.joda.time.DateTime;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.*;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.util.Base64Utils;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
+import szrservices.*;
-import com.skjolberg.mockito.soap.SoapServiceRule;
+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 java.io.IOException;
+import java.util.List;
-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.dao.ErnpEidData;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasSAuthenticationException;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.SzrCommunicationException;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.szr.SzrClient;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasResponseUtils;
-import at.gv.e_government.reference.namespace.persondata._20020228.PersonNameType;
-import at.gv.e_government.reference.namespace.persondata._20020228.PhysicalPersonType;
-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.data.Triple;
-import at.gv.egiz.eaaf.core.impl.idp.auth.data.SimpleIdentityLinkAssertionParser;
-import at.gv.egiz.eaaf.core.impl.utils.DomUtils;
-import szrservices.GetBPKFromStammzahlEncryptedResponse;
-import szrservices.GetBPKFromStammzahlEncryptedResponseType;
-import szrservices.GetIdentityLinkEidasResponse;
-import szrservices.IdentityLinkType;
-import szrservices.PersonInfoType;
-import szrservices.SZR;
-import szrservices.SZRException_Exception;
-import szrservices.SignContentEntry;
-import szrservices.SignContentResponse;
-import szrservices.SignContentResponseType;
-import szrservices.TravelDocumentType;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyList;
+import static org.mockito.Mockito.when;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
@@ -98,14 +73,9 @@ public class SzrClientTest {
@Autowired SzrClient szrClient;
@Autowired MsConnectorDummyConfigMap basicConfig;
- private static final String givenName = "Franz";
- private static final String familyName = "Mustermann";
- private static final String dateOfBirth = "1989-05-05";
- private static final String eIDASeID = "IS/AT/1234sdgsdfg56789ABCDEF";
private static final String DUMMY_TARGET = EaafConstants.URN_PREFIX_CDID + "ZP";
private SZR szrMock = null;
- ErnpEidData eidData = null;
@Rule
public SoapServiceRule soap = SoapServiceRule.newInstance();
@@ -117,18 +87,9 @@ public class SzrClientTest {
public void initializer() {
if (szrMock == null) {
szrMock = soap.mock(SZR.class, "http://localhost:1234/demoszr");
-
}
- eidData = ErnpEidData.builder()
- .familyName(familyName)
- .givenName(givenName)
- .dateOfBirth(new DateTime())
- .citizenCountryCode("IS")
- .pseudonym("1234sdgsdfg56789ABCDEF").build();
-
basicConfig.putConfigValue("eidas.ms.auth.eIDAS.szrclient.eidasbind.mds.inject", "false");
-
}
@@ -144,13 +105,13 @@ public class SzrClientTest {
// .thenReturn(Arrays.asList(result1));
when(szrMock.getStammzahlEncrypted(any(), any())).thenReturn(result1.getKey());
- String stammzahlEncrypted = szrClient.getEncryptedStammzahl(new PersonInfoType());
+ String stammzahlEncrypted = szrClient.getEncryptedStammzahl(getEidData());
Assert.assertEquals("bcBind not match", result1.getKey(), stammzahlEncrypted);
when(szrMock.getStammzahlEncrypted(any(), any())).thenReturn(null);
try {
- szrClient.getEncryptedStammzahl(new PersonInfoType());
+ szrClient.getEncryptedStammzahl(getEidData());
} catch (SzrCommunicationException e) {
Assert.assertTrue("Not correct error", e.getMessage().contains("ernb.01"));
}
@@ -171,7 +132,7 @@ public class SzrClientTest {
final String bcBind = szrClient
.getEidasBind(RandomStringUtils.randomAlphabetic(10), RandomStringUtils.randomAlphabetic(10),
- RandomStringUtils.randomAlphabetic(10), eidData);
+ RandomStringUtils.randomAlphabetic(10), getEidData());
Assert.assertNotNull("bcBind is null", bcBind);
Assert.assertEquals("bcBind not match", result1.getValue(), bcBind);
@@ -185,7 +146,7 @@ public class SzrClientTest {
try {
szrClient
.getEidasBind(RandomStringUtils.randomAlphabetic(10), RandomStringUtils.randomAlphabetic(10),
- RandomStringUtils.randomAlphabetic(10), eidData);
+ RandomStringUtils.randomAlphabetic(10), getEidData());
} catch (SzrCommunicationException e) {
Assert.assertTrue("Not correct error", e.getMessage().contains("ernb.01"));
@@ -202,7 +163,7 @@ public class SzrClientTest {
try {
szrClient
.getEidasBind(RandomStringUtils.randomAlphabetic(10), RandomStringUtils.randomAlphabetic(10),
- RandomStringUtils.randomAlphabetic(10), eidData);
+ RandomStringUtils.randomAlphabetic(10), getEidData());
} catch (SzrCommunicationException e) {
Assert.assertTrue("Not correct error", e.getMessage().contains("ernb.01"));
@@ -220,7 +181,7 @@ public class SzrClientTest {
try {
szrClient
.getEidasBind(RandomStringUtils.randomAlphabetic(10), RandomStringUtils.randomAlphabetic(10),
- RandomStringUtils.randomAlphabetic(10), eidData);
+ RandomStringUtils.randomAlphabetic(10), getEidData());
} catch (SzrCommunicationException e) {
Assert.assertTrue("Not correct error", e.getMessage().contains("ernb.01"));
@@ -242,7 +203,7 @@ public class SzrClientTest {
final String bcBind = szrClient
.getEidasBind(RandomStringUtils.randomAlphabetic(10), RandomStringUtils.randomAlphabetic(10),
- RandomStringUtils.randomAlphabetic(10), eidData);
+ RandomStringUtils.randomAlphabetic(10), getEidData());
Assert.assertNotNull("bcBind is null", bcBind);
Assert.assertEquals("bcBind not match", result1.getValue(), bcBind);
@@ -266,7 +227,7 @@ public class SzrClientTest {
final String bcBind = szrClient
.getEidasBind(RandomStringUtils.randomAlphabetic(10), RandomStringUtils.randomAlphabetic(10),
- RandomStringUtils.randomAlphabetic(10), eidData);
+ RandomStringUtils.randomAlphabetic(10), getEidData());
Assert.assertNotNull("bcBind is null", bcBind);
Assert.assertEquals("bcBind not match", result1.getValue(), bcBind);
@@ -275,13 +236,12 @@ public class SzrClientTest {
@Test
public void getIdentityLinkRawModeValidResponse()
- throws SZRException_Exception, EaafParserException,
- EidasSAuthenticationException, JAXBException {
+ 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(getPersonInfo());
+ final IdentityLinkType result = szrClient.getIdentityLinkInRawMode(getEidData());
Assert.assertNotNull(result);
Assert.assertNotNull(result.getAssertion());
@@ -309,13 +269,12 @@ public class SzrClientTest {
@Test
public void getIdentityLinkRawModeErrorTravelerDocExists()
- throws SZRException_Exception, IOException,
- EidasSAuthenticationException, ParserConfigurationException, SAXException {
+ throws SZRException_Exception, IOException, ParserConfigurationException, SAXException {
setSzrExceptionIdentityLink("/data/szr/szr_resp_error_travelerdocexists.xml");
try {
log.debug("Starting connecting SZR Gateway");
- szrClient.getIdentityLinkInRawMode(getPersonInfo());
+ szrClient.getIdentityLinkInRawMode(getEidData());
Assert.fail();
} catch (final SzrCommunicationException e) {
@@ -335,7 +294,7 @@ public class SzrClientTest {
@Ignore
@Test
public void getBpkTest() throws EidasSAuthenticationException {
- final List<String> bPK = szrClient.getBpk(getPersonInfo(), DUMMY_TARGET, basicConfig
+ final List<String> bPK = szrClient.getBpk(getEidData(), DUMMY_TARGET, basicConfig
.getBasicConfiguration(Constants.CONIG_PROPS_EIDAS_SZRCLIENT_PARAMS_VKZ, "no VKZ defined"));
if (bPK.isEmpty()) {
@@ -382,46 +341,15 @@ public class SzrClientTest {
}
- private String createHashFromUniqueId(String uniqueId) throws EidasSAuthenticationException {
- try {
- final MessageDigest md = MessageDigest.getInstance("SHA-256");
- final byte[] hash = md.digest(uniqueId.getBytes(StandardCharsets.UTF_8));
- return new String(Base64Utils.encode(hash), StandardCharsets.UTF_8).replaceAll("\r\n", "");
-
- } catch (final Exception ex) {
- throw new EidasSAuthenticationException("internal.03", new Object[]{}, ex);
-
- }
+ private ErnpEidData getEidData() {
+ return ErnpEidData.builder()
+ .familyName("Mustermann")
+ .givenName("Franz")
+ .dateOfBirth(new DateTime(1989,5,5,1,1))
+ .citizenCountryCode("IS")
+ .pseudonym("1234sdgsdfg56789ABCDEF")
+ .build();
}
- private PersonInfoType getPersonInfo() throws EidasSAuthenticationException {
- final PersonInfoType personInfo = new PersonInfoType();
- final PersonNameType personName = new PersonNameType();
- final PhysicalPersonType naturalPerson = new PhysicalPersonType();
- final TravelDocumentType eDocument = new TravelDocumentType();
-
- naturalPerson.setName(personName);
- personInfo.setPerson(naturalPerson);
- personInfo.setTravelDocument(eDocument);
-
- // parse some eID attributes
- final Triple<String, String, String> eIdentifier = EidasResponseUtils.parseEidasPersonalIdentifier(eIDASeID);
- final String uniqueId = createHashFromUniqueId(Objects.requireNonNull(eIdentifier).getThird());
- final String citizenCountry = eIdentifier.getFirst();
-
- // person information
- personName.setFamilyName(familyName);
- personName.setGivenName(givenName);
- naturalPerson.setDateOfBirth(dateOfBirth);
- eDocument.setIssuingCountry(citizenCountry);
- eDocument.setDocumentNumber(uniqueId);
-
- // eID document information
- eDocument.setDocumentType(basicConfig
- .getBasicConfiguration(Constants.CONIG_PROPS_EIDAS_SZRCLIENT_PARAMS_EDOCUMENTTYPE,
- Constants.SZR_CONSTANTS_DEFAULT_DOCUMENT_TYPE));
-
- return personInfo;
- }
}
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTestProduction.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTestProduction.java
index 38829d67..33d72a59 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTestProduction.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTestProduction.java
@@ -23,11 +23,16 @@
package at.asitplus.eidas.specific.modules.auth.eidas.v2.test;
-import java.nio.charset.StandardCharsets;
-import java.security.MessageDigest;
-import java.util.List;
-import java.util.Objects;
-
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ErnpEidData;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasSAuthenticationException;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.SzrCommunicationException;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.szr.SzrClient;
+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 org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.bouncycastle.util.encoders.Base64;
@@ -43,26 +48,10 @@ 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.springframework.util.Base64Utils;
import org.w3c.dom.Element;
-
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ErnpEidData;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasSAuthenticationException;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.SzrCommunicationException;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.szr.SzrClient;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasResponseUtils;
-import at.gv.e_government.reference.namespace.persondata._20020228.PersonNameType;
-import at.gv.e_government.reference.namespace.persondata._20020228.PhysicalPersonType;
-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.data.Triple;
-import at.gv.egiz.eaaf.core.impl.idp.auth.data.SimpleIdentityLinkAssertionParser;
import szrservices.IdentityLinkType;
-import szrservices.PersonInfoType;
-import szrservices.TravelDocumentType;
+
+import java.util.List;
@IfProfileValue(name = "spring.profiles.active", value = "devEnvironment")
@@ -82,12 +71,6 @@ public class SzrClientTestProduction {
@Autowired
IConfiguration basicConfig;
- private static final String givenName = "Franz";
- private static final String familyName = "Mustermann";
- // private static final String dateOfBirth = "1989-05-05";
- private static final String dateOfBirth = "1989-05-04";
- private static final String eIDASeID = "IS/AT/1234ffgsdfg56789ABCDEF";
-
private static final String DUMMY_TARGET = EaafConstants.URN_PREFIX_CDID + "ZP";
@Test
@@ -97,7 +80,7 @@ public class SzrClientTestProduction {
@Test
public void getVsz() throws EidasSAuthenticationException {
- String vsz = szrClient.getEncryptedStammzahl(getPersonInfo());
+ String vsz = szrClient.getEncryptedStammzahl(getEidData());
Assert.assertNotNull("vsz", vsz);
}
@@ -107,15 +90,8 @@ public class SzrClientTestProduction {
String vsz = RandomStringUtils.randomAlphanumeric(10);
String bindingPubKey = Base64.toBase64String(RandomStringUtils.random(20).getBytes());
String eidStatus = "urn:eidgvat:eid.status.eidas";
- ErnpEidData eidData = ErnpEidData.builder()
- .familyName(familyName)
- .givenName(givenName)
- .dateOfBirth(new DateTime())
- .citizenCountryCode("IS")
- .pseudonym("1234sdgsdfg56789ABCDEF").build();
-
- String eidasBind = szrClient.getEidasBind(vsz, bindingPubKey, eidStatus, eidData);
+ String eidasBind = szrClient.getEidasBind(vsz, bindingPubKey, eidStatus, getEidData());
Assert.assertNotNull("eidasBind", eidasBind);
@@ -125,8 +101,7 @@ public class SzrClientTestProduction {
@Test
public void getIdentityLinkRawMode() throws EaafParserException, EidasSAuthenticationException {
log.debug("Starting connecting SZR Gateway");
- final IdentityLinkType result = szrClient.getIdentityLinkInRawMode(
- getPersonInfo());
+ final IdentityLinkType result = szrClient.getIdentityLinkInRawMode(getEidData());
final Element idlFromSzr = (Element) result.getAssertion();
final IIdentityLink identityLink = new SimpleIdentityLinkAssertionParser(idlFromSzr).parseIdentityLink();
@@ -171,10 +146,9 @@ public class SzrClientTestProduction {
@Ignore
@Test
public void getBpkTest() throws EidasSAuthenticationException {
- final List<String> bPK = szrClient.getBpk(getPersonInfo(), DUMMY_TARGET,
- basicConfig.getBasicConfiguration(
- Constants.CONIG_PROPS_EIDAS_SZRCLIENT_PARAMS_VKZ,
- "no VKZ defined"));
+ String vkz = basicConfig.getBasicConfiguration(
+ Constants.CONIG_PROPS_EIDAS_SZRCLIENT_PARAMS_VKZ, "no VKZ defined");
+ final List<String> bPK = szrClient.getBpk(getEidData(), DUMMY_TARGET, vkz);
if (bPK.isEmpty()) {
throw new SzrCommunicationException("ernb.01", new Object[]{"bPK list is empty"});
@@ -187,46 +161,14 @@ public class SzrClientTestProduction {
}
- private String createHashFromUniqueId(String uniqueId) throws EidasSAuthenticationException {
- try {
- final MessageDigest md = MessageDigest.getInstance("SHA-256");
- final byte[] hash = md.digest(uniqueId.getBytes(StandardCharsets.UTF_8));
- return new String(Base64Utils.encode(hash), StandardCharsets.UTF_8).replaceAll("\r\n", "");
-
- } catch (final Exception ex) {
- throw new EidasSAuthenticationException("internal.03", new Object[] {}, ex);
-
- }
+ private ErnpEidData getEidData() {
+ return ErnpEidData.builder()
+ .familyName("Mustermann")
+ .givenName("Franz")
+ .dateOfBirth(new DateTime(1989,5,4,1,1))
+ .citizenCountryCode("IS")
+ .pseudonym("1234ffgsdfg56789ABCDEF")
+ .build();
}
- private PersonInfoType getPersonInfo() throws EidasSAuthenticationException {
- final PersonInfoType personInfo = new PersonInfoType();
- final PersonNameType personName = new PersonNameType();
- final PhysicalPersonType naturalPerson = new PhysicalPersonType();
- final TravelDocumentType eDocument = new TravelDocumentType();
-
- naturalPerson.setName(personName);
- personInfo.setPerson(naturalPerson);
- personInfo.setTravelDocument(eDocument);
-
- // parse some eID attributes
- final Triple<String, String, String> eIdentifier =
- EidasResponseUtils.parseEidasPersonalIdentifier(eIDASeID);
- final String uniqueId = createHashFromUniqueId(Objects.requireNonNull(eIdentifier).getThird());
- final String citizenCountry = eIdentifier.getFirst();
-
- // person information
- personName.setFamilyName(familyName);
- personName.setGivenName(givenName);
- naturalPerson.setDateOfBirth(dateOfBirth);
- eDocument.setIssuingCountry(citizenCountry);
- eDocument.setDocumentNumber(uniqueId);
-
- // eID document information
- eDocument.setDocumentType(basicConfig.getBasicConfiguration(
- Constants.CONIG_PROPS_EIDAS_SZRCLIENT_PARAMS_EDOCUMENTTYPE,
- Constants.SZR_CONSTANTS_DEFAULT_DOCUMENT_TYPE));
-
- return personInfo;
- }
}