diff options
author | Alexander Marsalek <amarsalek@iaik.tugraz.at> | 2020-12-15 23:46:02 +0100 |
---|---|---|
committer | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2021-01-15 14:17:36 +0100 |
commit | c893656f79dfdda49527aaba6f17f088884602f8 (patch) | |
tree | f49622443f05d7e1be7720b428f345da322b189c /eidas_modules/authmodule-eIDAS-v2 | |
parent | 41a2c873d585d00ee06cc95a5e30fe17f4bc85a9 (diff) | |
download | National_eIDAS_Gateway-c893656f79dfdda49527aaba6f17f088884602f8.tar.gz National_eIDAS_Gateway-c893656f79dfdda49527aaba6f17f088884602f8.tar.bz2 National_eIDAS_Gateway-c893656f79dfdda49527aaba6f17f088884602f8.zip |
implemented CountrySpecificDetailSearchResult, changed datetime to string
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2')
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 93dbc7c2..d8c14b8e 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 @@ -183,7 +183,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 @@ -265,12 +265,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, @@ -278,11 +283,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 ea4a4c76..54928eb7 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; @@ -289,6 +290,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 |