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/gv/egiz/pdfas/web/helper | |
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/gv/egiz/pdfas/web/helper')
-rw-r--r-- | pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java | 56 |
1 files changed, 33 insertions, 23 deletions
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, |