aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-web
diff options
context:
space:
mode:
authorAlexander Marsalek <amarsalek@iaik.tugraz.at>2021-04-15 17:45:47 +0200
committerAlexander Marsalek <amarsalek@iaik.tugraz.at>2021-04-15 17:45:47 +0200
commitf3c42b0079b7fe9a671d84bdb363b9f0fddcb804 (patch)
treef133053d90c29b7c04f6ee17a230ede5d3f68ba6 /pdf-as-web
parentd7d12cd83d1610b118a336024b260e11b7c83d98 (diff)
downloadpdf-as-4-f3c42b0079b7fe9a671d84bdb363b9f0fddcb804.tar.gz
pdf-as-4-f3c42b0079b7fe9a671d84bdb363b9f0fddcb804.tar.bz2
pdf-as-4-f3c42b0079b7fe9a671d84bdb363b9f0fddcb804.zip
untested JSON interface
Diffstat (limited to 'pdf-as-web')
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/JSONAPIServlet.java18
1 files changed, 14 insertions, 4 deletions
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 4925ec65..6a56c9dc 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
@@ -15,6 +15,7 @@ import at.gv.egiz.pdfas.web.stats.StatisticEvent;
import at.gv.egiz.pdfas.web.stats.StatisticFrontend;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
+import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -24,6 +25,7 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -43,7 +45,7 @@ public class JSONAPIServlet extends HttpServlet {
private static final String JSON_DATAURL = "dataUrl";
private static final String JSON_BKUURL = "bkuUrl";
private static final String JSON_SLREQUEST = "slRequest";
-
+ private static final String JSON_SBP = "sbp";
private static final Logger logger = LoggerFactory.getLogger(JSONAPIServlet.class);
@Override
@@ -133,15 +135,23 @@ public class JSONAPIServlet extends HttpServlet {
parameters.setPosition(position);
parameters.setProfile(profile);
- //TODO alex fill here
- Map<String, String> dynamicSignatureBlockArguments = null;
+ Map<String, String> signatureBlockParametersMap = new HashMap<>();
+ JSONArray jsonArray = jsonObject.getJSONArray(JSON_SBP);
+ for(int i=0; i<jsonArray.length();i++){
+ String s = jsonArray.getString(0);
+ if(!s.contains("=")) {//TODO or pass as map?
+ throw new Exception("Invalid parameter: "+s);
+ }
+ String[] values = s.split("=", 2);
+ signatureBlockParametersMap.put(values[0], values[1]);
+ }
if (PDFASSignParameters.Connector.MOA.equals(connectorEnum)
|| PDFASSignParameters.Connector.JKS.equals(connectorEnum)) {
// Plain server based signatures!!
PDFASSignResponse pdfasSignResponse = PdfAsHelper.synchronousServerSignature(
- inputDocument, parameters, dynamicSignatureBlockArguments);
+ inputDocument, parameters, signatureBlockParametersMap);
VerifyResult verifyResult = null;