aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java61
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/signator/binary/BinarySignator_1_0_0.java2
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java2
-rw-r--r--src/main/resources/DefaultConfiguration.zipbin673554 -> 673774 bytes
-rw-r--r--work/cfg/config.properties8
5 files changed, 63 insertions, 10 deletions
diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java b/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java
index 4cc6b69..4bf41d4 100644
--- a/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java
+++ b/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java
@@ -79,6 +79,7 @@ import at.knowcenter.wag.egov.egiz.exceptions.SettingsException;
import at.knowcenter.wag.egov.egiz.exceptions.SignatorFactoryException;
import at.knowcenter.wag.egov.egiz.exceptions.SignatureException;
import at.knowcenter.wag.egov.egiz.framework.SignatorFactory;
+import at.knowcenter.wag.egov.egiz.pdf.AdobeSignatureHelper;
import at.knowcenter.wag.egov.egiz.pdf.BinarySignatureHolder;
import at.knowcenter.wag.egov.egiz.pdf.NoSignatureHolder;
import at.knowcenter.wag.egov.egiz.pdf.ObjectExtractor;
@@ -110,6 +111,17 @@ public class PdfAsObject implements PdfAs
private static final String ENABLE_PLACEHOLDER_SEARCH_KEY = "enable_placeholder_search";
/**
+ * Configuration key for minimal signature block width threshold. Any width below this certain value will lead to a warning log entry."
+ */
+ private static final String SIGNATURE_BLOCK_WIDTH_THRESHOLD_FOR_WARNING_KEY = "signature_block_width_warning_threshold";
+
+ /**
+ * Minimal signature block width. If a width below that value is defined (by parameter, by placeholder or by configuration) a warning log entry is created.
+ */
+ public static final float DEFAULT_SIGNATURE_BLOCK_WIDTH_THRESHOLD = 150;
+
+
+ /**
* This constructor is for internal use only - use
* {@link at.gv.egiz.pdfas.PdfAsFactory} instead.
* Note: IAIK JCE and IAIK ECC security providers are automatically registered.
@@ -652,21 +664,54 @@ public class PdfAsObject implements PdfAs
}
boolean fromPlaceholder = false;
+ boolean fromSignParameters = false;
+ boolean fromConfig = false;
TablePos pos = null;
if (spd != null && spd.getTablePos() != null){
+ // position and width is determined by placeholder image
fromPlaceholder = true;
pos = spd.getTablePos();
} else {
+ // position and width is determined by api sign parameters
pos = PosHelper.formTablePos(signParameters.getSignaturePositioning());
+ if (pos != null) {
+ fromSignParameters = true;
+ }
}
-
- if (pos != null && !pos.isWauto() && pos.getWidth() < 150) {
- // very small, warn user
- String msg = "The {0} for the signature ({1}) is very small. The signature block might not get placed correcty.";
- String[] arguments = new String[]{ "given width", "" + pos.getWidth()};
- if (fromPlaceholder)
- arguments[0] = "width of the placeholder image that will be used";
- log.warn(MessageFormat.format(msg, arguments));
+
+ TablePos effectivePos = pos;
+ if (effectivePos == null) {
+ String pos_string = settings.getSetting(SignatureTypes.SIG_OBJ + signParameters.getSignatureProfileId() + ".pos", null);
+ if (pos_string != null) {
+ // position and width is determined by profile configuration
+ effectivePos = PdfAS.parsePositionFromPosString(pos_string);
+ fromConfig = true;
+ }
+ }
+ if (effectivePos != null) {
+ // check if width is lower than the smallest meaningful width
+ String thresholdString = AdobeSignatureHelper.getDefaultableConfigProperty(signParameters.getSignatureProfileId(), SIGNATURE_BLOCK_WIDTH_THRESHOLD_FOR_WARNING_KEY, String.valueOf(DEFAULT_SIGNATURE_BLOCK_WIDTH_THRESHOLD));
+ float threshold = DEFAULT_SIGNATURE_BLOCK_WIDTH_THRESHOLD;
+ try {
+ threshold = Float.parseFloat(thresholdString);
+ } catch (NumberFormatException e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Unable to parse threshold value (\"" + thresholdString + "\") of configuration value \"" + SIGNATURE_BLOCK_WIDTH_THRESHOLD_FOR_WARNING_KEY + "\". Using default value: " + DEFAULT_SIGNATURE_BLOCK_WIDTH_THRESHOLD);
+ }
+ }
+ if (!effectivePos.isWauto() && effectivePos.getWidth() < threshold) {
+ String msg = "The {0} for the signature block is very small ({1}). The signature block might not get placed correcty.";
+ String[] arguments = new String[]{ "given width", "" + effectivePos.getWidth()};
+ // very small, warn user
+ if (fromPlaceholder) {
+ arguments[0] = "width given by the placeholder image";
+ } else if (fromSignParameters) {
+ arguments[0] = "width defined by the sign parameters";
+ } else if (fromConfig) {
+ arguments[0] = "width defined by the profile " + signParameters.getSignatureProfileId();
+ }
+ log.warn(MessageFormat.format(msg, arguments));
+ }
}
Signator signator = createSignator(signParameters.getSignatureType());
diff --git a/src/main/java/at/gv/egiz/pdfas/impl/signator/binary/BinarySignator_1_0_0.java b/src/main/java/at/gv/egiz/pdfas/impl/signator/binary/BinarySignator_1_0_0.java
index 3d4be31..821d633 100644
--- a/src/main/java/at/gv/egiz/pdfas/impl/signator/binary/BinarySignator_1_0_0.java
+++ b/src/main/java/at/gv/egiz/pdfas/impl/signator/binary/BinarySignator_1_0_0.java
@@ -140,7 +140,7 @@ public class BinarySignator_1_0_0 implements Signator
boolean baikEnabled = "true".equalsIgnoreCase(baikStr);
if (baikEnabled) {
- log.debug("found baik enabled signature");
+ log.debug("BAIK enabled signature");
}
SignatureObject signature_object = PdfAS.createSignatureObjectFromType(profile);
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java b/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java
index c23abc7..7858344 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java
@@ -107,7 +107,7 @@ public abstract class PdfAS
* The current version of the pdf-as library. This version string is logged on every invocation
* of the api or the web application.
*/
- public static final String PDFAS_VERSION = "3.2-SNAPSHOT (20110121)";
+ public static final String PDFAS_VERSION = "3.2-SNAPSHOT (20110128)";
/**
* The key of the strict mode setting.
diff --git a/src/main/resources/DefaultConfiguration.zip b/src/main/resources/DefaultConfiguration.zip
index 55a8f32..6940943 100644
--- a/src/main/resources/DefaultConfiguration.zip
+++ b/src/main/resources/DefaultConfiguration.zip
Binary files differ
diff --git a/work/cfg/config.properties b/work/cfg/config.properties
index e1384a1..a75d0ba 100644
--- a/work/cfg/config.properties
+++ b/work/cfg/config.properties
@@ -168,6 +168,14 @@ defaults.phlength.timestamp=5000
# profilweise: sig_obj.PROFILE.phlength.line_break_tolerance=xyz
defaults.phlength.line_break_tolerance=10
+# Falls die Breite eines Signaturblocks definiert wird (über API, Commandline oder über das Profil),
+# die unterhalb eines sinnvollen Wertes liegt, dann wird im Log eine Warnung ausgegeben, da
+# Signaturblöcke unter Umständen nicht mehr sinnvoll dargestellt werden können.
+# Der Standard-Schwellwert für diese Warnungen (= 150) kann global oder profilweise festgelegt
+# werden (z.B. um die Warnung zu deaktivieren, kann der Wert auf 0 gesetzt werden).
+# default.signature_block_width_warning_threshold=xyz
+# sig_obj.PROFILE.signature_block_width_warning_threshold=xyz
+
# PDF/A-1b Unterstützung für alle Profile einschalten
default.SIG_PDFA1B_VALID=false