From c0f97e7b1ad5b6256eb935aeab06d159d68d1966 Mon Sep 17 00:00:00 2001 From: Alexander Marsalek Date: Mon, 12 Apr 2021 15:58:14 +0200 Subject: pdf-as-web signature block parameter handling --- .../java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper') 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 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 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 preProcessor, Map overwrite) throws Exception { + Map preProcessor, Map overwrite, Map 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); -- cgit v1.2.3