aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main/java
diff options
context:
space:
mode:
authorAlexander Marsalek <amarsalek@iaik.tugraz.at>2021-04-14 19:05:02 +0200
committerAlexander Marsalek <amarsalek@iaik.tugraz.at>2021-04-14 19:05:02 +0200
commit1be82e61c0acf4d7380dcee3e3fcaaa8a8386f1b (patch)
treee82cf8d679867779d4dbd2bf1a857dc8e9b3fafa /pdf-as-lib/src/main/java
parent97b362c9f6906ecaf94c3f0d4fba10ab60206b2a (diff)
downloadpdf-as-4-1be82e61c0acf4d7380dcee3e3fcaaa8a8386f1b.tar.gz
pdf-as-4-1be82e61c0acf4d7380dcee3e3fcaaa8a8386f1b.tar.bz2
pdf-as-4-1be82e61c0acf4d7380dcee3e3fcaaa8a8386f1b.zip
added sbp check
Diffstat (limited to 'pdf-as-lib/src/main/java')
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java3
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsParameter.java4
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsParameterImpl.java16
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/CertificateAndRequestParameterResolver.java1
4 files changed, 20 insertions, 4 deletions
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java
index 610f5eba..4d6cef47 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java
@@ -113,6 +113,9 @@ public interface IConfigurationConstants {
public static final String BG_COLOR_DETECTION = "sigblock.placement.bgcolor.detection.enabled";
public static final String SIG_PLACEMENT_DEBUG_OUTPUT = "sigblock.placement.debug.file";
+ public static final String SIG_BLOCK_PARAMETER_KEY_REGEX = "sigblockparameter.key.regex";
+ public static final String SIG_BLOCK_PARAMETER_VALUE_REGEX = "sigblockparameter.value.regex";
+
/**
* PADES Constants
*/
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsParameter.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsParameter.java
index 6303c0a0..5a646505 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsParameter.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsParameter.java
@@ -23,6 +23,8 @@
******************************************************************************/
package at.gv.egiz.pdfas.lib.api;
+import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
+
import java.util.Map;
import javax.activation.DataSource;
@@ -86,7 +88,7 @@ public interface PdfAsParameter {
*
* @param map the map
*/
- public void setDynamicSignatureBlockArguments(Map<String, String> map);
+ public void setDynamicSignatureBlockArguments(Map<String, String> map) throws PdfAsException;
/**
* Gets the dynamic signature-block values.
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsParameterImpl.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsParameterImpl.java
index d6161f2c..19111342 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsParameterImpl.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsParameterImpl.java
@@ -23,11 +23,15 @@
******************************************************************************/
package at.gv.egiz.pdfas.lib.impl;
+import java.util.Collections;
import java.util.Map;
import javax.activation.DataSource;
+import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
+import at.gv.egiz.pdfas.common.utils.CheckSignatureBlockParameters;
import at.gv.egiz.pdfas.lib.api.Configuration;
+import at.gv.egiz.pdfas.lib.api.IConfigurationConstants;
import at.gv.egiz.pdfas.lib.api.PdfAsParameter;
public class PdfAsParameterImpl implements PdfAsParameter {
@@ -79,8 +83,16 @@ protected Configuration configuration;
}
@Override
- public void setDynamicSignatureBlockArguments(Map<String, String> map) {
- this.dynamicSignatureBlockArgumentsMap = map;
+ public void setDynamicSignatureBlockArguments(Map<String, String> map) throws PdfAsException {
+ Map<String, String> tmpMap = Collections.unmodifiableMap(map);
+ String keyRegex = configuration.getValue(IConfigurationConstants.SIG_BLOCK_PARAMETER_KEY_REGEX);
+ String valueRegex = configuration.getValue(IConfigurationConstants.SIG_BLOCK_PARAMETER_VALUE_REGEX);
+ if( CheckSignatureBlockParameters.checkSignatureBlockParameterMapIsValid(tmpMap, keyRegex, valueRegex) == true) {
+ this.dynamicSignatureBlockArgumentsMap = tmpMap;
+ }else{
+ throw new PdfAsException("Invalid signature block parameters");
+ }
+
}
@Override
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/CertificateAndRequestParameterResolver.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/CertificateAndRequestParameterResolver.java
index ab2e5729..024f377f 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/CertificateAndRequestParameterResolver.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/CertificateAndRequestParameterResolver.java
@@ -63,7 +63,6 @@ public class CertificateAndRequestParameterResolver implements IResolver {
this.ctx = new OgnlContext(null, null, memberAccess);
this.ctx.put(IProfileConstants.SIGNATURE_BLOCK_PARAMETER, operationStatus.getSignParamter().getDynamicSignatureBlockArguments());
-// this.ctx.put(IProfileConstants.DYNAMIC_REQUEST_PARAMETERS, operationStatus.getRequestParameters());
this.ctx.put("sn", this.certificate.getSerialNumber().toString());