From 5b0a9142a0e00fa528f86f8fe432c0e44ed4ae8e Mon Sep 17 00:00:00 2001
From: Thomas <>
Date: Mon, 7 Feb 2022 15:19:56 +0100
Subject: refactor(matching): change 'kitt' and 'update' steps in
'InitialSearchTask'
- Update MDS in case of changes eIDAS data and already existing ERnP entry
- Add additional attributes in case of new eIDAS attributes outside of MDS
---
.../modules/auth/eidas/v2/dao/SimpleEidasData.java | 22 ++++++++++--
.../eidas/v2/service/RegisterSearchService.java | 22 ++++++++++--
.../auth/eidas/v2/tasks/InitialSearchTask.java | 42 +++++++++++-----------
3 files changed, 59 insertions(+), 27 deletions(-)
(limited to 'eidas_modules/authmodule-eIDAS-v2/src/main')
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 5ad92507..e76768b6 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
@@ -23,10 +23,11 @@
package at.asitplus.eidas.specific.modules.auth.eidas.v2.dao;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+
import at.gv.e_government.reference.namespace.persondata._20020228.PostalAddressType;
import lombok.Builder;
import lombok.Data;
-import org.apache.commons.lang3.builder.EqualsBuilder;
@Data
@Builder
@@ -68,8 +69,11 @@ public class SimpleEidasData {
.append(result.getGivenName(), givenName)
.append(result.getFamilyName(), familyName)
.append(result.getDateOfBirth(), dateOfBirth)
- .isEquals()
- && result.getPseudonym().stream().anyMatch(el -> el.equals(pseudonym));
+ .appendSuper(result.getPseudonym().stream().anyMatch(el -> el.equals(pseudonym)))
+ .appendSuper(checkOptionalAttributes(result.getPlaceOfBirth(), placeOfBirth))
+ .appendSuper(checkOptionalAttributes(result.getBirthName(), birthName))
+ .isEquals();
+
}
/**
@@ -84,5 +88,17 @@ public class SimpleEidasData {
.isEquals();
}
+ /**
+ * Check if eIDAS attribute is available.
+ *
+ * @param registerData Attribute value from register
+ * @param eidasData Attribute value from eIDAS
+ * @return true
if eidasData is null
or eidasData does not match to register value,
+ * otherwise false
+ */
+ private static boolean checkOptionalAttributes(String registerData, String eidasData) {
+ return eidasData == null || eidasData.equals(registerData);
+
+ }
}
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/RegisterSearchService.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/RegisterSearchService.java
index 488b571b..85ea942c 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/RegisterSearchService.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/RegisterSearchService.java
@@ -7,6 +7,7 @@ import java.util.List;
import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable;
+import org.springframework.lang.NonNull;
import org.springframework.stereotype.Service;
import com.google.common.collect.Streams;
@@ -186,34 +187,49 @@ public class RegisterSearchService {
* @param initialEidasData Received eidas data from initial authn
* @return
*/
+ @NonNull
public RegisterStatusResults step7aKittProcess(RegisterStatusResults registerResult,
SimpleEidasData initialEidasData) throws WorkflowException {
log.trace("Starting step7aKittProcess");
- // TODO verify with which data this method gets called
+
+ // check if only one single result was found
if (registerResult.getResultCount() != 1) {
throw new WorkflowException("step7aKittProcess", "getResultCount() != 1");
+
}
+
+ // perform updated operation in respect to register results
try {
if (registerResult.getResultsZmr().size() == 1) {
RegisterResult entryZmr = registerResult.getResultsZmr().get(0);
ZmrRegisterResult updateZmr = zmrClient
.update(registerResult.getOperationStatus().getZmrProcessId(), entryZmr, initialEidasData);
return RegisterStatusResults.fromZmr(updateZmr);
+
} else {
RegisterResult entryErnp = registerResult.getResultsErnp().get(0);
ErnpRegisterResult updateErnp = ernpClient.update(entryErnp, initialEidasData);
return RegisterStatusResults.fromErnp(registerResult.operationStatus, updateErnp);
+
}
} catch (final EidasSAuthenticationException e) {
throw new WorkflowException("kittMatchedIdentitiess", e.getMessage(),
!(e instanceof ZmrCommunicationException), e);
+
}
}
- //TODO: check this method, because it's different to 'step7aKittProcess'???
/**
* Automatic process to fix the register entries.
* Called when the alternative eIDAS authn leads to a match in a register.
+ *
+ *
This method perform two additional operations: + *