From e4e4fbf37aa0326b1c06f907a13593732c23deb7 Mon Sep 17 00:00:00 2001 From: Alexander Marsalek Date: Fri, 22 Jan 2021 09:53:50 +0100 Subject: processing after mobilephone auth response --- .../specific/modules/auth/eidas/v2/Constants.java | 2 +- .../modules/auth/eidas/v2/dao/SimpleEidasData.java | 4 +- .../auth/eidas/v2/ernp/DummyErnpClient.java | 6 ++ .../modules/auth/eidas/v2/ernp/IErnpClient.java | 1 + .../GenerateMobilePhoneSignatureRequestTask.java | 11 +++ .../auth/eidas/v2/tasks/InitialSearchTask.java | 35 +++---- .../ReceiveGuiAustrianResidenceResponseTask.java | 1 + ...eSignatureResponseAndSearchInRegistersTask.java | 101 +++++++++++++++++++++ .../ReceiveMobilePhoneSignatureResponseTask.java | 56 ------------ .../auth/eidas/v2/utils/EidasResponseUtils.java | 16 ++-- .../modules/auth/eidas/v2/utils/Utils.java | 48 ++++++++++ .../modules/auth/eidas/v2/zmr/DummyZmrClient.java | 6 ++ .../modules/auth/eidas/v2/zmr/IZmrClient.java | 2 + .../src/main/resources/eidas_v2_auth.beans.xml | 2 +- .../resources/SpringTest-context_tasks_test.xml | 2 +- 15 files changed, 203 insertions(+), 90 deletions(-) create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTask.java delete mode 100644 eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseTask.java create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/utils/Utils.java (limited to 'eidas_modules/authmodule-eIDAS-v2/src') 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 8a1a63f5..858637e9 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 @@ -34,7 +34,7 @@ public class Constants { public static final String DATA_FULL_EIDAS_RESPONSE = "resp_fulleIDASResponse"; public static final String DATA_RESULT_MATCHING_BPK = "matching-result-bpk"; public static final String DATA_SIMPLE_EIDAS = "simple_eidas_data"; - + public static final String DATA_INITIAL_REGISTER_RESULT = "initial_register_result"; // 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/SimpleEidasData.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java index b86984d0..17f2b1ee 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 @@ -84,10 +84,10 @@ public class SimpleEidasData { if (a == null && b == null) { return true; } - if (a == null && b != null) { + if (a == null) { return false; } - if (a != null && b == null) { + if (b == null) { return false; } return a.equals(b); 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 index 22482638..77411dd1 100644 --- 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 @@ -68,5 +68,11 @@ public class DummyErnpClient implements IErnpClient { return false; } + @Override + public List searchWithBpkZp(String bpkzp) { + //TODO + return Collections.emptyList(); + } + } 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 index 2f82387f..0c994f69 100644 --- 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 @@ -43,4 +43,5 @@ public interface IErnpClient { boolean createNewEntry(SimpleEidasData simpleEidasData); + List searchWithBpkZp(String bpkzp); } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/GenerateMobilePhoneSignatureRequestTask.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/GenerateMobilePhoneSignatureRequestTask.java index 0f2fc8a3..736ac6e5 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/GenerateMobilePhoneSignatureRequestTask.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/GenerateMobilePhoneSignatureRequestTask.java @@ -27,6 +27,7 @@ import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; import at.gv.egiz.eaaf.core.impl.idp.auth.modules.AbstractAuthServletTask; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; import javax.servlet.http.HttpServletRequest; @@ -48,6 +49,16 @@ public class GenerateMobilePhoneSignatureRequestTask extends AbstractAuthServlet try { log.trace("Starting GenerateMobilePhoneSignatureRequestTask"); //step 15a + // get entityID for ms-specific eIDAS node + final String msNodeEntityID = "TODO"; + + if (StringUtils.isEmpty(msNodeEntityID)) { + log.info("eIDAS authentication not possible -> NO EntityID for central eIDAS node FOUND!"); + throw new TaskExecutionException(pendingReq, "", null); + + } + //MsEidasNodeConstants.ENDPOINT_PVP_POST + //MsEidasNodeConstants.ENDPOINT_PVP_METADATA //TODO } catch (final Exception e) { 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 9e5b4d67..99da21a1 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 @@ -33,8 +33,10 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.ManualFixNeces import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.WorkflowException; import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.CountrySpecificDetailSearchProcessor; import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasResponseUtils; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.Utils; import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient; import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; +import at.gv.egiz.eaaf.core.exceptions.EaafStorageException; import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; import at.gv.egiz.eaaf.core.impl.data.Triple; import at.gv.egiz.eaaf.core.impl.idp.auth.data.AuthProcessDataWrapper; @@ -96,19 +98,26 @@ public class InitialSearchTask extends AbstractAuthServletTask { final SimpleEidasData eidData = convertSimpleMapToSimpleData(convertEidasAttrToSimpleMap( eidasResponse.getAttributes().getAttributeMap())); - String bpK = step2RegisterSearchWithPersonidentifier(eidData); + String bpK = step2RegisterSearchWithPersonidentifier(eidData, authProcessData); authProcessData.setGenericDataToSession(Constants.DATA_RESULT_MATCHING_BPK, bpK); - authProcessData.setGenericDataToSession(Constants.DATA_SIMPLE_EIDAS, eidasResponse); + authProcessData.setGenericDataToSession(Constants.DATA_SIMPLE_EIDAS, eidData); } catch (final Exception e) { log.error("Initial search FAILED.", e); throw new TaskExecutionException(pendingReq, "Initial search FAILED.", e); } } - private String step2RegisterSearchWithPersonidentifier(SimpleEidasData eidData) throws TaskExecutionException { + private String step2RegisterSearchWithPersonidentifier(SimpleEidasData eidData, + AuthProcessDataWrapper authProcessData) throws TaskExecutionException { log.trace("Starting step2RegisterSearchWithPersonidentifier"); String personIdentifier = eidData.getPseudonym(); MergedRegisterSearchResult result = searchInZmrAndErnp(personIdentifier); + //store data in session + try { + authProcessData.setGenericDataToSession(Constants.DATA_INITIAL_REGISTER_RESULT, result); + } catch (EaafStorageException e) { + throw new TaskExecutionException(pendingReq, "Initial search - Kitt Process necessary.",e); + } if (result.getResultCount() == 0) { return step5CheckAndPerformCountrySpecificSearchIfPossible(result, eidData); } else if (result.getResultCount() == 1) { @@ -184,24 +193,8 @@ public class InitialSearchTask extends AbstractAuthServletTask { MergedRegisterSearchResult countrySpecificDetailSearchResult, SimpleEidasData eidData) throws TaskExecutionException { log.trace("Starting step7aKittProcess"); - try { - if (initialSearchResult.getResultCount() != 0) { - throw new WorkflowException("initialSearchResult.getResultCount() != 0"); - } - if (countrySpecificDetailSearchResult.getResultCount() != 1) { - throw new WorkflowException("countrySpecificDetailSearchResult.getResultCount() != 1"); - } - if (countrySpecificDetailSearchResult.getResultsZmr().size() == 1) { - zmrClient.update(countrySpecificDetailSearchResult.getResultsZmr().get(0), eidData); - } - if (countrySpecificDetailSearchResult.getResultsErnp().size() == 1) { - ernpClient.update(countrySpecificDetailSearchResult.getResultsErnp().get(0), eidData); - } - String bpK = countrySpecificDetailSearchResult.getBpk(); - return bpK; - } catch (WorkflowException e) { - throw new TaskExecutionException(pendingReq, "Step7a failed.", e); - } + return Utils.step7aKittProcess(ernpClient, zmrClient, initialSearchResult, countrySpecificDetailSearchResult, + eidData, pendingReq); } private String step8RegisterSearchWithMds(SimpleEidasData eidData) { diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveGuiAustrianResidenceResponseTask.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveGuiAustrianResidenceResponseTask.java index 3bbb59d1..34fbf507 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveGuiAustrianResidenceResponseTask.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveGuiAustrianResidenceResponseTask.java @@ -68,6 +68,7 @@ public class ReceiveGuiAustrianResidenceResponseTask extends AbstractAuthServlet } } + } catch (final Exception e) { log.error("Parsing selected login method FAILED.", e); throw new TaskExecutionException(pendingReq, "Parsing selected login method FAILED.", e); diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTask.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTask.java new file mode 100644 index 00000000..b598cb92 --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTask.java @@ -0,0 +1,101 @@ +/* + * Copyright 2021 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.tasks; + +import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.MergedRegisterSearchResult; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.ernp.IErnpClient; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.ManualFixNecessaryException; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.Utils; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient; +import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; +import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; +import at.gv.egiz.eaaf.core.impl.idp.auth.data.AuthProcessDataWrapper; +import at.gv.egiz.eaaf.core.impl.idp.auth.modules.AbstractAuthServletTask; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +/** + * Task that searches ErnB and ZMR before adding person to SZR. + * + * @author amarsalek + */ +@Slf4j +@Component("ReceiveMobilePhoneSignatureResponseTask") +public class ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTask extends AbstractAuthServletTask { + + private final IErnpClient ernpClient; + private final IZmrClient zmrClient; + + public ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTask(IErnpClient ernpClient, IZmrClient zmrClient) { + this.ernpClient = ernpClient; + this.zmrClient = zmrClient; + } + + @Override + public void execute(ExecutionContext executionContext, HttpServletRequest request, HttpServletResponse response) + throws TaskExecutionException { + try { + log.trace("Starting ReceiveMobilePhoneSignatureResponseTask");//Node 15 + final AuthProcessDataWrapper authProcessData = pendingReq.getSessionData(AuthProcessDataWrapper.class); + MergedRegisterSearchResult initialSearchResult = + authProcessData.getGenericDataFromSession(Constants.DATA_INITIAL_REGISTER_RESULT, + MergedRegisterSearchResult.class); + SimpleEidasData eidData = authProcessData.getGenericDataFromSession(Constants.DATA_SIMPLE_EIDAS, + SimpleEidasData.class); + + //TODO extract bPK-ZP from response + String bpkzp = "TODO"; + MergedRegisterSearchResult result = searchInZmrAndErnp(bpkzp); + if (result.getResultCount() == 0) { + //go to step 16 + //TODO set context variable + return; + } else if (result.getResultCount() == 1) { + String bpk = Utils.step7aKittProcess(ernpClient, zmrClient, initialSearchResult, result, eidData, pendingReq); + authProcessData.setGenericDataToSession(Constants.DATA_RESULT_MATCHING_BPK, bpk); + //node 110 + //TODO bpk vs bpkzp???? same? + } else if (result.getResultCount() > 1) { + throw new ManualFixNecessaryException("bpkzp:" + bpkzp);// node 108 + } + + } catch (final Exception e) { + log.error("Initial search FAILED.", e); + throw new TaskExecutionException(pendingReq, "Initial search FAILED.", e); + } + } + + private MergedRegisterSearchResult searchInZmrAndErnp(String bpkzp) { + List resultsZmr = zmrClient.searchWithBpkZp(bpkzp); + List resultsErnp = ernpClient.searchWithBpkZp(bpkzp); + return new MergedRegisterSearchResult(resultsZmr, resultsErnp); + } +} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseTask.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseTask.java deleted file mode 100644 index 4329fc2e..00000000 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseTask.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2021 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.tasks; - -import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; -import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; -import at.gv.egiz.eaaf.core.impl.idp.auth.modules.AbstractAuthServletTask; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * Task that searches ErnB and ZMR before adding person to SZR. - * - * @author amarsalek - */ -@Slf4j -@Component("ReceiveMobilePhoneSignatureResponseTask") -public class ReceiveMobilePhoneSignatureResponseTask extends AbstractAuthServletTask { - - @Override - public void execute(ExecutionContext executionContext, HttpServletRequest request, HttpServletResponse response) - throws TaskExecutionException { - try { - log.trace("Starting ReceiveMobilePhoneSignatureResponseTask"); - //TODO - } catch (final Exception e) { - log.error("Initial search FAILED.", e); - throw new TaskExecutionException(pendingReq, "Initial search FAILED.", e); - } - } - -} 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 ef8822aa..1d47df20 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 @@ -49,7 +49,6 @@ import java.util.regex.Pattern; public class EidasResponseUtils { private static final Logger log = LoggerFactory.getLogger(EidasResponseUtils.class); - public static final String PERSONALIDENIFIER_VALIDATION_PATTERN = "^[A-Z,a-z]{2}/[A-Z,a-z]{2}/.*"; /** @@ -58,7 +57,7 @@ public class EidasResponseUtils { * * @param uniqueID eIDAS attribute value of a unique identifier * @return true if the uniqueID matches to eIDAS to Unique Identifier - * specification, otherwise false + * specification, otherwise false */ public static boolean validateEidasPersonalIdentifier(String uniqueID) { final Pattern pattern = Pattern.compile(PERSONALIDENIFIER_VALIDATION_PATTERN); @@ -73,12 +72,13 @@ public class EidasResponseUtils { * Unique Identifier * * @param uniqueID eIDAS attribute value of a unique identifier - * @return {@link Triple} that contains:
- * First : citizen country
- * Second: destination country
- * Third : unique identifier
- * or null if the attribute value has a wrong format + * @return {@link Trible} that contains:
+ * First : citizen country
+ * Second: destination country
+ * Third : unique identifier
+ * or null if the attribute value has a wrong format */ + public static Triple parseEidasPersonalIdentifier(String uniqueID) { if (!validateEidasPersonalIdentifier(uniqueID)) { log.error("eIDAS attribute value for {} looks wrong formated. Value: {}", @@ -96,7 +96,7 @@ public class EidasResponseUtils { * @param attributeDefinition eIDAS attribute definition * @param attributeValues Attributes from eIDAS response * @return Set of attribute values. If more then one value than the first value - * contains the 'Latin' value. + * contains the 'Latin' value. */ // TODO: check possible problem with nonLatinCharacters public static List translateStringListAttribute(AttributeDefinition attributeDefinition, diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/utils/Utils.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/utils/Utils.java new file mode 100644 index 00000000..5612d137 --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/utils/Utils.java @@ -0,0 +1,48 @@ +package at.asitplus.eidas.specific.modules.auth.eidas.v2.utils; + +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.exception.WorkflowException; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient; +import at.gv.egiz.eaaf.core.api.IRequest; +import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; + +public class Utils { + + /** + * Automatic process to fix the register entries. + * + * @param ernpClient ErnP client + * @param zmrClient ZMR client + * @param initialSearchResult Result of initial register search + * @param specificDetailSearchResult Result of last register search + * @param eidData Received eidas data + * @param pendingReq Pending request + * @return The bpk + * @throws TaskExecutionException if an error occurs during the register update + */ + public static String step7aKittProcess(IErnpClient ernpClient, IZmrClient zmrClient, + MergedRegisterSearchResult initialSearchResult, + MergedRegisterSearchResult specificDetailSearchResult, + SimpleEidasData eidData, IRequest pendingReq) throws TaskExecutionException { + try { + if (initialSearchResult.getResultCount() != 0) { + throw new WorkflowException("initialSearchResult.getResultCount() != 0"); + } + if (specificDetailSearchResult.getResultCount() != 1) { + throw new WorkflowException("countrySpecificDetailSearchResult.getResultCount() != 1"); + } + if (specificDetailSearchResult.getResultsZmr().size() == 1) { + zmrClient.update(specificDetailSearchResult.getResultsZmr().get(0), eidData); + } + if (specificDetailSearchResult.getResultsErnp().size() == 1) { + ernpClient.update(specificDetailSearchResult.getResultsErnp().get(0), eidData); + } + String bpK = specificDetailSearchResult.getBpk(); + return bpK; + } catch (WorkflowException e) { + throw new TaskExecutionException(pendingReq, "Step7a failed.", e); + } + } +} 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 b12c1bcb..87b00f07 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 @@ -62,4 +62,10 @@ public class DummyZmrClient implements IZmrClient { //TODO } + @Override + public List searchWithBpkZp(String bpkzp) { + //TODO + return Collections.emptyList(); + } + } 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 5175cd7b..2742ae31 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 @@ -40,4 +40,6 @@ public interface IZmrClient { List searchItSpecific(String taxNumber); void update(RegisterResult registerResult, SimpleEidasData eidData); + + List searchWithBpkZp(String bpkzp); } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/resources/eidas_v2_auth.beans.xml b/eidas_modules/authmodule-eIDAS-v2/src/main/resources/eidas_v2_auth.beans.xml index fb1fa0f3..d669835f 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/resources/eidas_v2_auth.beans.xml +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/resources/eidas_v2_auth.beans.xml @@ -123,7 +123,7 @@ scope="prototype" /> \ No newline at end of file -- cgit v1.2.3