aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Kollmann <christian.kollmann@a-sit.at>2021-03-04 17:47:41 +0100
committerChristian Kollmann <christian.kollmann@a-sit.at>2021-03-04 17:47:41 +0100
commit27f2e48e6a585e2d1462b60214b5cfcd8f40680b (patch)
tree9825839ab326ba77c7c4682bd7fcc77bee924a70
parent9df463ce8c8567a8f70c4f8f1988f5ae299b6369 (diff)
downloadNational_eIDAS_Gateway-27f2e48e6a585e2d1462b60214b5cfcd8f40680b.tar.gz
National_eIDAS_Gateway-27f2e48e6a585e2d1462b60214b5cfcd8f40680b.tar.bz2
National_eIDAS_Gateway-27f2e48e6a585e2d1462b60214b5cfcd8f40680b.zip
Copy post processing eIDAS attributes to InitialSearchTask
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java1
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/AbstractEidProcessor.java11
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateIdentityLinkTask.java2
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/InitialSearchTask.java43
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java37
5 files changed, 51 insertions, 43 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 748994bb..9409509b 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
@@ -35,6 +35,7 @@ import org.apache.commons.lang3.builder.EqualsBuilder;
@Builder
public class SimpleEidasData {
+ private final String personalIdentifier;
private final String citizenCountryCode;
// MDS
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/AbstractEidProcessor.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/AbstractEidProcessor.java
index f97517d5..6d067e69 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/AbstractEidProcessor.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/AbstractEidProcessor.java
@@ -54,6 +54,7 @@ import eu.eidas.auth.commons.light.impl.LightRequest.Builder;
import eu.eidas.auth.commons.protocol.eidas.SpType;
import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.eIDAS_ATTR_PERSONALIDENTIFIER;
+import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.eIDAS_ATTR_TAXREFERENCE;
import static at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasResponseUtils.processCountryCode;
import static at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasResponseUtils.processDateOfBirthToString;
@@ -77,7 +78,7 @@ public abstract class AbstractEidProcessor implements INationalEidProcessor {
@Override
public final SimpleEidasData postProcess(Map<String, Object> eidasAttrMap) throws EidPostProcessingException,
EidasAttributeException {
- return SimpleEidasData.builder()
+ SimpleEidasData.SimpleEidasDataBuilder builder = SimpleEidasData.builder()
// MDS attributes
.citizenCountryCode(processCountryCode(eidasAttrMap.get(eIDAS_ATTR_PERSONALIDENTIFIER)))
.pseudonym(processPseudonym(eidasAttrMap.get(Constants.eIDAS_ATTR_PERSONALIDENTIFIER)))
@@ -87,9 +88,11 @@ public abstract class AbstractEidProcessor implements INationalEidProcessor {
// additional attributes
.placeOfBirth(processPlaceOfBirth(eidasAttrMap.get(Constants.eIDAS_ATTR_PLACEOFBIRTH)))
.birthName(processBirthName(eidasAttrMap.get(Constants.eIDAS_ATTR_BIRTHNAME)))
- .address(processAddress(eidasAttrMap.get(Constants.eIDAS_ATTR_CURRENTADDRESS)))
- //.taxNumber(processTaxReference(eidasAttrMap.get(Constants.eIDAS_ATTR_TAXREFERENCE)))
- .build();
+ .address(processAddress(eidasAttrMap.get(Constants.eIDAS_ATTR_CURRENTADDRESS)));
+ if (eidasAttrMap.containsKey(eIDAS_ATTR_TAXREFERENCE)) {
+ builder.taxNumber(EidasResponseUtils.processTaxReference(eidasAttrMap.get(eIDAS_ATTR_TAXREFERENCE)));
+ }
+ return builder.build();
}
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 f70f0f85..66e7eb65 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
@@ -134,10 +134,10 @@ public class CreateIdentityLinkTask extends AbstractAuthServletTask {
.getGenericDataFromSession(Constants.DATA_FULL_EIDAS_RESPONSE, ILightResponse.class);
final Map<String, Object> eidasAttributes = convertEidasAttrToSimpleMap(
eidasResponse.getAttributes().getAttributeMap());
- final String personalIdentifier = (String) eidasAttributes.get(Constants.eIDAS_ATTR_PERSONALIDENTIFIER);
final SimpleEidasData eidData = eidPostProcessor.postProcess(eidasAttributes);
//final SimpleEidasData eidData =
getAuthProcessDataWrapper().getGenericDataFromSession(Constants.DATA_SIMPLE_EIDAS, SimpleEidasData.class);
+ final String personalIdentifier = (String) eidasAttributes.get(Constants.eIDAS_ATTR_PERSONALIDENTIFIER);
writeMdsLogInformation(eidData);
if (basicConfig.getBasicConfigurationBoolean(Constants.CONIG_PROPS_EIDAS_SZRCLIENT_DEBUG_USEDUMMY, false)) {
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 89b5444f..b917de21 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
@@ -26,10 +26,12 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.MergedRegisterSearchResult;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData;
+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.ManualFixNecessaryException;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.WorkflowException;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.CountrySpecificDetailSearchProcessor;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.ICcSpecificEidProcessingService;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasResponseUtils;
import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext;
@@ -58,14 +60,6 @@ import java.util.Map;
import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_TASK;
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.Constants.eIDAS_ATTR_BIRTHNAME;
-import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.eIDAS_ATTR_CURRENTADDRESS;
-import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.eIDAS_ATTR_CURRENTFAMILYNAME;
-import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.eIDAS_ATTR_CURRENTGIVENNAME;
-import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.eIDAS_ATTR_DATEOFBIRTH;
-import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.eIDAS_ATTR_PERSONALIDENTIFIER;
-import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.eIDAS_ATTR_PLACEOFBIRTH;
-import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.eIDAS_ATTR_TAXREFERENCE;
/**
* Task that searches registers (ERnP and ZMR) before adding person to SZR.
@@ -101,17 +95,20 @@ public class InitialSearchTask extends AbstractAuthServletTask {
private final List<CountrySpecificDetailSearchProcessor> handlers;
private final RegisterSearchService registerSearchService;
+ private final ICcSpecificEidProcessingService eidPostProcessor;
/**
* Constructor.
- *
- * @param handlers List of countrySpecificSearchProcessors
+ * @param handlers List of countrySpecificSearchProcessors
* @param registerSearchService Service for register search access
+ * @param eidPostProcessor Country-Specific post processing of attributes
*/
public InitialSearchTask(List<CountrySpecificDetailSearchProcessor> handlers,
- RegisterSearchService registerSearchService) {
+ RegisterSearchService registerSearchService,
+ ICcSpecificEidProcessingService eidPostProcessor) {
this.registerSearchService = registerSearchService;
this.handlers = handlers;
+ this.eidPostProcessor = eidPostProcessor;
log.info("Init with {} country specific detail search services", handlers.size());
}
@@ -237,31 +234,11 @@ public class InitialSearchTask extends AbstractAuthServletTask {
@NotNull
private SimpleEidasData convertEidasAttrToSimpleData()
- throws EidasAttributeException {
+ throws EidasAttributeException, EidPostProcessingException {
final ILightResponse eidasResponse = getAuthProcessDataWrapper()
.getGenericDataFromSession(Constants.DATA_FULL_EIDAS_RESPONSE, ILightResponse.class);
Map<String, Object> simpleMap = convertEidasAttrToSimpleMap(eidasResponse.getAttributes().getAttributeMap());
- return convertSimpleMapToSimpleData(simpleMap);
- }
-
- private SimpleEidasData convertSimpleMapToSimpleData(Map<String, Object> eidasAttrMap)
- throws EidasAttributeException {
- 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)) {
- builder.taxNumber(EidasResponseUtils.processTaxReference(eidasAttrMap.get(eIDAS_ATTR_TAXREFERENCE)));
- }
- //TODO other additional attributes
- return builder.build();
+ return eidPostProcessor.postProcess(simpleMap);
}
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/InitialSearchTaskTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java
index c9f123dc..643afb90 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
@@ -25,13 +25,19 @@ 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.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.ManualFixNecessaryException;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.DeSpecificDetailSearchProcessor;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.GenericEidProcessor;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.ItSpecificDetailSearchProcessor;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.ICcSpecificEidProcessingService;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.InitialSearchTask;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient;
+import at.gv.egiz.eaaf.core.api.IRequest;
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;
@@ -41,6 +47,7 @@ import at.gv.egiz.eaaf.core.impl.idp.process.ExecutionContextImpl;
import eu.eidas.auth.commons.attribute.AttributeDefinition;
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;
@@ -65,6 +72,7 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Map;
import java.util.Random;
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
@@ -86,6 +94,7 @@ public class InitialSearchTaskTest {
private IZmrClient zmrClient;
@Mock
private IErnpClient ernpClient;
+ private final ICcSpecificEidProcessingService eidPostProcessor = createEidPostProcessor();
private RegisterSearchService registerSearchService;
final ExecutionContext executionContext = new ExecutionContextImpl();
@@ -106,7 +115,7 @@ public class InitialSearchTaskTest {
public void setUp() throws URISyntaxException, EaafStorageException {
MockitoAnnotations.initMocks(this);
registerSearchService = new RegisterSearchService(zmrClient, ernpClient);
- task = new InitialSearchTask(new ArrayList<>(), registerSearchService);
+ task = new InitialSearchTask(new ArrayList<>(), registerSearchService, eidPostProcessor);
MockHttpServletRequest httpReq = new MockHttpServletRequest("POST", "https://localhost/authhandler");
MockHttpServletResponse httpResp = new MockHttpServletResponse();
@@ -119,6 +128,24 @@ public class InitialSearchTaskTest {
.setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response);
}
+ @NotNull
+ private ICcSpecificEidProcessingService createEidPostProcessor() {
+ return new ICcSpecificEidProcessingService() {
+
+ private final GenericEidProcessor genericEidProcessor = new GenericEidProcessor();
+
+ @Override
+ public SimpleEidasData postProcess(Map<String, Object> eidasAttrMap) throws EidPostProcessingException, EidasAttributeException {
+ return genericEidProcessor.postProcess(eidasAttrMap);
+ }
+
+ @Override
+ public void preProcess(String selectedCC, IRequest pendingReq, LightRequest.Builder authnRequestBuilder) {
+ genericEidProcessor.preProcess(pendingReq, authnRequestBuilder);
+ }
+ };
+ }
+
/**
* One match, but register update needed
*/
@@ -245,7 +272,7 @@ public class InitialSearchTaskTest {
Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList());
task = new InitialSearchTask(
Collections.singletonList(new ItSpecificDetailSearchProcessor(registerSearchService)),
- registerSearchService);
+ registerSearchService, eidPostProcessor);
task.execute(pendingReq1, executionContext);
@@ -273,7 +300,7 @@ public class InitialSearchTaskTest {
Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList());
task = new InitialSearchTask(
Collections.singletonList(new DeSpecificDetailSearchProcessor(registerSearchService)),
- registerSearchService);
+ registerSearchService, eidPostProcessor);
task.execute(pendingReq1, executionContext);
@@ -307,7 +334,7 @@ public class InitialSearchTaskTest {
Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList());
task = new InitialSearchTask(
Collections.singletonList(new DeSpecificDetailSearchProcessor(registerSearchService)),
- registerSearchService);
+ registerSearchService, eidPostProcessor);
TaskExecutionException exception = assertThrows(TaskExecutionException.class,
() -> task.execute(pendingReq1, executionContext));
@@ -340,7 +367,7 @@ public class InitialSearchTaskTest {
Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList());
task = new InitialSearchTask(
Collections.singletonList(new ItSpecificDetailSearchProcessor(registerSearchService)),
- registerSearchService);
+ registerSearchService, eidPostProcessor);
TaskExecutionException exception = assertThrows(TaskExecutionException.class,
() -> task.execute(pendingReq1, executionContext));