diff options
Diffstat (limited to 'modules/authmodule-eIDAS-v2/src/main/java/at')
2 files changed, 28 insertions, 2 deletions
diff --git a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/Constants.java b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/Constants.java index 9bb7055b..ce1d2a11 100644 --- a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/Constants.java +++ b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/Constants.java @@ -130,7 +130,11 @@ public class Constants { /** Enable / Disable matching based on address search **/ public static final String CONFIG_PROP_MATCHING_BY_ADDRESS = CONIG_PROPS_EIDAS_PREFIX + ".matching.byaddress.enable"; - + + public static final String CONFIG_PROP_MATCHING_BY_ADDRESS_MAX_RESULTS = + CONIG_PROPS_EIDAS_PREFIX + ".matching.byaddress.maxresults"; + public static final String DEFAULT_MATCHING_BY_ADDRESS_MAX_RESULTS = "250"; + // ZMR Client configuration properties public static final String CONIG_PROPS_EIDAS_ZMRCLIENT = CONIG_PROPS_EIDAS_PREFIX + ".zmrclient"; diff --git a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/controller/AdresssucheController.java b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/controller/AdresssucheController.java index 1c47f02c..4bb1343a 100644 --- a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/controller/AdresssucheController.java +++ b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/controller/AdresssucheController.java @@ -41,12 +41,14 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import at.asitplus.eidas.specific.core.MsEidasNodeConstants; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.zmr.ZmrAddressSoapClient; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasSAuthenticationException; import at.gv.bmi.namespace.zmr_su.zrm._20040201_.address.Adressdaten; import at.gv.e_government.reference.namespace.persondata.de._20040201.PostAdresseTyp; import at.gv.e_government.reference.namespace.persondata.de._20040201.ZustelladresseTyp; import at.gv.egiz.eaaf.core.api.data.EaafConstants; +import at.gv.egiz.eaaf.core.api.idp.IConfiguration; import at.gv.egiz.eaaf.core.api.utils.IPendingRequestIdGenerationStrategy; import at.gv.egiz.eaaf.core.exceptions.PendingReqIdValidationException; import lombok.AllArgsConstructor; @@ -69,6 +71,8 @@ public class AdresssucheController { public static final String PARAM_STREET = "street"; public static final String PARAM_NUMBER = "number"; + @Autowired IConfiguration basicConfig; + @Autowired private ZmrAddressSoapClient client; @@ -128,11 +132,29 @@ public class AdresssucheController { it.getZustelladresse().getStrassenname(), it.getZustelladresse().getOrientierungsnummer())) .collect(Collectors.toSet()); // TODO Add configuration option for the limit of 30 - final List<AdresssucheOutput> sorted = result.stream().sorted().limit(30).collect(Collectors.toList()); + + final List<AdresssucheOutput> sorted = result.stream() + .sorted() + .limit(getMaxResults()) + .collect(Collectors.toList()); + return new AdresssucheResult(sorted, result.size()); } + private long getMaxResults() { + String maxSearchResults = basicConfig.getBasicConfiguration( + Constants.CONFIG_PROP_MATCHING_BY_ADDRESS_MAX_RESULTS, + Constants.DEFAULT_MATCHING_BY_ADDRESS_MAX_RESULTS); + try { + return Long.valueOf(maxSearchResults); + + } catch (Exception e) { + log.warn("Invalid number of max. addressSearchResults. Using default value", e); + return Long.valueOf(Constants.DEFAULT_MATCHING_BY_ADDRESS_MAX_RESULTS); + } + } + private Adressdaten buildSearchInput(String postleitzahl, String municipality, String village, |