aboutsummaryrefslogtreecommitdiff
path: root/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveAustrianResidenceGuiResponseTask.java
diff options
context:
space:
mode:
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveAustrianResidenceGuiResponseTask.java')
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveAustrianResidenceGuiResponseTask.java117
1 files changed, 117 insertions, 0 deletions
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveAustrianResidenceGuiResponseTask.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveAustrianResidenceGuiResponseTask.java
new file mode 100644
index 00000000..2020274a
--- /dev/null
+++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveAustrianResidenceGuiResponseTask.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2021 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.modules.auth.eidas.v2.tasks;
+
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.InvalidUserInputException;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient;
+import at.gv.egiz.eaaf.core.api.data.EaafConstants;
+import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext;
+import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException;
+import at.gv.egiz.eaaf.core.impl.idp.auth.modules.AbstractAuthServletTask;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Enumeration;
+
+/**
+ * Task receives the response of {@link GenerateAustrianResidenceGuiTask} and handles it.
+ *
+ * @author amarsalek
+ */
+@Slf4j
+@Component("ReceiveAustrianResidenceGuiResponseTask")
+public class ReceiveAustrianResidenceGuiResponseTask extends AbstractAuthServletTask {
+
+ final String formerResidenceAvailableParameterName = "formerResidenceAvailable";
+ final String streetParameterName = "street";
+ final String zipCodeParameterName = "zipcode";
+ final String cityParameterName = "city";
+ private final IZmrClient zmrClient;
+
+ public ReceiveAustrianResidenceGuiResponseTask(IZmrClient zmrClient) {
+ this.zmrClient = zmrClient;
+ }
+
+ //TODO
+ @Override
+ public void execute(ExecutionContext executionContext, HttpServletRequest request, HttpServletResponse response)
+ throws TaskExecutionException {
+
+ log.trace("Starting ReceiveAustrianResidenceGuiResponseTask");
+ // set parameter execution context
+ final Enumeration<String> reqParamNames = request.getParameterNames();
+ String street = null;
+ String city = null;
+ String zipcode = null;
+ Boolean formerResidenceAvailable = false;
+ while (reqParamNames.hasMoreElements()) {
+ final String paramName = reqParamNames.nextElement();
+ if (StringUtils.isNotEmpty(paramName)
+ && !EaafConstants.PROCESS_ENGINE_PENDINGREQUESTID.equalsIgnoreCase(paramName)
+ && formerResidenceAvailableParameterName.equalsIgnoreCase(paramName)) {
+ formerResidenceAvailable =
+ Boolean.parseBoolean(StringEscapeUtils.escapeHtml(request.getParameter(paramName)));
+ }
+ if (StringUtils.isNotEmpty(paramName)
+ && !EaafConstants.PROCESS_ENGINE_PENDINGREQUESTID.equalsIgnoreCase(paramName)
+ && streetParameterName.equalsIgnoreCase(paramName)) {
+ street = StringEscapeUtils.escapeHtml(request.getParameter(paramName));
+ }
+ if (StringUtils.isNotEmpty(paramName)
+ && !EaafConstants.PROCESS_ENGINE_PENDINGREQUESTID.equalsIgnoreCase(paramName)
+ && cityParameterName.equalsIgnoreCase(paramName)) {
+ city = StringEscapeUtils.escapeHtml(request.getParameter(paramName));
+ }
+ if (StringUtils.isNotEmpty(paramName)
+ && !EaafConstants.PROCESS_ENGINE_PENDINGREQUESTID.equalsIgnoreCase(paramName)
+ && zipCodeParameterName.equalsIgnoreCase(paramName)) {
+ zipcode = StringEscapeUtils.escapeHtml(request.getParameter(paramName));
+ }
+ }
+ if (formerResidenceAvailable) {
+ //step 18
+ if (street.isEmpty() || city.isEmpty() || zipcode.isEmpty()) {
+ //form should ensure that mandatory fields are field =>
+ //this can never happen, expect somebody manipulated the response
+ throw new TaskExecutionException(pendingReq, "Invalid user input", new InvalidUserInputException());
+ }
+ step18_RegisterSearch(street, city, zipcode);//TODO also MDS?
+ } else {
+ //step 20 or for now (phase 1) step 9
+ executionContext.put(Constants.TRANSITION_TO_CREATE_NEW_ERNB_ENTRY_TASK, true);
+ }
+
+
+ }
+
+ private void step18_RegisterSearch(String street, String city, String zipcode) {
+ System.out.println(street + city + zipcode + zmrClient);//TODO
+ }
+
+}