diff options
author | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2015-03-20 14:41:50 +0100 |
---|---|---|
committer | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2015-03-20 14:41:50 +0100 |
commit | f179c8db3574d03bb1b6b5be1bd86c9ea04073ad (patch) | |
tree | 2e409af0e8bd762d9d38dc2d9fe7bc3402d7c343 /pdf-as-lib/src | |
parent | 0dc3dfacb8c8f5bbe4dff667a62dcfc879e06367 (diff) | |
download | pdf-as-4-f179c8db3574d03bb1b6b5be1bd86c9ea04073ad.tar.gz pdf-as-4-f179c8db3574d03bb1b6b5be1bd86c9ea04073ad.tar.bz2 pdf-as-4-f179c8db3574d03bb1b6b5be1bd86c9ea04073ad.zip |
added Placeholder ID and Mode configuration settings
Diffstat (limited to 'pdf-as-lib/src')
4 files changed, 48 insertions, 2 deletions
diff --git a/pdf-as-lib/src/configuration/cfg/advancedconfig.properties b/pdf-as-lib/src/configuration/cfg/advancedconfig.properties index cfe6ffbc..ec88b448 100644 --- a/pdf-as-lib/src/configuration/cfg/advancedconfig.properties +++ b/pdf-as-lib/src/configuration/cfg/advancedconfig.properties @@ -21,6 +21,18 @@ #enable_placeholder_search=true
+# These values should be configured at runtime:
+
+# Set this for placeholder Identifier
+# default is unset
+#placeholder_id=
+
+# Set this for placeholder Mode
+# MATCH_MODE_STRICT = 0
+# MATCH_MODE_MODERATE = 1
+# MATCH_MODE_LENIENT = 2
+#placeholder_mode=
+
##################
# Signaturdienste
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 24af4ad8..c1fd4fe5 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 @@ -43,6 +43,9 @@ public interface IConfigurationConstants { public static final String LEGACY_POSITIONING = ".legacy.pos"; + public static final String PLACEHOLDER_ID = "placeholder_id"; + public static final String PLACEHOLDER_MODE = "placeholder_mode"; + public static final String PLACEHOLDER_SEARCH_ENABLED = "enable_placeholder_search"; public static final String DEFAULT_SIGNATURE_PROFILE = SIG_OBJECT + SEPERATOR + TYPE + SEPERATOR + DEFAULT; diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/PlaceholderExtractorConstants.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/PlaceholderExtractorConstants.java new file mode 100644 index 00000000..2d898dd5 --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/PlaceholderExtractorConstants.java @@ -0,0 +1,11 @@ +package at.gv.egiz.pdfas.lib.impl.placeholder; + +public interface PlaceholderExtractorConstants { + public static final String QR_PLACEHOLDER_IDENTIFIER = "PDF-AS-POS"; + public static final int PLACEHOLDER_MATCH_MODE_STRICT = 0; + public static final int PLACEHOLDER_MATCH_MODE_MODERATE = 1; + public static final int PLACEHOLDER_MATCH_MODE_LENIENT = 2; + + public static final int PLACEHOLDER_MODE_MIN = 0; + public static final int PLACEHOLDER_MODE_MAX = 2; +} 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 1417f634..19ea496d 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 @@ -25,12 +25,15 @@ package at.gv.egiz.pdfas.lib.impl.placeholder; import java.io.IOException; +import at.gv.egiz.pdfas.common.exceptions.PDFASError; +import at.gv.egiz.pdfas.common.exceptions.PdfAsErrorCarrier; import at.gv.egiz.pdfas.common.exceptions.PdfAsException; import at.gv.egiz.pdfas.common.settings.ISettings; import at.gv.egiz.pdfas.lib.api.IConfigurationConstants; import at.gv.egiz.pdfas.lib.impl.status.OperationStatus; -public class PlaceholderFilter implements IConfigurationConstants { +public class PlaceholderFilter implements IConfigurationConstants, + PlaceholderExtractorConstants { public static SignaturePlaceholderData checkPlaceholderSignature( OperationStatus status, ISettings settings) throws PdfAsException, @@ -39,8 +42,25 @@ public class PlaceholderFilter implements IConfigurationConstants { if (status.getPlaceholderConfiguration().isGlobalPlaceholderEnabled()) { PlaceholderExtractor extractor = status.getBackend() .getPlaceholderExtractor(); + String placeholderID = settings.getValue(PLACEHOLDER_ID); + String placeholderModeString = settings.getValue(PLACEHOLDER_MODE); + int placeholderMode = PLACEHOLDER_MATCH_MODE_MODERATE; + if (placeholderModeString != null) { + 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)); + } + } SignaturePlaceholderData signaturePlaceholderData = extractor - .extract(status.getPdfObject(), null, 1); + .extract(status.getPdfObject(), placeholderID, placeholderMode); return signaturePlaceholderData; } |