diff options
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2')
4 files changed, 41 insertions, 42 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 f60a9906..748994bb 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 @@ -26,28 +26,28 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.dao; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.WorkflowException; import at.gv.e_government.reference.namespace.persondata._20020228.PostalAddressType; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import org.apache.commons.lang3.builder.EqualsBuilder; @Data -@AllArgsConstructor -@NoArgsConstructor +@Builder public class SimpleEidasData { - private String citizenCountryCode; + private final String citizenCountryCode; // MDS - private String pseudonym; - private String givenName; - private String familyName; - private String dateOfBirth; + private final String pseudonym; + private final String givenName; + private final String familyName; + private final String dateOfBirth; // additional attributes - private String placeOfBirth; - private String birthName; - private PostalAddressType address; - private String taxNumber; + private final String placeOfBirth; + private final String birthName; + private final PostalAddressType address; + private final String taxNumber; /** * Compares the register result with the eidas data. 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 d7bec42b..89b5444f 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 @@ -246,23 +246,22 @@ public class InitialSearchTask extends AbstractAuthServletTask { private SimpleEidasData convertSimpleMapToSimpleData(Map<String, Object> eidasAttrMap) throws EidasAttributeException { - SimpleEidasData result = new SimpleEidasData(); - result.setCitizenCountryCode(EidasResponseUtils.processCountryCode( - eidasAttrMap.get(eIDAS_ATTR_PERSONALIDENTIFIER))); - // MDS attributes - result.setPseudonym(EidasResponseUtils.processPseudonym(eidasAttrMap.get(eIDAS_ATTR_PERSONALIDENTIFIER))); - result.setFamilyName(EidasResponseUtils.processFamilyName(eidasAttrMap.get(eIDAS_ATTR_CURRENTFAMILYNAME))); - result.setGivenName(EidasResponseUtils.processGivenName(eidasAttrMap.get(eIDAS_ATTR_CURRENTGIVENNAME))); - result.setDateOfBirth(EidasResponseUtils.processDateOfBirthToString(eidasAttrMap.get(eIDAS_ATTR_DATEOFBIRTH))); - // additional attributes - result.setPlaceOfBirth(EidasResponseUtils.processPlaceOfBirth(eidasAttrMap.get(eIDAS_ATTR_PLACEOFBIRTH))); - result.setBirthName(EidasResponseUtils.processBirthName(eidasAttrMap.get(eIDAS_ATTR_BIRTHNAME))); - result.setAddress(EidasResponseUtils.processAddress(eidasAttrMap.get(eIDAS_ATTR_CURRENTADDRESS))); + SimpleEidasData.SimpleEidasDataBuilder builder = SimpleEidasData.builder() + .citizenCountryCode(EidasResponseUtils.processCountryCode(eidasAttrMap.get(eIDAS_ATTR_PERSONALIDENTIFIER))) + // MDS attributes + .pseudonym(EidasResponseUtils.processPseudonym(eidasAttrMap.get(eIDAS_ATTR_PERSONALIDENTIFIER))) + .familyName(EidasResponseUtils.processFamilyName(eidasAttrMap.get(eIDAS_ATTR_CURRENTFAMILYNAME))) + .givenName(EidasResponseUtils.processGivenName(eidasAttrMap.get(eIDAS_ATTR_CURRENTGIVENNAME))) + .dateOfBirth(EidasResponseUtils.processDateOfBirthToString(eidasAttrMap.get(eIDAS_ATTR_DATEOFBIRTH))) + // additional attributes + .placeOfBirth(EidasResponseUtils.processPlaceOfBirth(eidasAttrMap.get(eIDAS_ATTR_PLACEOFBIRTH))) + .birthName(EidasResponseUtils.processBirthName(eidasAttrMap.get(eIDAS_ATTR_BIRTHNAME))) + .address(EidasResponseUtils.processAddress(eidasAttrMap.get(eIDAS_ATTR_CURRENTADDRESS))); if (eidasAttrMap.containsKey(eIDAS_ATTR_TAXREFERENCE)) { - result.setTaxNumber(EidasResponseUtils.processTaxReference(eidasAttrMap.get(eIDAS_ATTR_TAXREFERENCE))); + builder.taxNumber(EidasResponseUtils.processTaxReference(eidasAttrMap.get(eIDAS_ATTR_TAXREFERENCE))); } //TODO other additional attributes - return result; + return builder.build(); } private Map<String, Object> convertEidasAttrToSimpleMap( 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 38693f49..d9405251 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 @@ -175,11 +175,12 @@ public class ReceiveAustrianResidenceGuiResponseTaskTest { @NotNull private SimpleEidasData setupEidasData() throws EaafStorageException { - SimpleEidasData result = new SimpleEidasData(); - result.setPseudonym(RandomStringUtils.randomAlphabetic(8)); - result.setFamilyName(RandomStringUtils.randomAlphabetic(8)); - result.setGivenName(RandomStringUtils.randomAlphabetic(8)); - result.setDateOfBirth("1970-01-01"); + 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; 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 01688214..77b87264 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 @@ -314,8 +314,9 @@ public class ReceiveMobilePhoneSignatureResponseTaskTest { setupMetadataResolver(); initResponse("/data/Response_with_EID.xml", true); AuthProcessDataWrapper authProcessData = pendingReq.getSessionData(AuthProcessDataWrapper.class); - SimpleEidasData eidData = createEidasDataMatchingToSamlResponse(); - eidData.setFamilyName(eidData.getFamilyName() + "notmatching"); + SimpleEidasData eidData = createEidasDataMatchingToSamlResponse() + .familyName("notmatching") + .build(); authProcessData.setGenericDataToSession(Constants.DATA_SIMPLE_EIDAS, eidData); TaskExecutionException e = assertThrows(TaskExecutionException.class, @@ -331,7 +332,7 @@ public class ReceiveMobilePhoneSignatureResponseTaskTest { setupMetadataResolver(); initResponse("/data/Response_with_EID.xml", true); AuthProcessDataWrapper authProcessData = pendingReq.getSessionData(AuthProcessDataWrapper.class); - SimpleEidasData eidData = createEidasDataMatchingToSamlResponse(); + SimpleEidasData eidData = createEidasDataMatchingToSamlResponse().build(); authProcessData.setGenericDataToSession(Constants.DATA_SIMPLE_EIDAS, eidData); MergedRegisterSearchResult registerSearchResult = new MergedRegisterSearchResult(Collections.emptyList(), Collections.emptyList()); Mockito.when(registerSearchService.searchWithBpkZp(eq(BPK_FROM_ID_AUSTRIA))).thenReturn(registerSearchResult); @@ -350,7 +351,7 @@ public class ReceiveMobilePhoneSignatureResponseTaskTest { setupMetadataResolver(); initResponse("/data/Response_with_EID.xml", true); AuthProcessDataWrapper authProcessData = pendingReq.getSessionData(AuthProcessDataWrapper.class); - SimpleEidasData eidData = createEidasDataMatchingToSamlResponse(); + SimpleEidasData eidData = createEidasDataMatchingToSamlResponse().build(); authProcessData.setGenericDataToSession(Constants.DATA_SIMPLE_EIDAS, eidData); MergedRegisterSearchResult registerSearchResult = buildResultWithOneMatch(); Mockito.when(registerSearchService.searchWithBpkZp(eq(BPK_FROM_ID_AUSTRIA))).thenReturn(registerSearchResult); @@ -370,7 +371,7 @@ public class ReceiveMobilePhoneSignatureResponseTaskTest { setupMetadataResolver(); initResponse("/data/Response_with_EID.xml", true); AuthProcessDataWrapper authProcessData = pendingReq.getSessionData(AuthProcessDataWrapper.class); - SimpleEidasData eidData = createEidasDataMatchingToSamlResponse(); + SimpleEidasData eidData = createEidasDataMatchingToSamlResponse().build(); authProcessData.setGenericDataToSession(Constants.DATA_SIMPLE_EIDAS, eidData); MergedRegisterSearchResult registerSearchResult = buildResultWithTwoMatches(); Mockito.when(registerSearchService.searchWithBpkZp(eq(BPK_FROM_ID_AUSTRIA))).thenReturn(registerSearchResult); @@ -400,14 +401,12 @@ public class ReceiveMobilePhoneSignatureResponseTaskTest { return new MergedRegisterSearchResult(results, Collections.emptyList()); } - @NotNull - private SimpleEidasData createEidasDataMatchingToSamlResponse() { + private SimpleEidasData.SimpleEidasDataBuilder createEidasDataMatchingToSamlResponse() { // data from "/data/Response_with_EID.xml" - SimpleEidasData result = new SimpleEidasData(); - result.setFamilyName("Mustermann"); - result.setGivenName("Max"); - result.setDateOfBirth("1940-01-01"); - return result; + return SimpleEidasData.builder() + .familyName("Mustermann") + .givenName("Max") + .dateOfBirth("1940-01-01"); } private void addSamlResponseToHttpReq(Response response) throws TransformerException, IOException, MarshallingException { |