diff options
author | Thomas <> | 2023-11-22 16:01:38 +0100 |
---|---|---|
committer | Thomas <> | 2023-11-22 16:01:38 +0100 |
commit | e139d108925c6c5bdd8eaf6aab09f4275b7c2171 (patch) | |
tree | 05d42b3877e387694af89756975d510d4f8271a4 /pdf-as-web/src/main/java/at | |
parent | dd3da582f803f21abd4480413f2d288a22f102c5 (diff) | |
download | pdf-as-4-e139d108925c6c5bdd8eaf6aab09f4275b7c2171.tar.gz pdf-as-4-e139d108925c6c5bdd8eaf6aab09f4275b7c2171.tar.bz2 pdf-as-4-e139d108925c6c5bdd8eaf6aab09f4275b7c2171.zip |
feat(web): add configuration parameter to use different domain for DataURL communication
Diffstat (limited to 'pdf-as-web/src/main/java/at')
-rw-r--r-- | pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java | 5 | ||||
-rw-r--r-- | pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java | 56 |
2 files changed, 38 insertions, 23 deletions
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java index 1fffb17d..81b60131 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java @@ -39,6 +39,7 @@ import at.gv.egiz.pdfas.web.helper.PdfAsHelper; public class WebConfiguration implements IConfigurationConstants { public static final String PUBLIC_URL = "public.url"; + public static final String PUBLIC_DATA_URL = "public.data.url"; public static final String LOCAL_BKU_ENABLED = "bku.sign.enabled"; public static final String ONLINE_BKU_ENABLED = "moc.sign.enabled"; public static final String MOBILE_BKU_ENABLED = "mobile.sign.enabled"; @@ -226,6 +227,10 @@ public class WebConfiguration implements IConfigurationConstants { return properties.getProperty(PUBLIC_URL); } + public static String getPublicDataURL() { + return properties.getProperty(PUBLIC_DATA_URL); + } + public static String getLocalBKUURL() { if(getLocalBKUEnabled()) { String overwrite = properties.getProperty(CONFIG_BKU_URL); diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java index 8b98a322..9900dda4 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java @@ -1363,29 +1363,35 @@ public class PdfAsHelper { private static String generateURL(HttpServletRequest request, HttpServletResponse response, String Servlet) { - HttpSession session = request.getSession(); - String publicURL = WebConfiguration.getPublicURL(); - String dataURL = null; - if (publicURL != null) { - dataURL = publicURL + Servlet + ";jsessionid=" + session.getId(); - } else { - if ((request.getScheme().equals("http") && request.getServerPort() == 80) - || (request.getScheme().equals("https") && request - .getServerPort() == 443)) { - dataURL = request.getScheme() + "://" + request.getServerName() - + request.getContextPath() + Servlet + ";jsessionid=" - + session.getId(); - } else { - dataURL = request.getScheme() + "://" + request.getServerName() - + ":" + request.getServerPort() - + request.getContextPath() + Servlet + ";jsessionid=" - + session.getId(); - } - } - log.debug("Generated URL: " + dataURL); - return dataURL; + return generateURL(request, response, Servlet, WebConfiguration.getPublicURL()); + } + private static String generateURL(HttpServletRequest request, + HttpServletResponse response, String Servlet, String publicURL) { + HttpSession session = request.getSession(); + String dataURL = null; + if (publicURL != null) { + dataURL = publicURL + Servlet + ";jsessionid=" + session.getId(); + } else { + if ((request.getScheme().equals("http") && request.getServerPort() == 80) + || (request.getScheme().equals("https") && request + .getServerPort() == 443)) { + dataURL = request.getScheme() + "://" + request.getServerName() + + request.getContextPath() + Servlet + ";jsessionid=" + + session.getId(); + } else { + dataURL = request.getScheme() + "://" + request.getServerName() + + ":" + request.getServerPort() + + request.getContextPath() + Servlet + ";jsessionid=" + + session.getId(); + } + } + log.debug("Generated URL: " + dataURL); + return dataURL; + } + + public static void regenerateSession(HttpServletRequest request) { request.getSession(false).invalidate(); request.getSession(true); @@ -1393,12 +1399,16 @@ public class PdfAsHelper { public static String generateDataURLSL20(HttpServletRequest request, HttpServletResponse response) { - return generateURL(request, response, PDF_SL20_DATAURL_PAGE); + return generateURL(request, response, PDF_SL20_DATAURL_PAGE, + WebConfiguration.getPublicDataURL() != null + ? WebConfiguration.getPublicDataURL() : WebConfiguration.getPublicURL()); } public static String generateDataURL(HttpServletRequest request, HttpServletResponse response) { - return generateURL(request, response, PDF_DATAURL_PAGE); + return generateURL(request, response, PDF_DATAURL_PAGE, + WebConfiguration.getPublicDataURL() != null + ? WebConfiguration.getPublicDataURL() : WebConfiguration.getPublicURL()); } public static String generateProvideURL(HttpServletRequest request, |