aboutsummaryrefslogtreecommitdiff
path: root/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/URLRewriter.java
diff options
context:
space:
mode:
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.java44
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() +