aboutsummaryrefslogtreecommitdiff
path: root/eidas_modules/authmodule-eIDAS-v2/src/main/java/at
diff options
context:
space:
mode:
authorAlexander Marsalek <amarsalek@iaik.tugraz.at>2020-12-15 23:46:02 +0100
committerAlexander Marsalek <amarsalek@iaik.tugraz.at>2021-01-04 14:16:19 +0100
commit6782b19cc51833b4499984bb92d59fd00f8c0efd (patch)
treeabd1837cae2c8f58ec822890d1e1e83c6e0f7dc7 /eidas_modules/authmodule-eIDAS-v2/src/main/java/at
parent75c403b2067dac3ccafae3b751f8714ebff342fa (diff)
downloadNational_eIDAS_Gateway-6782b19cc51833b4499984bb92d59fd00f8c0efd.tar.gz
National_eIDAS_Gateway-6782b19cc51833b4499984bb92d59fd00f8c0efd.tar.bz2
National_eIDAS_Gateway-6782b19cc51833b4499984bb92d59fd00f8c0efd.zip
implemented CountrySpecificDetailSearchResult, changed datetime to string
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src/main/java/at')
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/CountrySpecificDetailSearchResult.java26
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java9
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/InitialSearchTask.java17
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/utils/EidasResponseUtils.java17
4 files changed, 51 insertions, 18 deletions
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/CountrySpecificDetailSearchResult.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/CountrySpecificDetailSearchResult.java
index 710e286c..b74172f9 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/CountrySpecificDetailSearchResult.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/CountrySpecificDetailSearchResult.java
@@ -1,14 +1,32 @@
package at.asitplus.eidas.specific.modules.auth.eidas.v2.dao;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.WorkflowException;
+
+import java.util.ArrayList;
+
public class CountrySpecificDetailSearchResult {
//TODO is the result the same as the one form the initial search?
- int resultsZmr;
- int resultsErnb;
+ ArrayList<RegisterResult> resultsZmr = new ArrayList<>();
+ ArrayList<RegisterResult> resultsErnb = new ArrayList<>();
public int getResultCount() {
- return resultsZmr + resultsErnb;
+ return resultsZmr.size() + resultsErnb.size();
}
-
+ /**
+ * Verfies that there is only one match and retunrs the bpk.
+ * @return bpk bpk of the match
+ * @throws WorkflowException if multiple results have been found
+ */
+ public String getBpk() throws WorkflowException {
+ if (getResultCount() != 1) {
+ throw new WorkflowException("getResultCount() != 1");
+ }
+ if (resultsZmr.size() == 1) {
+ return resultsZmr.get(0).getBpk();
+ } else {
+ return resultsErnb.get(0).getBpk();
+ }
+ }
}
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 c41dd39e..43d85772 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,9 +26,6 @@ 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.Data;
-import org.joda.time.DateTime;
-
-import java.text.SimpleDateFormat;
@Data
public class SimpleEidasData {
@@ -39,7 +36,7 @@ public class SimpleEidasData {
private String pseudonym = null;
private String givenName = null;
private String familyName = null;
- private DateTime dateOfBirth = null;
+ private String dateOfBirth = null;
// additional attributes
private String placeOfBirth = null;
@@ -47,10 +44,6 @@ public class SimpleEidasData {
private PostalAddressType address = null;
private String taxNumber;
- public String getFormatedDateOfBirth() {
- return new SimpleDateFormat("yyyy-MM-dd").format(dateOfBirth.toDate());
- }
-
/**
* Compares the register result with the eidas data.
* @param result The register data to use for comparison
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 fdf80669..ec56a6dd 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
@@ -180,7 +180,7 @@ public class InitialSearchTask extends AbstractAuthServletTask {
eidasAttrMap.get(Constants.eIDAS_ATTR_CURRENTFAMILYNAME)));
simpleEidasData.setGivenName(EidasResponseUtils.processGivenName(
eidasAttrMap.get(Constants.eIDAS_ATTR_CURRENTGIVENNAME)));
- simpleEidasData.setDateOfBirth(EidasResponseUtils.processDateOfBirth(
+ simpleEidasData.setDateOfBirth(EidasResponseUtils.processDateOfBirthToString(
eidasAttrMap.get(Constants.eIDAS_ATTR_DATEOFBIRTH)));
// additional attributes
@@ -262,12 +262,17 @@ public class InitialSearchTask extends AbstractAuthServletTask {
}
private String step7a(MergedRegisterSearchResult initialSearchResult,
- CountrySpecificDetailSearchResult countrySpecificDetailSearchResult, SimpleEidasData eidData) {
+ CountrySpecificDetailSearchResult countrySpecificDetailSearchResult,
+ SimpleEidasData eidData) throws TaskExecutionException {
//TODO automerge
log.debug("Automerge " + initialSearchResult + " with " + eidData + " " + countrySpecificDetailSearchResult);
//TODO
- String bpK = "103";
- return bpK;
+ try {
+ String bpK = countrySpecificDetailSearchResult.getBpk();
+ return bpK;
+ } catch (WorkflowException e) {
+ throw new TaskExecutionException(pendingReq, "Step7a failed.", e);
+ }
}
private String step8(MergedRegisterSearchResult initialSearchResult,
@@ -275,11 +280,11 @@ public class InitialSearchTask extends AbstractAuthServletTask {
MergedRegisterSearchResult mdsSearchResult = new MergedRegisterSearchResult();
ArrayList<RegisterResult> resultsZmr =
- zmrClient.searchWithMds(eidData.getGivenName(), eidData.getFamilyName(), eidData.getFormatedDateOfBirth());
+ zmrClient.searchWithMds(eidData.getGivenName(), eidData.getFamilyName(), eidData.getDateOfBirth());
mdsSearchResult.setResultsZmr(resultsZmr);
ArrayList<RegisterResult> resultsErnb =
- ernbClient.searchWithMds(eidData.getGivenName(), eidData.getFamilyName(), eidData.getFormatedDateOfBirth());
+ ernbClient.searchWithMds(eidData.getGivenName(), eidData.getFamilyName(), eidData.getDateOfBirth());
mdsSearchResult.setResultsErnb(resultsErnb);
log.debug("Automerge " + initialSearchResult + " with " + eidData + " " + mdsSearchResult);
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 c68a602b..5a1db0e0 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
@@ -23,6 +23,7 @@
package at.asitplus.eidas.specific.modules.auth.eidas.v2.utils;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
@@ -282,6 +283,22 @@ public class EidasResponseUtils {
}
/**
+ * Post-Process the eIDAS DateOfBirth attribute to a string.
+ *
+ * @param dateOfBirthObj eIDAS date-of-birth attribute information
+ * @return formated user's date-of-birth as string
+ * @throws EidasAttributeException if NO attribute is available
+ * @throws EidPostProcessingException if post-processing fails
+ */
+ public static String processDateOfBirthToString(Object dateOfBirthObj) throws EidPostProcessingException,
+ EidasAttributeException {
+ if (dateOfBirthObj == null || !(dateOfBirthObj instanceof DateTime)) {
+ throw new EidasAttributeException(Constants.eIDAS_ATTR_DATEOFBIRTH);
+ }
+ return new SimpleDateFormat("yyyy-MM-dd").format(((DateTime) dateOfBirthObj).toDate());
+ }
+
+ /**
* Post-Process the eIDAS GivenName attribute.
*
* @param givenNameObj eIDAS givenName attribute information