aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet
diff options
context:
space:
mode:
authorThomas Lenz <tlenz@iaik.tugraz.at>2016-03-14 11:40:13 +0100
committerThomas Lenz <tlenz@iaik.tugraz.at>2016-03-14 11:40:13 +0100
commitb01fc5becad147315bbd8d168f5435ee126e638d (patch)
tree981f82a60365af9ce0e2526cc5240c8263a2c5df /id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet
parentf67427831d1f8c49ce6c474691b880d90a42b584 (diff)
downloadmoa-id-spss-b01fc5becad147315bbd8d168f5435ee126e638d.tar.gz
moa-id-spss-b01fc5becad147315bbd8d168f5435ee126e638d.tar.bz2
moa-id-spss-b01fc5becad147315bbd8d168f5435ee126e638d.zip
add independent mandate-service selection step to choose between MIS and ELGA mandate-service
Diffstat (limited to 'id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/GUILayoutBuilderServlet.java150
1 files changed, 150 insertions, 0 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/GUILayoutBuilderServlet.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/GUILayoutBuilderServlet.java
new file mode 100644
index 000000000..09b344f9d
--- /dev/null
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/GUILayoutBuilderServlet.java
@@ -0,0 +1,150 @@
+/*
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * 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.gv.egovernment.moa.id.auth.servlet;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang.StringEscapeUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import at.gv.egovernment.moa.id.auth.frontend.builder.IGUIFormBuilder;
+import at.gv.egovernment.moa.id.auth.frontend.builder.ServiceProviderSpecificGUIFormBuilderConfiguration;
+import at.gv.egovernment.moa.id.auth.servlet.AbstractController;
+import at.gv.egovernment.moa.id.commons.MOAIDAuthConstants;
+import at.gv.egovernment.moa.id.commons.api.AuthConfiguration;
+import at.gv.egovernment.moa.id.commons.api.IRequest;
+import at.gv.egovernment.moa.id.moduls.IRequestStorage;
+import at.gv.egovernment.moa.id.util.HTTPUtils;
+import at.gv.egovernment.moa.logging.Logger;
+import at.gv.egovernment.moa.util.MiscUtil;
+
+/**
+ * @author tlenz
+ *
+ */
+@Controller
+public class GUILayoutBuilderServlet extends AbstractController {
+
+ public static final String ENDPOINT_CSS = "/css/buildCSS";
+ public static final String ENDPOINT_JS = "/js/buildJS";
+
+ @Autowired AuthConfiguration authConfig;
+ @Autowired IRequestStorage requestStoreage;
+ @Autowired IGUIFormBuilder formBuilder;
+
+ public GUILayoutBuilderServlet() {
+ super();
+ Logger.debug("Registering servlet " + getClass().getName()
+ + " with mappings '" + ENDPOINT_CSS
+ + "' and '" + ENDPOINT_JS + "'.");
+
+ }
+
+ @RequestMapping(value = "/css/buildCSS", method = {RequestMethod.GET})
+ public void buildCSS(HttpServletRequest req, HttpServletResponse resp) throws IOException {
+ try {
+ IRequest pendingReq = extractPendingRequest(req);
+
+ //initialize GUI builder configuration
+ ServiceProviderSpecificGUIFormBuilderConfiguration config = null;
+ if (pendingReq != null)
+ config = new ServiceProviderSpecificGUIFormBuilderConfiguration(
+ pendingReq,
+ ServiceProviderSpecificGUIFormBuilderConfiguration.VIEW_TEMPLATE_CSS,
+ null);
+
+ else
+ config = new ServiceProviderSpecificGUIFormBuilderConfiguration(
+ HTTPUtils.extractAuthURLFromRequest(req),
+ ServiceProviderSpecificGUIFormBuilderConfiguration.VIEW_TEMPLATE_CSS,
+ null);
+
+ //build GUI component
+ formBuilder.build(resp, config, "text/css;charset=UTF-8", "CSS-Form");
+
+ } catch (Exception e) {
+ Logger.warn("GUI ressource:'CSS' generation FAILED.");
+ resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Created resource failed");
+ }
+
+ }
+
+ @RequestMapping(value = "/js/buildJS", method = {RequestMethod.GET})
+ public void buildJavaScript(HttpServletRequest req, HttpServletResponse resp) throws IOException {
+ try {
+ IRequest pendingReq = extractPendingRequest(req);
+
+ //initialize GUI builder configuration
+ ServiceProviderSpecificGUIFormBuilderConfiguration config = null;
+ if (pendingReq != null)
+ config = new ServiceProviderSpecificGUIFormBuilderConfiguration(
+ pendingReq,
+ ServiceProviderSpecificGUIFormBuilderConfiguration.VIEW_TEMPLATE_JS,
+ null);
+
+ else
+ config = new ServiceProviderSpecificGUIFormBuilderConfiguration(
+ HTTPUtils.extractAuthURLFromRequest(req),
+ ServiceProviderSpecificGUIFormBuilderConfiguration.VIEW_TEMPLATE_JS,
+ null);
+
+ //build GUI component
+ formBuilder.build(resp, config, "text/javascript;charset=UTF-8", "JavaScript");
+
+ } catch (Exception e) {
+ Logger.warn("GUI ressource:'JavaScript' generation FAILED.");
+ resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Created resource failed");
+ }
+
+ }
+
+ private IRequest extractPendingRequest(HttpServletRequest req) {
+ try {
+ String pendingReqID = StringEscapeUtils.escapeHtml(
+ req.getParameter(MOAIDAuthConstants.PARAM_TARGET_PENDINGREQUESTID));
+
+ if (MiscUtil.isNotEmpty(pendingReqID)) {
+ IRequest pendingReq = requestStorage.getPendingRequest(pendingReqID);
+ if (pendingReq != null) {
+ Logger.trace("GUI-Layout builder: Pending-request:"
+ + pendingReqID + " found -> Build specific template");
+ return pendingReq;
+
+ }
+ }
+
+ Logger.trace("GUI-Layout builder: No pending-request found -> Use default templates");
+
+ } catch (Exception e) {
+ Logger.warn("GUI-Layout builder-servlet has an error during request-preprocessing.", e);
+ }
+
+ return null;
+ }
+}