diff options
author | gregor <gregor@d688527b-c9ab-4aba-bd8d-4036d912da1d> | 2006-06-26 14:50:59 +0000 |
---|---|---|
committer | gregor <gregor@d688527b-c9ab-4aba-bd8d-4036d912da1d> | 2006-06-26 14:50:59 +0000 |
commit | e06e1534392fadfd84c84fb403be56fa9c852fdb (patch) | |
tree | 8a924d4f5a5080dec1bd4e5d4ab53e0e8f6184f7 | |
parent | a8c6c5e86da29a1e17d73f672b95bf58e8aa6de0 (diff) | |
download | moa-id-spss-e06e1534392fadfd84c84fb403be56fa9c852fdb.tar.gz moa-id-spss-e06e1534392fadfd84c84fb403be56fa9c852fdb.tar.bz2 moa-id-spss-e06e1534392fadfd84c84fb403be56fa9c852fdb.zip |
Verzeichnis verschoben nach /src
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@714 d688527b-c9ab-4aba-bd8d-4036d912da1d
-rw-r--r-- | spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/URLRewriter.java | 143 | ||||
-rw-r--r-- | spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/Constants.java (renamed from spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/Constants.java) | 18 | ||||
-rw-r--r-- | spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/DOMUtils.java (renamed from spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/DOMUtils.java) | 0 | ||||
-rw-r--r-- | spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/URLRewriter.java | 157 | ||||
-rw-r--r-- | spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/Utils.java (renamed from spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/Utils.java) | 0 | ||||
-rw-r--r-- | spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/XPathUtils.java (renamed from spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/XPathUtils.java) | 0 | ||||
-rw-r--r-- | spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/beans/ChecksInfoBean.java (renamed from spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/ChecksInfoBean.java) | 0 | ||||
-rw-r--r-- | spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/beans/DataInfoBean.java (renamed from spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/DataInfoBean.java) | 0 | ||||
-rw-r--r-- | spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/beans/HashInputDataInfo.java (renamed from spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/HashInputDataInfo.java) | 0 | ||||
-rw-r--r-- | spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/beans/InitPropertiesBean.java | 36 | ||||
-rw-r--r-- | spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/beans/SignerInfoBean.java (renamed from spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/SignerInfoBean.java) | 0 | ||||
-rw-r--r-- | spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/filters/RequestWrapper.java (renamed from spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/filters/RequestWrapper.java) | 0 | ||||
-rw-r--r-- | spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/filters/ResponseWrapper.java (renamed from spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/filters/ResponseWrapper.java) | 0 | ||||
-rw-r--r-- | spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/filters/SL2MOAFilter.java (renamed from spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/filters/SL2MOAFilter.java) | 11 | ||||
-rw-r--r-- | spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/filters/ServletInputStream.java (renamed from spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/filters/ServletInputStream.java) | 0 | ||||
-rw-r--r-- | spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/filters/ServletOutputStream.java (renamed from spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/filters/ServletOutputStream.java) | 0 | ||||
-rw-r--r-- | spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/listeners/ContextListener.java (renamed from spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/listeners/ContextListener.java) | 59 | ||||
-rw-r--r-- | spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/listeners/XMLParserErrorHandler.java (renamed from spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/listeners/XMLParserErrorHandler.java) | 0 | ||||
-rw-r--r-- | spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/moainvoker/MOAInvoker.java (renamed from spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/moainvoker/MOAInvoker.java) | 0 | ||||
-rw-r--r-- | spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/servlets/HashInputDataServlet.java (renamed from spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/servlets/HashInputDataServlet.java) | 0 | ||||
-rw-r--r-- | spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/servlets/MOAServlet.java (renamed from spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/servlets/MOAServlet.java) | 0 | ||||
-rw-r--r-- | spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/servlets/ReturnServlet.java (renamed from spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/servlets/ReturnServlet.java) | 4 | ||||
-rw-r--r-- | spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/servlets/SLRequest.java (renamed from spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/servlets/SLRequest.java) | 0 | ||||
-rw-r--r-- | spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/transformers/MOA2SL.java (renamed from spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/transformers/MOA2SL.java) | 0 | ||||
-rw-r--r-- | spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/transformers/QName.java (renamed from spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/transformers/QName.java) | 0 | ||||
-rw-r--r-- | spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/transformers/SL2MOA.java (renamed from spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/transformers/SL2MOA.java) | 0 | ||||
-rw-r--r-- | spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/transformers/Utils.java (renamed from spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/transformers/Utils.java) | 0 | ||||
-rw-r--r-- | spss.slinterface/src/test/at/gv/egovernment/moa/spss/slinterface/DataURLBean.java (renamed from spss.slinterface/WEB-INF/src/test/at/gv/egovernment/moa/spss/slinterface/DataURLBean.java) | 0 | ||||
-rw-r--r-- | spss.slinterface/src/test/at/gv/egovernment/moa/spss/slinterface/DataURLServlet.java (renamed from spss.slinterface/WEB-INF/src/test/at/gv/egovernment/moa/spss/slinterface/DataURLServlet.java) | 0 | ||||
-rw-r--r-- | spss.slinterface/src/test/at/gv/egovernment/moa/spss/slinterface/RewriteServlet.java (renamed from spss.slinterface/WEB-INF/src/test/at/gv/egovernment/moa/spss/slinterface/RewriteServlet.java) | 2 |
30 files changed, 256 insertions, 174 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 deleted file mode 100644 index a47192d69..000000000 --- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/URLRewriter.java +++ /dev/null @@ -1,143 +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_; - - /** - * 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 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) - { - // 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 slInterfaceWebAppServURLStr = initProps_.getProperty(Constants.IP_REW_SLI_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; - } - - 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/Constants.java b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/Constants.java index 3043792fc..419f1fb9b 100644 --- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/Constants.java +++ b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/Constants.java @@ -16,9 +16,9 @@ public class Constants // Init properties - public static final String IP_SL2MOA_STYLESHEET_ = "location.stylesheet.sl2moa"; - - public static final String IP_MOA2SL_STYLESHEET_ = "location.stylesheet.moa2sl"; + // TODO Revisit if constants can be removed + // 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"; public static final String IP_MOA_SCHEMA_ = "location.schema.moa"; public static final String IP_SLXHTML_SCHEMA_ = "location.schema.slxhtml"; @@ -28,12 +28,13 @@ public class Constants public static final String IP_RES_SHOWETSI_ = "result.showetsi"; public static final String IP_RES_SHOWSLMAN_ = "result.showslmanifest"; + public static final String IP_REW_ = "rewrite"; 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_SLI_WEBAPPSERV_URL_ = "rewrite.sliWebAppServUrl"; + public static final String IP_REW_MOASL_URLPARAMNAME_ = "rewrite.MOASLUrlParamName"; + public static final String IP_REW_MOASL_WEBAPPSERV_URL_ = "rewrite.MOASLWebAppServUrl"; // Logging hierarchies @@ -48,8 +49,10 @@ public class Constants // Web service context parameters public static final String WSCP_INIT_PROPS_ = "initProperties"; - public static final String WSCP_SL2MOA_TRANSFORMER_ = "sl2MoaTransformer"; - public static final String WSCP_MOA2SL_TRANSFORMER_ = "moa2SlTransformer"; + public static final String WSCP_INITPROPS_BEAN_ = "initPropertiesBean"; + // TODO Revisit if constants can be removed + // 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"; @@ -65,6 +68,7 @@ public class Constants public static final String NSURI_SL_10_ = "http://www.buergerkarte.at/namespaces/securitylayer/20020225#"; public static final String NSURI_SL_11_ = "http://www.buergerkarte.at/namespaces/securitylayer/20020831#"; + // TODO Change Namespace to final SL 1.2 public static final String NSURI_SL_12_ = "http://www.buergerkarte.at/namespaces/securitylayer/20031231#"; public static final String NSURI_MOA_12_ = "http://reference.e-government.gv.at/namespace/moa/20020822#"; public static final String NSURI_NAMESPACES_ = "http://www.w3.org/2000/xmlns/"; diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/DOMUtils.java b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/DOMUtils.java index 814d7832e..814d7832e 100644 --- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/DOMUtils.java +++ b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/DOMUtils.java 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 new file mode 100644 index 000000000..683851ff9 --- /dev/null +++ b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/URLRewriter.java @@ -0,0 +1,157 @@ +/* + * 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(); + } +} diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/Utils.java b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/Utils.java index 50ae5dc03..50ae5dc03 100644 --- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/Utils.java +++ b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/Utils.java diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/XPathUtils.java b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/XPathUtils.java index 16e4938ed..16e4938ed 100644 --- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/XPathUtils.java +++ b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/XPathUtils.java diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/ChecksInfoBean.java b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/beans/ChecksInfoBean.java index 00c9fd517..00c9fd517 100644 --- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/ChecksInfoBean.java +++ b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/beans/ChecksInfoBean.java diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/DataInfoBean.java b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/beans/DataInfoBean.java index 570f3fb15..570f3fb15 100644 --- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/DataInfoBean.java +++ b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/beans/DataInfoBean.java diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/HashInputDataInfo.java b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/beans/HashInputDataInfo.java index e2cb27ab3..e2cb27ab3 100644 --- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/HashInputDataInfo.java +++ b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/beans/HashInputDataInfo.java diff --git a/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/beans/InitPropertiesBean.java b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/beans/InitPropertiesBean.java new file mode 100644 index 000000000..8cb7e0a41 --- /dev/null +++ b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/beans/InitPropertiesBean.java @@ -0,0 +1,36 @@ +package at.gv.egovernment.moa.spss.slinterface.beans; + +import java.util.Properties; + +import org.apache.log4j.Logger; + +import at.gv.egovernment.moa.spss.slinterface.Constants; + +/** + * @author Gregor Karlinger (mailto:gregor.karlinger@siemens.com) + */ +public class InitPropertiesBean +{ + private Properties initProps_; + + private static Logger logger_ = Logger.getLogger(Constants.LH_BEANS_); + + public InitPropertiesBean(Properties props) + { + initProps_ = props; + } + + public String getMOASLWebAppURL() + { + String webAppServerURLProp = initProps_.getProperty(Constants.IP_REW_MOASL_WEBAPPSERV_URL_); + logger_.debug("MOA SL Web application server URL property: " + webAppServerURLProp); + if (webAppServerURLProp == null || webAppServerURLProp.trim().length() == 0) + { + String defaultWebAppServerURL = "http://localhost:8080"; + logger_.info("MOA SL Web application server URL property not available, using default (" + defaultWebAppServerURL + ")"); + return defaultWebAppServerURL; + } + else return webAppServerURLProp; + + } +} diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/SignerInfoBean.java b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/beans/SignerInfoBean.java index 2893b2ac3..2893b2ac3 100644 --- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/SignerInfoBean.java +++ b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/beans/SignerInfoBean.java diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/filters/RequestWrapper.java b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/filters/RequestWrapper.java index a6652a56e..a6652a56e 100644 --- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/filters/RequestWrapper.java +++ b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/filters/RequestWrapper.java diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/filters/ResponseWrapper.java b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/filters/ResponseWrapper.java index 420723abb..420723abb 100644 --- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/filters/ResponseWrapper.java +++ b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/filters/ResponseWrapper.java diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/filters/SL2MOAFilter.java b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/filters/SL2MOAFilter.java index bcc797532..0ff14551f 100644 --- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/filters/SL2MOAFilter.java +++ b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/filters/SL2MOAFilter.java @@ -9,7 +9,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.CharArrayReader; import java.io.IOException; -import java.io.InputStream; import java.io.Reader; import java.util.Iterator; import java.util.List; @@ -20,17 +19,12 @@ import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.RequestDispatcher; -import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.stream.StreamSource; import org.apache.commons.fileupload.DiskFileUpload; import org.apache.commons.fileupload.FileItem; @@ -202,7 +196,8 @@ public class SL2MOAFilter implements Filter /* ---------------------------------------------------------------------------------------------------- */ - private void initTransformer(ServletContext context, String initPropStylesheetLoc) throws ServletException + // TODO Revisit if method can be removed + /* private void initTransformer(ServletContext context, String initPropStylesheetLoc) throws ServletException { String stylesheetName = (Constants.IP_SL2MOA_STYLESHEET_.equals(initPropStylesheetLoc)) @@ -238,7 +233,7 @@ public class SL2MOAFilter implements Filter throw new ServletException(message, e); } context.setAttribute(contextAttrName, transformer); - } + }*/ /* ---------------------------------------------------------------------------------------------------- */ diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/filters/ServletInputStream.java b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/filters/ServletInputStream.java index b0609c2f8..b0609c2f8 100644 --- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/filters/ServletInputStream.java +++ b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/filters/ServletInputStream.java diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/filters/ServletOutputStream.java b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/filters/ServletOutputStream.java index b790ee55c..b790ee55c 100644 --- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/filters/ServletOutputStream.java +++ b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/filters/ServletOutputStream.java diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/listeners/ContextListener.java b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/listeners/ContextListener.java index b865b2ee4..8b8befb1c 100644 --- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/listeners/ContextListener.java +++ b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/listeners/ContextListener.java @@ -26,6 +26,7 @@ import org.xml.sax.SAXException; import at.gv.egovernment.moa.spss.slinterface.Constants; import at.gv.egovernment.moa.spss.slinterface.URLRewriter; +import at.gv.egovernment.moa.spss.slinterface.beans.InitPropertiesBean; /** * @author Gregor Karlinger (mailto:gregor.karlinger@cio.gv.at) @@ -45,7 +46,9 @@ public class ContextListener implements ServletContextListener "http://apache.org/xml/features/dom/create-entity-ref-nodes"; protected static final String XERCES_DEFER_NODE_EXPANSION_ = "http://apache.org/xml/features/dom/defer-node-expansion"; - + protected static final String XERCES_AUGMENT_PSI_ = + "http://apache.org/xml/features/validation/schema/augment-psvi"; + private static final int BIG_PRIME = 2039; private static Logger logger_ = Logger.getLogger(Constants.LH_LISTENERS_); @@ -54,6 +57,7 @@ public class ContextListener implements ServletContextListener /** * Initializes the web application. + * @throws Exception * * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent) */ @@ -66,7 +70,8 @@ public class ContextListener implements ServletContextListener String initPropsLoc = System.getProperty(Constants.SP_INIT_PROPS_LOC_); if (initPropsLoc == null) { - logger_.error("System property \"" + Constants.SP_INIT_PROPS_LOC_ + "\" not set."); + logger_.fatal("System property \"" + Constants.SP_INIT_PROPS_LOC_ + "\" not set."); + logger_.fatal("Web application initialization failed."); return; } @@ -87,12 +92,18 @@ public class ContextListener implements ServletContextListener Properties initProps = new Properties(); initProps.load(initPropsIS); context.setAttribute(Constants.WSCP_INIT_PROPS_, initProps); + + // Prepare application bean knowing about init properties + InitPropertiesBean initPropsBean = new InitPropertiesBean(initProps); + context.setAttribute(Constants.WSCP_INITPROPS_BEAN_, initPropsBean); } catch (IOException e) { - logger_.error("Cannot load initialization properties from location \"" + initPropsLoc + "\".", e); + logger_.fatal("Cannot load initialization properties from location \"" + initPropsLoc + "\".", e); + logger_.fatal("Web application initialization failed."); + return; } - + // 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); @@ -111,15 +122,28 @@ public class ContextListener implements ServletContextListener // Schema for Security-Layer 1.2 alpha (including LocRefContent) Properties initProps = (Properties) context.getAttribute(Constants.WSCP_INIT_PROPS_); String slSchemaLoc = initProps.getProperty(Constants.IP_SL_SCHEMA_); - preparseSchema(context, preparser, slSchemaLoc); + if (!preparseSchema(context, preparser, slSchemaLoc)) + { + logger_.fatal("Web application initialization failed."); + return; + } // Schema for MOA 1.2 String moaSchemaLoc = initProps.getProperty(Constants.IP_MOA_SCHEMA_); - preparseSchema(context, preparser, moaSchemaLoc); + if (!preparseSchema(context, preparser, moaSchemaLoc)) + { + logger_.fatal("Web application initialization failed."); + return; + } // Schema for SLXHTML 1.0 String slxhtmlSchemaLoc = initProps.getProperty(Constants.IP_SLXHTML_SCHEMA_); - preparseSchema(context, preparser, slxhtmlSchemaLoc); + if (!preparseSchema(context, preparser, slxhtmlSchemaLoc)) + { + logger_.fatal("Web application initialization failed."); + return; + } + // TODO parser is not threadsafe DOMParser xmlParser = new DOMParser(symbolTable, grammarPool); @@ -132,16 +156,20 @@ public class ContextListener implements ServletContextListener xmlParser.setFeature(XERCES_INCLUDE_IGNORABLE_WHITESPACE_FEATURE, true); xmlParser.setFeature(XERCES_CREATE_ENTITY_REF_NODES_FEATURE, false); xmlParser.setFeature(XERCES_DEFER_NODE_EXPANSION_, true); - xmlParser.setFeature("http://apache.org/xml/features/validation/schema/augment-psvi", false); // TODO Stringkonstante + xmlParser.setFeature(XERCES_AUGMENT_PSI_, false); xmlParser.setErrorHandler(new XMLParserErrorHandler(false, true, true)); - } catch (SAXException e) { String message = "Initialization of XML parser failed."; - logger_.error(message, e); + logger_.fatal(message, e); + logger_.fatal("Web application initialization failed."); + return; } context.setAttribute(Constants.WSCP_XMLPARSER_, xmlParser); + + String message = "Web application initialization succeeded."; + logger_.info(message); } /* ---------------------------------------------------------------------------------------------------- */ @@ -160,13 +188,14 @@ public class ContextListener implements ServletContextListener /* ---------------------------------------------------------------------------------------------------- */ - private void preparseSchema(ServletContext context, XMLGrammarPreparser preparser, String schemaLoc) + private boolean preparseSchema(ServletContext context, XMLGrammarPreparser preparser, String schemaLoc) { InputStream schemaIS = context.getResourceAsStream(schemaLoc); if (schemaIS == null) { String message = "Cannot load schema from location \"" + schemaLoc + "\"."; - logger_.error(message); + logger_.fatal(message); + return false; } try { @@ -177,9 +206,9 @@ public class ContextListener implements ServletContextListener catch (Exception e) { String message = "Parsing schema loaded from location \"" + schemaLoc + "\" failed."; - logger_.error(message, e); + logger_.fatal(message, e); + return false; } + return true; } - - } diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/listeners/XMLParserErrorHandler.java b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/listeners/XMLParserErrorHandler.java index 496d0aadb..496d0aadb 100644 --- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/listeners/XMLParserErrorHandler.java +++ b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/listeners/XMLParserErrorHandler.java diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/moainvoker/MOAInvoker.java b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/moainvoker/MOAInvoker.java index e89d255f0..e89d255f0 100644 --- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/moainvoker/MOAInvoker.java +++ b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/moainvoker/MOAInvoker.java diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/servlets/HashInputDataServlet.java b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/servlets/HashInputDataServlet.java index f7cfb7e6c..f7cfb7e6c 100644 --- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/servlets/HashInputDataServlet.java +++ b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/servlets/HashInputDataServlet.java diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/servlets/MOAServlet.java b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/servlets/MOAServlet.java index 362793064..362793064 100644 --- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/servlets/MOAServlet.java +++ b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/servlets/MOAServlet.java diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/servlets/ReturnServlet.java b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/servlets/ReturnServlet.java index 052c51f94..84ce26be0 100644 --- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/servlets/ReturnServlet.java +++ b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/servlets/ReturnServlet.java @@ -72,6 +72,8 @@ public class ReturnServlet extends HttpServlet URLConnection dataURLConn; try { + // TODO Does not conform to SL/Bindings/sec. 3.3.2.2 + // Open connection to DataURL URL dataURL = new URL(slRequest.dataUrl_); dataURLConn = dataURL.openConnection(); @@ -97,6 +99,8 @@ public class ReturnServlet extends HttpServlet private void forwardResponse(URLConnection dataURLConn, ServletResponse response) throws ServletException { + // TODO Does not conform to SL/Bindings/sec. 3.3.2.1 + // Make sure that content type of DataURL response is text/html String dataURLContentType = dataURLConn.getContentType(); if (dataURLContentType == null || !dataURLContentType.startsWith("text/html")) diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/servlets/SLRequest.java b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/servlets/SLRequest.java index 3c19d5ff6..3c19d5ff6 100644 --- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/servlets/SLRequest.java +++ b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/servlets/SLRequest.java diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/transformers/MOA2SL.java b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/transformers/MOA2SL.java index 2e82d4d32..2e82d4d32 100644 --- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/transformers/MOA2SL.java +++ b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/transformers/MOA2SL.java diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/transformers/QName.java b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/transformers/QName.java index 6da0c433f..6da0c433f 100644 --- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/transformers/QName.java +++ b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/transformers/QName.java diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/transformers/SL2MOA.java b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/transformers/SL2MOA.java index 6c476e9ce..6c476e9ce 100644 --- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/transformers/SL2MOA.java +++ b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/transformers/SL2MOA.java diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/transformers/Utils.java b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/transformers/Utils.java index d03895efe..d03895efe 100644 --- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/transformers/Utils.java +++ b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/transformers/Utils.java diff --git a/spss.slinterface/WEB-INF/src/test/at/gv/egovernment/moa/spss/slinterface/DataURLBean.java b/spss.slinterface/src/test/at/gv/egovernment/moa/spss/slinterface/DataURLBean.java index 4cf099a45..4cf099a45 100644 --- a/spss.slinterface/WEB-INF/src/test/at/gv/egovernment/moa/spss/slinterface/DataURLBean.java +++ b/spss.slinterface/src/test/at/gv/egovernment/moa/spss/slinterface/DataURLBean.java diff --git a/spss.slinterface/WEB-INF/src/test/at/gv/egovernment/moa/spss/slinterface/DataURLServlet.java b/spss.slinterface/src/test/at/gv/egovernment/moa/spss/slinterface/DataURLServlet.java index ff4cbbe59..ff4cbbe59 100644 --- a/spss.slinterface/WEB-INF/src/test/at/gv/egovernment/moa/spss/slinterface/DataURLServlet.java +++ b/spss.slinterface/src/test/at/gv/egovernment/moa/spss/slinterface/DataURLServlet.java diff --git a/spss.slinterface/WEB-INF/src/test/at/gv/egovernment/moa/spss/slinterface/RewriteServlet.java b/spss.slinterface/src/test/at/gv/egovernment/moa/spss/slinterface/RewriteServlet.java index 46b1f793d..43685d4f4 100644 --- a/spss.slinterface/WEB-INF/src/test/at/gv/egovernment/moa/spss/slinterface/RewriteServlet.java +++ b/spss.slinterface/src/test/at/gv/egovernment/moa/spss/slinterface/RewriteServlet.java @@ -45,7 +45,7 @@ public class RewriteServlet extends HttpServlet Properties initProps = (Properties) this.getServletContext().getAttribute(Constants.WSCP_INIT_PROPS_); String paramName = (initProps != null) - ? initProps.getProperty(Constants.IP_REW_SLI_URLPARAMNAME_) + ? initProps.getProperty(Constants.IP_REW_MOASL_URLPARAMNAME_) : null; if (paramName == null || "".equals(paramName)) |