aboutsummaryrefslogtreecommitdiff
path: root/eidas_modules/authmodule-eIDAS-v2/src/main
diff options
context:
space:
mode:
authorChristian Kollmann <christian.kollmann@a-sit.at>2021-07-12 11:20:23 +0200
committerChristian Kollmann <christian.kollmann@a-sit.at>2021-07-12 11:20:31 +0200
commit0b896fd9d035ba5719394ecaaba02ef6b5dc5666 (patch)
tree948c27c7e1c63efab2e65beadb5bfce76cf54bfe /eidas_modules/authmodule-eIDAS-v2/src/main
parent38d2a59abe9f0bd04abd2caf4ea110afd3f5ff11 (diff)
downloadNational_eIDAS_Gateway-0b896fd9d035ba5719394ecaaba02ef6b5dc5666.tar.gz
National_eIDAS_Gateway-0b896fd9d035ba5719394ecaaba02ef6b5dc5666.tar.bz2
National_eIDAS_Gateway-0b896fd9d035ba5719394ecaaba02ef6b5dc5666.zip
Fix typos, remove newlines
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src/main')
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/InitialSearchTask.java123
1 files changed, 46 insertions, 77 deletions
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 220c4e56..4103939d 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
@@ -23,24 +23,6 @@
package at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks;
-import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_TASK;
-import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.lang3.StringUtils;
-import org.jetbrains.annotations.NotNull;
-import org.joda.time.DateTime;
-import org.springframework.stereotype.Component;
-
-import com.google.common.collect.ImmutableMap;
-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.dao.MatchedPersonResult;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult;
@@ -58,11 +40,26 @@ 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.idp.auth.modules.AbstractAuthServletTask;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
import eu.eidas.auth.commons.attribute.AttributeDefinition;
import eu.eidas.auth.commons.attribute.AttributeValue;
import eu.eidas.auth.commons.light.ILightResponse;
import eu.eidas.auth.commons.protocol.eidas.impl.PostalAddress;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.jetbrains.annotations.NotNull;
+import org.joda.time.DateTime;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_TASK;
+import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK;
/**
* Task that searches registers (ERnP and ZMR) before adding person to SZR.
@@ -88,6 +85,7 @@ import lombok.extern.slf4j.Slf4j;
*
* @author amarsalek
* @author ckollmann
+ * @author tlenz
*/
@Slf4j
@Component("InitialSearchTask")
@@ -99,6 +97,7 @@ public class InitialSearchTask extends AbstractAuthServletTask {
/**
* Constructor.
+ *
* @param registerSearchService Service for register search access
* @param eidPostProcessor Country-Specific post processing of attributes
*/
@@ -106,7 +105,6 @@ public class InitialSearchTask extends AbstractAuthServletTask {
ICcSpecificEidProcessingService eidPostProcessor) {
this.registerSearchService = registerSearchService;
this.eidPostProcessor = eidPostProcessor;
-
}
@Override
@@ -116,120 +114,91 @@ public class InitialSearchTask extends AbstractAuthServletTask {
final SimpleEidasData eidasData = convertEidasAttrToSimpleData();
MatchingTaskUtils.storeInitialEidasData(pendingReq, eidasData);
step2RegisterSearchWithPersonIdentifier(executionContext, eidasData);
-
- } catch (WorkflowException e) {
+ } catch (WorkflowException e) {
throw new TaskExecutionException(pendingReq, "Initial search failed", e);
-
} catch (final Exception e) {
log.error("Initial search failed", e);
throw new TaskExecutionException(pendingReq, "Initial search failed with a generic error", e);
-
}
}
private void step2RegisterSearchWithPersonIdentifier(
ExecutionContext executionContext, SimpleEidasData eidasData) throws WorkflowException, EaafStorageException {
- try {
+ try {
log.trace("Starting step2RegisterSearchWithPersonIdentifier");
- RegisterStatusResults initialSearchResult = registerSearchService.searchWithPersonIdentifier(eidasData);
+ RegisterStatusResults initialSearchResult = registerSearchService.searchWithPersonIdentifier(eidasData);
int resultCount = initialSearchResult.getResultCount();
if (resultCount == 0) {
step6CountrySpecificSearch(executionContext, initialSearchResult.getOperationStatus(), eidasData);
-
- } else if (resultCount == 1) {
- // find person by PersonalIdentifier --> finalize first matching task
- foundMatchFinializeTask(initialSearchResult, eidasData);
-
+ } else if (resultCount == 1) {
+ foundMatchFinalizeTask(initialSearchResult, eidasData);
} else {
- throw new WorkflowException("step2RegisterSearchWithPersonIdentifier",
+ throw new WorkflowException("step2RegisterSearchWithPersonIdentifier",
"More than one entry with unique personal-identifier", true);
-
}
-
} catch (WorkflowException e) {
- //TODO: what we do in case of a workflow error and manual matching are necessary??
-
- log.warn("Workflow error during matching step: {}. Reason: {}", e.getProcessStepName(), e.getErrorReason());
+ //TODO: what we do in case of a workflow error and manual matching are necessary??
+ log.warn("Workflow error during matching step: {}. Reason: {}", e.getProcessStepName(), e.getErrorReason());
throw e;
-
}
}
-
+
private void step6CountrySpecificSearch(
ExecutionContext executionContext, RegisterOperationStatus registerOperationStatus, SimpleEidasData eidasData)
throws EaafStorageException, WorkflowException {
-
log.trace("Starting 'step6CountrySpecificSearch' ... ");
RegisterStatusResults countrySpecificResult = registerSearchService.searchWithCountrySpecifics(
registerOperationStatus, eidasData);
if (countrySpecificResult.getResultCount() == 0) {
log.trace("'step6CountrySpecificSearch' ends with no result. Forward to next matching step ... ");
step8RegisterSearchWithMds(executionContext, countrySpecificResult.getOperationStatus(), eidasData);
-
} else if (countrySpecificResult.getResultCount() == 1) {
log.trace("'step6CountrySpecificSearch' finds a person. Forward to 'step7aKittProcess' step ... ");
registerSearchService.step7aKittProcess(countrySpecificResult, eidasData);
-
- // find person by country-specific information --> finalize first matching task
- foundMatchFinializeTask(countrySpecificResult, eidasData);
-
+ foundMatchFinalizeTask(countrySpecificResult, eidasData);
} else {
- throw new WorkflowException("step6CountrySpecificSearch",
- "More than one entry with unique country-specific informations", true);
-
- }
+ throw new WorkflowException("step6CountrySpecificSearch",
+ "More than one entry with unique country-specific information", true);
+ }
}
- private void step8RegisterSearchWithMds(ExecutionContext executionContext,
- RegisterOperationStatus registerOperationStatus, SimpleEidasData eidasData)
+ private void step8RegisterSearchWithMds(ExecutionContext executionContext,
+ RegisterOperationStatus registerOperationStatus, SimpleEidasData eidasData)
throws EaafStorageException, WorkflowException {
log.trace("Starting step8RegisterSearchWithMds");
RegisterStatusResults registerData = registerSearchService.searchWithMds(registerOperationStatus, eidasData);
-
if (registerData.getResultCount() == 0) {
log.debug("Matching step: 'step8RegisterSearchWithMds' has no result. Forward to create new ERnP entry ... ");
executionContext.put(TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_TASK, true);
-
} else {
log.debug("Matching step: 'step8RegisterSearchWithMds' has #{} results. "
+ "Forward to GUI based matching steps ... ", registerData.getResultCount());
-
MatchingTaskUtils.storeIntermediateMatchingResult(pendingReq, registerData);
executionContext.put(TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK, true);
-
}
}
-
-
- private void foundMatchFinializeTask(RegisterStatusResults searchResult, SimpleEidasData eidasData)
+ private void foundMatchFinalizeTask(RegisterStatusResults searchResult, SimpleEidasData eidasData)
throws WorkflowException, EaafStorageException {
- // check if register update is required
RegisterResult updatedResult = step3CheckRegisterUpdateNecessary(searchResult.getResult(), eidasData);
-
- // store search result
- MatchingTaskUtils.storeFinalMatchingResult(pendingReq,
- MatchedPersonResult.generateFormMatchingResult(updatedResult, eidasData.getCitizenCountryCode()));
-
+ MatchedPersonResult result = MatchedPersonResult.generateFormMatchingResult(
+ updatedResult, eidasData.getCitizenCountryCode());
+ MatchingTaskUtils.storeFinalMatchingResult(pendingReq, result);
}
-
- private RegisterResult step3CheckRegisterUpdateNecessary(RegisterResult searchResult,
- SimpleEidasData eidasData) throws WorkflowException {
+
+ private RegisterResult step3CheckRegisterUpdateNecessary(RegisterResult searchResult,
+ SimpleEidasData eidasData) throws WorkflowException {
log.trace("Starting step3CheckRegisterUpdateNecessary");
if (!eidasData.equalsRegisterData(searchResult)) {
log.info("Skipping update-register-information step, because it's not supported yet");
-
//TODO: return updated search result if updates are allowed
return searchResult;
-
- } else {
- log.debug("Register information match to eIDAS information. No update requird");
+ } else {
+ log.debug("Register information match to eIDAS information. No update required");
return searchResult;
-
}
-
}
-
+
@NotNull
private SimpleEidasData convertEidasAttrToSimpleData()
throws EidasAttributeException, EidPostProcessingException {
@@ -237,7 +206,6 @@ public class InitialSearchTask extends AbstractAuthServletTask {
.getGenericDataFromSession(Constants.DATA_FULL_EIDAS_RESPONSE, ILightResponse.class);
Map<String, Object> simpleMap = convertEidasAttrToSimpleMap(eidasResponse.getAttributes().getAttributeMap());
return eidPostProcessor.postProcess(simpleMap);
-
}
private Map<String, Object> convertEidasAttrToSimpleMap(
@@ -249,7 +217,7 @@ public class InitialSearchTask extends AbstractAuthServletTask {
final DateTime attribute = EidasResponseUtils.translateDateAttribute(el, attributeMap.get(el).asList());
if (attribute != null) {
result.put(el.getFriendlyName(), attribute);
- log.trace("Find attr '{}' with value: {}", el.getFriendlyName(), attribute.toString());
+ log.trace("Find attr '{}' with value: {}", el.getFriendlyName(), attribute);
} else {
log.info("Ignore empty 'DateTime' attribute");
}
@@ -258,7 +226,7 @@ public class InitialSearchTask extends AbstractAuthServletTask {
.translateAddressAttribute(el, attributeMap.get(el).asList());
if (addressAttribute != null) {
result.put(el.getFriendlyName(), addressAttribute);
- log.trace("Find attr '{}' with value: {}", el.getFriendlyName(), addressAttribute.toString());
+ log.trace("Find attr '{}' with value: {}", el.getFriendlyName(), addressAttribute);
} else {
log.info("Ignore empty 'PostalAddress' attribute");
}
@@ -273,7 +241,8 @@ public class InitialSearchTask extends AbstractAuthServletTask {
}
}
}
- log.debug("Receive #{} attributes with names: {}", result.size(), result.keySet().toString());
+ log.debug("Receive #{} attributes with names: {}", result.size(), result.keySet());
return result;
}
+
}