From ed033b4105eec8c00189729bd4b38b17c6b40509 Mon Sep 17 00:00:00 2001 From: Alexander Marsalek Date: Thu, 7 Jan 2021 18:16:45 +0100 Subject: Resolve merge comments --- .../specific/modules/auth/eidas/v2/Constants.java | 2 +- .../modules/auth/eidas/v2/dao/ErnbEidData.java | 2 +- .../eidas/v2/dao/MergedRegisterSearchResult.java | 57 ++++++- .../modules/auth/eidas/v2/dao/RegisterResult.java | 61 +++---- .../modules/auth/eidas/v2/dao/SimpleEidasData.java | 27 ++- .../auth/eidas/v2/ernb/DummyErnbClient.java | 43 ----- .../modules/auth/eidas/v2/ernb/IErnbClient.java | 20 --- .../auth/eidas/v2/ernp/DummyErnpClient.java | 66 ++++++++ .../modules/auth/eidas/v2/ernp/IErnpClient.java | 43 +++++ .../v2/exception/ManualFixNecessaryException.java | 6 +- .../auth/eidas/v2/exception/WorkflowException.java | 6 +- .../CountrySpecificDetailSearchProcessor.java | 61 +++++++ .../handler/DeSpecificDetailSearchProcessor.java | 35 +++- .../ICountrySpecificDetailSearchProcessor.java | 61 ------- .../handler/ItSpecificDetailSearchProcessor.java | 34 +++- .../auth/eidas/v2/tasks/InitialSearchTask.java | 188 +++++++++------------ .../eidas/v2/tasks/ReceiveAuthnResponseTask.java | 2 +- .../auth/eidas/v2/utils/EidasResponseUtils.java | 82 +++------ .../modules/auth/eidas/v2/zmr/DummyZmrClient.java | 27 ++- .../modules/auth/eidas/v2/zmr/IZmrClient.java | 27 ++- 20 files changed, 481 insertions(+), 369 deletions(-) delete mode 100644 eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernb/DummyErnbClient.java delete mode 100644 eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernb/IErnbClient.java create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/DummyErnpClient.java create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/IErnpClient.java create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/CountrySpecificDetailSearchProcessor.java delete mode 100644 eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ICountrySpecificDetailSearchProcessor.java (limited to 'eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas') 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 767a2d12..57fd6ef1 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 @@ -32,7 +32,7 @@ public class Constants { public static final String DATA_REQUESTED_LOA_LIST = "req_requestedLoA"; public static final String DATA_REQUESTED_LOA_COMPERISON = "req_requestedLoAComperision"; public static final String DATA_FULL_EIDAS_RESPONSE = "resp_fulleIDASResponse"; - public static final String DATA_RESULT_MATCHING_BPK = "matching-result-bpk";//TODO? + public static final String DATA_RESULT_MATCHING_BPK = "matching-result-bpk"; // templates for post-binding forwarding public static final String TEMPLATE_POST_FORWARD_NAME = "eidas_node_forward.html"; diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/ErnbEidData.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/ErnbEidData.java index 6c7eeb6b..b780d3e8 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/ErnbEidData.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/ErnbEidData.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 A-SIT Plus GmbH + * Copyright 2020 A-SIT Plus GmbH * AT-specific eIDAS Connector has been developed in a cooperation between EGIZ, * A-SIT Plus GmbH, A-SIT, and Graz University of Technology. * diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/MergedRegisterSearchResult.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/MergedRegisterSearchResult.java index 056b0450..7703af2a 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/MergedRegisterSearchResult.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/MergedRegisterSearchResult.java @@ -1,3 +1,26 @@ +/* + * Copyright 2020 A-SIT Plus GmbH + * AT-specific eIDAS Connector has been developed in a cooperation between EGIZ, + * A-SIT Plus GmbH, A-SIT, and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "License"); + * You may not use this work except in compliance with the License. + * You may obtain a copy of the License at: + * https://joinup.ec.europa.eu/news/understanding-eupl-v12 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + package at.asitplus.eidas.specific.modules.auth.eidas.v2.dao; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.WorkflowException; @@ -5,28 +28,48 @@ import lombok.Data; import java.util.ArrayList; -@Data public class MergedRegisterSearchResult { +@Data +public class MergedRegisterSearchResult { + + final ArrayList resultsZmr; + final ArrayList resultsErnp; - ArrayList resultsZmr = new ArrayList<>(); - ArrayList resultsErnb = new ArrayList<>(); + public MergedRegisterSearchResult(ArrayList resultsZmr, ArrayList resultsErnp) { + this.resultsZmr = resultsZmr; + this.resultsErnp = resultsErnp; + } public int getResultCount() { - return resultsZmr.size() + resultsErnb.size(); + return resultsZmr.size() + resultsErnp.size(); } /** - * Verfies that there is only one match and retunrs the bpk. + * Verifies that there is only one match and returns 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"); + } + return getResult().getBpk(); + } + + /** + * Returns the results, if there is exactly one, throws exception otherwise. + * + * @return The result + * @throws WorkflowException Results does not contain exactly one result + */ + public RegisterResult getResult() throws WorkflowException { if (getResultCount() != 1) { throw new WorkflowException("getResultCount() != 1"); } if (resultsZmr.size() == 1) { - return resultsZmr.get(0).getBpk(); + return resultsZmr.get(0); } else { - return resultsErnb.get(0).getBpk(); + return resultsErnp.get(0); } } } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/RegisterResult.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/RegisterResult.java index c92808a1..1cc36fe9 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/RegisterResult.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/RegisterResult.java @@ -1,3 +1,26 @@ +/* + * Copyright 2020 A-SIT Plus GmbH + * AT-specific eIDAS Connector has been developed in a cooperation between EGIZ, + * A-SIT Plus GmbH, A-SIT, and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "License"); + * You may not use this work except in compliance with the License. + * You may obtain a copy of the License at: + * https://joinup.ec.europa.eu/news/understanding-eupl-v12 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + package at.asitplus.eidas.specific.modules.auth.eidas.v2.dao; import at.gv.e_government.reference.namespace.persondata._20020228.PostalAddressType; @@ -7,18 +30,18 @@ import lombok.Data; public class RegisterResult { // MDS - private String pseudonym = null; - private String givenName = null; - private String familyName = null; - private String dateOfBirth = null; + private String pseudonym; + private String givenName; + private String familyName; + private String dateOfBirth; // additional attributes - private String placeOfBirth = null; - private String birthName = null; - private String taxNumber = null; - private PostalAddressType address = null; + private String placeOfBirth; + private String birthName; + private String taxNumber; + private PostalAddressType address; - private String bpk = null; + private String bpk; /** * Register search result. @@ -37,26 +60,6 @@ public class RegisterResult { this.dateOfBirth = dateOfBirth; } - /** - * Register search result. - * - * @param bpk The bpk - * @param pseudonym The pseudonym - * @param givenName The givenName - * @param familyName The familyName - * @param dateOfBirth The dateOfBirth - * @param placeOfBirth The placeOfBirth - */ - public RegisterResult(String bpk, String pseudonym, String givenName, String familyName, String dateOfBirth, - String placeOfBirth) { - this.bpk = bpk; - this.pseudonym = pseudonym; - this.givenName = givenName; - this.familyName = familyName; - this.dateOfBirth = dateOfBirth; - this.placeOfBirth = placeOfBirth; - } - /** * Register search result. * 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 674f5b48..57597122 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 @@ -1,5 +1,5 @@ /* - * Copyright 2018 A-SIT Plus GmbH + * Copyright 2020 A-SIT Plus GmbH * AT-specific eIDAS Connector has been developed in a cooperation between EGIZ, * A-SIT Plus GmbH, A-SIT, and Graz University of Technology. * @@ -30,18 +30,18 @@ import lombok.Data; @Data public class SimpleEidasData { - private String citizenCountryCode = null; + private String citizenCountryCode; // MDS - private String pseudonym = null; - private String givenName = null; - private String familyName = null; - private String dateOfBirth = null; + private String pseudonym; + private String givenName; + private String familyName; + private String dateOfBirth; // additional attributes - private String placeOfBirth = null; - private String birthName = null; - private PostalAddressType address = null; + private String placeOfBirth; + private String birthName; + private PostalAddressType address; private String taxNumber; /** @@ -51,14 +51,7 @@ public class SimpleEidasData { * @throws WorkflowException if multiple results have been found */ public boolean equalsRegisterData(MergedRegisterSearchResult result) throws WorkflowException { - if (result.getResultCount() != 1) { - throw new WorkflowException("result.getResultCount() != 1"); - } - if (result.getResultsErnb().size() == 1) { - return equalsRegisterData(result.getResultsErnb().get(0)); - } else { - return equalsRegisterData(result.getResultsZmr().get(0)); - } + return equalsRegisterData(result.getResult()); } private boolean equalsRegisterData(RegisterResult result) { diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernb/DummyErnbClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernb/DummyErnbClient.java deleted file mode 100644 index 2d2fa76d..00000000 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernb/DummyErnbClient.java +++ /dev/null @@ -1,43 +0,0 @@ -package at.asitplus.eidas.specific.modules.auth.eidas.v2.ernb; - -import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; - -@Service("ErnbClientForeIDAS") -public class DummyErnbClient implements IErnbClient { - - @Override - public ArrayList searchWithPersonIdentifer(String personIdentifer) { - return resultEmpty(); - } - - @Override - public ArrayList searchWithMds(String givenName, String familyName, String dateOfBirth) { - return resultEmpty();//TODO will I only receive matches where all three values match perfectly? - } - - @Override - public ArrayList searchDeSpecific(String givenName, String familyName, String dateOfBirth, - String birthPlace, String birthName) { - return resultEmpty();//TODO - } - - @Override - public ArrayList searchItSpecific(String txNumber) { - return resultEmpty();//TODO - } - - @Override - public void update(RegisterResult registerResult, SimpleEidasData eidData) { - //TODO - } - - private ArrayList resultEmpty() { - return new ArrayList();//Nobody found - } - - -} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernb/IErnbClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernb/IErnbClient.java deleted file mode 100644 index cda4c426..00000000 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernb/IErnbClient.java +++ /dev/null @@ -1,20 +0,0 @@ -package at.asitplus.eidas.specific.modules.auth.eidas.v2.ernb; - -import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; - -import java.util.ArrayList; - -public interface IErnbClient { - - ArrayList searchWithPersonIdentifer(String personIdentifer); - - ArrayList searchWithMds(String givenName, String familyName, String dateOfBirth); - - ArrayList searchDeSpecific(String givenName, String familyName, String dateOfBirth, - String birthPlace, String birthName); - - ArrayList searchItSpecific(String txNumber); - - void update(RegisterResult registerResult, SimpleEidasData eidData); -} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/DummyErnpClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/DummyErnpClient.java new file mode 100644 index 00000000..3b49ab95 --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/DummyErnpClient.java @@ -0,0 +1,66 @@ +/* + * Copyright 2020 A-SIT Plus GmbH + * AT-specific eIDAS Connector has been developed in a cooperation between EGIZ, + * A-SIT Plus GmbH, A-SIT, and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "License"); + * You may not use this work except in compliance with the License. + * You may obtain a copy of the License at: + * https://joinup.ec.europa.eu/news/understanding-eupl-v12 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + +package at.asitplus.eidas.specific.modules.auth.eidas.v2.ernp; + +import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; + +@Service("ErnbClientForeIDAS") +public class DummyErnpClient implements IErnpClient { + + @Override + public ArrayList searchWithPersonIdentifier(String personIdentifier) { + return resultEmpty(); + } + + @Override + public ArrayList searchWithMds(String givenName, String familyName, String dateOfBirth) { + return resultEmpty();//TODO will I only receive matches where all three values match perfectly? + } + + @Override + public ArrayList searchDeSpecific(String givenName, String familyName, String dateOfBirth, + String birthPlace, String birthName) { + return resultEmpty();//TODO + } + + @Override + public ArrayList searchItSpecific(String taxNumber) { + return resultEmpty();//TODO + } + + @Override + public void update(RegisterResult registerResult, SimpleEidasData eidData) { + //TODO + } + + private ArrayList resultEmpty() { + return new ArrayList();//Nobody found + } + + +} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/IErnpClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/IErnpClient.java new file mode 100644 index 00000000..01ac88fb --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/IErnpClient.java @@ -0,0 +1,43 @@ +/* + * Copyright 2020 A-SIT Plus GmbH + * AT-specific eIDAS Connector has been developed in a cooperation between EGIZ, + * A-SIT Plus GmbH, A-SIT, and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "License"); + * You may not use this work except in compliance with the License. + * You may obtain a copy of the License at: + * https://joinup.ec.europa.eu/news/understanding-eupl-v12 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + +package at.asitplus.eidas.specific.modules.auth.eidas.v2.ernp; + +import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; + +import java.util.ArrayList; + +public interface IErnpClient { + + ArrayList searchWithPersonIdentifier(String personIdentifier); + + ArrayList searchWithMds(String givenName, String familyName, String dateOfBirth); + + ArrayList searchDeSpecific(String givenName, String familyName, String dateOfBirth, + String birthPlace, String birthName); + + ArrayList searchItSpecific(String taxNumber); + + void update(RegisterResult registerResult, SimpleEidasData eidData); +} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/exception/ManualFixNecessaryException.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/exception/ManualFixNecessaryException.java index c22e8135..2fecaa6b 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/exception/ManualFixNecessaryException.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/exception/ManualFixNecessaryException.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 A-SIT Plus GmbH + * Copyright 2020 A-SIT Plus GmbH * AT-specific eIDAS Connector has been developed in a cooperation between EGIZ, * A-SIT Plus GmbH, A-SIT, and Graz University of Technology. * @@ -29,10 +29,10 @@ public class ManualFixNecessaryException extends EidasSAuthenticationException { private static final long serialVersionUID = 1L; public ManualFixNecessaryException(String personIdentifier) { - super("eidas.00", new Object[] { personIdentifier });//TODO "eidas.00" + super("eidas.09", new Object[] { personIdentifier }); } public ManualFixNecessaryException(SimpleEidasData eidData) { - super("eidas.00", new Object[] { eidData.getPseudonym() });//TODO "eidas.00" => what info to pass??? + super("eidas.09", new Object[] { eidData.getPseudonym() });//TODO what info to pass??? } } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/exception/WorkflowException.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/exception/WorkflowException.java index aa879bcc..b6f3309b 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/exception/WorkflowException.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/exception/WorkflowException.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 A-SIT Plus GmbH + * Copyright 2020 A-SIT Plus GmbH * AT-specific eIDAS Connector has been developed in a cooperation between EGIZ, * A-SIT Plus GmbH, A-SIT, and Graz University of Technology. * @@ -19,7 +19,7 @@ * file for details on the various modules and licenses. * The "NOTICE" text file is part of the distribution. Any derivative works * that you distribute must include a readable copy of the "NOTICE" text file. -*/ + */ package at.asitplus.eidas.specific.modules.auth.eidas.v2.exception; @@ -27,7 +27,7 @@ public class WorkflowException extends EidasSAuthenticationException { private static final long serialVersionUID = 1L; public WorkflowException(String data) { - super("eidas.00", new Object[] { data }); + super("eidas.08", new Object[]{data}); } } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/CountrySpecificDetailSearchProcessor.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/CountrySpecificDetailSearchProcessor.java new file mode 100644 index 00000000..c5b3b231 --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/CountrySpecificDetailSearchProcessor.java @@ -0,0 +1,61 @@ +/* + * Copyright 2020 A-SIT Plus GmbH + * AT-specific eIDAS Connector has been developed in a cooperation between EGIZ, + * A-SIT Plus GmbH, A-SIT, and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "License"); + * You may not use this work except in compliance with the License. + * You may obtain a copy of the License at: + * https://joinup.ec.europa.eu/news/understanding-eupl-v12 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + +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.ernp.IErnpClient; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient; + +public abstract class CountrySpecificDetailSearchProcessor { + + protected IErnpClient ernbClient; + protected IZmrClient zmrClient; + + public CountrySpecificDetailSearchProcessor(IErnpClient ernbClient, IZmrClient zmrClient) { + this.ernbClient = ernbClient; + this.zmrClient = zmrClient; + } + + /** + * Get a friendlyName of this post-processor implementation. + * + * @return + */ + 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 + * @return true if this implementation can handle the country, otherwise false + */ + public abstract boolean canHandle(String countryCode, 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/DeSpecificDetailSearchProcessor.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/DeSpecificDetailSearchProcessor.java index e8cb7a1a..a29725c8 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 @@ -1,17 +1,40 @@ +/* + * Copyright 2020 A-SIT Plus GmbH + * AT-specific eIDAS Connector has been developed in a cooperation between EGIZ, + * A-SIT Plus GmbH, A-SIT, and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "License"); + * You may not use this work except in compliance with the License. + * You may obtain a copy of the License at: + * https://joinup.ec.europa.eu/news/understanding-eupl-v12 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + package at.asitplus.eidas.specific.modules.auth.eidas.v2.handler; 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.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.ernp.IErnpClient; import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient; import java.util.ArrayList; -public class DeSpecificDetailSearchProcessor extends ICountrySpecificDetailSearchProcessor { +public class DeSpecificDetailSearchProcessor extends CountrySpecificDetailSearchProcessor { - public DeSpecificDetailSearchProcessor(IErnbClient ernbClient, IZmrClient zmrClient) { + public DeSpecificDetailSearchProcessor(IErnpClient ernbClient, IZmrClient zmrClient) { super(ernbClient, zmrClient); } @@ -31,17 +54,17 @@ public class DeSpecificDetailSearchProcessor extends ICountrySpecificDetailSearc @Override public MergedRegisterSearchResult search(SimpleEidasData eidData) { - MergedRegisterSearchResult searchResult = new MergedRegisterSearchResult(); + ArrayList resultsZmr = zmrClient.searchDeSpecific(eidData.getGivenName(), eidData.getFamilyName(), eidData.getDateOfBirth(), eidData.getPlaceOfBirth(), eidData.getBirthName()); - searchResult.setResultsZmr(resultsZmr); ArrayList resultsErnb = ernbClient.searchDeSpecific(eidData.getGivenName(), eidData.getFamilyName(), eidData.getDateOfBirth(), eidData.getPlaceOfBirth(), eidData.getBirthName()); - searchResult.setResultsErnb(resultsErnb); + + MergedRegisterSearchResult searchResult = new MergedRegisterSearchResult(resultsZmr, 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 deleted file mode 100644 index 6a2b2c0a..00000000 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ICountrySpecificDetailSearchProcessor.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2018 A-SIT Plus GmbH - * AT-specific eIDAS Connector has been developed in a cooperation between EGIZ, - * A-SIT Plus GmbH, A-SIT, and Graz University of Technology. - * - * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "License"); - * You may not use this work except in compliance with the License. - * You may obtain a copy of the License at: - * https://joinup.ec.europa.eu/news/understanding-eupl-v12 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This product combines work with different licenses. See the "NOTICE" text - * file for details on the various modules and licenses. - * The "NOTICE" text file is part of the distribution. Any derivative works - * that you distribute must include a readable copy of the "NOTICE" text file. - */ - -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; - -public abstract class ICountrySpecificDetailSearchProcessor { - - protected IErnbClient ernbClient; - protected IZmrClient zmrClient; - - public ICountrySpecificDetailSearchProcessor(IErnbClient ernbClient, IZmrClient zmrClient) { - this.ernbClient = ernbClient; - this.zmrClient = zmrClient; - } - - /** - * Get a friendlyName of this post-processor implementation. - * - * @return - */ - 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 - * @return true if this implementation can handle the country, otherwise false - */ - public abstract boolean canHandle(String countryCode, 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 a94a67b3..e730066d 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 @@ -1,17 +1,40 @@ +/* + * Copyright 2020 A-SIT Plus GmbH + * AT-specific eIDAS Connector has been developed in a cooperation between EGIZ, + * A-SIT Plus GmbH, A-SIT, and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "License"); + * You may not use this work except in compliance with the License. + * You may obtain a copy of the License at: + * https://joinup.ec.europa.eu/news/understanding-eupl-v12 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + package at.asitplus.eidas.specific.modules.auth.eidas.v2.handler; 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.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.ernp.IErnpClient; import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient; import java.util.ArrayList; -public class ItSpecificDetailSearchProcessor extends ICountrySpecificDetailSearchProcessor { +public class ItSpecificDetailSearchProcessor extends CountrySpecificDetailSearchProcessor { - public ItSpecificDetailSearchProcessor(IErnbClient ernbClient, IZmrClient zmrClient) { + public ItSpecificDetailSearchProcessor(IErnpClient ernbClient, IZmrClient zmrClient) { super(ernbClient, zmrClient); } @@ -28,15 +51,14 @@ public class ItSpecificDetailSearchProcessor extends ICountrySpecificDetailSearc @Override public MergedRegisterSearchResult search(SimpleEidasData eidData) { - MergedRegisterSearchResult searchResult = new MergedRegisterSearchResult(); ArrayList resultsZmr = zmrClient.searchItSpecific(eidData.getTaxNumber()); - searchResult.setResultsZmr(resultsZmr); ArrayList resultsErnb = ernbClient.searchItSpecific(eidData.getTaxNumber()); - searchResult.setResultsErnb(resultsErnb); + + MergedRegisterSearchResult searchResult = new MergedRegisterSearchResult(resultsZmr, resultsErnb); return searchResult; } } 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 5906ee6c..c4f0f146 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 @@ -1,5 +1,5 @@ /* - * Copyright 2018 A-SIT Plus GmbH + * Copyright 2020 A-SIT Plus GmbH * AT-specific eIDAS Connector has been developed in a cooperation between EGIZ, * A-SIT Plus GmbH, A-SIT, and Graz University of Technology. * @@ -42,12 +42,11 @@ 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.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.exception.EidPostProcessingException; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.ernp.IErnpClient; 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.handler.CountrySpecificDetailSearchProcessor; import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasResponseUtils; import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient; import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; @@ -63,29 +62,32 @@ import lombok.extern.slf4j.Slf4j; /** - * Task that searches ErnB and ZMR before adding person to SZR. + * Task that searches ErnP and ZMR before adding person to SZR. * - * @author tlenz + * @author amarsalek */ @Slf4j @Component("InitialSearchTask") -// NOTE: General: Please rebase git commit and squash them where useful, i.e. "remove unused import" should -// not be a separate commit. public class InitialSearchTask extends AbstractAuthServletTask { - private List handlers = new ArrayList<>(); + private final List handlers; + private final IErnpClient ernpClient; + private final IZmrClient zmrClient; - private IErnbClient ernbClient; - private IZmrClient zmrClient; - - /* - * (non-Javadoc) - * - * @see at.gv.egovernment.moa.id.process.springweb.MoaIdTask#execute(at.gv. - * egovernment.moa.id.process.api.ExecutionContext, - * javax.servlet.http.HttpServletRequest, - * javax.servlet.http.HttpServletResponse) + /** + * Constructor. + * @param handlers List of countrySpecificSearchProcessors + * @param ernpClient Ernp client + * @param zmrClient ZMR client */ + public InitialSearchTask(List handlers, IErnpClient ernpClient, + IZmrClient zmrClient) { + this.ernpClient = ernpClient; + this.zmrClient = zmrClient; + this.handlers = handlers; + log.info("# " + handlers.size() + " country specific detail search services are registered"); + } + @Override public void execute(ExecutionContext executionContext, HttpServletRequest request, HttpServletResponse response) throws TaskExecutionException { @@ -94,7 +96,6 @@ public class InitialSearchTask extends AbstractAuthServletTask { final ILightResponse eidasResponse = authProcessData .getGenericDataFromSession(Constants.DATA_FULL_EIDAS_RESPONSE, ILightResponse.class); - // post-process eIDAS attributes final SimpleEidasData eidData = convertSimpleMapToSimpleData(convertEidasAttrToSimpleMap( eidasResponse.getAttributes().getAttributeMap())); @@ -107,10 +108,11 @@ public class InitialSearchTask extends AbstractAuthServletTask { } private String step2RegisterSearchWithPersonidentifier(SimpleEidasData eidData) throws TaskExecutionException { + log.trace("Starting step2RegisterSearchWithPersonidentifier"); String personIdentifier = eidData.getPseudonym(); MergedRegisterSearchResult result = searchInZmrAndErnp(personIdentifier); if (result.getResultCount() == 0) { - return step5CheckCountrySpecificSearchPossible(result, eidData); + return step5CheckAndPerformCountrySpecificSearchIfPossible(result, eidData); } else if (result.getResultCount() == 1) { return step3CheckRegisterUpdateNecessary(result, eidData); } @@ -118,46 +120,9 @@ public class InitialSearchTask extends AbstractAuthServletTask { new ManualFixNecessaryException(personIdentifier)); } - private SimpleEidasData convertSimpleMapToSimpleData(Map eidasAttrMap) - throws EidasAttributeException, EidPostProcessingException { - SimpleEidasData simpleEidasData = new SimpleEidasData(); - - final Object eIdentifierObj = eidasAttrMap.get(Constants.eIDAS_ATTR_PERSONALIDENTIFIER); - final Triple eIdentifier = - EidasResponseUtils.parseEidasPersonalIdentifier((String) eIdentifierObj); - simpleEidasData.setCitizenCountryCode(eIdentifier.getFirst()); - - // MDS attributes - simpleEidasData.setPseudonym(EidasResponseUtils.processPseudonym( - eidasAttrMap.get(Constants.eIDAS_ATTR_PERSONALIDENTIFIER))); - simpleEidasData.setFamilyName(EidasResponseUtils.processFamilyName( - eidasAttrMap.get(Constants.eIDAS_ATTR_CURRENTFAMILYNAME))); - simpleEidasData.setGivenName(EidasResponseUtils.processGivenName( - eidasAttrMap.get(Constants.eIDAS_ATTR_CURRENTGIVENNAME))); - simpleEidasData.setDateOfBirth(EidasResponseUtils.processDateOfBirthToString( - eidasAttrMap.get(Constants.eIDAS_ATTR_DATEOFBIRTH))); - - // additional attributes - simpleEidasData.setPlaceOfBirth(EidasResponseUtils.processPlaceOfBirth( - eidasAttrMap.get(Constants.eIDAS_ATTR_PLACEOFBIRTH))); - simpleEidasData.setBirthName(EidasResponseUtils.processBirthName( - eidasAttrMap.get(Constants.eIDAS_ATTR_BIRTHNAME))); - 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; - } - private String step3CheckRegisterUpdateNecessary(MergedRegisterSearchResult result, SimpleEidasData eidData) throws TaskExecutionException { - //check if data from eidas authentication matches with data from register - log.debug("Compare " + result + " with " + eidData); + log.trace("Starting step3CheckRegisterUpdateNecessary"); try { if (eidData.equalsRegisterData(result)) { //No update necessary, just return bpk @@ -172,18 +137,19 @@ public class InitialSearchTask extends AbstractAuthServletTask { private String step4UpdateRegisterData(MergedRegisterSearchResult result, SimpleEidasData eidData) throws WorkflowException { + log.trace("Starting step4UpdateRegisterData"); log.debug("Update " + result + " with " + eidData); //TODO wann rechtlich möglich? return result.getBpk(); } - private String step5CheckCountrySpecificSearchPossible(MergedRegisterSearchResult result, SimpleEidasData eidData) - throws TaskExecutionException { + private String step5CheckAndPerformCountrySpecificSearchIfPossible( + MergedRegisterSearchResult result, SimpleEidasData eidData) throws TaskExecutionException { + log.trace("Starting step5CheckAndPerformCountrySpecificSearchIfPossible"); String citizenCountry = eidData.getCitizenCountryCode(); - ICountrySpecificDetailSearchProcessor foundHandler = null; - for (final ICountrySpecificDetailSearchProcessor el : handlers) { - //5 check if country specific search is possible + CountrySpecificDetailSearchProcessor foundHandler = null; + for (final CountrySpecificDetailSearchProcessor el : handlers) { if (el.canHandle(citizenCountry, eidData)) { log.debug("Found suitable country specific search handler for " + citizenCountry + " by using: " + el.getName()); @@ -192,18 +158,16 @@ public class InitialSearchTask extends AbstractAuthServletTask { } } if (foundHandler == null) { - //MDS search return step8RegisterSearchWithMds(result, eidData); } else { - //country specific search return step6CountrySpecificSearch(foundHandler, result, eidData); } } - private String step6CountrySpecificSearch(ICountrySpecificDetailSearchProcessor countrySpecificDetailSearchProcessor, + private String step6CountrySpecificSearch(CountrySpecificDetailSearchProcessor countrySpecificDetailSearchProcessor, MergedRegisterSearchResult initialSearchResult, SimpleEidasData eidData) throws TaskExecutionException { - //6 country specific search + log.trace("Starting step6CountrySpecificSearch"); MergedRegisterSearchResult countrySpecificDetailSearchResult = countrySpecificDetailSearchProcessor.search(eidData); @@ -212,7 +176,7 @@ public class InitialSearchTask extends AbstractAuthServletTask { return step8RegisterSearchWithMds(initialSearchResult, eidData); case 1: return step7aKittProcess(initialSearchResult, countrySpecificDetailSearchResult, eidData); - default://should not happen + default: throw new TaskExecutionException(pendingReq, "Detail search - Kitt Process necessary.", new ManualFixNecessaryException(eidData)); } @@ -221,8 +185,7 @@ public class InitialSearchTask extends AbstractAuthServletTask { private String step7aKittProcess(MergedRegisterSearchResult initialSearchResult, MergedRegisterSearchResult countrySpecificDetailSearchResult, SimpleEidasData eidData) throws TaskExecutionException { - //Automerge data - log.debug("Automerge " + initialSearchResult + " with " + eidData + " " + countrySpecificDetailSearchResult); + log.trace("Starting step7aKittProcess"); try { if (initialSearchResult.getResultCount() != 0) { throw new WorkflowException("initialSearchResult.getResultCount() != 0"); @@ -231,14 +194,11 @@ public class InitialSearchTask extends AbstractAuthServletTask { throw new WorkflowException("countrySpecificDetailSearchResult.getResultCount() != 1"); } if (countrySpecificDetailSearchResult.getResultsZmr().size() == 1) { - //update ZMR zmrClient.update(countrySpecificDetailSearchResult.getResultsZmr().get(0), eidData); } - if (countrySpecificDetailSearchResult.getResultsErnb().size() == 1) { - //update ErnB - ernbClient.update(countrySpecificDetailSearchResult.getResultsErnb().get(0), eidData); + if (countrySpecificDetailSearchResult.getResultsErnp().size() == 1) { + ernpClient.update(countrySpecificDetailSearchResult.getResultsErnp().get(0), eidData); } - String bpK = countrySpecificDetailSearchResult.getBpk(); return bpK; } catch (WorkflowException e) { @@ -248,35 +208,70 @@ public class InitialSearchTask extends AbstractAuthServletTask { private String step8RegisterSearchWithMds(MergedRegisterSearchResult initialSearchResult, SimpleEidasData eidData) { - MergedRegisterSearchResult mdsSearchResult = new MergedRegisterSearchResult(); - + log.trace("Starting step8RegisterSearchWithMds"); ArrayList resultsZmr = zmrClient.searchWithMds(eidData.getGivenName(), eidData.getFamilyName(), eidData.getDateOfBirth()); - mdsSearchResult.setResultsZmr(resultsZmr); - ArrayList resultsErnb = - ernbClient.searchWithMds(eidData.getGivenName(), eidData.getFamilyName(), eidData.getDateOfBirth()); - mdsSearchResult.setResultsErnb(resultsErnb); + ArrayList resultsErnp = + ernpClient.searchWithMds(eidData.getGivenName(), eidData.getFamilyName(), eidData.getDateOfBirth()); + MergedRegisterSearchResult mdsSearchResult = new MergedRegisterSearchResult(resultsZmr, resultsErnp); log.debug("Automerge " + initialSearchResult + " with " + eidData + " " + mdsSearchResult); //TODO implement next phase and return correct value return "TODO-Temporary-Endnode-105"; } private MergedRegisterSearchResult searchInZmrAndErnp(String personIdentifier) { - MergedRegisterSearchResult initialSearchResult = new MergedRegisterSearchResult(); ArrayList resultsZmr = - zmrClient.searchWithPersonIdentifer(personIdentifier); - initialSearchResult.setResultsZmr(resultsZmr); + zmrClient.searchWithPersonIdentifier(personIdentifier); - ArrayList resultsErnb = - ernbClient.searchWithPersonIdentifer(personIdentifier); - initialSearchResult.setResultsErnb(resultsErnb); + ArrayList resultsErnp = + ernpClient.searchWithPersonIdentifier(personIdentifier); + MergedRegisterSearchResult initialSearchResult = new MergedRegisterSearchResult(resultsZmr, resultsErnp); return initialSearchResult; } + private SimpleEidasData convertSimpleMapToSimpleData(Map eidasAttrMap) + throws EidasAttributeException { + SimpleEidasData simpleEidasData = new SimpleEidasData(); + + final Object eIdentifierObj = eidasAttrMap.get(Constants.eIDAS_ATTR_PERSONALIDENTIFIER); + final Triple eIdentifier = + EidasResponseUtils.parseEidasPersonalIdentifier((String) eIdentifierObj); + if (eIdentifier == null) { + throw new EidasAttributeException("Error processing eIdentifier"); + } + simpleEidasData.setCitizenCountryCode(eIdentifier.getFirst()); + + // MDS attributes + simpleEidasData.setPseudonym(EidasResponseUtils.processPseudonym( + eidasAttrMap.get(Constants.eIDAS_ATTR_PERSONALIDENTIFIER))); + simpleEidasData.setFamilyName(EidasResponseUtils.processFamilyName( + eidasAttrMap.get(Constants.eIDAS_ATTR_CURRENTFAMILYNAME))); + simpleEidasData.setGivenName(EidasResponseUtils.processGivenName( + eidasAttrMap.get(Constants.eIDAS_ATTR_CURRENTGIVENNAME))); + simpleEidasData.setDateOfBirth(EidasResponseUtils.processDateOfBirthToString( + eidasAttrMap.get(Constants.eIDAS_ATTR_DATEOFBIRTH))); + + // additional attributes + simpleEidasData.setPlaceOfBirth(EidasResponseUtils.processPlaceOfBirth( + eidasAttrMap.get(Constants.eIDAS_ATTR_PLACEOFBIRTH))); + simpleEidasData.setBirthName(EidasResponseUtils.processBirthName( + eidasAttrMap.get(Constants.eIDAS_ATTR_BIRTHNAME))); + 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; + } + private Map convertEidasAttrToSimpleMap( ImmutableMap, ImmutableSet>> attributeMap) { final Map result = new HashMap<>(); @@ -293,7 +288,6 @@ public class InitialSearchTask extends AbstractAuthServletTask { } else { log.info("Ignore empty 'DateTime' attribute"); } - } else if (PostalAddress.class.equals(parameterizedType)) { final PostalAddress addressAttribute = EidasResponseUtils .translateAddressAttribute(el, attributeMap.get(el).asList()); @@ -304,7 +298,6 @@ public class InitialSearchTask extends AbstractAuthServletTask { } else { log.info("Ignore empty 'PostalAddress' attribute"); } - } else { final List natPersonIdObj = EidasResponseUtils .translateStringListAttribute(el, attributeMap.get(el)); @@ -312,7 +305,6 @@ public class InitialSearchTask extends AbstractAuthServletTask { if (StringUtils.isNotEmpty(stringAttr)) { result.put(el.getFriendlyName(), stringAttr); log.trace("Find attr '" + el.getFriendlyName() + "' with value: " + stringAttr); - } else { log.info("Ignore empty 'String' attribute"); } @@ -324,18 +316,4 @@ public class InitialSearchTask extends AbstractAuthServletTask { return result; } - - /** - * Constructor. - * @param handlers List of countrySpecificSearchProcessors - * @param ernbClient Ernb client - * @param zmrClient ZMR client - */ - public InitialSearchTask(List handlers, IErnbClient ernbClient, - IZmrClient zmrClient) { - this.ernbClient = ernbClient; - this.zmrClient = zmrClient; - this.handlers = handlers; - log.info("# " + handlers.size() + " country specific detail search services are registered"); - } } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveAuthnResponseTask.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveAuthnResponseTask.java index 684546f7..0f733e8d 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveAuthnResponseTask.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveAuthnResponseTask.java @@ -94,7 +94,7 @@ public class ReceiveAuthnResponseTask extends AbstractAuthServletTask { attrRegistry); // ********************************************************** - // ******* Store resonse infos into session object ********** + // ******* Store response infos into session object ********** // ********************************************************** // update MOA-Session data with received information 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 aaa4212a..fa26c2c5 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 @@ -31,9 +31,6 @@ import java.util.regex.Pattern; import javax.annotation.Nullable; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidPostProcessingException; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasAttributeException; -import at.gv.e_government.reference.namespace.persondata._20020228.PostalAddressType; import org.apache.commons.lang3.StringUtils; import org.joda.time.DateTime; import org.slf4j.Logger; @@ -43,6 +40,8 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasAttributeException; +import at.gv.e_government.reference.namespace.persondata._20020228.PostalAddressType; import at.gv.egiz.eaaf.core.impl.data.Triple; import eu.eidas.auth.commons.attribute.AttributeDefinition; import eu.eidas.auth.commons.attribute.AttributeValue; @@ -177,7 +176,6 @@ public class EidasResponseUtils { ImmutableList> attributeValues) { final AttributeValue firstAttributeValue = attributeValues.get(0); return (PostalAddress) firstAttributeValue.getValue(); - } /** @@ -185,34 +183,24 @@ public class EidasResponseUtils { * * @param currentAddressObj eIDAS current address information * @return current address or null if no attribute is available - * @throws EidPostProcessingException if post-processing fails * @throws EidasAttributeException if eIDAS attribute is of a wrong type */ - public static PostalAddressType processAddress(Object currentAddressObj) throws EidPostProcessingException, - EidasAttributeException { - + public static PostalAddressType processAddress(Object currentAddressObj) throws EidasAttributeException { if (currentAddressObj != null) { if (currentAddressObj instanceof PostalAddress) { final PostalAddressType result = new PostalAddressType(); result.setPostalCode(((PostalAddress) currentAddressObj).getPostCode()); result.setMunicipality(((PostalAddress) currentAddressObj).getPostName()); - // TODO: add more mappings - return result; - } else { log.warn("eIDAS attr: " + Constants.eIDAS_ATTR_CURRENTADDRESS + " is of WRONG type"); throw new EidasAttributeException(Constants.eIDAS_ATTR_CURRENTADDRESS); - } - } else { log.debug("NO '" + Constants.eIDAS_ATTR_CURRENTADDRESS + "' attribute. Post-Processing skipped ... "); } - return null; - } /** @@ -220,27 +208,20 @@ public class EidasResponseUtils { * * @param birthNameObj eIDAS birthname information * @return birthName or null if no attribute is available - * @throws EidPostProcessingException if post-processing fails * @throws EidasAttributeException if eIDAS attribute is of a wrong type */ - public static String processBirthName(Object birthNameObj) throws EidPostProcessingException, - EidasAttributeException { + public static String processBirthName(Object birthNameObj) throws EidasAttributeException { if (birthNameObj != null) { if (birthNameObj instanceof String) { return (String) birthNameObj; - } else { log.warn("eIDAS attr: " + Constants.eIDAS_ATTR_BIRTHNAME + " is of WRONG type"); throw new EidasAttributeException(Constants.eIDAS_ATTR_BIRTHNAME); - } - } else { log.debug("NO '" + Constants.eIDAS_ATTR_BIRTHNAME + "' attribute. Post-Processing skipped ... "); } - return null; - } /** @@ -248,11 +229,9 @@ public class EidasResponseUtils { * * @param placeOfBirthObj eIDAS Place-of-Birth information * @return place of Birth or null if no attribute is available - * @throws EidPostProcessingException if post-processing fails * @throws EidasAttributeException if eIDAS attribute is of a wrong type */ - public static String processPlaceOfBirth(Object placeOfBirthObj) throws EidPostProcessingException, - EidasAttributeException { + public static String processPlaceOfBirth(Object placeOfBirthObj) throws EidasAttributeException { if (placeOfBirthObj != null) { if (placeOfBirthObj instanceof String) { return (String) placeOfBirthObj; @@ -266,9 +245,7 @@ public class EidasResponseUtils { } else { log.debug("NO '" + Constants.eIDAS_ATTR_PLACEOFBIRTH + "' attribute. Post-Processing skipped ... "); } - return null; - } /** @@ -277,16 +254,12 @@ public class EidasResponseUtils { * @param dateOfBirthObj eIDAS date-of-birth attribute information * @return formated user's date-of-birth * @throws EidasAttributeException if NO attribute is available - * @throws EidPostProcessingException if post-processing fails */ - public static DateTime processDateOfBirth(Object dateOfBirthObj) throws EidPostProcessingException, - EidasAttributeException { - if (dateOfBirthObj == null || !(dateOfBirthObj instanceof DateTime)) { + public static DateTime processDateOfBirth(Object dateOfBirthObj) throws EidasAttributeException { + if (!(dateOfBirthObj instanceof DateTime)) { throw new EidasAttributeException(Constants.eIDAS_ATTR_DATEOFBIRTH); } - return (DateTime) dateOfBirthObj; - } /** @@ -295,11 +268,9 @@ public class EidasResponseUtils { * @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)) { + public static String processDateOfBirthToString(Object dateOfBirthObj) throws EidasAttributeException { + if (!(dateOfBirthObj instanceof DateTime)) { throw new EidasAttributeException(Constants.eIDAS_ATTR_DATEOFBIRTH); } return new SimpleDateFormat("yyyy-MM-dd").format(((DateTime) dateOfBirthObj).toDate()); @@ -311,16 +282,12 @@ public class EidasResponseUtils { * @param givenNameObj eIDAS givenName attribute information * @return formated user's givenname * @throws EidasAttributeException if NO attribute is available - * @throws EidPostProcessingException if post-processing fails */ - public static String processGivenName(Object givenNameObj) throws EidPostProcessingException, - EidasAttributeException { - if (givenNameObj == null || !(givenNameObj instanceof String)) { + public static String processGivenName(Object givenNameObj) throws EidasAttributeException { + if (!(givenNameObj instanceof String)) { throw new EidasAttributeException(Constants.eIDAS_ATTR_CURRENTGIVENNAME); } - return (String) givenNameObj; - } /** @@ -329,16 +296,12 @@ public class EidasResponseUtils { * @param familyNameObj eIDAS familyName attribute information * @return formated user's familyname * @throws EidasAttributeException if NO attribute is available - * @throws EidPostProcessingException if post-processing fails */ - public static String processFamilyName(Object familyNameObj) throws EidPostProcessingException, - EidasAttributeException { - if (familyNameObj == null || !(familyNameObj instanceof String)) { + public static String processFamilyName(Object familyNameObj) throws EidasAttributeException { + if (!(familyNameObj instanceof String)) { throw new EidasAttributeException(Constants.eIDAS_ATTR_CURRENTFAMILYNAME); } - return (String) familyNameObj; - } /** @@ -347,17 +310,16 @@ public class EidasResponseUtils { * @param personalIdObj eIDAS PersonalIdentifierAttribute * @return Unique personal identifier without country-code information * @throws EidasAttributeException if NO attribute is available - * @throws EidPostProcessingException if post-processing fails */ - public static String processPseudonym(Object personalIdObj) throws EidPostProcessingException, - EidasAttributeException { - if (personalIdObj == null || !(personalIdObj instanceof String)) { + public static String processPseudonym(Object personalIdObj) throws EidasAttributeException { + if (!(personalIdObj instanceof String)) { throw new EidasAttributeException(Constants.eIDAS_ATTR_PERSONALIDENTIFIER); } - final Triple eIdentifier = EidasResponseUtils.parseEidasPersonalIdentifier((String) personalIdObj); - + if (eIdentifier.getThird() == null) { + throw new EidasAttributeException("Error processing eIdentifier"); + } return eIdentifier.getThird(); } @@ -367,15 +329,11 @@ public class EidasResponseUtils { * @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)) { + public static String processTaxReference(Object taxReferenceObj) throws EidasAttributeException { + if (!(taxReferenceObj instanceof String)) { throw new EidasAttributeException(Constants.eIDAS_ATTR_CURRENTGIVENNAME); } - return (String) taxReferenceObj; - } } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/zmr/DummyZmrClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/zmr/DummyZmrClient.java index f4d77b03..60dd2ef2 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/zmr/DummyZmrClient.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/zmr/DummyZmrClient.java @@ -1,3 +1,26 @@ +/* + * Copyright 2020 A-SIT Plus GmbH + * AT-specific eIDAS Connector has been developed in a cooperation between EGIZ, + * A-SIT Plus GmbH, A-SIT, and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "License"); + * You may not use this work except in compliance with the License. + * You may obtain a copy of the License at: + * https://joinup.ec.europa.eu/news/understanding-eupl-v12 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + package at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult; @@ -10,7 +33,7 @@ import java.util.ArrayList; public class DummyZmrClient implements IZmrClient { @Override - public ArrayList searchWithPersonIdentifer(String personIdentifer) { + public ArrayList searchWithPersonIdentifier(String personIdentifier) { return resultEmpty(); } @@ -26,7 +49,7 @@ public class DummyZmrClient implements IZmrClient { } @Override - public ArrayList searchItSpecific(String txNumber) { + public ArrayList searchItSpecific(String taxNumber) { return resultEmpty();//TODO } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/zmr/IZmrClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/zmr/IZmrClient.java index 4af7bfe9..3a518e64 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/zmr/IZmrClient.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/zmr/IZmrClient.java @@ -1,3 +1,26 @@ +/* + * Copyright 2020 A-SIT Plus GmbH + * AT-specific eIDAS Connector has been developed in a cooperation between EGIZ, + * A-SIT Plus GmbH, A-SIT, and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "License"); + * You may not use this work except in compliance with the License. + * You may obtain a copy of the License at: + * https://joinup.ec.europa.eu/news/understanding-eupl-v12 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + package at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult; @@ -7,14 +30,14 @@ import java.util.ArrayList; public interface IZmrClient { - ArrayList searchWithPersonIdentifer(String personIdentifer); + ArrayList searchWithPersonIdentifier(String personIdentifier); ArrayList searchWithMds(String givenName, String familyName, String dateOfBirth); ArrayList searchDeSpecific(String givenName, String familyName, String dateOfBirth, String birthPlace, String birthName); - ArrayList searchItSpecific(String txNumber); + ArrayList searchItSpecific(String taxNumber); void update(RegisterResult registerResult, SimpleEidasData eidData); } -- cgit v1.2.3