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/Constants.java1
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/DeSpecificDetailSearchProcessor.java18
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ICountrySpecificDetailSearchProcessor.java29
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ItSpecificDetailSearchProcessor.java16
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/InitialSearchTask.java72
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/utils/EidasResponseUtils.java17
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskFirstTest.java305
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/resources/SpringTest-context_tasks_test.xml7
8 files changed, 328 insertions, 137 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 cc275f24..145cf262 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
@@ -140,6 +140,7 @@ public class Constants {
public static final String eIDAS_ATTR_PLACEOFBIRTH = "PlaceOfBirth";
public static final String eIDAS_ATTR_BIRTHNAME = "BirthName";
public static final String eIDAS_ATTR_CURRENTADDRESS = "CurrentAddress";
+ public static final String eIDAS_ATTR_TAXREFERENCE = "TaxReference";
public static final String eIDAS_ATTR_LEGALPERSONIDENTIFIER = "LegalPersonIdentifier";
public static final String eIDAS_ATTR_LEGALNAME = "LegalName";
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/DeSpecificDetailSearchProcessor.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/DeSpecificDetailSearchProcessor.java
index 9fa13fe8..51d6952f 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/DeSpecificDetailSearchProcessor.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/DeSpecificDetailSearchProcessor.java
@@ -3,24 +3,10 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.handler;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.MergedRegisterSearchResult;
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.ernb.IErnbClient;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient;
-import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
-public class DeSpecificDetailSearchProcessor implements ICountrySpecificDetailSearchProcessor {
-
- @Autowired
- private IErnbClient ernbClient;
-
- @Autowired
- private IZmrClient zmrClient;
-
- @Override
- public String getName() {
- return this.getClass().getName();
- }
+public class DeSpecificDetailSearchProcessor extends ICountrySpecificDetailSearchProcessor {
@Override
public boolean canHandle(String countryCode, SimpleEidasData eidData) {
@@ -47,7 +33,7 @@ public class DeSpecificDetailSearchProcessor implements ICountrySpecificDetailSe
ArrayList<RegisterResult> resultsErnb =
ernbClient.searchDeSpecific(eidData.getGivenName(), eidData.getFamilyName(), eidData.getDateOfBirth(),
- eidData.getPlaceOfBirth(), eidData.getBirthName());
+ eidData.getPlaceOfBirth(), eidData.getBirthName());
searchResult.setResultsErnb(resultsErnb);
return searchResult;
}
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ICountrySpecificDetailSearchProcessor.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ICountrySpecificDetailSearchProcessor.java
index 887aef4a..3d6b35e9 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ICountrySpecificDetailSearchProcessor.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ICountrySpecificDetailSearchProcessor.java
@@ -25,25 +25,44 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.handler;
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.ernb.IErnbClient;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient;
+import org.springframework.beans.factory.annotation.Autowired;
-public interface ICountrySpecificDetailSearchProcessor {
+public abstract class ICountrySpecificDetailSearchProcessor {
+
+
+ protected IErnbClient ernbClient;
+ protected IZmrClient zmrClient;
+
+ @Autowired
+ public void setErnbClient(IErnbClient ernbClient) {
+ this.ernbClient = ernbClient;
+ }
+
+ @Autowired
+ public void setZmrClient(IZmrClient zmrClient) {
+ this.zmrClient = zmrClient;
+ }
/**
* Get a friendlyName of this post-processor implementation.
*
* @return
*/
- String getName();
+ public String getName() {
+ return this.getClass().getName();
+ }
/**
* Check if this postProcessor is sensitive for a specific country.
*
* @param countryCode of the eID data that should be processed
- * @param eidData eID data
+ * @param eidData eID data
* @return true if this implementation can handle the country, otherwise false
*/
- boolean canHandle(String countryCode, SimpleEidasData eidData);
+ public abstract boolean canHandle(String countryCode, SimpleEidasData eidData);
- MergedRegisterSearchResult search(SimpleEidasData eidData);
+ public abstract MergedRegisterSearchResult search(SimpleEidasData eidData);
}
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ItSpecificDetailSearchProcessor.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ItSpecificDetailSearchProcessor.java
index e3b9e702..d055345a 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ItSpecificDetailSearchProcessor.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ItSpecificDetailSearchProcessor.java
@@ -3,24 +3,10 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.handler;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.MergedRegisterSearchResult;
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.ernb.IErnbClient;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient;
-import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
-public class ItSpecificDetailSearchProcessor implements ICountrySpecificDetailSearchProcessor {
-
- @Autowired
- private IErnbClient ernbClient;
-
- @Autowired
- private IZmrClient zmrClient;
-
- @Override
- public String getName() {
- return this.getClass().getName();
- }
+public class ItSpecificDetailSearchProcessor extends ICountrySpecificDetailSearchProcessor {
@Override
public boolean canHandle(String countryCode, SimpleEidasData eidData) {
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 9df24e9f..e722200c 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
@@ -25,11 +25,9 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -50,6 +48,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.ernb.IErnbClient;
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.ICountrySpecificDetailSearchProcessor;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasResponseUtils;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient;
@@ -74,52 +73,14 @@ import lombok.extern.slf4j.Slf4j;
@Component("InitialSearchTask")
public class InitialSearchTask extends AbstractAuthServletTask {
- private final List<ICountrySpecificDetailSearchProcessor> handlers = new ArrayList<>();
+ private List<ICountrySpecificDetailSearchProcessor> handlers = new ArrayList<>();
- // @Autowired
- // private AuthBlockSigningService authBlockSigner;
- // @Autowired
- // private IConfiguration basicConfig;
- // @Autowired
- // private SzrClient szrClient;
- // @Autowired
- // private ICcSpecificEidProcessingService eidPostProcessor;
-
- // private static final String EID_STATUS = "urn:eidgvat:eid.status.eidas";
@Autowired
private ApplicationContext context;
- @Autowired
private IErnbClient ernbClient;
-
- @Autowired
private IZmrClient zmrClient;
- @PostConstruct
- private void initialize() {
- log.debug("Initialize country specific detail search services ... ");
- final Map<String, ICountrySpecificDetailSearchProcessor> postProcessors = context.getBeansOfType(
- ICountrySpecificDetailSearchProcessor.class);
- final Iterator<Map.Entry<String, ICountrySpecificDetailSearchProcessor>> iterator =
- postProcessors.entrySet().iterator();
- while (iterator.hasNext()) {
- final Map.Entry<String, ICountrySpecificDetailSearchProcessor> el = iterator.next();
- log.debug("Find country specific detail search services with name: " + el.getKey());
- handlers.add(el.getValue());
-
- }
-
- // log.trace("Sorting country specific detail search services on priority ... ");
- // Collections.sort(handlers, (thisAuthModule, otherAuthModule) -> {
- // final int thisOrder = thisAuthModule.getPriority();
- // final int otherOrder = otherAuthModule.getPriority();
- // return thisOrder < otherOrder ? 1 : thisOrder == otherOrder ? 0 : -1;
- // });
-
- log.info("# " + handlers.size() + " country specific detail search services are registrated");
-
- }
-
/*
* (non-Javadoc)
*
@@ -136,6 +97,9 @@ public class InitialSearchTask extends AbstractAuthServletTask {
final ILightResponse eidasResponse = authProcessData
.getGenericDataFromSession(Constants.DATA_FULL_EIDAS_RESPONSE, ILightResponse.class);
+ ImmutableMap<AttributeDefinition<?>, ImmutableSet<? extends AttributeValue<?>>> aa =
+ eidasResponse.getAttributes().getAttributeMap();
+
final Map<String, Object> simpleAttrMap = convertEidasAttrToSimpleMap(
eidasResponse.getAttributes().getAttributeMap());
@@ -143,7 +107,7 @@ public class InitialSearchTask extends AbstractAuthServletTask {
final SimpleEidasData eidData = convertSimpleMapToSimpleData(simpleAttrMap);
String bpK = step2(eidData);
- authProcessData.setGenericDataToSession(Constants.DATA_RESULT_MATCHING_BPK,bpK);
+ authProcessData.setGenericDataToSession(Constants.DATA_RESULT_MATCHING_BPK, bpK);
} catch (final Exception e) {
log.error("Initial search FAILED.", e);
throw new TaskExecutionException(pendingReq, "Initial search FAILED.", e);
@@ -160,7 +124,7 @@ public class InitialSearchTask extends AbstractAuthServletTask {
return step3(result, eidData);
} //else if (result.getResultCount() > 1) {
throw new TaskExecutionException(pendingReq, "Initial search - Kitt Process necessary.",
- new ManualFixNecessaryException(personIdentifier));
+ new ManualFixNecessaryException(personIdentifier));
// }
// return null;
}
@@ -192,6 +156,11 @@ public class InitialSearchTask extends AbstractAuthServletTask {
simpleEidasData.setAddress(EidasResponseUtils.processAddress(
eidasAttrMap.get(Constants.eIDAS_ATTR_CURRENTADDRESS)));
+ if (eidasAttrMap.containsKey(Constants.eIDAS_ATTR_TAXREFERENCE)) {
+ simpleEidasData.setTaxNumber(EidasResponseUtils.processTaxReference(
+ eidasAttrMap.get(Constants.eIDAS_ATTR_TAXREFERENCE)));
+ }
+
//TODO other additional attributes
return simpleEidasData;
}
@@ -214,10 +183,10 @@ public class InitialSearchTask extends AbstractAuthServletTask {
}
private String step4(MergedRegisterSearchResult result,
- SimpleEidasData eidData) throws WorkflowException {
+ SimpleEidasData eidData) throws WorkflowException {
log.debug("Update " + result + " with " + eidData);
//TODO
-
+
return result.getBpk();
}
@@ -245,7 +214,7 @@ public class InitialSearchTask extends AbstractAuthServletTask {
}
private String step6(ICountrySpecificDetailSearchProcessor countrySpecificDetailSearchProcessor,
- MergedRegisterSearchResult initialSearchResult, SimpleEidasData eidData)
+ MergedRegisterSearchResult initialSearchResult, SimpleEidasData eidData)
throws TaskExecutionException {
//6 country specific search
MergedRegisterSearchResult countrySpecificDetailSearchResult =
@@ -277,7 +246,7 @@ public class InitialSearchTask extends AbstractAuthServletTask {
}
private String step8(MergedRegisterSearchResult initialSearchResult,
- SimpleEidasData eidData) {
+ SimpleEidasData eidData) {
MergedRegisterSearchResult mdsSearchResult = new MergedRegisterSearchResult();
ArrayList<RegisterResult> resultsZmr =
@@ -357,11 +326,20 @@ public class InitialSearchTask extends AbstractAuthServletTask {
//just for testing
//TODO is there a nicer solution?
+ @Autowired
public void setErnbClient(IErnbClient ernbClient) {
this.ernbClient = ernbClient;
}
+ @Autowired
public void setZmrClient(IZmrClient zmrClient) {
this.zmrClient = zmrClient;
}
+
+ @Autowired
+ public void setHandlers(List<ICountrySpecificDetailSearchProcessor> handlers) {
+ this.handlers = handlers;
+ log.info("# " + handlers.size() + " country specific detail search services are registrated");
+ }
+
}
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/utils/EidasResponseUtils.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/utils/EidasResponseUtils.java
index 54928eb7..aaa4212a 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/utils/EidasResponseUtils.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/utils/EidasResponseUtils.java
@@ -359,6 +359,23 @@ public class EidasResponseUtils {
EidasResponseUtils.parseEidasPersonalIdentifier((String) personalIdObj);
return eIdentifier.getThird();
+ }
+
+ /**
+ * Post-Process the eIDAS TaxReference attribute.
+ *
+ * @param taxReferenceObj eIDAS TaxReference attribute information
+ * @return formated user's TaxReference
+ * @throws EidasAttributeException if NO attribute is available
+ * @throws EidPostProcessingException if post-processing fails
+ */
+ public static String processTaxReference(Object taxReferenceObj) throws EidPostProcessingException,
+ EidasAttributeException {
+ if (taxReferenceObj == null || !(taxReferenceObj instanceof String)) {
+ throw new EidasAttributeException(Constants.eIDAS_ATTR_CURRENTGIVENNAME);
+ }
+
+ return (String) taxReferenceObj;
}
}
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskFirstTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskFirstTest.java
index 5c75d1e4..64a73bda 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskFirstTest.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskFirstTest.java
@@ -5,6 +5,9 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.ernb.DummyErnbClient;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.ernb.IErnbClient;
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.ICountrySpecificDetailSearchProcessor;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.ItSpecificDetailSearchProcessor;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.InitialSearchTask;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.DummyZmrClient;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient;
@@ -25,7 +28,6 @@ import org.jetbrains.annotations.NotNull;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
@@ -47,6 +49,7 @@ import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
+import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class)
@@ -107,54 +110,55 @@ public class InitialSearchTaskFirstTest {
@Test
@DirtiesContext
/**
- * Two matches found in ZMR
+ * One match, but register update needed
*/
- public void testNode101a() throws Exception {
+ public void testNode100a() throws Exception {
//Mock ZMR
ArrayList<RegisterResult> zmrResult = new ArrayList<>();
- zmrResult.add(new RegisterResult("bpkMax","de/st/max123", "Max", "Mustermann", "1111-01-01"));
- zmrResult.add(new RegisterResult("bpkMax","de/st/max123", "Maximilian", "Mustermann", "1111-01-01"));
+ String randomBpk = RandomStringUtils.randomNumeric(6);
+ zmrResult.add(new RegisterResult(randomBpk,"de/st/max123", "Max_new", "Mustermann", "2011-01-01"));
+
zmrClient = Mockito.mock(DummyZmrClient.class);
Mockito.when(zmrClient.searchWithPersonIdentifer("max123")).thenReturn(zmrResult);//"de/st/max123"???
task.setZmrClient(zmrClient);
//Mock ernb
ArrayList<RegisterResult> ernbResult = new ArrayList<>();
+
ernbClient = Mockito.mock(DummyErnbClient.class);
Mockito.when(ernbClient.searchWithPersonIdentifer("max123")).thenReturn(ernbResult);//"de/st/max123"???
task.setErnbClient(ernbClient);
try {
task.execute(pendingReq, executionContext);
- Assert.assertTrue("Wrong workflow, should not reach this point/ get a bpk", false);
String bPk = (String)
pendingReq.getSessionData(AuthProcessDataWrapper.class).getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK);
+ Assert.assertTrue("Wrong bpk", bPk.equals(randomBpk));
} catch (final TaskExecutionException e) {
- Throwable origE = e.getOriginalException();
- Assert.assertTrue("Wrong exception", (origE.getCause() instanceof ManualFixNecessaryException));
+ Assert.assertTrue("Wrong workflow, should not reach this point", false);
}
}
-
@Test
@DirtiesContext
/**
- * Two matches found in ErnB
+ * One match, but register update needed
*/
- public void testNode101b() throws Exception {
+ public void testNode100b() throws Exception {
//Mock ZMR
ArrayList<RegisterResult> zmrResult = new ArrayList<>();
+
zmrClient = Mockito.mock(DummyZmrClient.class);
Mockito.when(zmrClient.searchWithPersonIdentifer("max123")).thenReturn(zmrResult);//"de/st/max123"???
task.setZmrClient(zmrClient);
//Mock ernb
ArrayList<RegisterResult> ernbResult = new ArrayList<>();
- ernbResult.add(new RegisterResult("bpkMax","de/st/max123", "Max", "Mustermann", "1111-01-01"));
- ernbResult.add(new RegisterResult("bpkMax","de/st/max123", "Maximilian", "Mustermann", "1111-01-01"));
+ String randomBpk = RandomStringUtils.randomNumeric(6);
+ ernbResult.add(new RegisterResult(randomBpk,"de/st/max123", "Max_new", "Mustermann", "2011-01-01"));
ernbClient = Mockito.mock(DummyErnbClient.class);
Mockito.when(ernbClient.searchWithPersonIdentifer("max123")).thenReturn(ernbResult);//"de/st/max123"???
@@ -162,68 +166,67 @@ public class InitialSearchTaskFirstTest {
try {
task.execute(pendingReq, executionContext);
- Assert.assertTrue("Wrong workflow, should not reach this point/ get a bpk", false);
String bPk = (String)
pendingReq.getSessionData(AuthProcessDataWrapper.class).getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK);
+ Assert.assertTrue("Wrong bpk", bPk.equals(randomBpk));
} catch (final TaskExecutionException e) {
- Throwable origE = e.getOriginalException();
- Assert.assertTrue("Wrong exception", (origE.getCause() instanceof ManualFixNecessaryException));
+ Assert.assertTrue("Wrong workflow, should not reach this point", false);
}
}
+
@Test
@DirtiesContext
/**
- * One match, but register update needed
+ * Two matches found in ZMR
*/
- public void testNode100a() throws Exception {
+ public void testNode101a() throws Exception {
//Mock ZMR
ArrayList<RegisterResult> zmrResult = new ArrayList<>();
- String randomBpk = RandomStringUtils.randomNumeric(6);
- zmrResult.add(new RegisterResult(randomBpk,"de/st/max123", "Max_new", "Mustermann", "1111-01-01"));
-
+ zmrResult.add(new RegisterResult("bpkMax","de/st/max123", "Max", "Mustermann", "2011-01-01"));
+ zmrResult.add(new RegisterResult("bpkMax","de/st/max123", "Maximilian", "Mustermann", "2011-01-01"));
zmrClient = Mockito.mock(DummyZmrClient.class);
Mockito.when(zmrClient.searchWithPersonIdentifer("max123")).thenReturn(zmrResult);//"de/st/max123"???
task.setZmrClient(zmrClient);
//Mock ernb
ArrayList<RegisterResult> ernbResult = new ArrayList<>();
-
ernbClient = Mockito.mock(DummyErnbClient.class);
Mockito.when(ernbClient.searchWithPersonIdentifer("max123")).thenReturn(ernbResult);//"de/st/max123"???
task.setErnbClient(ernbClient);
try {
task.execute(pendingReq, executionContext);
+ Assert.assertTrue("Wrong workflow, should not reach this point/ get a bpk", false);
String bPk = (String)
pendingReq.getSessionData(AuthProcessDataWrapper.class).getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK);
- Assert.assertTrue("Wrong bpk", bPk.equals(randomBpk));
} catch (final TaskExecutionException e) {
- Assert.assertTrue("Wrong workflow, should not reach this point", false);
+ Throwable origE = e.getOriginalException();
+ Assert.assertTrue("Wrong exception", (origE.getCause() instanceof ManualFixNecessaryException));
}
}
+
@Test
@DirtiesContext
/**
- * One match, but register update needed
+ * Two matches found in ErnB
*/
- public void testNode100b() throws Exception {
+ public void testNode101b() throws Exception {
//Mock ZMR
ArrayList<RegisterResult> zmrResult = new ArrayList<>();
-
zmrClient = Mockito.mock(DummyZmrClient.class);
Mockito.when(zmrClient.searchWithPersonIdentifer("max123")).thenReturn(zmrResult);//"de/st/max123"???
task.setZmrClient(zmrClient);
//Mock ernb
ArrayList<RegisterResult> ernbResult = new ArrayList<>();
- String randomBpk = RandomStringUtils.randomNumeric(6);
- ernbResult.add(new RegisterResult(randomBpk,"de/st/max123", "Max_new", "Mustermann", "1111-01-01"));
+ ernbResult.add(new RegisterResult("bpkMax","de/st/max123", "Max", "Mustermann", "2011-01-01"));
+ ernbResult.add(new RegisterResult("bpkMax","de/st/max123", "Maximilian", "Mustermann", "2011-01-01"));
ernbClient = Mockito.mock(DummyErnbClient.class);
Mockito.when(ernbClient.searchWithPersonIdentifer("max123")).thenReturn(ernbResult);//"de/st/max123"???
@@ -231,12 +234,13 @@ public class InitialSearchTaskFirstTest {
try {
task.execute(pendingReq, executionContext);
+ Assert.assertTrue("Wrong workflow, should not reach this point/ get a bpk", false);
String bPk = (String)
pendingReq.getSessionData(AuthProcessDataWrapper.class).getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK);
- Assert.assertTrue("Wrong bpk", bPk.equals(randomBpk));
} catch (final TaskExecutionException e) {
- Assert.assertTrue("Wrong workflow, should not reach this point", false);
+ Throwable origE = e.getOriginalException();
+ Assert.assertTrue("Wrong exception", (origE.getCause() instanceof ManualFixNecessaryException));
}
}
@@ -255,7 +259,7 @@ public class InitialSearchTaskFirstTest {
//Mock ernb
ArrayList<RegisterResult> ernbResult = new ArrayList<>();
- ernbResult.add(new RegisterResult("bpkMax","de/st/max123", "Max", "Mustermann", "1111-01-01"));
+ ernbResult.add(new RegisterResult("bpkMax","de/st/max123", "Max", "Mustermann", "2011-01-01"));
ernbClient = Mockito.mock(DummyErnbClient.class);
Mockito.when(ernbClient.searchWithPersonIdentifer("max123")).thenReturn(ernbResult);//"de/st/max123"???
@@ -281,7 +285,7 @@ public class InitialSearchTaskFirstTest {
//Mock ZMR
ArrayList<RegisterResult> zmrResult = new ArrayList<>();
- zmrResult.add(new RegisterResult("bpkMax","de/st/max123", "Max", "Mustermann", "1111-01-01"));
+ zmrResult.add(new RegisterResult("bpkMax","de/st/max123", "Max", "Mustermann", "2011-01-01"));
zmrClient = Mockito.mock(DummyZmrClient.class);
Mockito.when(zmrClient.searchWithPersonIdentifer("max123")).thenReturn(zmrResult);//"de/st/max123"???
@@ -305,13 +309,18 @@ public class InitialSearchTaskFirstTest {
}
}
- @Ignore
@Test
@DirtiesContext
/**
* One match found in ZMR and ErnB with detail search
*/
- public void testNode103() throws Exception {
+ public void testNode103IT() throws Exception {
+ String bpkRegister = "bpkMax";
+ String taxNumber = "tax123";
+ final AuthenticationResponse response = buildDummyAuthResponseMaxMustermannIT_Tax(taxNumber);
+ TestRequestImpl pendingReq1 = new TestRequestImpl();
+ pendingReq1.getSessionData(AuthProcessDataWrapper.class)
+ .setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response);
//Mock ZMR initial search
ArrayList<RegisterResult> zmrResultInitial = new ArrayList<>();
@@ -320,10 +329,10 @@ public class InitialSearchTaskFirstTest {
ArrayList<RegisterResult> zmrResultSpecific = new ArrayList<>();
//String bpk, String pseudonym, String givenName, String familyName, String dateOfBirth,
// String placeOfBirth, String birthName, String taxNumber, PostalAddressType address
- zmrResultSpecific.add(new RegisterResult("bpkMax","de/st/max1234", "Max", "Mustermann", "1111-01-01", null, null,
- "tax123", null));
+ zmrResultSpecific.add(new RegisterResult(bpkRegister,"it/st/max1234", "Max", "Mustermann", "2011-01-01", null,
+ null, taxNumber, null));
- Mockito.when(zmrClient.searchItSpecific("tax123")).thenReturn(zmrResultSpecific);
+ Mockito.when(zmrClient.searchItSpecific(taxNumber)).thenReturn(zmrResultSpecific);
task.setZmrClient(zmrClient);
//Mock ernb initial search
@@ -333,24 +342,160 @@ public class InitialSearchTaskFirstTest {
task.setErnbClient(ernbClient);
+ //Mock country specific search
+ List<ICountrySpecificDetailSearchProcessor> handlers = new ArrayList<>();
+ ItSpecificDetailSearchProcessor it = new ItSpecificDetailSearchProcessor();
+ it.setErnbClient(ernbClient);
+ it.setZmrClient(zmrClient);
+ handlers.add(it);
+ task.setHandlers(handlers);
+
try {
- task.execute(pendingReq, executionContext);
+ task.execute(pendingReq1, executionContext);
String bPk = (String)
- pendingReq.getSessionData(AuthProcessDataWrapper.class).getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK);
- Assert.assertTrue("Wrong bpk", bPk.equals("bpkMax"));
+ pendingReq1.getSessionData(AuthProcessDataWrapper.class).getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK);
+ Assert.assertTrue("Wrong bpk", bPk.equals(bpkRegister));
+ } catch (final TaskExecutionException e) {
+ Assert.assertTrue("Wrong workflow, should not reach this point", false);
+ }
+ }
+
+ @Test
+ @DirtiesContext
+ /**
+ * Multiple matches found in ZMR and ErnB with detail search
+ */
+ public void testNode103DE() throws Exception {
+ String givenName = "Max";
+ String familyName = "Mustermann";
+ String pseudonym = "de/st/max1234";
+ String bpk = "bpkMax";
+ String dateOfBirth = "2011-01-01";
+ String placeOfBirth = "München";
+ String birthName = "BabyMax";
+ final AuthenticationResponse response = buildDummyAuthResponseDE(givenName, familyName, pseudonym,
+ dateOfBirth, placeOfBirth, birthName);
+ TestRequestImpl pendingReq1 = new TestRequestImpl();
+ pendingReq1.getSessionData(AuthProcessDataWrapper.class)
+ .setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response);
+
+ //Mock ZMR initial search
+ ArrayList<RegisterResult> zmrResultInitial = new ArrayList<>();
+ zmrClient = Mockito.mock(DummyZmrClient.class);
+ Mockito.when(zmrClient.searchWithPersonIdentifer("max123")).thenReturn(zmrResultInitial);
+ ArrayList<RegisterResult> zmrResultSpecific = new ArrayList<>();
+
+ zmrResultSpecific.add(new RegisterResult(bpk, pseudonym, givenName, familyName, dateOfBirth, placeOfBirth, birthName,
+ null, null));
+
+ //.searchDeSpecific(eidData.getGivenName(), eidData.getFamilyName(), eidData.getDateOfBirth(),
+ // eidData.getPlaceOfBirth(), eidData.getBirthName()
+ Mockito.when(zmrClient.searchDeSpecific(givenName, familyName, dateOfBirth, placeOfBirth, birthName)).thenReturn(zmrResultSpecific);
+
+ task.setZmrClient(zmrClient);
+
+ //Mock ernb initial search
+ ArrayList<RegisterResult> ernbResultInitial = new ArrayList<>();
+ ernbClient = Mockito.mock(DummyErnbClient.class);
+ Mockito.when(ernbClient.searchWithPersonIdentifer("max123")).thenReturn(ernbResultInitial);//"de/st/max123"???
+
+ task.setErnbClient(ernbClient);
+
+ //Mock country specific search
+ List<ICountrySpecificDetailSearchProcessor> handlers = new ArrayList<>();
+ DeSpecificDetailSearchProcessor de = new DeSpecificDetailSearchProcessor();
+ de.setErnbClient(ernbClient);
+ de.setZmrClient(zmrClient);
+ handlers.add(de);
+ task.setHandlers(handlers);
+
+ try {
+ task.execute(pendingReq1, executionContext);
+
+ String bPk = (String)
+ pendingReq1.getSessionData(AuthProcessDataWrapper.class).getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK);
+ Assert.assertTrue("Wrong bpk", bPk.equals(bpk));
} catch (final TaskExecutionException e) {
Assert.assertTrue("Wrong workflow, should not reach this point", false);
}
}
- @Ignore
@Test
@DirtiesContext
/**
* Multiple matches found in ZMR and ErnB with detail search
*/
- public void testNode104() throws Exception {
+ public void testNode104DE() throws Exception {
+ String givenName = "Max";
+ String familyName = "Mustermann";
+ String pseudonym1 = "de/st/max1234";
+ String pseudonym2 = "de/st/max12345";
+ String bpk1 = "bpkMax";
+ String bpk2 = "bpkMax1";
+ String dateOfBirth = "2011-01-01";
+ String placeOfBirth = "München";
+ String birthName = "BabyMax";
+ final AuthenticationResponse response = buildDummyAuthResponseDE(givenName, familyName, pseudonym1,
+ dateOfBirth, placeOfBirth, birthName);
+ TestRequestImpl pendingReq1 = new TestRequestImpl();
+ pendingReq1.getSessionData(AuthProcessDataWrapper.class)
+ .setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response);
+
+ //Mock ZMR initial search
+ ArrayList<RegisterResult> zmrResultInitial = new ArrayList<>();
+ zmrClient = Mockito.mock(DummyZmrClient.class);
+ Mockito.when(zmrClient.searchWithPersonIdentifer("max123")).thenReturn(zmrResultInitial);
+ ArrayList<RegisterResult> zmrResultSpecific = new ArrayList<>();
+
+ zmrResultSpecific.add(new RegisterResult(bpk1, pseudonym1, givenName, familyName, dateOfBirth, placeOfBirth, birthName,
+ null, null));
+ zmrResultSpecific.add(new RegisterResult(bpk2, pseudonym2, givenName, familyName, dateOfBirth, placeOfBirth, birthName,
+ null, null));
+ //.searchDeSpecific(eidData.getGivenName(), eidData.getFamilyName(), eidData.getDateOfBirth(),
+ // eidData.getPlaceOfBirth(), eidData.getBirthName()
+ Mockito.when(zmrClient.searchDeSpecific(givenName, familyName, dateOfBirth, placeOfBirth, birthName)).thenReturn(zmrResultSpecific);
+
+ task.setZmrClient(zmrClient);
+
+ //Mock ernb initial search
+ ArrayList<RegisterResult> ernbResultInitial = new ArrayList<>();
+ ernbClient = Mockito.mock(DummyErnbClient.class);
+ Mockito.when(ernbClient.searchWithPersonIdentifer("max123")).thenReturn(ernbResultInitial);//"de/st/max123"???
+
+ task.setErnbClient(ernbClient);
+
+ //Mock country specific search
+ List<ICountrySpecificDetailSearchProcessor> handlers = new ArrayList<>();
+ DeSpecificDetailSearchProcessor de = new DeSpecificDetailSearchProcessor();
+ de.setErnbClient(ernbClient);
+ de.setZmrClient(zmrClient);
+ handlers.add(de);
+ task.setHandlers(handlers);
+
+ try {
+ task.execute(pendingReq1, executionContext);
+
+ Assert.assertTrue("Wrong workflow, should not reach this point/ get a bpk", false);
+
+ } catch (final TaskExecutionException e) {
+ Throwable origE = e.getOriginalException();
+ Assert.assertTrue("Wrong exception", (origE.getCause() instanceof ManualFixNecessaryException));
+ }
+ }
+
+ @Test
+ @DirtiesContext
+ /**
+ * Multiple matches found in ZMR and ErnB with detail search
+ */
+ public void testNode104IT() throws Exception {
+
+ String fakeTaxNumber = "tax123";
+ final AuthenticationResponse response = buildDummyAuthResponseMaxMustermannIT_Tax(fakeTaxNumber);
+ TestRequestImpl pendingReq1 = new TestRequestImpl();
+ pendingReq1.getSessionData(AuthProcessDataWrapper.class)
+ .setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response);
//Mock ZMR initial search
ArrayList<RegisterResult> zmrResultInitial = new ArrayList<>();
@@ -359,11 +504,11 @@ public class InitialSearchTaskFirstTest {
ArrayList<RegisterResult> zmrResultSpecific = new ArrayList<>();
//String bpk, String pseudonym, String givenName, String familyName, String dateOfBirth,
// String placeOfBirth, String birthName, String taxNumber, PostalAddressType address
- zmrResultSpecific.add(new RegisterResult("bpkMax","de/st/max1234", "Max", "Mustermann", "1111-01-01", null, null,
- "tax123", null));
- zmrResultSpecific.add(new RegisterResult("bpkMax1","de/st/max1235", "Max", "Mustermann", "1111-01-01", null, null,
- "tax123", null));
- Mockito.when(zmrClient.searchItSpecific("tax123")).thenReturn(zmrResultSpecific);
+ zmrResultSpecific.add(new RegisterResult("bpkMax","it/st/max1234", "Max", "Mustermann", "2011-01-01", null, null,
+ fakeTaxNumber, null));
+ zmrResultSpecific.add(new RegisterResult("bpkMax1","it/st/max1235", "Max", "Mustermann", "2011-01-01", null, null,
+ fakeTaxNumber, null));
+ Mockito.when(zmrClient.searchItSpecific(fakeTaxNumber)).thenReturn(zmrResultSpecific);
task.setZmrClient(zmrClient);
@@ -375,8 +520,16 @@ public class InitialSearchTaskFirstTest {
task.setErnbClient(ernbClient);
+ //Mock country specific search
+ List<ICountrySpecificDetailSearchProcessor> handlers = new ArrayList<>();
+ ItSpecificDetailSearchProcessor it = new ItSpecificDetailSearchProcessor();
+ it.setErnbClient(ernbClient);
+ it.setZmrClient(zmrClient);
+ handlers.add(it);
+ task.setHandlers(handlers);
+
try {
- task.execute(pendingReq, executionContext);
+ task.execute(pendingReq1, executionContext);
Assert.assertTrue("Wrong workflow, should not reach this point/ get a bpk", false);
@@ -386,7 +539,6 @@ public class InitialSearchTaskFirstTest {
}
}
-
@Test
@DirtiesContext
/**
@@ -427,12 +579,35 @@ public class InitialSearchTaskFirstTest {
@NotNull
private AuthenticationResponse buildDummyAuthResponseMaxMustermann() throws URISyntaxException {
return buildDummyAuthResponse("Max", "Mustermann",
- "de/st/max123", "1111-01-01");
+ "de/st/max123", "2011-01-01");
+ }
+
+ private AuthenticationResponse buildDummyAuthResponseMaxMustermannIT() throws URISyntaxException {
+ return buildDummyAuthResponse("Max", "Mustermann",
+ "it/st/max123", "2011-01-01");
+ }
+
+ private AuthenticationResponse buildDummyAuthResponseMaxMustermannIT_Tax(String taxNumber) throws URISyntaxException {
+ return buildDummyAuthResponse("Max", "Mustermann",
+ "it/st/max123", "2011-01-01", taxNumber, null, null);
}
@NotNull
private AuthenticationResponse buildDummyAuthResponse(String givenName, String familyName, String identifier,
String dateOfBirth) throws URISyntaxException {
+ return buildDummyAuthResponse(givenName, familyName, identifier, dateOfBirth, null, null, null);
+ }
+
+ @NotNull
+ private AuthenticationResponse buildDummyAuthResponseDE(String givenName, String familyName, String identifier,
+ String dateOfBirth, String placeOfBirth,
+ String birthName) throws URISyntaxException {
+ return buildDummyAuthResponse(givenName, familyName, identifier, dateOfBirth, null, placeOfBirth, birthName);
+ }
+ @NotNull
+ private AuthenticationResponse buildDummyAuthResponse(String givenName, String familyName, String identifier,
+ String dateOfBirth, String taxNumber, String placeOfBirth,
+ String birthName) throws URISyntaxException {
final AttributeDefinition attributeDef = AttributeDefinition.builder()
.friendlyName(Constants.eIDAS_ATTR_PERSONALIDENTIFIER).nameUri(new URI("ad", "sd", "ff"))
.personType(PersonType.LEGAL_PERSON).xmlType(new QName("http://saf", "as", "af"))
@@ -449,12 +624,34 @@ public class InitialSearchTaskFirstTest {
.friendlyName(Constants.eIDAS_ATTR_DATEOFBIRTH).nameUri(new URI("ad", "sd", "fffff"))
.personType(PersonType.LEGAL_PERSON).xmlType(new QName("http://saf", "as", "affff"))
.attributeValueMarshaller("eu.eidas.auth.commons.attribute.impl.DateTimeAttributeValueMarshaller").build();
-
- final ImmutableAttributeMap attributeMap = ImmutableAttributeMap.builder()
+ final AttributeDefinition attributeDef5 = AttributeDefinition.builder()
+ .friendlyName(Constants.eIDAS_ATTR_TAXREFERENCE).nameUri(new URI("ad", "sd", "ffffff"))
+ .personType(PersonType.LEGAL_PERSON).xmlType(new QName("http://saf", "as", "afffff"))
+ .attributeValueMarshaller("eu.eidas.auth.commons.attribute.impl.LiteralStringAttributeValueMarshaller").build();
+ final AttributeDefinition attributeDef6 = AttributeDefinition.builder()
+ .friendlyName(Constants.eIDAS_ATTR_PLACEOFBIRTH).nameUri(new URI("ad", "sd", "fffffff"))
+ .personType(PersonType.LEGAL_PERSON).xmlType(new QName("http://saf", "as", "affffff"))
+ .attributeValueMarshaller("eu.eidas.auth.commons.attribute.impl.LiteralStringAttributeValueMarshaller").build();
+ final AttributeDefinition attributeDef7 = AttributeDefinition.builder()
+ .friendlyName(Constants.eIDAS_ATTR_BIRTHNAME).nameUri(new URI("ad", "sd", "ffffffff"))
+ .personType(PersonType.LEGAL_PERSON).xmlType(new QName("http://saf", "as", "afffffff"))
+ .attributeValueMarshaller("eu.eidas.auth.commons.attribute.impl.LiteralStringAttributeValueMarshaller").build();
+ ImmutableAttributeMap.Builder builder = ImmutableAttributeMap.builder()
.put(attributeDef, identifier)
.put(attributeDef2, familyName)
.put(attributeDef3, givenName)
- .put(attributeDef4, dateOfBirth).build();
+ .put(attributeDef4, dateOfBirth);
+
+ if(taxNumber != null) {
+ builder.put(attributeDef5, taxNumber);
+ }
+ if(birthName != null) {
+ builder.put(attributeDef7, birthName);
+ }
+ if(placeOfBirth != null) {
+ builder.put(attributeDef6, placeOfBirth);
+ }
+ final ImmutableAttributeMap attributeMap = builder.build();
val b = new AuthenticationResponse.Builder();
return b.id("aasdf").issuer("asd").subject("asf").statusCode("200").inResponseTo("asdf").subjectNameIdFormat(
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/SpringTest-context_tasks_test.xml b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/SpringTest-context_tasks_test.xml
index 17e32b86..cde374a1 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/SpringTest-context_tasks_test.xml
+++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/SpringTest-context_tasks_test.xml
@@ -74,4 +74,11 @@
<bean id="ZmrClientForeIDAS"
class="at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.DummyZmrClient" />
+ <bean id="DE-Specific-Search"
+ class="at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.DeSpecificDetailSearchProcessor">
+ </bean>
+
+ <bean id="IT-Specific-Search"
+ class="at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.ItSpecificDetailSearchProcessor">
+ </bean>
</beans> \ No newline at end of file