aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpdanner <pdanner@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2010-12-07 09:53:11 +0000
committerpdanner <pdanner@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2010-12-07 09:53:11 +0000
commitf9e1c1419ebfccb6343460a989ed891054358bef (patch)
tree6e3a6cf07f56bdcb9d1d0ee24507fd6950620df3 /src
parentcded133a98ae8402ea56213fa0e3549222dfd3ec (diff)
downloadpdf-as-3-f9e1c1419ebfccb6343460a989ed891054358bef.tar.gz
pdf-as-3-f9e1c1419ebfccb6343460a989ed891054358bef.tar.bz2
pdf-as-3-f9e1c1419ebfccb6343460a989ed891054358bef.zip
Added enable_placeholder_search config parameter
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@692 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java71
-rw-r--r--src/main/resources/DefaultConfiguration.zipbin671784 -> 671973 bytes
2 files changed, 54 insertions, 17 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 2c9a9ad..dc6e106 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
@@ -39,6 +39,7 @@ import at.gv.egiz.pdfas.api.xmldsig.ReconstructXMLDsigResult;
import at.gv.egiz.pdfas.api.xmldsig.XMLDsigData;
import at.gv.egiz.pdfas.commandline.CommandlineConnectorChooser;
import at.gv.egiz.pdfas.exceptions.ErrorCode;
+import at.gv.egiz.pdfas.exceptions.framework.PlaceholderExtractionException;
import at.gv.egiz.pdfas.framework.ConnectorParameters;
import at.gv.egiz.pdfas.framework.DataSourceHolder;
import at.gv.egiz.pdfas.framework.config.SettingsHelper;
@@ -73,6 +74,7 @@ import at.knowcenter.wag.egov.egiz.exceptions.ConnectorException;
import at.knowcenter.wag.egov.egiz.exceptions.OutOfMemoryException;
import at.knowcenter.wag.egov.egiz.exceptions.PDFDocumentException;
import at.knowcenter.wag.egov.egiz.exceptions.PresentableException;
+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;
@@ -104,6 +106,8 @@ public class PdfAsObject implements PdfAs
*/
private static Log log = LogFactory.getLog(CheckHelper.class);
+ private static final String ENABLE_PLACEHOLDER_SEARCH_KEY = "enable_placeholder_search";
+
/**
* This constructor is for internal use only - use
* {@link at.gv.egiz.pdfas.PdfAsFactory} instead.
@@ -631,26 +635,24 @@ public class PdfAsObject implements PdfAs
}
signParameters.setDocument(PdfAS.applyStrictMode(signParameters.getDocument()));
-
- SignaturePlaceholderData spd = null;
- SignaturePlaceholderContext.setSignaturePlaceholderData(null);
- if (signParameters.isCheckForPlaceholder()) {
- spd = SignaturePlaceholderExtractor.extract(signParameters.getDocument().createInputStream(), signParameters.getPlaceholderId(), signParameters.getPlaceholderMatchMode());
- if (spd != null){
- if (spd.getProfile() != null)
- signParameters.setSignatureProfileId(spd.getProfile());
- if (spd.getType() != null)
- signParameters.setSignatureType(spd.getType());
- if (spd.getKey() != null)
- signParameters.setSignatureKeyIdentifier(spd.getKey());
- }
+
+ SettingsReader settings = SettingsReader.getInstance();
+ String defaultProfile = settings.getValueFromKey(SignatureTypes.DEFAULT_TYPE);
+
+ SignaturePlaceholderData spd = getSignaturePlaceholder(signParameters, defaultProfile);
+ if (spd != null){
+ if (spd.getProfile() != null)
+ signParameters.setSignatureProfileId(spd.getProfile());
+ if (spd.getType() != null)
+ signParameters.setSignatureType(spd.getType());
+ if (spd.getKey() != null)
+ signParameters.setSignatureKeyIdentifier(spd.getKey());
+ // check again, we might have destroyed something
+ CheckHelper.checkSignParameters(signParameters, true);
}
- CheckHelper.checkSignParameters(signParameters, true);
-
+
if (signParameters.getSignatureProfileId() == null)
{
- SettingsReader settings = SettingsReader.getInstance();
- String defaultProfile = settings.getValueFromKey(SignatureTypes.DEFAULT_TYPE);
signParameters.setSignatureProfileId(defaultProfile);
}
@@ -674,6 +676,41 @@ public class PdfAsObject implements PdfAs
}
+ private SignaturePlaceholderData getSignaturePlaceholder(SignParameters signParameters,
+ String defaultProfile) throws SettingsException, PDFDocumentException, PlaceholderExtractionException {
+ SignaturePlaceholderData spd = null;
+ SignaturePlaceholderContext.setSignaturePlaceholderData(null);
+
+ SettingsReader settings = SettingsReader.getInstance();
+
+ // check sig_obj.PROFILID.enable_placeholder_search
+ String profile = signParameters.getSignatureProfileId();
+ if (profile == null)
+ profile = defaultProfile;
+ String key = SignatureTypes.SIG_OBJ + profile + "." + ENABLE_PLACEHOLDER_SEARCH_KEY;
+ String enableSearchString = settings.getValueFromKey(key);
+
+ if (enableSearchString == null){
+ // check global enable_placeholder_search
+ enableSearchString = settings.getValueFromKey(ENABLE_PLACEHOLDER_SEARCH_KEY);
+ }
+
+ boolean enableSearch = true;
+ if (enableSearchString != null && enableSearchString.trim().equalsIgnoreCase("false"))
+ enableSearch = false;
+
+ if (enableSearch)
+ {
+ if (signParameters.isCheckForPlaceholder()) {
+ spd = SignaturePlaceholderExtractor.extract(
+ signParameters.getDocument().createInputStream(),
+ signParameters.getPlaceholderId(),
+ signParameters.getPlaceholderMatchMode());
+ }
+ }
+ return spd;
+ }
+
private Signator createSignator(String signatureType) throws SignatorFactoryException {
PdfASID signatorId = null;
if (signatureType.equals(Constants.SIGNATURE_TYPE_BINARY))
diff --git a/src/main/resources/DefaultConfiguration.zip b/src/main/resources/DefaultConfiguration.zip
index d83bacb..d665f61 100644
--- a/src/main/resources/DefaultConfiguration.zip
+++ b/src/main/resources/DefaultConfiguration.zip
Binary files differ