diff options
Diffstat (limited to 'pdf-as-lib/src/main/java/at/gv/egiz')
3 files changed, 36 insertions, 2 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 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; } |