From 401cd39689d73f1cc865bb3c7cfca40a3f5ac625 Mon Sep 17 00:00:00 2001 From: Christian Kollmann Date: Wed, 1 Dec 2021 14:46:18 +0100 Subject: Add simple page to search for an Austrian Address --- .../controller/AdresssucheController.java | 131 +++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 connector/src/main/java/at/asitplus/eidas/specific/connector/controller/AdresssucheController.java (limited to 'connector/src/main/java/at/asitplus/eidas/specific') diff --git a/connector/src/main/java/at/asitplus/eidas/specific/connector/controller/AdresssucheController.java b/connector/src/main/java/at/asitplus/eidas/specific/connector/controller/AdresssucheController.java new file mode 100644 index 00000000..35f56012 --- /dev/null +++ b/connector/src/main/java/at/asitplus/eidas/specific/connector/controller/AdresssucheController.java @@ -0,0 +1,131 @@ +/* + * Copyright 2018 A-SIT Plus GmbH + * AT-specific eIDAS Connector has been developed in a cooperation between EGIZ, + * A-SIT Plus GmbH, A-SIT, and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "License"); + * You may not use this work except in compliance with the License. + * You may obtain a copy of the License at: + * https://joinup.ec.europa.eu/news/understanding-eupl-v12 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + +package at.asitplus.eidas.specific.connector.controller; + +import at.asitplus.eidas.specific.connector.MsEidasNodeConstants; +import at.asitplus.eidas.specific.connector.gui.StaticGuiBuilderConfiguration; +import at.gv.egiz.eaaf.core.api.gui.IGuiBuilderConfiguration; +import at.gv.egiz.eaaf.core.api.gui.ISpringMvcGuiFormBuilder; +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.GuiBuildException; +import at.gv.egiz.eaaf.core.exceptions.PendingReqIdValidationException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.io.ResourceLoader; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * Default process-engine signaling controller. + * + * @author tlenz + */ +@Controller +@Slf4j +public class AdresssucheController { + + @Autowired + private ISpringMvcGuiFormBuilder guiBuilder; + + @Autowired + private IConfiguration basicConfig; + + @Autowired + private ResourceLoader resourceLoader; + + @Autowired + private IPendingRequestIdGenerationStrategy pendingReqGeneration; + + @RequestMapping(value = {"/test"}, method = {RequestMethod.GET}) + public void test(HttpServletRequest request, HttpServletResponse response) throws GuiBuildException { + final IGuiBuilderConfiguration config = new StaticGuiBuilderConfiguration( + basicConfig, + "http://localhost:8080/ms_connector/", + basicConfig.getBasicConfiguration(//TODO + MsEidasNodeConstants.PROP_CONFIG_WEBCONTENT_TEMPLATES_RESIDENCY, + MsEidasNodeConstants.TEMPLATE_HTML_RESIDENCY), + MsEidasNodeConstants.ENDPOINT_RESIDENCY_INPUT, + resourceLoader); + // TODO Set the pendingId somehow + guiBuilder.build(request, response, config, "Query Austrian residency"); + } + + @RequestMapping(value = {"/residency/search"}, method = {RequestMethod.POST}) + public ResponseEntity search(@RequestParam("city") String city, + @RequestParam("street") String street, + @RequestParam("number") String number, + @RequestParam("pendingid") String pendingId) { + log.info("Search with '{}', '{}', '{}'", city, street, number); + // TODO validate pendingId +// try { +// pendingReqGeneration.validateAndGetPendingRequestId(pendingId); +// } catch (PendingReqIdValidationException e) { +// log.warn("Search with pendingId '{}' is not valid", pendingId); +// return ResponseEntity.badRequest().build(); +// } + AdresssucheOutput output = new AdresssucheOutput("Where the streets have no name", "No Name", "42"); + return ResponseEntity.ok(output); + } + + public static class AdresssucheOutput { + private final String city; + private final String street; + private final String number; + + public AdresssucheOutput(String city, String street, String number) { + this.city = city; + this.street = street; + this.number = number; + } + + public String getCity() { + return city; + } + + public String getStreet() { + return street; + } + + public String getNumber() { + return number; + } + + @Override + public String toString() { + return "AdresssucheOutput{" + + "city='" + city + '\'' + + ", street='" + street + '\'' + + ", number='" + number + '\'' + + '}'; + } + } + +} -- cgit v1.2.3