aboutsummaryrefslogtreecommitdiff
path: root/spss.slinterface/WEB-INF/src/at
diff options
context:
space:
mode:
authorgregor <gregor@d688527b-c9ab-4aba-bd8d-4036d912da1d>2005-02-02 11:08:33 +0000
committergregor <gregor@d688527b-c9ab-4aba-bd8d-4036d912da1d>2005-02-02 11:08:33 +0000
commit9c8ad6efb95fbdfcf9c734b3ecf542b36a031f15 (patch)
treed17b8fb03676d895d9ee09890f8f6fc1672ef127 /spss.slinterface/WEB-INF/src/at
parent53b50fbb42d20b5ed780f9779bcd934276fa3cf8 (diff)
downloadmoa-id-spss-9c8ad6efb95fbdfcf9c734b3ecf542b36a031f15.tar.gz
moa-id-spss-9c8ad6efb95fbdfcf9c734b3ecf542b36a031f15.tar.bz2
moa-id-spss-9c8ad6efb95fbdfcf9c734b3ecf542b36a031f15.zip
Anpassung an neue Systemlandschaft im BKA: Dynamische Kodierung des Proxy-Hosts beim URL-Rewriting (Abfrage von Remote-Adresse aus dem Request)
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@269 d688527b-c9ab-4aba-bd8d-4036d912da1d
Diffstat (limited to 'spss.slinterface/WEB-INF/src/at')
-rw-r--r--spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/Constants.java9
-rw-r--r--spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/URLRewriter.java44
-rw-r--r--spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/DataInfoBean.java11
-rw-r--r--spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/filters/SL2MOAFilter.java5
4 files changed, 51 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 6e3a7c1b7..b35faa6d9 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
@@ -15,6 +15,7 @@ public class Constants
"at.gv.egovernment.moa.spss.slinterface.PropertiesLocation";
// Init properties
+
public static final String IP_SL2MOA_STYLESHEET_ = "location.stylesheet.sl2moa";
public static final String IP_MOA2SL_STYLESHEET_ = "location.stylesheet.moa2sl";
public static final String IP_SL_SCHEMA_ = "location.schema.sl";
@@ -25,9 +26,13 @@ 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_PROXYURL_ = "rewrite.proxyURL";
+ public static final String IP_REW_PROXYURL_HOSTDUMMY_ = "rewrite.proxyURL.proxyhostDummy";
+ public static final String IP_REW_DNS_LOOKUP_PREFIX_ = "rewrite.dn.";
+ public static final String IP_REW_DNS_LOOKUP_DEFAULT_ = "rewrite.dn.default";
public static final String IP_REW_SLI_URLPARAMNAME_ = "rewrite.sliUrlParamName";
- public static final String IP_REW_SLIRUL_ = "result.sliUrl";
+ public static final String IP_REW_SLI_WEBAPPSERV_URL_ = "rewrite.sliWebAppServUrl";
// Logging hierarchies
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
index e1b8e77e5..a47192d69 100644
--- 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
@@ -9,6 +9,8 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;
+import javax.servlet.http.HttpSession;
+
import org.apache.log4j.Logger;
/**
@@ -32,40 +34,61 @@ public class URLRewriter
/**
* Rewrites the specified URL.
*
- * @param url A URL relative to the context path of the serlet.
+ * @param url A URL relative to the root of the web application server containing MOA SL.
*
- * @param sessionId The session id which will be considered in the rewritten URL.
+ * @param session The session 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)
+ public String rewrite(String url, HttpSession session)
{
- String proxyURLStr = initProps_.getProperty(Constants.IP_REW_PROXYRUL_);
+ // Get remote IP address and resolve to remote to remote domain name
+ String remoteAddr = (String)session.getAttribute("remoteAddr");
+ String remoteName = null;
+ if (remoteAddr != null)
+ {
+ remoteName = initProps_.getProperty(Constants.IP_REW_DNS_LOOKUP_PREFIX_ + remoteAddr);
+ logger_.debug("Remote address lookup succeeded for IP " + remoteAddr + ", using " + remoteName);
+ }
+ if (remoteName == null)
+ {
+ remoteName = initProps_.getProperty(Constants.IP_REW_DNS_LOOKUP_DEFAULT_);
+ logger_.debug("Remote address lookup failed for IP " + remoteAddr + ", using default: " + remoteName);
+ }
+
+ // Get proxy URL and replace proxy URL hostname placeholder with remote domain name
+ String proxyURLStr = initProps_.getProperty(Constants.IP_REW_PROXYURL_);
+ int pHStartIndex = proxyURLStr.indexOf(initProps_.getProperty(Constants.IP_REW_PROXYURL_HOSTDUMMY_));
+ proxyURLStr = proxyURLStr.substring(0, pHStartIndex)
+ + remoteName
+ + proxyURLStr.substring(pHStartIndex
+ + initProps_.getProperty(Constants.IP_REW_PROXYURL_HOSTDUMMY_).length());
+
String slInterfaceURLParamName = initProps_.getProperty(Constants.IP_REW_SLI_URLPARAMNAME_);
- String slInterfaceURLStr = initProps_.getProperty(Constants.IP_REW_SLIRUL_);
+ String slInterfaceWebAppServURLStr = initProps_.getProperty(Constants.IP_REW_SLI_WEBAPPSERV_URL_);
if (proxyURLStr == null ||
slInterfaceURLParamName == null ||
- slInterfaceURLStr == null ||
+ slInterfaceWebAppServURLStr == null ||
"".equals(proxyURLStr.trim()) ||
"".equals(slInterfaceURLParamName.trim()) ||
- "".equals(slInterfaceURLStr.trim()))
+ "".equals(slInterfaceWebAppServURLStr.trim()))
{
logger_.warn("Some params for URL rewriting are not available; rewriting disabled:" +
" proxyURL: \"" + proxyURLStr + "\"," +
" slInterfaceURLParamName: \"" + slInterfaceURLParamName + "\"," +
- " slInterfaceURL: \"" + slInterfaceURLStr + "\"");
+ " slInterfaceWebAppServURLStr: \"" + slInterfaceWebAppServURLStr + "\"");
return url;
}
URL slInterfaceURL = null;
try
{
- slInterfaceURL = new URL(slInterfaceURLStr + url);
+ slInterfaceURL = new URL(slInterfaceWebAppServURLStr + url);
}
catch (MalformedURLException e)
{
- logger_.warn("Parameter \"slInterfaceURL\" is not a valid URL: \"" + slInterfaceURLStr + "\"");
+ logger_.warn("Parameter \"slInterfaceURL\" is not a valid URL: \"" + slInterfaceWebAppServURLStr + url + "\"");
return url;
}
URL proxyURL = null;
@@ -79,6 +102,7 @@ public class URLRewriter
return url;
}
+ String sessionId = session.getId();
String sessionIdParam = (sessionId != null) ? (";" + "jsessionid=" + sessionId) : "";
String returnValue =
proxyURL.getProtocol() +
diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/DataInfoBean.java b/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/DataInfoBean.java
index 76b06605b..3b58a8327 100644
--- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/DataInfoBean.java
+++ b/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/DataInfoBean.java
@@ -25,6 +25,7 @@ import java.util.Set;
import java.util.StringTokenizer;
import javax.servlet.ServletContext;
+import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener;
@@ -81,7 +82,7 @@ public class DataInfoBean implements HttpSessionBindingListener
ServletContext context_;
String contextPath_;
- String sessionId_;
+ HttpSession session_;
Properties initProps_;
@@ -94,12 +95,12 @@ public class DataInfoBean implements HttpSessionBindingListener
/* ---------------------------------------------------------------------------------------------------- */
- public DataInfoBean(Document moaRequestDoc, Document moaResponseDoc, String contextPath, String sessionId,
+ public DataInfoBean(Document moaRequestDoc, Document moaResponseDoc, String contextPath, HttpSession session,
ServletContext context) throws Exception
{
context_ = context;
contextPath_ = contextPath;
- sessionId_ = sessionId;
+ session_ = session;
initProps_ = (Properties) context_.getAttribute(Constants.WSCP_INIT_PROPS_);
hashInputDataInfos_ = new ArrayList();
@@ -120,7 +121,7 @@ public class DataInfoBean implements HttpSessionBindingListener
for (int i = 0; i < hidElems.size(); i++)
{
// Open file for current hash input data
- String currHidFileNameStr = tempDir + sessionId_ + "_" + System.currentTimeMillis() + "_" +
+ String currHidFileNameStr = tempDir + session_.getId() + "_" + System.currentTimeMillis() + "_" +
random.nextLong();
currHidFileNameStr = context_.getRealPath(currHidFileNameStr);
FileOutputStream currHidFOS;
@@ -335,7 +336,7 @@ public class DataInfoBean implements HttpSessionBindingListener
String tempDir = initProps.getProperty(Constants.IP_TEMP_DIR_);
URLRewriter urlRewriter = (URLRewriter) context_.getAttribute(Constants.WSCP_URL_REWRITER_);
String newSrcAttrValue = urlRewriter.rewrite(
- contextPath_ + tempDir + currHidi.filename_.substring(slashPos + 1), sessionId_);
+ contextPath_ + tempDir + currHidi.filename_.substring(slashPos + 1), session_);
srcAttr.setNodeValue(newSrcAttrValue);
}
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 28ceb7ac6..084633728 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
@@ -87,6 +87,9 @@ public class SL2MOAFilter implements Filter
// Check if request is HTTP-POST
checkHttpPost((HttpServletRequest) request);
+ // Remember remote IP address for later URL rewriting
+ session.setAttribute("remoteAddr", request.getRemoteAddr());
+
// Get SL request from content of request
SLRequest slRequest = parseRequest((HttpServletRequest) request);
session.setAttribute("slRequest", slRequest);
@@ -138,7 +141,7 @@ public class SL2MOAFilter implements Filter
moaXMLRequestDoc,
moaResponseDoc,
((HttpServletRequest) request).getContextPath(),
- session.getId(),
+ session,
config_.getServletContext());
session.setAttribute("dataInfo", dataInfo);
}