aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgregor <gregor@d688527b-c9ab-4aba-bd8d-4036d912da1d>2003-12-16 11:26:04 +0000
committergregor <gregor@d688527b-c9ab-4aba-bd8d-4036d912da1d>2003-12-16 11:26:04 +0000
commit30b51f122dac66296e5b17c9ca2cc89a871ffdc2 (patch)
treed4947622f94132c6d026e1a1fc47913c2614b7d3
parentbedb12d7f975451198071b5b3f7102c248879592 (diff)
downloadmoa-id-spss-30b51f122dac66296e5b17c9ca2cc89a871ffdc2.tar.gz
moa-id-spss-30b51f122dac66296e5b17c9ca2cc89a871ffdc2.tar.bz2
moa-id-spss-30b51f122dac66296e5b17c9ca2cc89a871ffdc2.zip
Rewrite der URLs für signierte Dateien und Bilder implementiert und getestet.
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@74 d688527b-c9ab-4aba-bd8d-4036d912da1d
-rw-r--r--spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/Constants.java4
-rw-r--r--spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/URLRewriter.java119
-rw-r--r--spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/listeners/ContextListener.java5
-rw-r--r--spss.slinterface/WEB-INF/src/test/at/gv/egovernment/moa/spss/slinterface/RewriteServlet.java73
-rw-r--r--spss.slinterface/WEB-INF/web.xml46
-rw-r--r--spss.slinterface/moa-spss-sl.warbin0 -> 6978409 bytes
-rw-r--r--spss.slinterface/pages/resultOverview.jsp17
-rw-r--r--spss.slinterface/res/resources/properties/init.properties10
8 files changed, 256 insertions, 18 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 8dd6a87ff..6e3a7c1b7 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
@@ -25,6 +25,9 @@ public class Constants
public static final String IP_SP_TRUSTPROFILEID_ = "service.sp.trustProfileId";
public static final String IP_RES_SHOWETSI_ = "result.showetsi";
public static final String IP_RES_SHOWSLMAN_ = "result.showslmanifest";
+ public static final String IP_REW_PROXYRUL_ = "rewrite.proxyURL";
+ public static final String IP_REW_SLI_URLPARAMNAME_ = "rewrite.sliUrlParamName";
+ public static final String IP_REW_SLIRUL_ = "result.sliUrl";
// Logging hierarchies
@@ -41,6 +44,7 @@ public class Constants
public static final String WSCP_SL2MOA_TRANSFORMER_ = "sl2MoaTransformer";
public static final String WSCP_MOA2SL_TRANSFORMER_ = "moa2SlTransformer";
public static final String WSCP_XMLPARSER_ = "xmlParser";
+ public static final String WSCP_URL_REWRITER_ = "urlRewriter";
// Security-Layer constants
diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/URLRewriter.java b/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/URLRewriter.java
new file mode 100644
index 000000000..e1b8e77e5
--- /dev/null
+++ b/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/URLRewriter.java
@@ -0,0 +1,119 @@
+/*
+ * Created on 15.12.2003
+ *
+ * (c) Stabsstelle IKT-Strategie des Bundes
+ */
+package at.gv.egovernment.moa.spss.slinterface;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Properties;
+
+import org.apache.log4j.Logger;
+
+/**
+ * @author Gregor Karlinger (mailto:gregor.karlinger@cio.gv.at)
+ */
+public class URLRewriter
+{
+ private static Logger logger_ = Logger.getLogger(Constants.LH_LISTENERS_);
+
+ Properties initProps_;
+
+ /**
+ * Class that manges the rewriting of URLs for the result pages. Necessary as workaround for the deploy-
+ * ment in the Federal Chancellory.
+ */
+ public URLRewriter(Properties initProps)
+ {
+ initProps_ = initProps;
+ }
+
+ /**
+ * Rewrites the specified URL.
+ *
+ * @param url A URL relative to the context path of the serlet.
+ *
+ * @param sessionId The session id which will be considered in the rewritten URL.
+ *
+ * @return A URL fitting for the proxy component running at the Federal Chancellory.
+ */
+ public String rewrite(String url, String sessionId)
+ {
+ String proxyURLStr = initProps_.getProperty(Constants.IP_REW_PROXYRUL_);
+ String slInterfaceURLParamName = initProps_.getProperty(Constants.IP_REW_SLI_URLPARAMNAME_);
+ String slInterfaceURLStr = initProps_.getProperty(Constants.IP_REW_SLIRUL_);
+
+ if (proxyURLStr == null ||
+ slInterfaceURLParamName == null ||
+ slInterfaceURLStr == null ||
+ "".equals(proxyURLStr.trim()) ||
+ "".equals(slInterfaceURLParamName.trim()) ||
+ "".equals(slInterfaceURLStr.trim()))
+ {
+ logger_.warn("Some params for URL rewriting are not available; rewriting disabled:" +
+ " proxyURL: \"" + proxyURLStr + "\"," +
+ " slInterfaceURLParamName: \"" + slInterfaceURLParamName + "\"," +
+ " slInterfaceURL: \"" + slInterfaceURLStr + "\"");
+ return url;
+ }
+
+ URL slInterfaceURL = null;
+ try
+ {
+ slInterfaceURL = new URL(slInterfaceURLStr + url);
+ }
+ catch (MalformedURLException e)
+ {
+ logger_.warn("Parameter \"slInterfaceURL\" is not a valid URL: \"" + slInterfaceURLStr + "\"");
+ return url;
+ }
+ URL proxyURL = null;
+ try
+ {
+ proxyURL = new URL(proxyURLStr);
+ }
+ catch (MalformedURLException e)
+ {
+ logger_.warn("Parameter \"proxyURL\" is not a valid URL: \"" + proxyURLStr + "\"");
+ return url;
+ }
+
+ String sessionIdParam = (sessionId != null) ? (";" + "jsessionid=" + sessionId) : "";
+ String returnValue =
+ proxyURL.getProtocol() +
+ "://" +
+ proxyURL.getHost() +
+ ((proxyURL.getPort() != -1) ? (":" + proxyURL.getPort()) : "") +
+ proxyURL.getPath() +
+ ((proxyURL.getQuery() != null) ? "?" + proxyURL.getQuery() + "&" : "?") +
+ slInterfaceURLParamName + "=" +
+ slInterfaceURL.getProtocol() +
+ "://" +
+ slInterfaceURL.getHost() +
+ ((slInterfaceURL.getPort() != -1) ? (":" + slInterfaceURL.getPort()) : "") +
+ slInterfaceURL.getPath() +
+ sessionIdParam +
+ ((slInterfaceURL.getQuery() != null) ? "?" + escapeQueryPart(slInterfaceURL.getQuery()) : "");
+
+ logger_.debug("Rewritten URL: " + returnValue);
+ return returnValue;
+ }
+
+ private String escapeQueryPart(String query)
+ {
+ StringBuffer querySB = new StringBuffer();
+ for (int i = 0; i < query.length(); i++)
+ {
+ if (query.charAt(i) == '&')
+ {
+ querySB.append("%26");
+ }
+ else
+ {
+ querySB.append(query.charAt(i));
+ }
+ }
+ return querySB.toString();
+ }
+}
diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/listeners/ContextListener.java b/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/listeners/ContextListener.java
index 83b6e96dd..3fa3a90a2 100644
--- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/listeners/ContextListener.java
+++ b/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/listeners/ContextListener.java
@@ -24,6 +24,7 @@ import org.apache.xerces.xni.parser.XMLInputSource;
import org.xml.sax.SAXException;
import at.gv.egovernment.moa.spss.slinterface.Constants;
+import at.gv.egovernment.moa.spss.slinterface.URLRewriter;
/**
* @author Gregor Karlinger (mailto:gregor.karlinger@cio.gv.at)
@@ -81,6 +82,10 @@ public class ContextListener implements ServletContextListener
logger_.error("Cannot load initialization properties from location \"" + initPropsLoc + "\".", e);
}
+ // Put helper object for rewriting URLs in the result page into the context
+ URLRewriter urlRewriter = new URLRewriter((Properties)context.getAttribute(Constants.WSCP_INIT_PROPS_));
+ context.setAttribute(Constants.WSCP_URL_REWRITER_, urlRewriter);
+
// Initialize XML parser
SymbolTable symbolTable = new SymbolTable(BIG_PRIME);
XMLGrammarPool grammarPool = new XMLGrammarPoolImpl();
diff --git a/spss.slinterface/WEB-INF/src/test/at/gv/egovernment/moa/spss/slinterface/RewriteServlet.java b/spss.slinterface/WEB-INF/src/test/at/gv/egovernment/moa/spss/slinterface/RewriteServlet.java
new file mode 100644
index 000000000..46b1f793d
--- /dev/null
+++ b/spss.slinterface/WEB-INF/src/test/at/gv/egovernment/moa/spss/slinterface/RewriteServlet.java
@@ -0,0 +1,73 @@
+/*
+ * Created on 15.12.2003
+ *
+ * (c) Stabsstelle IKT-Strategie des Bundes
+ */
+package test.at.gv.egovernment.moa.spss.slinterface;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Properties;
+
+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 RewriteServlet extends HttpServlet
+{
+ private static Logger logger_ = Logger.getLogger(Constants.LH_TEST_);
+
+ public RewriteServlet()
+ {
+ super();
+ }
+
+ /* ---------------------------------------------------------------------------------------------------- */
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException
+ {
+ // Read content form POST request
+ try
+ {
+ logger_.debug("Received GET request:");
+ logger_.debug("Request URI: \"" + request.getRequestURL() + "\"");
+
+ Properties initProps = (Properties) this.getServletContext().getAttribute(Constants.WSCP_INIT_PROPS_);
+ String paramName = (initProps != null)
+ ? initProps.getProperty(Constants.IP_REW_SLI_URLPARAMNAME_)
+ : null;
+
+ if (paramName == null || "".equals(paramName))
+ throw new ServletException("Could not get rewrite parameter name from init properties.");
+
+ logger_.debug("SLInterface rewrite parameter : \"" + paramName + "\"");
+
+ String slInterfaceURLStr = request.getParameter(paramName);
+ URL slInterfaceURL = new URL(slInterfaceURLStr);
+ URLConnection slInterfaceURLConn = slInterfaceURL.openConnection();
+
+ response.setContentType(slInterfaceURLConn.getContentType());
+
+ InputStream slInterfaceIS = slInterfaceURLConn.getInputStream();
+ OutputStream responseOS = response.getOutputStream();
+ Utils.transferStreams(slInterfaceIS, responseOS);
+ }
+ catch (Exception e)
+ {
+ String message = "Failed to get answer from SL interface.";
+ 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 6d282bd1c..da7d74f7b 100644
--- a/spss.slinterface/WEB-INF/web.xml
+++ b/spss.slinterface/WEB-INF/web.xml
@@ -32,15 +32,6 @@
</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>HashInputDataServlet</servlet-name>
<display-name>Displays a particular hash input data</display-name>
<servlet-class>
@@ -58,17 +49,32 @@
<load-on-startup>0</load-on-startup>
</servlet>
+ <!-- For test purposes only -->
+ <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>
+
+ <!-- For test purposes only -->
+ <servlet>
+ <servlet-name>RewriteServlet</servlet-name>
+ <display-name>URL rewriting test servlet</display-name>
+ <servlet-class>
+ test.at.gv.egovernment.moa.spss.slinterface.RewriteServlet
+ </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>HashInputDataServlet</servlet-name>
<url-pattern>/showdata</url-pattern>
</servlet-mapping>
@@ -78,4 +84,16 @@
<url-pattern>/return</url-pattern>
</servlet-mapping>
+ <!-- For test purposes only -->
+ <servlet-mapping>
+ <servlet-name>DataURLServlet</servlet-name>
+ <url-pattern>/dataurl</url-pattern>
+ </servlet-mapping>
+
+ <!-- For test purposes only -->
+ <servlet-mapping>
+ <servlet-name>RewriteServlet</servlet-name>
+ <url-pattern>/rewrite</url-pattern>
+ </servlet-mapping>
+
</web-app>
diff --git a/spss.slinterface/moa-spss-sl.war b/spss.slinterface/moa-spss-sl.war
new file mode 100644
index 000000000..14a74a2ca
--- /dev/null
+++ b/spss.slinterface/moa-spss-sl.war
Binary files differ
diff --git a/spss.slinterface/pages/resultOverview.jsp b/spss.slinterface/pages/resultOverview.jsp
index 5e27178f4..32a0cd403 100644
--- a/spss.slinterface/pages/resultOverview.jsp
+++ b/spss.slinterface/pages/resultOverview.jsp
@@ -25,7 +25,11 @@
<td>
<table bgcolor="#eeeeee" width="790px" border="1" cellpadding="3">
<td width="150px" align="center"><img width="70px"
- <% out.print("src=\"" + request.getContextPath() + "/pages/images/aut-emb2.gif\" alt=\"Republik Österreich\""); %>
+ <% out.print(
+ "src=\"" +
+ ((at.gv.egovernment.moa.spss.slinterface.URLRewriter) application.getAttribute(at.gv.egovernment.moa.spss.slinterface.Constants.WSCP_URL_REWRITER_)).rewrite(
+ request.getContextPath() + "/pages/images/aut-emb2.gif\"", null) +
+ " alt=\"Republik Österreich\""); %>
></td>
<td align="center"><b>Bundeskanzleramt der Republik Österreich - Signaturprüfdienst</b></td>
</table>
@@ -222,10 +226,17 @@
if (doShow)
{
out.print("<tr><td width=\"150px\" align=\"right\"><code>");
- out.print("<a href=\"" + response.encodeURL(request.getContextPath() + dataInfo.getHashInputDataURL()) + "\"");
+
+ // out.print("<a href=\"" + response.encodeURL(request.getContextPath() + dataInfo.getHashInputDataURL()) + "\"");
+ out.print(
+ "<a href=\"" +
+ ((at.gv.egovernment.moa.spss.slinterface.URLRewriter) application.getAttribute(at.gv.egovernment.moa.spss.slinterface.Constants.WSCP_URL_REWRITER_)).rewrite(
+ response.encodeURL(request.getContextPath() + dataInfo.getHashInputDataURL()), request.getSession().getId()) +
+ "\"");
+
boolean isSLXHTML = dataInfo.getIsSLXHTMLDocument();
if (isSLXHTML) out.write(" target=\"_blank\"");
- out.print(">Datum Nr." + (j + 1) + "</a>");
+ out.print(">Datei Nr." + (j + 1) + "</a>");
out.print("</code></td><td align=\"left\">");
if (isSLXHTML)
{
diff --git a/spss.slinterface/res/resources/properties/init.properties b/spss.slinterface/res/resources/properties/init.properties
index 59724d207..634fff872 100644
--- a/spss.slinterface/res/resources/properties/init.properties
+++ b/spss.slinterface/res/resources/properties/init.properties
@@ -11,4 +11,12 @@ service.sp.endpoint = http://localhost:8080/moa-spss/services/SignatureVerificat
service.sp.trustProfileId = TrustProfile1
result.showetsi = false
-result.showslmanifest = false \ No newline at end of file
+result.showslmanifest = false
+
+rewrite.proxyURL = http://localhost:8080/moa-spss-sl/rewrite
+rewrite.sliUrlParamName = targetURL
+result.sliUrl = http://localhost:8080
+
+
+
+ \ No newline at end of file