aboutsummaryrefslogtreecommitdiff
path: root/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/servlets
diff options
context:
space:
mode:
authorgregor <gregor@d688527b-c9ab-4aba-bd8d-4036d912da1d>2003-11-25 19:41:46 +0000
committergregor <gregor@d688527b-c9ab-4aba-bd8d-4036d912da1d>2003-11-25 19:41:46 +0000
commitb548b9859413b3a974a5bad900c20fef4ae058d4 (patch)
tree16bfbdc29121d542cbf3fcb575994d8ca908b269 /spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/servlets
parent1e415c3e382800fa4d0e8fb8759f0d7589f5917a (diff)
downloadmoa-id-spss-b548b9859413b3a974a5bad900c20fef4ae058d4.tar.gz
moa-id-spss-b548b9859413b3a974a5bad900c20fef4ae058d4.tar.bz2
moa-id-spss-b548b9859413b3a974a5bad900c20fef4ae058d4.zip
Zwischenstand
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@62 d688527b-c9ab-4aba-bd8d-4036d912da1d
Diffstat (limited to 'spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/servlets')
-rw-r--r--spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/servlets/ResultServlet.java125
-rw-r--r--spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/servlets/SLRequest.java19
2 files changed, 144 insertions, 0 deletions
diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/servlets/ResultServlet.java b/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/servlets/ResultServlet.java
new file mode 100644
index 000000000..67397a1ee
--- /dev/null
+++ b/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/servlets/ResultServlet.java
@@ -0,0 +1,125 @@
+/*
+ * Created on 25.11.2003
+ *
+ * (c) Stabsstelle IKT-Strategie des Bundes
+ */
+package at.gv.egovernment.moa.spss.slinterface.servlets;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.net.URLConnection;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.log4j.Logger;
+import org.w3c.dom.Document;
+
+import at.gv.egovernment.moa.spss.slinterface.Constants;
+import at.gv.egovernment.moa.spss.slinterface.Utils;
+import at.gv.egovernment.moa.spss.slinterface.moainvoker.MOAInvoker;
+
+/**
+ * @author Gregor Karlinger (mailto:gregor.karlinger@cio.gv.at)
+ */
+public class ResultServlet extends HttpServlet
+{
+
+ private static Logger logger_ = Logger.getLogger(Constants.LH_SERVLETS_);
+
+ /**
+ * Default constructor.
+ */
+ public ResultServlet()
+ {
+ super();
+ }
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException
+ {
+ // Get session
+ HttpSession session = request.getSession(false);
+ if (session == null)
+ {
+ String message = "No session available";
+ logger_.error(message);
+ throw new ServletException(message);
+ }
+
+ // Get original SL request from session
+ SLRequest slRequest = (SLRequest) session.getAttribute("slRequest");
+ if (slRequest == null)
+ {
+ String message = "Session object \"slRequest\" not available.";
+ logger_.error(message);
+ throw new ServletException(message);
+ }
+
+ // Get SL response from session
+ Document slResponseDoc = (Document) session.getAttribute("slResponseDoc");
+ if (slResponseDoc == null)
+ {
+ String message = "Session object \"slResponseDoc\" not available.";
+ logger_.error(message);
+ throw new ServletException(message);
+ }
+
+ URLConnection dataURLConn;
+ try
+ {
+ // Open connection to DataURL
+ URL dataURL = new URL(slRequest.dataUrl_);
+ dataURLConn = dataURL.openConnection();
+ dataURLConn.setDoOutput(true);
+ OutputStream dataURLOS = dataURLConn.getOutputStream();
+ MOAInvoker.serializeDocument(slResponseDoc, dataURLOS);
+ dataURLOS.flush();
+ }
+ catch (Exception e)
+ {
+ String message = "Sending SL XML response to DataURL failed.";
+ logger_.error(message, e);
+ throw new ServletException(message, e);
+ }
+
+ // Forward response from DataURL to client
+ forwardResponse(dataURLConn, response);
+
+ session.invalidate();
+ }
+
+ /* ---------------------------------------------------------------------------------------------------- */
+
+ private void forwardResponse(URLConnection dataURLConn, ServletResponse response) throws ServletException
+ {
+ // Make sure that content type of DataURL response is text/html
+ String dataURLContentType = dataURLConn.getContentType();
+ if (dataURLContentType == null || !dataURLContentType.startsWith("text/html"))
+ {
+ String message = "Unsupported content type of DataURL response: \"" + dataURLContentType + "\".";
+ logger_.error(message);
+ throw new ServletException(message);
+ }
+
+ try
+ {
+ InputStream dataURLIS = dataURLConn.getInputStream();
+ byte[] dataURLResponse = Utils.readFromInputStream(dataURLIS);
+ response.setContentType("text/html");
+ OutputStream responseOS = response.getOutputStream();
+ responseOS.write(dataURLResponse);
+ responseOS.flush();
+ }
+ catch (Exception e)
+ {
+ String message = "Forwarding DataURL response to client failed.";
+ logger_.error(message, e);
+ throw new ServletException(message, e);
+ }
+ }
+}
diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/servlets/SLRequest.java b/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/servlets/SLRequest.java
new file mode 100644
index 000000000..3c19d5ff6
--- /dev/null
+++ b/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/servlets/SLRequest.java
@@ -0,0 +1,19 @@
+/*
+ * Created on 25.11.2003
+ *
+ * (c) Stabsstelle IKT-Strategie des Bundes
+ */
+package at.gv.egovernment.moa.spss.slinterface.servlets;
+
+/**
+ * Helper class, representing the fields of a Security-Layer request.
+ *
+ * @author Gregor Karlinger (mailto:gregor.karlinger@cio.gv.at)
+ */
+public class SLRequest
+{
+ public String xmlRequest_;
+ public String dataUrl_;
+ public String stylesheetUrl_;
+ public String redirectUrl_;
+}