diff options
Diffstat (limited to 'pdf-as-web/src/main/java/at/gv')
-rw-r--r-- | pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java | 11 | ||||
-rw-r--r-- | pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/JSONAPIServlet.java | 5 |
2 files changed, 16 insertions, 0 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 7fbed8d9..6c3b4a76 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 @@ -58,6 +58,7 @@ public class WebConfiguration implements IConfigurationConstants { public static final String RELOAD_PASSWORD = "reload.pwd"; public static final String RELOAD_ENABLED = "reload.enabled"; public static final String KEEP_SIGNED_DOCUMENT = "keep.signed"; + public static final String JSON_API_ENABLED = "json.enabled"; public static final String MOA_LIST = "moal"; public static final String MOA_URL = "url"; @@ -301,6 +302,16 @@ public class WebConfiguration implements IConfigurationConstants { return false; } + public static boolean isJSONAPIEnabled() { + String value = properties.getProperty(JSON_API_ENABLED); + if (value != null) { + if (value.equals("true")) { + return true; + } + } + return false; + } + public static boolean isKeepSignedDocument() { String value = properties.getProperty(KEEP_SIGNED_DOCUMENT); if (value != null) { diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/JSONAPIServlet.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/JSONAPIServlet.java index 1b9b4560..67b242d0 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/JSONAPIServlet.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/JSONAPIServlet.java @@ -56,6 +56,11 @@ public class JSONAPIServlet extends HttpServlet { protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + if(!WebConfiguration.isJSONAPIEnabled()) { + logger.info("Access to JSON API, but JSON API is disabled. Returning 404 error."); + resp.sendError(404); + } + String jsonString = IOUtils.toString(req.getInputStream(), "UTF-8"); logger.debug("Reading json String {}", jsonString); |