aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper')
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java15
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java22
2 files changed, 33 insertions, 4 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 3323a252..fc499f94 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
@@ -35,6 +35,7 @@ import java.net.URLEncoder;
import java.security.cert.CertificateException;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import javax.imageio.ImageIO;
import javax.servlet.RequestDispatcher;
@@ -298,7 +299,7 @@ public class PdfAsHelper {
}
public static List<VerifyResult> synchornousVerify(byte[] pdfData,
- int signIdx, SignatureVerificationLevel lvl) throws Exception {
+ int signIdx, SignatureVerificationLevel lvl, Map<String, String> preProcessor) throws Exception {
logger.debug("Verifing Signature index: " + signIdx);
Configuration config = pdfAs.getConfiguration();
@@ -308,6 +309,7 @@ public class PdfAsHelper {
VerifyParameter verifyParameter = PdfAsFactory.createVerifyParameter(
config, dataSource);
+ verifyParameter.setPreprocessorArguments(preProcessor);
verifyParameter.setSignatureVerificationLevel(lvl);
verifyParameter.setDataSource(dataSource);
verifyParameter.setConfiguration(config);
@@ -425,6 +427,11 @@ public class PdfAsHelper {
// set Signature Position
signParameter.setSignaturePosition(params.getPosition());
+ // Set Preprocessor
+ if(params.getPreprocessor() != null) {
+ signParameter.setPreprocessorArguments(params.getPreprocessor().getMap());
+ }
+
SignResult signResult = pdfAs.sign(signParameter);
PDFASSignResponse signResponse = new PDFASSignResponse();
@@ -444,7 +451,7 @@ public class PdfAsHelper {
public static void startSignature(HttpServletRequest request,
HttpServletResponse response, ServletContext context,
byte[] pdfData, String connector, String position,
- String transactionId, String profile) throws Exception {
+ String transactionId, String profile, Map<String, String> preProcessor) throws Exception {
// TODO: Protect session so that only one PDF can be signed during one
// session
@@ -483,7 +490,7 @@ public class PdfAsHelper {
throw new PdfAsWebException(
"Invalid connector (bku | onlinebku | mobilebku | moa | jks)");
}
-
+ signParameter.setPreprocessorArguments(preProcessor);
signParameter.setPlainSigner(signer);
session.setAttribute(PDF_SIGNER, signer);
session.setAttribute(PDF_SL_INTERACTIVE, connector);
@@ -677,7 +684,7 @@ public class PdfAsHelper {
PDFASVerificationResponse verResponse = new PDFASVerificationResponse();
List<VerifyResult> verResults = PdfAsHelper.synchornousVerify(
signedPdf, -2,
- PdfAsHelper.getVerificationLevel(request));
+ PdfAsHelper.getVerificationLevel(request), null);
if (verResults.size() != 1) {
throw new WebServiceException(
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java
index c8f35f3c..9c5f8cc6 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java
@@ -23,6 +23,10 @@
******************************************************************************/
package at.gv.egiz.pdfas.web.helper;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
import javax.servlet.http.HttpServletRequest;
import at.gv.egiz.pdfas.lib.api.verify.VerifyParameter.SignatureVerificationLevel;
@@ -63,6 +67,8 @@ public class PdfAsParameterExtractor {
public static final String PARAM_SIG_IDX = "sig-idx";
public static final String PARAM_FILENAME = "filename";
+ public static final String PARAM_PREPROCESSOR_PREFIX = "pp:";
+
public static String getConnector(HttpServletRequest request) {
String connector = (String)request.getAttribute(PARAM_CONNECTOR);
if(connector != null) {
@@ -85,6 +91,22 @@ public class PdfAsParameterExtractor {
return (String)request.getAttribute(PARAM_INVOKE_URL);
}
+ public static Map<String, String> getPreProcessorMap(HttpServletRequest request) {
+ Map<String, String> map = new HashMap<String, String>();
+
+ Enumeration<String> parameterNames = request.getAttributeNames();
+ while(parameterNames.hasMoreElements()) {
+ String parameterName = parameterNames.nextElement();
+ if(parameterName.startsWith(PARAM_PREPROCESSOR_PREFIX)) {
+ String key = parameterName.substring(PARAM_PREPROCESSOR_PREFIX.length());
+ String value = (String)request.getAttribute(parameterName);
+ map.put(key, value);
+ }
+ }
+
+ return map;
+ }
+
public static SignatureVerificationLevel getVerificationLevel(HttpServletRequest request) {
String value = (String)request.getAttribute(PARAM_VERIFY_LEVEL);
if(value != null) {