diff options
author | Alexander Marsalek <amarsalek@iaik.tugraz.at> | 2020-12-17 13:18:37 +0100 |
---|---|---|
committer | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2021-01-15 14:19:26 +0100 |
commit | 21613f2d1af10639b65077c5600763e82b5eb63c (patch) | |
tree | ac273db909dbbb40edb6cdf0d09af9971553c819 /eidas_modules/authmodule-eIDAS-v2/src/main | |
parent | 20b28fa85e5fc24868b22fa769e87f1dcacf205a (diff) | |
download | National_eIDAS_Gateway-21613f2d1af10639b65077c5600763e82b5eb63c.tar.gz National_eIDAS_Gateway-21613f2d1af10639b65077c5600763e82b5eb63c.tar.bz2 National_eIDAS_Gateway-21613f2d1af10639b65077c5600763e82b5eb63c.zip |
country specific tests
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src/main')
6 files changed, 70 insertions, 83 deletions
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 cc275f24..145cf262 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 @@ -140,6 +140,7 @@ public class Constants { public static final String eIDAS_ATTR_PLACEOFBIRTH = "PlaceOfBirth"; public static final String eIDAS_ATTR_BIRTHNAME = "BirthName"; public static final String eIDAS_ATTR_CURRENTADDRESS = "CurrentAddress"; + public static final String eIDAS_ATTR_TAXREFERENCE = "TaxReference"; public static final String eIDAS_ATTR_LEGALPERSONIDENTIFIER = "LegalPersonIdentifier"; public static final String eIDAS_ATTR_LEGALNAME = "LegalName"; diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/DeSpecificDetailSearchProcessor.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/DeSpecificDetailSearchProcessor.java index 9fa13fe8..51d6952f 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/DeSpecificDetailSearchProcessor.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/DeSpecificDetailSearchProcessor.java @@ -3,24 +3,10 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.handler; 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.ernb.IErnbClient; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient; -import org.springframework.beans.factory.annotation.Autowired; import java.util.ArrayList; -public class DeSpecificDetailSearchProcessor implements ICountrySpecificDetailSearchProcessor { - - @Autowired - private IErnbClient ernbClient; - - @Autowired - private IZmrClient zmrClient; - - @Override - public String getName() { - return this.getClass().getName(); - } +public class DeSpecificDetailSearchProcessor extends ICountrySpecificDetailSearchProcessor { @Override public boolean canHandle(String countryCode, SimpleEidasData eidData) { @@ -47,7 +33,7 @@ public class DeSpecificDetailSearchProcessor implements ICountrySpecificDetailSe ArrayList<RegisterResult> resultsErnb = ernbClient.searchDeSpecific(eidData.getGivenName(), eidData.getFamilyName(), eidData.getDateOfBirth(), - eidData.getPlaceOfBirth(), eidData.getBirthName()); + eidData.getPlaceOfBirth(), eidData.getBirthName()); searchResult.setResultsErnb(resultsErnb); return searchResult; } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ICountrySpecificDetailSearchProcessor.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ICountrySpecificDetailSearchProcessor.java index 887aef4a..3d6b35e9 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ICountrySpecificDetailSearchProcessor.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ICountrySpecificDetailSearchProcessor.java @@ -25,25 +25,44 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.handler; 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.ernb.IErnbClient; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient; +import org.springframework.beans.factory.annotation.Autowired; -public interface ICountrySpecificDetailSearchProcessor { +public abstract class ICountrySpecificDetailSearchProcessor { + + + protected IErnbClient ernbClient; + protected IZmrClient zmrClient; + + @Autowired + public void setErnbClient(IErnbClient ernbClient) { + this.ernbClient = ernbClient; + } + + @Autowired + public void setZmrClient(IZmrClient zmrClient) { + this.zmrClient = zmrClient; + } /** * Get a friendlyName of this post-processor implementation. * * @return */ - String getName(); + public String getName() { + return this.getClass().getName(); + } /** * Check if this postProcessor is sensitive for a specific country. * * @param countryCode of the eID data that should be processed - * @param eidData eID data + * @param eidData eID data * @return true if this implementation can handle the country, otherwise false */ - boolean canHandle(String countryCode, SimpleEidasData eidData); + public abstract boolean canHandle(String countryCode, SimpleEidasData eidData); - MergedRegisterSearchResult search(SimpleEidasData eidData); + public abstract MergedRegisterSearchResult search(SimpleEidasData eidData); } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ItSpecificDetailSearchProcessor.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ItSpecificDetailSearchProcessor.java index e3b9e702..d055345a 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ItSpecificDetailSearchProcessor.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ItSpecificDetailSearchProcessor.java @@ -3,24 +3,10 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.handler; 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.ernb.IErnbClient; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient; -import org.springframework.beans.factory.annotation.Autowired; import java.util.ArrayList; -public class ItSpecificDetailSearchProcessor implements ICountrySpecificDetailSearchProcessor { - - @Autowired - private IErnbClient ernbClient; - - @Autowired - private IZmrClient zmrClient; - - @Override - public String getName() { - return this.getClass().getName(); - } +public class ItSpecificDetailSearchProcessor extends ICountrySpecificDetailSearchProcessor { @Override public boolean canHandle(String countryCode, SimpleEidasData eidData) { 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 9df24e9f..e722200c 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 @@ -25,11 +25,9 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; -import javax.annotation.PostConstruct; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -50,6 +48,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.ernb.IErnbClient; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidPostProcessingException; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasAttributeException; 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.ICountrySpecificDetailSearchProcessor; import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasResponseUtils; import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient; @@ -74,52 +73,14 @@ import lombok.extern.slf4j.Slf4j; @Component("InitialSearchTask") public class InitialSearchTask extends AbstractAuthServletTask { - private final List<ICountrySpecificDetailSearchProcessor> handlers = new ArrayList<>(); + private List<ICountrySpecificDetailSearchProcessor> handlers = new ArrayList<>(); - // @Autowired - // private AuthBlockSigningService authBlockSigner; - // @Autowired - // private IConfiguration basicConfig; - // @Autowired - // private SzrClient szrClient; - // @Autowired - // private ICcSpecificEidProcessingService eidPostProcessor; - - // private static final String EID_STATUS = "urn:eidgvat:eid.status.eidas"; @Autowired private ApplicationContext context; - @Autowired private IErnbClient ernbClient; - - @Autowired private IZmrClient zmrClient; - @PostConstruct - private void initialize() { - log.debug("Initialize country specific detail search services ... "); - final Map<String, ICountrySpecificDetailSearchProcessor> postProcessors = context.getBeansOfType( - ICountrySpecificDetailSearchProcessor.class); - final Iterator<Map.Entry<String, ICountrySpecificDetailSearchProcessor>> iterator = - postProcessors.entrySet().iterator(); - while (iterator.hasNext()) { - final Map.Entry<String, ICountrySpecificDetailSearchProcessor> el = iterator.next(); - log.debug("Find country specific detail search services with name: " + el.getKey()); - handlers.add(el.getValue()); - - } - - // log.trace("Sorting country specific detail search services on priority ... "); - // Collections.sort(handlers, (thisAuthModule, otherAuthModule) -> { - // final int thisOrder = thisAuthModule.getPriority(); - // final int otherOrder = otherAuthModule.getPriority(); - // return thisOrder < otherOrder ? 1 : thisOrder == otherOrder ? 0 : -1; - // }); - - log.info("# " + handlers.size() + " country specific detail search services are registrated"); - - } - /* * (non-Javadoc) * @@ -136,6 +97,9 @@ public class InitialSearchTask extends AbstractAuthServletTask { final ILightResponse eidasResponse = authProcessData .getGenericDataFromSession(Constants.DATA_FULL_EIDAS_RESPONSE, ILightResponse.class); + ImmutableMap<AttributeDefinition<?>, ImmutableSet<? extends AttributeValue<?>>> aa = + eidasResponse.getAttributes().getAttributeMap(); + final Map<String, Object> simpleAttrMap = convertEidasAttrToSimpleMap( eidasResponse.getAttributes().getAttributeMap()); @@ -143,7 +107,7 @@ public class InitialSearchTask extends AbstractAuthServletTask { final SimpleEidasData eidData = convertSimpleMapToSimpleData(simpleAttrMap); String bpK = step2(eidData); - authProcessData.setGenericDataToSession(Constants.DATA_RESULT_MATCHING_BPK,bpK); + authProcessData.setGenericDataToSession(Constants.DATA_RESULT_MATCHING_BPK, bpK); } catch (final Exception e) { log.error("Initial search FAILED.", e); throw new TaskExecutionException(pendingReq, "Initial search FAILED.", e); @@ -160,7 +124,7 @@ public class InitialSearchTask extends AbstractAuthServletTask { return step3(result, eidData); } //else if (result.getResultCount() > 1) { throw new TaskExecutionException(pendingReq, "Initial search - Kitt Process necessary.", - new ManualFixNecessaryException(personIdentifier)); + new ManualFixNecessaryException(personIdentifier)); // } // return null; } @@ -192,6 +156,11 @@ public class InitialSearchTask extends AbstractAuthServletTask { simpleEidasData.setAddress(EidasResponseUtils.processAddress( eidasAttrMap.get(Constants.eIDAS_ATTR_CURRENTADDRESS))); + if (eidasAttrMap.containsKey(Constants.eIDAS_ATTR_TAXREFERENCE)) { + simpleEidasData.setTaxNumber(EidasResponseUtils.processTaxReference( + eidasAttrMap.get(Constants.eIDAS_ATTR_TAXREFERENCE))); + } + //TODO other additional attributes return simpleEidasData; } @@ -214,10 +183,10 @@ public class InitialSearchTask extends AbstractAuthServletTask { } private String step4(MergedRegisterSearchResult result, - SimpleEidasData eidData) throws WorkflowException { + SimpleEidasData eidData) throws WorkflowException { log.debug("Update " + result + " with " + eidData); //TODO - + return result.getBpk(); } @@ -245,7 +214,7 @@ public class InitialSearchTask extends AbstractAuthServletTask { } private String step6(ICountrySpecificDetailSearchProcessor countrySpecificDetailSearchProcessor, - MergedRegisterSearchResult initialSearchResult, SimpleEidasData eidData) + MergedRegisterSearchResult initialSearchResult, SimpleEidasData eidData) throws TaskExecutionException { //6 country specific search MergedRegisterSearchResult countrySpecificDetailSearchResult = @@ -277,7 +246,7 @@ public class InitialSearchTask extends AbstractAuthServletTask { } private String step8(MergedRegisterSearchResult initialSearchResult, - SimpleEidasData eidData) { + SimpleEidasData eidData) { MergedRegisterSearchResult mdsSearchResult = new MergedRegisterSearchResult(); ArrayList<RegisterResult> resultsZmr = @@ -357,11 +326,20 @@ public class InitialSearchTask extends AbstractAuthServletTask { //just for testing //TODO is there a nicer solution? + @Autowired public void setErnbClient(IErnbClient ernbClient) { this.ernbClient = ernbClient; } + @Autowired public void setZmrClient(IZmrClient zmrClient) { this.zmrClient = zmrClient; } + + @Autowired + public void setHandlers(List<ICountrySpecificDetailSearchProcessor> handlers) { + this.handlers = handlers; + log.info("# " + handlers.size() + " country specific detail search services are registrated"); + } + } 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 54928eb7..aaa4212a 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 @@ -359,6 +359,23 @@ public class EidasResponseUtils { EidasResponseUtils.parseEidasPersonalIdentifier((String) personalIdObj); return eIdentifier.getThird(); + } + + /** + * Post-Process the eIDAS TaxReference attribute. + * + * @param taxReferenceObj eIDAS TaxReference attribute information + * @return formated user's TaxReference + * @throws EidasAttributeException if NO attribute is available + * @throws EidPostProcessingException if post-processing fails + */ + public static String processTaxReference(Object taxReferenceObj) throws EidPostProcessingException, + EidasAttributeException { + if (taxReferenceObj == null || !(taxReferenceObj instanceof String)) { + throw new EidasAttributeException(Constants.eIDAS_ATTR_CURRENTGIVENNAME); + } + + return (String) taxReferenceObj; } } |