aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-web
diff options
context:
space:
mode:
authorAlexander Marsalek <amarsalek@iaik.tugraz.at>2021-04-12 15:58:14 +0200
committerAlexander Marsalek <amarsalek@iaik.tugraz.at>2021-04-12 15:58:14 +0200
commitc0f97e7b1ad5b6256eb935aeab06d159d68d1966 (patch)
treee014d891f58b87a5ca7dbb5c63e6334d9385c266 /pdf-as-web
parentbc6073700024e4b3c95bcf5bf3e48efb6edd14ab (diff)
downloadpdf-as-4-c0f97e7b1ad5b6256eb935aeab06d159d68d1966.tar.gz
pdf-as-4-c0f97e7b1ad5b6256eb935aeab06d159d68d1966.tar.bz2
pdf-as-4-c0f97e7b1ad5b6256eb935aeab06d159d68d1966.zip
pdf-as-web signature block parameter handling
Diffstat (limited to 'pdf-as-web')
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java17
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java19
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/JSONAPIServlet.java14
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/UIEntryPointServlet.java4
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASSigningImpl.java4
5 files changed, 35 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 11ee4790..0e08de59 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
@@ -364,11 +364,13 @@ public class PdfAsHelper {
* The Web response
* @param pdfData
* The pdf data
+ * @param dynamicSignatureBlockArguments
* @return The signed pdf data
* @throws Exception
*/
- public static byte[] synchornousSignature(HttpServletRequest request,
- HttpServletResponse response, byte[] pdfData) throws Exception {
+ public static byte[] synchronousSignature(HttpServletRequest request,
+ HttpServletResponse response, byte[] pdfData,
+ Map<String, String> dynamicSignatureBlockArguments) throws Exception {
validatePdfSize(request, response, pdfData);
Configuration config = pdfAs.getConfiguration();
@@ -506,6 +508,8 @@ public class PdfAsHelper {
// set Signature Position
signParameter.setSignaturePosition(buildPosString(request, response));
+ //set signature block parameters
+ signParameter.getDynamicSignatureBlockArguments().putAll(dynamicSignatureBlockArguments);
@SuppressWarnings("unused")
SignResult result = pdfAs.sign(signParameter);
@@ -522,8 +526,8 @@ public class PdfAsHelper {
* @return The signed pdf data
* @throws Exception
*/
- public static PDFASSignResponse synchornousServerSignature(byte[] pdfData,
- PDFASSignParameters params) throws Exception {
+ public static PDFASSignResponse synchronousServerSignature(byte[] pdfData,
+ PDFASSignParameters params, Map<String, String> dynamicSignatureBlockArguments) throws Exception {
Configuration config = pdfAs.getConfiguration();
if (WebConfiguration.isAllowExtOverwrite() && params.getOverrides() != null) {
@@ -658,6 +662,8 @@ public class PdfAsHelper {
signParameter.setPreprocessorArguments(params.getPreprocessor()
.getMap());
}
+ //TODO alex
+ signParameter.getDynamicSignatureBlockArguments().putAll(dynamicSignatureBlockArguments);
SignResult signResult = pdfAs.sign(signParameter);
@@ -771,7 +777,7 @@ public class PdfAsHelper {
HttpServletResponse response, ServletContext context,
byte[] pdfData, String connector, String position,
String transactionId, String profile,
- Map<String, String> preProcessor, Map<String, String> overwrite) throws Exception {
+ Map<String, String> preProcessor, Map<String, String> overwrite, Map<String, String> dynamicSignatureBlockArguments) throws Exception {
// TODO: Protect session so that only one PDF can be signed during one
// session
@@ -856,6 +862,7 @@ public class PdfAsHelper {
// set Signature Position
signParameter.setSignaturePosition(position);
+ signParameter.setDynamicSignatureBlockArguments(dynamicSignatureBlockArguments);
StatusRequest statusRequest = pdfAs.startSign(signParameter);
session.setAttribute(PDF_STATUS, statusRequest);
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java
index 2c2af9a9..841b8428 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java
@@ -27,7 +27,6 @@ import at.gv.egiz.pdfas.common.exceptions.PDFASError;
import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
import at.gv.egiz.pdfas.common.exceptions.PdfAsSettingsValidationException;
import at.gv.egiz.pdfas.common.settings.ISettings;
-import at.gv.egiz.pdfas.common.utils.StringUtils;
import at.gv.egiz.pdfas.lib.api.IConfigurationConstants;
import at.gv.egiz.pdfas.lib.api.PdfAsFactory;
import at.gv.egiz.pdfas.lib.api.verify.VerifyParameter.SignatureVerificationLevel;
@@ -57,6 +56,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.util.List;
+import java.util.Map;
/**
* Servlet implementation class Sign
@@ -366,7 +366,11 @@ public class ExternSignServlet extends HttpServlet {
PdfAsHelper.setSignatureDataHash(request, pdfDataHash);
logger.debug("Storing signatures data hash: " + pdfDataHash);
-
+
+ //TODO alex parse??
+ Map<String, String> dynamicSignatureBlockArguments = null;
+
+
logger.debug("Starting signature creation with: " + connector);
//IPlainSigner signer;
@@ -396,11 +400,12 @@ public class ExternSignServlet extends HttpServlet {
}
PdfAsHelper.setStatisticEvent(request, response, statisticEvent);
-
- PdfAsHelper.startSignature(request, response, getServletContext(), pdfData, connector,
+
+
+ PdfAsHelper.startSignature(request, response, getServletContext(), pdfData, connector,
PdfAsHelper.buildPosString(request, response), transactionId, PdfAsParameterExtractor
.getSigType(request), PdfAsParameterExtractor.getPreProcessorMap(request),
- PdfAsParameterExtractor.getOverwriteMap(request));
+ PdfAsParameterExtractor.getOverwriteMap(request), dynamicSignatureBlockArguments);
return;
} else if (connector.equals("jks") || connector.equals("moa")) {
// start synchronous siganture creation
@@ -432,8 +437,8 @@ public class ExternSignServlet extends HttpServlet {
}
}
- byte[] pdfSignedData = PdfAsHelper.synchornousSignature(request,
- response, pdfData);
+ byte[] pdfSignedData = PdfAsHelper.synchronousSignature(request,
+ response, pdfData, dynamicSignatureBlockArguments);
PdfAsHelper.setSignedPdf(request, response, pdfSignedData);
statisticEvent.setStatus(Status.OK);
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 13d874e8..4925ec65 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
@@ -1,9 +1,7 @@
package at.gv.egiz.pdfas.web.servlets;
import at.gv.egiz.pdfas.api.ws.PDFASSignParameters;
-import at.gv.egiz.pdfas.api.ws.PDFASSignRequest;
import at.gv.egiz.pdfas.api.ws.PDFASSignResponse;
-import at.gv.egiz.pdfas.api.ws.VerificationLevel;
import at.gv.egiz.pdfas.common.exceptions.PDFASError;
import at.gv.egiz.pdfas.lib.api.verify.VerifyParameter;
import at.gv.egiz.pdfas.lib.api.verify.VerifyResult;
@@ -15,10 +13,8 @@ import at.gv.egiz.pdfas.web.helper.JSONStartResponse;
import at.gv.egiz.pdfas.web.helper.PdfAsHelper;
import at.gv.egiz.pdfas.web.stats.StatisticEvent;
import at.gv.egiz.pdfas.web.stats.StatisticFrontend;
-import at.gv.egiz.pdfas.web.store.RequestStore;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
-import org.json.HTTP;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -27,8 +23,6 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.xml.ws.WebServiceException;
-import java.io.BufferedReader;
import java.io.IOException;
import java.util.List;
import java.util.Map;
@@ -139,11 +133,15 @@ public class JSONAPIServlet extends HttpServlet {
parameters.setPosition(position);
parameters.setProfile(profile);
+ //TODO alex fill here
+ Map<String, String> dynamicSignatureBlockArguments = null;
+
if (PDFASSignParameters.Connector.MOA.equals(connectorEnum)
|| PDFASSignParameters.Connector.JKS.equals(connectorEnum)) {
// Plain server based signatures!!
- PDFASSignResponse pdfasSignResponse = PdfAsHelper.synchornousServerSignature(
- inputDocument, parameters);
+
+ PDFASSignResponse pdfasSignResponse = PdfAsHelper.synchronousServerSignature(
+ inputDocument, parameters, dynamicSignatureBlockArguments);
VerifyResult verifyResult = null;
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/UIEntryPointServlet.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/UIEntryPointServlet.java
index 73f8299c..664dd9b3 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/UIEntryPointServlet.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/UIEntryPointServlet.java
@@ -174,13 +174,15 @@ public class UIEntryPointServlet extends HttpServlet {
overwrite = pdfAsRequest.getParameters().getOverrides()
.getMap();
}
+ //TODO alex
+ Map<String, String> dynamicSignatureBlockArguments = pdfAsRequest.getSignatureBlockParameters();
PdfAsHelper.startSignature(req, resp, getServletContext(),
pdfAsRequest.getInputData(), connector.toString(),
pdfAsRequest.getParameters().getPosition(),
pdfAsRequest.getParameters().getTransactionId(),
pdfAsRequest.getParameters().getProfile(), map,
- overwrite);
+ overwrite, dynamicSignatureBlockArguments);
} else {
throw new PdfAsWebException("Invalid connector ("
+ Connector.BKU + " | " + Connector.ONLINEBKU + " | "
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASSigningImpl.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASSigningImpl.java
index f850c5ae..ccbaf4fb 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASSigningImpl.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASSigningImpl.java
@@ -104,8 +104,8 @@ public class PDFASSigningImpl implements PDFASSigning {
|| request.getParameters().getConnector()
.equals(Connector.JKS)) {
// Plain server based signatures!!
- response = PdfAsHelper.synchornousServerSignature(
- request.getInputData(), request.getParameters());
+ response = PdfAsHelper.synchronousServerSignature(
+ request.getInputData(), request.getParameters(), request.getSignatureBlockParameters());
VerifyResult verifyResult = null;
if (request.getVerificationLevel() != null &&