aboutsummaryrefslogtreecommitdiff
path: root/spss.slinterface
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
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')
-rw-r--r--spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/Constants.java1
-rw-r--r--spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/Utils.java33
-rw-r--r--spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/filters/SL2MOAFilter.java131
-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
-rw-r--r--spss.slinterface/WEB-INF/src/test/at/gv/egovernment/moa/spss/slinterface/DataURLBean.java46
-rw-r--r--spss.slinterface/WEB-INF/src/test/at/gv/egovernment/moa/spss/slinterface/DataURLServlet.java83
-rw-r--r--spss.slinterface/WEB-INF/web.xml28
-rw-r--r--spss.slinterface/pages/test/dataURL.jsp18
-rw-r--r--spss.slinterface/test/slrequests/simpleVerReq.xml39
10 files changed, 431 insertions, 92 deletions
diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/Constants.java b/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/Constants.java
index b47f245fa..cb37fe843 100644
--- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/Constants.java
+++ b/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/Constants.java
@@ -28,6 +28,7 @@ public class Constants
public static final String LH_LISTENERS_ = LH_BASE_ + ".listeners";
public static final String LH_FILTERS_ = LH_BASE_ + ".filters";
public static final String LH_SERVLETS_ = LH_BASE_ + ".servlets";
+ public static final String LH_TEST_ = LH_BASE_ + ".test";
// Web service context parameters
diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/Utils.java b/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/Utils.java
new file mode 100644
index 000000000..8c1292734
--- /dev/null
+++ b/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/Utils.java
@@ -0,0 +1,33 @@
+/*
+ * Created on 25.11.2003
+ *
+ * (c) Stabsstelle IKT-Strategie des Bundes
+ */
+package at.gv.egovernment.moa.spss.slinterface;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * @author Gregor Karlinger (mailto:gregor.karlinger@cio.gv.at)
+ */
+public class Utils
+{
+ public static byte[] readFromInputStream(InputStream inputStream) throws IOException
+ {
+ byte[] currentBytes = new byte[500];
+ int bytesRead;
+ ByteArrayOutputStream result = new ByteArrayOutputStream();
+ do
+ {
+ bytesRead = inputStream.read(currentBytes);
+ if (bytesRead > 0)
+ {
+ result.write(currentBytes, 0, bytesRead);
+ }
+ }
+ while (bytesRead != -1);
+ return result.toByteArray();
+ }
+}
diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/filters/SL2MOAFilter.java b/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/filters/SL2MOAFilter.java
index 77c1b9c0e..08b8635ba 100644
--- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/filters/SL2MOAFilter.java
+++ b/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/filters/SL2MOAFilter.java
@@ -10,6 +10,7 @@ import java.io.ByteArrayOutputStream;
import java.io.CharArrayReader;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
import java.io.Reader;
import java.util.Iterator;
import java.util.List;
@@ -25,12 +26,10 @@ import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.apache.commons.fileupload.DiskFileUpload;
@@ -46,6 +45,7 @@ import org.xml.sax.SAXException;
import at.gv.egovernment.moa.spss.slinterface.Constants;
import at.gv.egovernment.moa.spss.slinterface.moainvoker.MOAInvoker;
+import at.gv.egovernment.moa.spss.slinterface.servlets.SLRequest;
import at.gv.egovernment.moa.spss.slinterface.transformers.MOA2SL;
import at.gv.egovernment.moa.spss.slinterface.transformers.SL2MOA;
@@ -57,7 +57,6 @@ public class SL2MOAFilter implements Filter
private static Logger logger_ = Logger.getLogger(Constants.LH_FILTERS_);
private FilterConfig config_;
- private SLRequest slRequest_;
/* ---------------------------------------------------------------------------------------------------- */
@@ -68,63 +67,32 @@ public class SL2MOAFilter implements Filter
{
// Store filter configuration
config_ = config;
-
- slRequest_ = new SLRequest();
-
- // Initialize stylesheet transform SL2MOA
-// ServletContext context = config_.getServletContext();
-// Transformer sl2MoaTransformer = (Transformer) context.getAttribute(Constants.WSCP_SL2MOA_TRANSFORMER_);
-// if (sl2MoaTransformer == null)
-// {
-// initTransformer(context, Constants.IP_SL2MOA_STYLESHEET_);
-// }
-
- // Initialize stylesheet transform MOA2SL
-// Transformer moa2SlTransformer = (Transformer) context.getAttribute(Constants.WSCP_MOA2SL_TRANSFORMER_);
-// if (moa2SlTransformer == null)
-// {
-// initTransformer(context, Constants.IP_MOA2SL_STYLESHEET_);
-// }
-
}
/* ---------------------------------------------------------------------------------------------------- */
- /*
+ /**
* @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse,
* javax.servlet.FilterChain)
*/
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException
{
+ // Create session
+ HttpSession session = ((HttpServletRequest) request).getSession(true);
+
// Check if request is HTTP-POST
checkHttpPost((HttpServletRequest) request);
// Get SL request from content of request
- parseRequest((HttpServletRequest) request);
+ SLRequest slRequest = parseRequest((HttpServletRequest) request);
+ session.setAttribute("slRequest", slRequest);
// Schema validate SL request
- CharArrayReader slXmlRequestCAR = new CharArrayReader(slRequest_.xmlRequest_.toCharArray());
+ CharArrayReader slXmlRequestCAR = new CharArrayReader(slRequest.xmlRequest_.toCharArray());
Document slXMLRequestDoc = parseSlXmlRequest(slXmlRequestCAR);
// Transform SL request into a MOA SPSS request
-// Transformer sl2MoaTransformer =
-// (Transformer) config_.getServletContext().getAttribute(Constants.WSCP_SL2MOA_TRANSFORMER_);
-// DOMSource slXMLRequestDS = new DOMSource(slXMLRequestDoc);
-// ByteArrayOutputStream moaRequestBOS = new ByteArrayOutputStream();
-// StreamResult moaRequestResult = new StreamResult(moaRequestBOS);
-// try
-// {
-// sl2MoaTransformer.transform(slXMLRequestDS, moaRequestResult);
-// }
-// catch (TransformerException e)
-// {
-// String message = "Transforming SL XML request into MOA XML request failed.";
-// logger_.error(message, e);
-// throw new ServletException(message, e);
-// }
-// logger_.debug("MOA XML Request:\n" + moaRequestBOS.toString());
-// ByteArrayInputStream moaRequestIS = new ByteArrayInputStream(moaRequestBOS.toByteArray());
Properties initProps = (Properties)config_.getServletContext().getAttribute(Constants.WSCP_INIT_PROPS_);
String trustProfileId = initProps.getProperty(Constants.IP_SP_TRUSTPROFILEID_);
Document moaXMLRequestDoc = SL2MOA.toMoaVerifyXMLSignatureRequest(slXMLRequestDoc, trustProfileId);
@@ -138,36 +106,17 @@ public class SL2MOAFilter implements Filter
ResponseWrapper responseWrapper = new ResponseWrapper((HttpServletResponse) response);
chain.doFilter(requestWrapper, responseWrapper);
- // Prepare response to client
- response.setContentType("text/xml");
-
- // Transform MOA response into a SL response and send SL response back to client
-// Transformer moa2SlTransformer =
-// (Transformer) config_.getServletContext().getAttribute(Constants.WSCP_MOA2SL_TRANSFORMER_);
-// ServletOutputStream moaResponseSOS = (ServletOutputStream) responseWrapper.getOutputStream();
-// ByteArrayInputStream moaResponseBIS = new ByteArrayInputStream(moaResponseSOS.toByteArray());
-// StreamSource moaResponseSource = new StreamSource(moaResponseBIS);
-// StreamResult slResponseResult = new StreamResult(response.getOutputStream());
-// try
-// {
-// moa2SlTransformer.transform(moaResponseSource, slResponseResult);
-// }
-// catch (TransformerException e)
-// {
-// String message = "Transforming MOA XML response into SL XML response failed.";
-// logger_.error(message, e);
-// throw new ServletException(message, e);
-// }
+ // Transform MOA response into a SL response
DOMParser xmlParser = (DOMParser) config_.getServletContext().getAttribute(Constants.WSCP_XMLPARSER_);
ServletOutputStream moaResponseSOS = (ServletOutputStream) responseWrapper.getOutputStream();
ByteArrayInputStream moaResponseBIS = new ByteArrayInputStream(moaResponseSOS.toByteArray());
InputSource responseSource = new InputSource(moaResponseBIS);
+ Document slResponseDoc;
try
{
xmlParser.parse(responseSource);
Document moaResponseDoc = xmlParser.getDocument();
- Document slResponseDoc = MOA2SL.toSlVerifyXMLSignatureResponse(moaResponseDoc);
- MOAInvoker.serializeDocument(slResponseDoc, response.getOutputStream());
+ slResponseDoc = MOA2SL.toSlVerifyXMLSignatureResponse(moaResponseDoc);
}
catch (SAXException e)
{
@@ -175,7 +124,16 @@ public class SL2MOAFilter implements Filter
logger_.error(message, e);
throw new ServletException(message, e);
}
-
+ session.setAttribute("slResponseDoc", slResponseDoc);
+
+ String continueURL = ((HttpServletRequest) request).getContextPath() + "/results";
+ continueURL = ((HttpServletResponse) response).encodeURL(continueURL);
+ String responseStr = "<html><body><a href=\"" + continueURL + ">Und weiter geht es ...</a></body></html>";
+
+ response.setContentType("text/html");
+ OutputStream responseOS = response.getOutputStream();
+ responseOS.write(responseStr.getBytes("UTF-8"));
+ responseOS.flush();
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -233,8 +191,10 @@ public class SL2MOAFilter implements Filter
/**
* Parses the http request.
*/
- private void parseRequest(HttpServletRequest request) throws IOException
+ private SLRequest parseRequest(HttpServletRequest request) throws IOException
{
+ SLRequest slRequest = new SLRequest();
+
// Check if request URL ends with "http-security-layer-request"
// @TODO Don't know if this check is sufficient - spec says request URL must have this value as path
String requestURI = request.getRequestURI();
@@ -267,13 +227,13 @@ public class SL2MOAFilter implements Filter
FileItem currItem = (FileItem) itemsIt.next();
String currItemName = currItem.getFieldName();
if (Constants.SLC_NAME_XML_REQUEST_.equals(currItemName))
- slRequest_.xmlRequest_ = currItem.getString();
+ slRequest.xmlRequest_ = currItem.getString();
else if (Constants.SLC_NAME_DATA_URL_.equals(currItemName))
- slRequest_.dataUrl_ = currItem.getString();
+ slRequest.dataUrl_ = currItem.getString();
else if (Constants.SLC_NAME_STYLESHEET_URL_.equals(currItemName))
- slRequest_.stylesheetUrl_ = currItem.getString();
+ slRequest.stylesheetUrl_ = currItem.getString();
else if (Constants.SLC_NAME_REDIRECT_URL_.equals(currItemName))
- slRequest_.redirectUrl_ = currItem.getString();
+ slRequest.redirectUrl_ = currItem.getString();
else
continue; // @TODO Do not evaluate other params at the moment
}
@@ -288,26 +248,28 @@ public class SL2MOAFilter implements Filter
String currName = (String) paramNames.next();
String[] currValues = (String[]) paramsMap.get(currName);
if (Constants.SLC_NAME_XML_REQUEST_.equals(currName))
- slRequest_.xmlRequest_ = currValues[0];
+ slRequest.xmlRequest_ = currValues[0];
else if (Constants.SLC_NAME_DATA_URL_.equals(currName))
- slRequest_.dataUrl_ = currValues[0];
+ slRequest.dataUrl_ = currValues[0];
else if (Constants.SLC_NAME_STYLESHEET_URL_.equals(currName))
- slRequest_.stylesheetUrl_ = currValues[0];
+ slRequest.stylesheetUrl_ = currValues[0];
else if (Constants.SLC_NAME_REDIRECT_URL_.equals(currName))
- slRequest_.redirectUrl_ = currValues[0];
+ slRequest.redirectUrl_ = currValues[0];
else
continue; // @TODO Do not evaluate other params at the moment
}
}
- if (slRequest_.xmlRequest_ == null || slRequest_.dataUrl_ == null ||
- slRequest_.stylesheetUrl_ != null || slRequest_.redirectUrl_ != null)
+ if (slRequest.xmlRequest_ == null || slRequest.dataUrl_ == null ||
+ slRequest.stylesheetUrl_ != null || slRequest.redirectUrl_ != null)
{
- // @TODO Only combindation of XMLRequest and StylesheetURL allowed at the moment
+ // @TODO Only combination of XMLRequest and DataURL allowed at the moment
String message = "Currently only (XMLRequest + DataURL) is supported.";
logger_.error(message);
throw new IOException(message);
}
+
+ return slRequest;
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -367,19 +329,4 @@ public class SL2MOAFilter implements Filter
throw new ServletException(message);
}
}
-
- /* ---------------------------------------------------------------------------------------------------- */
-
- /**
- * Helper class, representing the fields of a Security-Layer request.
- *
- * @author Gregor Karlinger (mailto:gregor.karlinger@cio.gv.at)
- */
- class SLRequest
- {
- public String xmlRequest_;
- public String dataUrl_;
- public String stylesheetUrl_;
- public String redirectUrl_;
- }
}
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_;
+}
diff --git a/spss.slinterface/WEB-INF/src/test/at/gv/egovernment/moa/spss/slinterface/DataURLBean.java b/spss.slinterface/WEB-INF/src/test/at/gv/egovernment/moa/spss/slinterface/DataURLBean.java
new file mode 100644
index 000000000..4cf099a45
--- /dev/null
+++ b/spss.slinterface/WEB-INF/src/test/at/gv/egovernment/moa/spss/slinterface/DataURLBean.java
@@ -0,0 +1,46 @@
+/*
+ * Created on 25.11.2003
+ *
+ * (c) Stabsstelle IKT-Strategie des Bundes
+ */
+package test.at.gv.egovernment.moa.spss.slinterface;
+
+/**
+ * @author Gregor Karlinger (mailto:gregor.karlinger@cio.gv.at)
+ */
+public class DataURLBean
+{
+ String title_;
+ String contentType_;
+ String content_;
+
+ public DataURLBean()
+ {
+ super();
+ title_="unknown";
+ contentType_="unknown";
+ content_="unknown";
+ }
+
+ public DataURLBean(String title, String contentType, String content)
+ {
+ title_ = title;
+ contentType_ = contentType;
+ content_ = content;
+ }
+
+ public String getTitle()
+ {
+ return title_;
+ }
+
+ public String getContentType()
+ {
+ return contentType_;
+ }
+
+ public String getContent()
+ {
+ return content_;
+ }
+}
diff --git a/spss.slinterface/WEB-INF/src/test/at/gv/egovernment/moa/spss/slinterface/DataURLServlet.java b/spss.slinterface/WEB-INF/src/test/at/gv/egovernment/moa/spss/slinterface/DataURLServlet.java
new file mode 100644
index 000000000..ff4cbbe59
--- /dev/null
+++ b/spss.slinterface/WEB-INF/src/test/at/gv/egovernment/moa/spss/slinterface/DataURLServlet.java
@@ -0,0 +1,83 @@
+/*
+ * Created on 25.11.2003
+ *
+ * (c) Stabsstelle IKT-Strategie des Bundes
+ */
+package test.at.gv.egovernment.moa.spss.slinterface;
+
+import java.io.IOException;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.log4j.Logger;
+
+import at.gv.egovernment.moa.spss.slinterface.Constants;
+import at.gv.egovernment.moa.spss.slinterface.Utils;
+
+/**
+ * @author Gregor Karlinger (mailto:gregor.karlinger@cio.gv.at)
+ */
+public class DataURLServlet extends HttpServlet
+{
+ private static Logger logger_ = Logger.getLogger(Constants.LH_TEST_);
+
+ public DataURLServlet()
+ {
+ super();
+ }
+
+ /* ---------------------------------------------------------------------------------------------------- */
+
+ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException
+ {
+ // Read content form POST request
+ try
+ {
+ logger_.debug("Received POST request:");
+ logger_.debug("Content type: \"" + request.getContentType() + "\".");
+ byte[] contentBytes = Utils.readFromInputStream(request.getInputStream());
+ String contentStr = new String(contentBytes);
+ logger_.debug("Content:\n" + new String(contentStr));
+
+ StringBuffer contentStrBuf = new StringBuffer(contentStr);
+ int startPos = 0;
+ while (startPos < contentStrBuf.length())
+ {
+ if (contentStrBuf.charAt(startPos) == '<')
+ {
+ contentStrBuf.replace(startPos, startPos + 1, "&lt;");
+ startPos += 4;
+ }
+ startPos++;
+ }
+ contentStr = contentStrBuf.toString();
+
+ DataURLBean dataURLBean = new DataURLBean("Data URL Results", request.getContentType(), contentStr);
+ request.setAttribute("dataURLResult", dataURLBean);
+ }
+ catch (Exception e)
+ {
+ String message = "Failed to read content from POST request.";
+ logger_.error(message, e);
+ throw new ServletException(message, e);
+ }
+
+ // Invoke response JSP page
+ try
+ {
+ response.setContentType("text/html");
+ RequestDispatcher dispatcher = request.getRequestDispatcher("/pages/test/dataURL.jsp");
+ dispatcher.include(request, response);
+ }
+ catch (IOException e)
+ {
+ String message = "Failed to send simple HTML answer to client.";
+ logger_.error(message, e);
+ throw new ServletException(message, e);
+ }
+ }
+}
diff --git a/spss.slinterface/WEB-INF/web.xml b/spss.slinterface/WEB-INF/web.xml
index db502faf8..b2907b1f2 100644
--- a/spss.slinterface/WEB-INF/web.xml
+++ b/spss.slinterface/WEB-INF/web.xml
@@ -31,9 +31,37 @@
<load-on-startup>0</load-on-startup>
</servlet>
+ <servlet>
+ <servlet-name>DataURLServlet</servlet-name>
+ <display-name>DataURL test servlet</display-name>
+ <servlet-class>
+ test.at.gv.egovernment.moa.spss.slinterface.DataURLServlet
+ </servlet-class>
+ <load-on-startup>0</load-on-startup>
+ </servlet>
+
+ <servlet>
+ <servlet-name>ResultServlet</servlet-name>
+ <display-name>Result servlet</display-name>
+ <servlet-class>
+ at.gv.egovernment.moa.spss.slinterface.servlets.ResultServlet
+ </servlet-class>
+ <load-on-startup>0</load-on-startup>
+ </servlet>
+
<servlet-mapping>
<servlet-name>MOAServlet</servlet-name>
<url-pattern>/http-security-layer-request</url-pattern>
</servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>DataURLServlet</servlet-name>
+ <url-pattern>/dataurl</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>ResultServlet</servlet-name>
+ <url-pattern>/results</url-pattern>
+ </servlet-mapping>
+
</web-app>
diff --git a/spss.slinterface/pages/test/dataURL.jsp b/spss.slinterface/pages/test/dataURL.jsp
new file mode 100644
index 000000000..c2b62697f
--- /dev/null
+++ b/spss.slinterface/pages/test/dataURL.jsp
@@ -0,0 +1,18 @@
+<%@ page contentType="text/html; charset=UTF-8" %>
+
+<jsp:useBean
+ id="dataURLResult"
+ class="test.at.gv.egovernment.moa.spss.slinterface.DataURLBean" scope="request">
+</jsp:useBean>
+
+<html>
+ <head>
+ <head><title><jsp:getProperty name="dataURLResult" property="title"/></title></head>
+ </head>
+ <body>
+ <h1>Content-Type</h1>
+ <p><pre><jsp:getProperty name="dataURLResult" property="contentType"/></pre></p>
+ <h1>Content</h1>
+ <p><pre><jsp:getProperty name="dataURLResult" property="content"/></pre></p>
+ </body>
+</html> \ No newline at end of file
diff --git a/spss.slinterface/test/slrequests/simpleVerReq.xml b/spss.slinterface/test/slrequests/simpleVerReq.xml
new file mode 100644
index 000000000..fdc1daec9
--- /dev/null
+++ b/spss.slinterface/test/slrequests/simpleVerReq.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<sl11:VerifyXMLSignatureRequest xmlns:sl10="http://www.buergerkarte.at/namespaces/securitylayer/20020225#" xmlns:sl11="http://www.buergerkarte.at/namespaces/securitylayer/20020831#" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#">
+ <sl11:SignatureInfo>
+ <sl11:SignatureEnvironment>
+ <sl10:XMLContent>
+<dsig:Signature Id="HS_signature" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:SignedInfo><dsig:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/><dsig:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/><dsig:Reference Id="reference-data-1" URI="#signed-data"><dsig:Transforms><dsig:Transform Algorithm="http://www.w3.org/2002/06/xmldsig-filter2"><xf2:XPath Filter="intersect" xmlns:xf2="http://www.w3.org/2002/06/xmldsig-filter2">id(&apos;signed-data&apos;)/node()</xf2:XPath></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><dsig:DigestValue>aylv7lNNes2pI022g7zfY1AOUmI=</dsig:DigestValue></dsig:Reference><dsig:Reference Type="http://uri.etsi.org/01903/v1.1.1#SignedProperties" URI="#refetsi"><dsig:Transforms><dsig:Transform Algorithm="http://www.w3.org/2002/06/xmldsig-filter2"><xf2:XPath Filter="intersect" xmlns:etsi="http://uri.etsi.org/01903/v1.1.1#" xmlns:xf2="http://www.w3.org/2002/06/xmldsig-filter2">id(&apos;refetsi&apos;)/etsi:QualifyingProperties/etsi:SignedProperties</xf2:XPath></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><dsig:DigestValue>rYJgLYFMHaAcQjIlwSpFqXp5d1A=</dsig:DigestValue></dsig:Reference></dsig:SignedInfo><dsig:SignatureValue>VnwHohi/ootc3mIWh2WnInNvjA+/kJOr5bDRl5no1CMsNA+1qhoVZCErHt75gp9m
+O0MPBAcl7KfvkDTbHuMR1oG1Z4RUh52cE5oQietiwHGQIeuWEJ+IGcVcnkoayz4z
+2tQLkdotBhV0mCmkQjyADNn8P4H5yHNsdPq0joqy+2Q=</dsig:SignatureValue><dsig:KeyInfo><dsig:X509Data><dsig:X509Certificate>MIIE4DCCA8igAwIBAgICGEowDQYJKoZIhvcNAQEFBQAwgZcxCzAJBgNVBAYTAkFU
+MUgwRgYDVQQKEz9BLVRydXN0IEdlcy4gZi4gU2ljaGVyaGVpdHNzeXN0ZW1lIGlt
+IGVsZWt0ci4gRGF0ZW52ZXJrZWhyIEdtYkgxHjAcBgNVBAsTFWEtc2lnbi1QcmVt
+aXVtLVNpZy0wMTEeMBwGA1UEAxMVYS1zaWduLVByZW1pdW0tU2lnLTAxMB4XDTAz
+MDEyNzEwMTQxM1oXDTA2MDEyNzEwMTQxM1owZDELMAkGA1UEBhMCQVQxGTAXBgNV
+BAMTEEdyZWdvciBLYXJsaW5nZXIxEjAQBgNVBAQTCUthcmxpbmdlcjEPMA0GA1UE
+KhMGR3JlZ29yMRUwEwYDVQQFEww5MTM4OTU1NTI5MTEwgZ8wDQYJKoZIhvcNAQEB
+BQADgY0AMIGJAoGBANrnnGN6wiOyq/rskasBf/Tz4grEKI+NBAuDgO5aqObNDBAe
+PISMQ2nFNX2nzoSNx7j7esl4KdgySmJkZWs/nErpE5fB8lHOfrPRD61dodS+Nhwi
+RWlm+I+ua+mOwR18fg/Cwt3YpXZihzZ+ju7eFlxRifHtKJCLOld6IvdFdFCtAgMB
+AAGjggHqMIIB5jATBgNVHSMEDDAKgAhA1/OeG4c6zDA+BggrBgEFBQcBAwEB/wQv
+MC0wCAYGBACORgEBMBUGBgQAjkYBAjALEwNFVVICAQACAQAwCgYIKwYBBQUHCwEw
+fQYIKwYBBQUHAQEEcTBvMEIGCCsGAQUFBzAChjZodHRwOi8vd3d3LmEtdHJ1c3Qu
+YXQvY2VydHMvYS1zaWduLVByZW1pdW0tU2lnLTAxYS5jcnQwKQYIKwYBBQUHMAGG
+HWh0dHA6Ly93d3cuYS10cnVzdC5hdDo4Mi9vY3NwME8GA1UdIARIMEYwRAYGKigA
+EQELMDowOAYIKwYBBQUHAgEWLGh0dHA6Ly93d3cuYS10cnVzdC5hdC9kb2NzL2Nw
+L2Etc2lnbi1QcmVtaXVtMGoGA1UdHwRjMGEwX6BdoFuGWWxkYXA6Ly9sZGFwLmEt
+dHJ1c3QuYXQvb3U9YS1zaWduLVByZW1pdW0tU2lnLTAxLG89QS1UcnVzdCxjPUFU
+P2NlcnRpZmljYXRlcmV2b2NhdGlvbmxpc3Q/MBEGA1UdDgQKBAhOYExavdLCITAO
+BgNVHQ8BAf8EBAMCBsAwJQYDVR0RBB4wHIEaZ3JlZ29yLmthcmxpbmdlckBjaW8u
+Z3YuYXQwCQYDVR0TBAIwADANBgkqhkiG9w0BAQUFAAOCAQEAL+A2+Z5gQvn6SnZe
+sLvVVVB1crHe7NI/Om2rEwha4PfEk2pV9UdOg7C1XSzRu9jCNXIAuUSIpxTtAoJH
+sCk82S+iuEEgyVaXU/zFcbgT/k7opHXHswEC6ab2SQnyOlugyG+o7e9nRwAQTzzj
+ryICr3KACQcVwCpLKCgsU6gYQL1bi/c5vk4rnDYquSm1U34+xIl77CefZN/peGU4
+26vUzGma30wHBepLX5M+NXT7ILRzRk4i8oyOccIzOMi/iwAODJmgSSMcYjUgAngE
+oGYK9ngWu7Rr1gvy4lvOwpGGRpz2MP3nU9H2IfKk36n6hhVpc3EC6aF02RdIBD+x
+8VxVsA==</dsig:X509Certificate></dsig:X509Data></dsig:KeyInfo><dsig:Object Id="signed-data">Das ist ein Test.</dsig:Object><dsig:Object Id="refetsi"><etsi:QualifyingProperties Target="#HS_signature" xmlns:etsi="http://uri.etsi.org/01903/v1.1.1#"><etsi:SignedProperties><etsi:SignedSignatureProperties><etsi:SigningTime>2003-08-14T12:53:27Z</etsi:SigningTime><etsi:SigningCertificate><etsi:Cert><etsi:CertDigest><etsi:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><etsi:DigestValue>wl/zuayZxKuYlH2G2FQCTcosSSg=</etsi:DigestValue></etsi:CertDigest><etsi:IssuerSerial><dsig:X509IssuerName>CN=a-sign-Premium-Sig-01,OU=a-sign-Premium-Sig-01,O=A-Trust Ges. f. Sicherheitssysteme im elektr. Datenverkehr GmbH,C=AT</dsig:X509IssuerName><dsig:X509SerialNumber>6218</dsig:X509SerialNumber></etsi:IssuerSerial></etsi:Cert></etsi:SigningCertificate><etsi:SignaturePolicyIdentifier><etsi:SignaturePolicyImplied/></etsi:SignaturePolicyIdentifier></etsi:SignedSignatureProperties><etsi:SignedDataObjectProperties><etsi:DataObjectFormat ObjectReference="#reference-data-1"><etsi:MimeType>text/plain</etsi:MimeType></etsi:DataObjectFormat></etsi:SignedDataObjectProperties></etsi:SignedProperties></etsi:QualifyingProperties></dsig:Object></dsig:Signature>
+ </sl10:XMLContent>
+ </sl11:SignatureEnvironment>
+ <sl11:SignatureLocation>/dsig:Signature</sl11:SignatureLocation>
+ </sl11:SignatureInfo>
+</sl11:VerifyXMLSignatureRequest>