aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpdanner <pdanner@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2010-12-16 12:16:09 +0000
committerpdanner <pdanner@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2010-12-16 12:16:09 +0000
commitd40090e3b400fe3de4ffa7179cddbe23f7b593bd (patch)
tree2af64c435b58908acae0ff215d98b6ef11b3b720 /src
parentf00945924e6d2662d71e65d143622f3b26b34dd6 (diff)
downloadpdf-as-3-d40090e3b400fe3de4ffa7179cddbe23f7b593bd.tar.gz
pdf-as-3-d40090e3b400fe3de4ffa7179cddbe23f7b593bd.tar.bz2
pdf-as-3-d40090e3b400fe3de4ffa7179cddbe23f7b593bd.zip
Moved MATCH_MODE_* constants from SignParameters to Constants.
Added javadoc and updated Anwendungsbeschreibung git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@715 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/gv/egiz/pdfas/api/commons/Constants.java19
-rw-r--r--src/main/java/at/gv/egiz/pdfas/api/sign/SignParameters.java42
-rw-r--r--src/main/java/at/gv/egiz/pdfas/commandline/Main.java10
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/api/internal/PdfAsInternalObject.java2
-rw-r--r--src/main/java/at/gv/egiz/pdfas/placeholder/SignaturePlaceholderExtractor.java5
5 files changed, 49 insertions, 29 deletions
diff --git a/src/main/java/at/gv/egiz/pdfas/api/commons/Constants.java b/src/main/java/at/gv/egiz/pdfas/api/commons/Constants.java
index 122aec8..7f6ab4b 100644
--- a/src/main/java/at/gv/egiz/pdfas/api/commons/Constants.java
+++ b/src/main/java/at/gv/egiz/pdfas/api/commons/Constants.java
@@ -117,5 +117,24 @@ public final class Constants
public static final String ADOBE_SIG_FILTER = AdobeSignatureHelper.ADOBE_SIG_FILTER;
+ /**
+ * Strict matching mode for placeholder extraction.<br/>
+ * If the placeholder with the given id is not found in the document, an exception will be thrown.
+ */
+ public static final int PLACEHOLDER_MATCH_MODE_STRICT = 0;
+
+ /**
+ * A moderate matching mode for placeholder extraction.<br/>
+ * If the placeholder with the given id is not found in the document, the first placeholder without an id will be taken.<br/>
+ * If there is no such placeholder, the signature will be placed as usual, according to the pos parameter of the signature profile used.
+ */
+ public static final int PLACEHOLDER_MATCH_MODE_MODERATE = 1;
+
+ /**
+ * A more lenient matching mode for placeholder extraction.<br/>
+ * If the placeholder with the given id is not found in the document, the first found placeholder will be taken, regardless if it has an id set, or not.<br/>
+ * If there is no placeholder at all, the signature will be placed as usual, according to the pos parameter of the signature profile used.
+ */
+ public static final int PLACEHOLDER_MATCH_MODE_LENIENT = 2;
}
diff --git a/src/main/java/at/gv/egiz/pdfas/api/sign/SignParameters.java b/src/main/java/at/gv/egiz/pdfas/api/sign/SignParameters.java
index 0bf1000..a53a140 100644
--- a/src/main/java/at/gv/egiz/pdfas/api/sign/SignParameters.java
+++ b/src/main/java/at/gv/egiz/pdfas/api/sign/SignParameters.java
@@ -20,25 +20,6 @@ import at.knowcenter.wag.egov.egiz.sig.SignatureTypes;
public class SignParameters
{
// 23.11.2010 changed by exthex - added parameters for placeholder handling
- /**
- * Strict matching mode for placeholder extraction.<br/>
- * If the placeholder with the given id is not found in the document, an exception will be thrown.
- */
- public static final int PLACEHOLDER_MATCH_MODE_STRICT = 0;
-
- /**
- * A moderate matching mode for placeholder extraction.<br/>
- * If the placeholder with the given id is not found in the document, the first placeholder without an id will be taken.<br/>
- * If there is no such placeholder, the signature will be placed as usual, according to the pos parameter of the signature profile used.
- */
- public static final int PLACEHOLDER_MATCH_MODE_MODERATE = 1;
-
- /**
- * A more lenient matching mode for placeholder extraction.<br/>
- * If the placeholder with the given id is not found in the document, the first found placeholder will be taken, regardless if it has an id set, or not.<br/>
- * If there is no placeholder at all, the signature will be placed as usual, according to the pos parameter of the signature profile used.
- */
- public static final int PLACEHOLDER_MATCH_MODE_LENIENT = 2;
/**
* The document to be signed.
@@ -138,9 +119,9 @@ public class SignParameters
* The matching mode for placeholder extraction.<br/>
* If a {@link SignParameters#placeholderId} is set, the match mode determines what is to be done, if no matching placeholder is found in the document.
* <br/>
- * Defaults to {@link SignParameters#PLACEHOLDER_MATCH_MODE_MODERATE}.
+ * Defaults to {@link Constants#PLACEHOLDER_MATCH_MODE_MODERATE}.
*/
- protected int placeholderMatchMode = PLACEHOLDER_MATCH_MODE_MODERATE;
+ protected int placeholderMatchMode = Constants.PLACEHOLDER_MATCH_MODE_MODERATE;
protected Properties overrideProps = new Properties();
@@ -323,6 +304,7 @@ public class SignParameters
}
/**
+ * Get the value of the checkForPlaceholder flag.
*
* @return
*/
@@ -331,6 +313,9 @@ public class SignParameters
}
/**
+ * Set this to true, if you want a search for placeholder images to be performed and
+ * appropriate images to be replaced.
+ * If this is not set, a search will only be performed if the configuration property "enable_placeholder_search" is set to true.
*
* @param check
*/
@@ -339,6 +324,8 @@ public class SignParameters
}
/**
+ * Set an explicit placeholder id.
+ * Only placeholder images that have a matching ID property embedded will be considered for replacement.
*
* @param placeholderId
*/
@@ -347,6 +334,7 @@ public class SignParameters
}
/**
+ * The id of the placeholder to replace.
*
* @return the placeholderId
*/
@@ -355,6 +343,16 @@ public class SignParameters
}
/**
+ * Set the behavior if no exactly matching placeholder could be found.<br/>
+ * Exactly matching meaning:<br/>
+ * <ul><li>If a placeholderId is set: a placeholder which has exactly this id embedded</li>
+ * <li>If no placeholderId is set: a placeholder without an embedded id is found</li></ul>
+ *
+ * @see Constants#PLACEHOLDER_MATCH_MODE_LENIENT
+ * @see Constants#PLACEHOLDER_MATCH_MODE_MODERATE
+ * @see Constants#PLACEHOLDER_MATCH_MODE_STRICT
+ *
+ * Defaults to {@link Constants#PLACEHOLDER_MATCH_MODE_MODERATE}.
*
* @param placeholderMatchMode
*/
@@ -363,7 +361,9 @@ public class SignParameters
}
/**
+ * Get the placeholder matching mode.
*
+ * @see SignParameters#getPlaceholderMatchMode()
* @return the placeholderMatchMode
*/
public int getPlaceholderMatchMode() {
diff --git a/src/main/java/at/gv/egiz/pdfas/commandline/Main.java b/src/main/java/at/gv/egiz/pdfas/commandline/Main.java
index 4a70f3f..2ffecec 100644
--- a/src/main/java/at/gv/egiz/pdfas/commandline/Main.java
+++ b/src/main/java/at/gv/egiz/pdfas/commandline/Main.java
@@ -241,7 +241,7 @@ public abstract class Main
boolean search_placeholder = true;
String placeholderId = null;
- int placeholderMatchMode = SignParameters.PLACEHOLDER_MATCH_MODE_MODERATE;
+ int placeholderMatchMode = Constants.PLACEHOLDER_MATCH_MODE_MODERATE;
int verify_which = -1;
@@ -369,11 +369,11 @@ public abstract class Main
}
String matchMode = args[i];
if (matchMode.equals(VALUE_PLACEHOLDER_MATCH_MODE_LENIENT))
- placeholderMatchMode = SignParameters.PLACEHOLDER_MATCH_MODE_LENIENT;
+ placeholderMatchMode = Constants.PLACEHOLDER_MATCH_MODE_LENIENT;
else if (matchMode.equals(VALUE_PLACEHOLDER_MATCH_MODE_MODERATE))
- placeholderMatchMode = SignParameters.PLACEHOLDER_MATCH_MODE_MODERATE;
+ placeholderMatchMode = Constants.PLACEHOLDER_MATCH_MODE_MODERATE;
else if (matchMode.equals(VALUE_PLACEHOLDER_MATCH_MODE_STRICT))
- placeholderMatchMode = SignParameters.PLACEHOLDER_MATCH_MODE_STRICT;
+ placeholderMatchMode = Constants.PLACEHOLDER_MATCH_MODE_STRICT;
else
printUnrecognizedValue(PARAMETER_PLACEHOLDER_MATCH_MODE, args[i]);
continue;
@@ -1092,7 +1092,7 @@ public abstract class Main
writer.println(" " + PARAMETER_PLACEHOLDER_SEARCH + " <true|false> ... [optional] if set to true, the source document will be scanned for signature placeholder images. If not set, the enable_placeholder_search value in the config file decides whether or not a search for placeholder images will be performed.");
writer.println(" " + PARAMETER_PLACEHOLDER_ID + " <id> ... [optional] search for signature placeholder images containing the given id");
- writer.println(" " + PARAMETER_PLACEHOLDER_MATCH_MODE + " <" + VALUE_PLACEHOLDER_MATCH_MODE_LENIENT + "|" + VALUE_PLACEHOLDER_MATCH_MODE_MODERATE + "|" + VALUE_PLACEHOLDER_MATCH_MODE_STRICT + "> ... [optional] specify the behaviour if no matching placeholder could be found. Default is <moderate>.");
+ writer.println(" " + PARAMETER_PLACEHOLDER_MATCH_MODE + " <" + VALUE_PLACEHOLDER_MATCH_MODE_LENIENT + "|" + VALUE_PLACEHOLDER_MATCH_MODE_MODERATE + "|" + VALUE_PLACEHOLDER_MATCH_MODE_STRICT + "> ... [optional] specify the behavior if no matching placeholder could be found. Default is <moderate>.");
writer.println(" " + VALUE_PLACEHOLDER_MATCH_MODE_LENIENT + " ... sign in place of the first found placeholder, regardless if it matches exactly, or at the end of the document if none is found.");
writer.println(" " + VALUE_PLACEHOLDER_MATCH_MODE_MODERATE + " ... sign in place of the first found placeholder which has no explicit id set, or at the end of the document if none is found.");
writer.println(" " + VALUE_PLACEHOLDER_MATCH_MODE_STRICT + " ... throws a PlaceholderExtractionException.");
diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/internal/PdfAsInternalObject.java b/src/main/java/at/gv/egiz/pdfas/impl/api/internal/PdfAsInternalObject.java
index 6531678..74e5bba 100644
--- a/src/main/java/at/gv/egiz/pdfas/impl/api/internal/PdfAsInternalObject.java
+++ b/src/main/java/at/gv/egiz/pdfas/impl/api/internal/PdfAsInternalObject.java
@@ -67,7 +67,7 @@ import at.knowcenter.wag.egov.egiz.sig.signatureobject.SignatureObjectHelper;
/**
* @see PdfAsInternal
*
- * @author mmocnik
+ * @author exthex
*
*/
public class PdfAsInternalObject implements PdfAsInternal {
diff --git a/src/main/java/at/gv/egiz/pdfas/placeholder/SignaturePlaceholderExtractor.java b/src/main/java/at/gv/egiz/pdfas/placeholder/SignaturePlaceholderExtractor.java
index 50c3281..85d14f8 100644
--- a/src/main/java/at/gv/egiz/pdfas/placeholder/SignaturePlaceholderExtractor.java
+++ b/src/main/java/at/gv/egiz/pdfas/placeholder/SignaturePlaceholderExtractor.java
@@ -24,6 +24,7 @@ import org.apache.pdfbox.util.PDFOperator;
import org.apache.pdfbox.util.PDFStreamEngine;
import org.apache.pdfbox.util.ResourceLoader;
+import at.gv.egiz.pdfas.api.commons.Constants;
import at.gv.egiz.pdfas.api.sign.SignParameters;
import at.gv.egiz.pdfas.exceptions.ErrorCode;
import at.gv.egiz.pdfas.exceptions.framework.PlaceholderExtractionException;
@@ -131,7 +132,7 @@ public class SignaturePlaceholderExtractor extends PDFStreamEngine {
private static SignaturePlaceholderData matchPlaceholderDocument(
List placeholders, String placeholderId, int matchMode) throws PlaceholderExtractionException {
- if (matchMode == SignParameters.PLACEHOLDER_MATCH_MODE_STRICT)
+ if (matchMode == Constants.PLACEHOLDER_MATCH_MODE_STRICT)
throw new PlaceholderExtractionException(ErrorCode.SIGNATURE_PLACEHOLDER_EXTRACTION_FAILED, "no suitable placeholder found and STRICT matching mode requested.");
if (placeholders.size() == 0)
@@ -144,7 +145,7 @@ public class SignaturePlaceholderExtractor extends PDFStreamEngine {
return spd;
}
- if (matchMode == SignParameters.PLACEHOLDER_MATCH_MODE_LENIENT)
+ if (matchMode == Constants.PLACEHOLDER_MATCH_MODE_LENIENT)
return (SignaturePlaceholderData)placeholders.get(0);
return null;