aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authortknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2011-01-28 11:06:52 +0000
committertknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2011-01-28 11:06:52 +0000
commitb0b9a063b8ef0641839206fd574dc62f96da162c (patch)
tree8fb9d8161956efd44b11a45bfe2300ce3906323b /src/main/java/at
parent2271407bc5fd54807fb66e6793c25ea196d1f65c (diff)
downloadpdf-as-3-b0b9a063b8ef0641839206fd574dc62f96da162c.tar.gz
pdf-as-3-b0b9a063b8ef0641839206fd574dc62f96da162c.tar.bz2
pdf-as-3-b0b9a063b8ef0641839206fd574dc62f96da162c.zip
Logging in case of too small signature blocks extended (now a warning is logged regardless the fact WHY a signature block is small (API, Placeholder or Configuration)).
The default threshold value is 150. An optional configuration key (global "default.signature_block_width_warning_threshold=xyz" and local per profile "sig_obj.PROFILE.signature_block_width_warning_threshold=xyz") has been added in order to make the threshold configurable (there might be profiles some day that need to be small, e.g. some versions of minimal layout blocks). git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@739 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java/at')
-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
3 files changed, 55 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.