From 87e5fa9dd9966d427e45e36b9c3530b3c28d1f32 Mon Sep 17 00:00:00 2001 From: Christian Kollmann Date: Mon, 22 Feb 2021 15:06:43 +0100 Subject: Refactor: Use less static imports --- .../auth/eidas/v2/tasks/InitialSearchTask.java | 40 +++++++++------------- 1 file changed, 16 insertions(+), 24 deletions(-) (limited to 'eidas_modules/authmodule-eIDAS-v2') 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 4d5daa6e..81035f6d 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 @@ -30,6 +30,7 @@ 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.service.RegisterSearchService; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasResponseUtils; 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; @@ -68,18 +69,6 @@ import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.eIDAS_A import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.eIDAS_ATTR_PERSONALIDENTIFIER; import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.eIDAS_ATTR_PLACEOFBIRTH; import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.eIDAS_ATTR_TAXREFERENCE; -import static at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasResponseUtils.processAddress; -import static at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasResponseUtils.processBirthName; -import static at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasResponseUtils.processCountryCode; -import static at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasResponseUtils.processDateOfBirthToString; -import static at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasResponseUtils.processFamilyName; -import static at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasResponseUtils.processGivenName; -import static at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasResponseUtils.processPlaceOfBirth; -import static at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasResponseUtils.processPseudonym; -import static at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasResponseUtils.processTaxReference; -import static at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasResponseUtils.translateAddressAttribute; -import static at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasResponseUtils.translateDateAttribute; -import static at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasResponseUtils.translateStringListAttribute; /** * Task that searches registers (ERnP and ZMR) before adding person to SZR. @@ -89,6 +78,7 @@ import static at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasRespon */ @Slf4j @Component("InitialSearchTask") +@SuppressWarnings("PMD.TooManyStaticImports") public class InitialSearchTask extends AbstractAuthServletTask { private final List handlers; @@ -259,18 +249,19 @@ public class InitialSearchTask extends AbstractAuthServletTask { private SimpleEidasData convertSimpleMapToSimpleData(Map eidasAttrMap) throws EidasAttributeException { SimpleEidasData result = new SimpleEidasData(); - result.setCitizenCountryCode(processCountryCode(eidasAttrMap.get(eIDAS_ATTR_PERSONALIDENTIFIER))); + result.setCitizenCountryCode(EidasResponseUtils.processCountryCode( + eidasAttrMap.get(eIDAS_ATTR_PERSONALIDENTIFIER))); // MDS attributes - 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))); + result.setPseudonym(EidasResponseUtils.processPseudonym(eidasAttrMap.get(eIDAS_ATTR_PERSONALIDENTIFIER))); + result.setFamilyName(EidasResponseUtils.processFamilyName(eidasAttrMap.get(eIDAS_ATTR_CURRENTFAMILYNAME))); + result.setGivenName(EidasResponseUtils.processGivenName(eidasAttrMap.get(eIDAS_ATTR_CURRENTGIVENNAME))); + result.setDateOfBirth(EidasResponseUtils.processDateOfBirthToString(eidasAttrMap.get(eIDAS_ATTR_DATEOFBIRTH))); // additional attributes - result.setPlaceOfBirth(processPlaceOfBirth(eidasAttrMap.get(eIDAS_ATTR_PLACEOFBIRTH))); - result.setBirthName(processBirthName(eidasAttrMap.get(eIDAS_ATTR_BIRTHNAME))); - result.setAddress(processAddress(eidasAttrMap.get(eIDAS_ATTR_CURRENTADDRESS))); + result.setPlaceOfBirth(EidasResponseUtils.processPlaceOfBirth(eidasAttrMap.get(eIDAS_ATTR_PLACEOFBIRTH))); + result.setBirthName(EidasResponseUtils.processBirthName(eidasAttrMap.get(eIDAS_ATTR_BIRTHNAME))); + result.setAddress(EidasResponseUtils.processAddress(eidasAttrMap.get(eIDAS_ATTR_CURRENTADDRESS))); if (eidasAttrMap.containsKey(eIDAS_ATTR_TAXREFERENCE)) { - result.setTaxNumber(processTaxReference(eidasAttrMap.get(eIDAS_ATTR_TAXREFERENCE))); + result.setTaxNumber(EidasResponseUtils.processTaxReference(eidasAttrMap.get(eIDAS_ATTR_TAXREFERENCE))); } //TODO other additional attributes return result; @@ -282,7 +273,7 @@ public class InitialSearchTask extends AbstractAuthServletTask { for (final AttributeDefinition el : attributeMap.keySet()) { final Class parameterizedType = el.getParameterizedType(); if (DateTime.class.equals(parameterizedType)) { - final DateTime attribute = translateDateAttribute(el, attributeMap.get(el).asList()); + 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()); @@ -290,7 +281,8 @@ public class InitialSearchTask extends AbstractAuthServletTask { log.info("Ignore empty 'DateTime' attribute"); } } else if (PostalAddress.class.equals(parameterizedType)) { - final PostalAddress addressAttribute = translateAddressAttribute(el, attributeMap.get(el).asList()); + final PostalAddress addressAttribute = EidasResponseUtils + .translateAddressAttribute(el, attributeMap.get(el).asList()); if (addressAttribute != null) { result.put(el.getFriendlyName(), addressAttribute); log.trace("Find attr '{}' with value: {}", el.getFriendlyName(), addressAttribute.toString()); @@ -298,7 +290,7 @@ public class InitialSearchTask extends AbstractAuthServletTask { log.info("Ignore empty 'PostalAddress' attribute"); } } else { - final List natPersonIdObj = translateStringListAttribute(el, attributeMap.get(el)); + final List natPersonIdObj = EidasResponseUtils.translateStringListAttribute(el, attributeMap.get(el)); final String stringAttr = natPersonIdObj.get(0); if (StringUtils.isNotEmpty(stringAttr)) { result.put(el.getFriendlyName(), stringAttr); -- cgit v1.2.3