aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib
diff options
context:
space:
mode:
authorAlexander Marsalek <amarsalek@iaik.tugraz.at>2021-04-20 21:12:16 +0200
committerAlexander Marsalek <amarsalek@iaik.tugraz.at>2021-04-20 21:23:59 +0200
commitaa45585a4cb9e7aff0ef3da3c6a6fe43b9ace98c (patch)
treeadbd5148432a702578c36fbf0bf5bf7a0a5409a3 /pdf-as-lib
parent649b3cd196987eac24a519d987676a0ba09e2432 (diff)
downloadpdf-as-4-aa45585a4cb9e7aff0ef3da3c6a6fe43b9ace98c.tar.gz
pdf-as-4-aa45585a4cb9e7aff0ef3da3c6a6fe43b9ace98c.tar.bz2
pdf-as-4-aa45585a4cb9e7aff0ef3da3c6a6fe43b9ace98c.zip
fix?
Diffstat (limited to 'pdf-as-lib')
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/PlaceholderExtractor.java4
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/PlaceholderFilter.java63
2 files changed, 67 insertions, 0 deletions
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/PlaceholderExtractor.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/PlaceholderExtractor.java
index 4c352b90..0a55b834 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/PlaceholderExtractor.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/PlaceholderExtractor.java
@@ -3,6 +3,10 @@ package at.gv.egiz.pdfas.lib.impl.placeholder;
import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
import at.gv.egiz.pdfas.lib.impl.status.PDFObject;
+import java.util.List;
+
public interface PlaceholderExtractor {
SignaturePlaceholderData extract(PDFObject doc, String placeholderId, int matchMode) throws PdfAsException;
+
+ List<SignaturePlaceholderData> extractList(PDFObject pdfObject, String placeholderID, int placeholderMode) throws PdfAsException;
}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/PlaceholderFilter.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/PlaceholderFilter.java
index 500b9e24..99c09295 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/PlaceholderFilter.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/PlaceholderFilter.java
@@ -24,6 +24,7 @@
package at.gv.egiz.pdfas.lib.impl.placeholder;
import java.io.IOException;
+import java.util.List;
import at.gv.egiz.pdfas.common.exceptions.PDFASError;
import at.gv.egiz.pdfas.common.exceptions.PdfAsErrorCarrier;
@@ -102,4 +103,66 @@ public class PlaceholderFilter implements IConfigurationConstants,
return null;
}
+ public static List<SignaturePlaceholderData> checkPlaceholderSignatureLocationList(OperationStatus status, ISettings settings, String signatureLocation) throws PdfAsException,
+ IOException {
+ String placeholderID;
+
+ if (status.getPlaceholderConfiguration().isGlobalPlaceholderEnabled()) {
+ PlaceholderExtractor extractor = status.getBackend().getPlaceholderExtractor();
+
+ if(StringUtils.isNotEmpty(signatureLocation)) {
+ placeholderID = signatureLocation;
+ } else {
+ placeholderID = PlaceholderWebConfiguration.getValue(PLACEHOLDER_WEB_ID);
+ if(StringUtils.isEmpty(placeholderID)) {
+ placeholderID = settings.getValue(PLACEHOLDER_ID);
+ }
+ }
+
+ String placeholderModeString = settings.getValue(PLACEHOLDER_MODE);
+ int placeholderMode = PLACEHOLDER_MATCH_MODE_MODERATE;
+ if (StringUtils.isNotEmpty(placeholderModeString)) {
+ try {
+ placeholderMode = Integer.parseInt(placeholderModeString);
+ if (placeholderMode < PLACEHOLDER_MODE_MIN
+ || placeholderMode > PLACEHOLDER_MODE_MAX) {
+ throw new PdfAsErrorCarrier(new PDFASError(
+ PDFASError.ERROR_INVALID_PLACEHOLDER_MODE));
+ }
+ } catch (NumberFormatException e) {
+ throw new PdfAsErrorCarrier(new PDFASError(
+ PDFASError.ERROR_INVALID_PLACEHOLDER_MODE, e));
+ }
+ }
+ return extractor.extractList(status.getPdfObject(), placeholderID,
+ placeholderMode);
+
+ } else if (status.getPlaceholderConfiguration().isProfileConfigurationEnabled(status.getRequestedSignature().getSignatureProfileID())) {
+ //filter for local placeholder in selected profiles
+ PlaceholderExtractor extractor = status.getBackend().getPlaceholderExtractor();
+ int placeholderMode = PLACEHOLDER_MATCH_MODE_SORTED;
+
+ placeholderID = status.getPlaceholderConfiguration().getProfilePlaceholderID(status.getRequestedSignature().getSignatureProfileID());
+ if(StringUtils.isNotEmpty(placeholderID)) {
+ placeholderMode = PLACEHOLDER_MATCH_MODE_MODERATE;
+ }
+ String placeholderModeString = settings.getValue(PLACEHOLDER_MODE);
+ if (StringUtils.isNotEmpty(placeholderModeString)) {
+ try {
+ placeholderMode = Integer.parseInt(placeholderModeString);
+ if (placeholderMode < PLACEHOLDER_MODE_MIN
+ || placeholderMode > PLACEHOLDER_MODE_MAX) {
+ throw new PdfAsErrorCarrier(new PDFASError(
+ PDFASError.ERROR_INVALID_PLACEHOLDER_MODE));
+ }
+ } catch (NumberFormatException e) {
+ throw new PdfAsErrorCarrier(new PDFASError(
+ PDFASError.ERROR_INVALID_PLACEHOLDER_MODE, e));
+ }
+ }
+ return extractor.extractList(status.getPdfObject(), placeholderID,
+ placeholderMode);
+ }
+ return null;
+ }
} \ No newline at end of file