diff options
author | pdanner <pdanner@d688527b-c9ab-4aba-bd8d-4036d912da1d> | 2007-09-05 10:02:19 +0000 |
---|---|---|
committer | pdanner <pdanner@d688527b-c9ab-4aba-bd8d-4036d912da1d> | 2007-09-05 10:02:19 +0000 |
commit | 4075bf26b65cf2be4c55f2e9cbdc1b854a41dbce (patch) | |
tree | ce47b59636e31eb8aa64f075773cbef88c9324f3 /spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/URLRewriter.java | |
parent | 31d5acacc9c22f45251827b38ad689cdeb705efc (diff) | |
download | moa-id-spss-4075bf26b65cf2be4c55f2e9cbdc1b854a41dbce.tar.gz moa-id-spss-4075bf26b65cf2be4c55f2e9cbdc1b854a41dbce.tar.bz2 moa-id-spss-4075bf26b65cf2be4c55f2e9cbdc1b854a41dbce.zip |
removed obsolete files
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@990 d688527b-c9ab-4aba-bd8d-4036d912da1d
Diffstat (limited to 'spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/URLRewriter.java')
-rw-r--r-- | spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/URLRewriter.java | 157 |
1 files changed, 0 insertions, 157 deletions
diff --git a/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/URLRewriter.java b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/URLRewriter.java deleted file mode 100644 index 683851ff9..000000000 --- a/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/URLRewriter.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * 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 javax.servlet.http.HttpSession; - -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_; - - /** - * Flag indicating whether rewriting should take place or not. - */ - boolean doRewrite_; - - /** - * 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; - doRewrite_ = Boolean.valueOf(initProps_.getProperty(Constants.IP_REW_)).booleanValue(); - } - - /** - * Rewrites the specified URL. - * - * @param url A URL relative to the root of the web application server containing MOA SL. - * - * @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, HttpSession session) - { - if (doRewrite_) - { - // 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_MOASL_URLPARAMNAME_); - String slInterfaceWebAppServURLStr = initProps_.getProperty(Constants.IP_REW_MOASL_WEBAPPSERV_URL_); - - if (proxyURLStr == null || - slInterfaceURLParamName == null || - slInterfaceWebAppServURLStr == null || - "".equals(proxyURLStr.trim()) || - "".equals(slInterfaceURLParamName.trim()) || - "".equals(slInterfaceWebAppServURLStr.trim())) - { - logger_.warn("Some params for URL rewriting are not available; rewriting disabled:" + - " proxyURL: \"" + proxyURLStr + "\"," + - " slInterfaceURLParamName: \"" + slInterfaceURLParamName + "\"," + - " slInterfaceWebAppServURLStr: \"" + slInterfaceWebAppServURLStr + "\""); - return url; - } - - URL slInterfaceURL = null; - try - { - slInterfaceURL = new URL(slInterfaceWebAppServURLStr + url); - } - catch (MalformedURLException e) - { - logger_.warn("Parameter \"slInterfaceURL\" is not a valid URL: \"" + slInterfaceWebAppServURLStr + url + "\""); - 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 sessionId = session.getId(); - 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; - } - else - { - logger_.debug("URL rewriting disabled via configuration. URL \"" + url + "\" remains unchanged."); - return url; - } - } - - 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(); - } -} |