aboutsummaryrefslogtreecommitdiff
path: root/eidas_modules/authmodule-eIDAS-v2
diff options
context:
space:
mode:
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2')
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/InitialSearchTask.java67
1 files changed, 25 insertions, 42 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 3ebb2116..c4d067f5 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,7 +23,6 @@
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;
@@ -32,7 +31,6 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasAttribute
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.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;
@@ -58,6 +56,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.*;
+import static at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasResponseUtils.*;
+
/**
* Task that searches registers (ERnP and ZMR) before adding person to SZR.
*
@@ -93,14 +94,14 @@ public class InitialSearchTask extends AbstractAuthServletTask {
try {
final AuthProcessDataWrapper authProcessData = pendingReq.getSessionData(AuthProcessDataWrapper.class);
final ILightResponse eidasResponse = authProcessData
- .getGenericDataFromSession(Constants.DATA_FULL_EIDAS_RESPONSE, ILightResponse.class);
+ .getGenericDataFromSession(DATA_FULL_EIDAS_RESPONSE, ILightResponse.class);
final SimpleEidasData eidData = convertSimpleMapToSimpleData(convertEidasAttrToSimpleMap(
eidasResponse.getAttributes().getAttributeMap()));
final String bpK = step2RegisterSearchWithPersonidentifier(executionContext, eidData, authProcessData);
- authProcessData.setGenericDataToSession(Constants.DATA_RESULT_MATCHING_BPK, bpK);
- authProcessData.setGenericDataToSession(Constants.DATA_SIMPLE_EIDAS, eidData);
+ authProcessData.setGenericDataToSession(DATA_RESULT_MATCHING_BPK, bpK);
+ authProcessData.setGenericDataToSession(DATA_SIMPLE_EIDAS, eidData);
} catch (final Exception e) {
log.error("Initial search FAILED.", e);
throw new TaskExecutionException(pendingReq, "Initial search FAILED.", e);
@@ -115,7 +116,7 @@ public class InitialSearchTask extends AbstractAuthServletTask {
MergedRegisterSearchResult result = searchInZmrAndErnp(personIdentifier);
//store data in session
try {
- authProcessData.setGenericDataToSession(Constants.DATA_INITIAL_REGISTER_RESULT, result);
+ authProcessData.setGenericDataToSession(DATA_INITIAL_REGISTER_RESULT, result);
} catch (EaafStorageException e) {
throw new TaskExecutionException(pendingReq, "Initial search - Kitt Process necessary.", e);
}
@@ -209,9 +210,9 @@ public class InitialSearchTask extends AbstractAuthServletTask {
MergedRegisterSearchResult mdsSearchResult = new MergedRegisterSearchResult(resultsZmr, resultsErnp);
if (mdsSearchResult.getResultCount() == 0) {
- executionContext.put(Constants.TRANSITION_TO_CREATE_NEW_ERNB_ENTRY_TASK, true);
+ executionContext.put(TRANSITION_TO_CREATE_NEW_ERNB_ENTRY_TASK, true);
} else {
- executionContext.put(Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK, true);
+ executionContext.put(TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK, true);
}
// todo das suchergebnis auch noch speichern für später!
//TODO implement next phase and return correct value
@@ -226,52 +227,36 @@ public class InitialSearchTask extends AbstractAuthServletTask {
private SimpleEidasData convertSimpleMapToSimpleData(Map<String, Object> eidasAttrMap)
throws EidasAttributeException {
- SimpleEidasData simpleEidasData = new SimpleEidasData();
+ SimpleEidasData result = new SimpleEidasData();
- final Object eIdentifierObj = eidasAttrMap.get(Constants.eIDAS_ATTR_PERSONALIDENTIFIER);
- final Triple<String, String, String> eIdentifier =
- EidasResponseUtils.parseEidasPersonalIdentifier((String) eIdentifierObj);
- if (eIdentifier == null) {
- throw new EidasAttributeException("Error processing eIdentifier");
- }
- simpleEidasData.setCitizenCountryCode(eIdentifier.getFirst());
+ result.setCitizenCountryCode(processCountryCode(eidasAttrMap.get(eIDAS_ATTR_PERSONALIDENTIFIER)));
// 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)));
+ result.setPseudonym(processPseudonym(eidasAttrMap.get(eIDAS_ATTR_PERSONALIDENTIFIER)));
+ result.setFamilyName(processFamilyName(eidasAttrMap.get(eIDAS_ATTR_CURRENTFAMILYNAME)));
+ result.setGivenName(processGivenName(eidasAttrMap.get(eIDAS_ATTR_CURRENTGIVENNAME)));
+ result.setDateOfBirth(processDateOfBirthToString(eidasAttrMap.get(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)));
+ result.setPlaceOfBirth(processPlaceOfBirth(eidasAttrMap.get(eIDAS_ATTR_PLACEOFBIRTH)));
+ result.setBirthName(processBirthName(eidasAttrMap.get(eIDAS_ATTR_BIRTHNAME)));
+ result.setAddress(processAddress(eidasAttrMap.get(eIDAS_ATTR_CURRENTADDRESS)));
- if (eidasAttrMap.containsKey(Constants.eIDAS_ATTR_TAXREFERENCE)) {
- simpleEidasData.setTaxNumber(EidasResponseUtils.processTaxReference(
- eidasAttrMap.get(Constants.eIDAS_ATTR_TAXREFERENCE)));
+ if (eidasAttrMap.containsKey(eIDAS_ATTR_TAXREFERENCE)) {
+ result.setTaxNumber(processTaxReference(eidasAttrMap.get(eIDAS_ATTR_TAXREFERENCE)));
}
//TODO other additional attributes
- return simpleEidasData;
+ return result;
}
private Map<String, Object> convertEidasAttrToSimpleMap(
ImmutableMap<AttributeDefinition<?>, ImmutableSet<? extends AttributeValue<?>>> attributeMap) {
final Map<String, Object> result = new HashMap<>();
-
for (final AttributeDefinition<?> el : attributeMap.keySet()) {
-
final Class<?> parameterizedType = el.getParameterizedType();
if (DateTime.class.equals(parameterizedType)) {
- final DateTime attribute = EidasResponseUtils.translateDateAttribute(el, attributeMap.get(el).asList());
+ final DateTime attribute = translateDateAttribute(el, attributeMap.get(el).asList());
if (attribute != null) {
result.put(el.getFriendlyName(), attribute);
log.trace("Find attr '{}' with value: {}", el.getFriendlyName(), attribute.toString());
@@ -280,8 +265,7 @@ public class InitialSearchTask extends AbstractAuthServletTask {
log.info("Ignore empty 'DateTime' attribute");
}
} else if (PostalAddress.class.equals(parameterizedType)) {
- final PostalAddress addressAttribute = EidasResponseUtils
- .translateAddressAttribute(el, attributeMap.get(el).asList());
+ final PostalAddress addressAttribute = translateAddressAttribute(el, attributeMap.get(el).asList());
if (addressAttribute != null) {
result.put(el.getFriendlyName(), addressAttribute);
log.trace("Find attr '{}' with value: {}", el.getFriendlyName(), addressAttribute.toString());
@@ -290,8 +274,7 @@ public class InitialSearchTask extends AbstractAuthServletTask {
log.info("Ignore empty 'PostalAddress' attribute");
}
} else {
- final List<String> natPersonIdObj = EidasResponseUtils
- .translateStringListAttribute(el, attributeMap.get(el));
+ final List<String> natPersonIdObj = translateStringListAttribute(el, attributeMap.get(el));
final String stringAttr = natPersonIdObj.get(0);
if (StringUtils.isNotEmpty(stringAttr)) {
result.put(el.getFriendlyName(), stringAttr);
@@ -301,7 +284,7 @@ public class InitialSearchTask extends AbstractAuthServletTask {
}
}
}
- log.debug("Receive #" + result.size() + " attributes with names: " + result.keySet().toString());
+ log.debug("Receive #{} attributes with names: {}", result.size(), result.keySet().toString());
return result;
}
} \ No newline at end of file