diff options
author | gregor <gregor@d688527b-c9ab-4aba-bd8d-4036d912da1d> | 2005-02-02 11:08:33 +0000 |
---|---|---|
committer | gregor <gregor@d688527b-c9ab-4aba-bd8d-4036d912da1d> | 2005-02-02 11:08:33 +0000 |
commit | 9c8ad6efb95fbdfcf9c734b3ecf542b36a031f15 (patch) | |
tree | d17b8fb03676d895d9ee09890f8f6fc1672ef127 /spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/URLRewriter.java | |
parent | 53b50fbb42d20b5ed780f9779bcd934276fa3cf8 (diff) | |
download | moa-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/gv/egovernment/moa/spss/slinterface/URLRewriter.java')
-rw-r--r-- | spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/URLRewriter.java | 44 |
1 files changed, 34 insertions, 10 deletions
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() + |