aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/gv')
-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
2 files changed, 54 insertions, 9 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);