diff options
author | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2016-06-27 16:06:53 +0200 |
---|---|---|
committer | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2016-06-27 16:06:53 +0200 |
commit | 9440e26621193d138ebe26b32405b33d41b7c7ab (patch) | |
tree | a5e0001d80c6d2e9f82837fe334c222d11e7e6d3 /pdf-as-web/src/main/java/at/gv/egiz/pdfas/web | |
parent | 06cf27605579abab9d18615d1fef701b941e06f6 (diff) | |
download | pdf-as-4-9440e26621193d138ebe26b32405b33d41b7c7ab.tar.gz pdf-as-4-9440e26621193d138ebe26b32405b33d41b7c7ab.tar.bz2 pdf-as-4-9440e26621193d138ebe26b32405b33d41b7c7ab.zip |
added configuration entry for json API
Diffstat (limited to 'pdf-as-web/src/main/java/at/gv/egiz/pdfas/web')
-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); |