aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz/pdfas/impl/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/gv/egiz/pdfas/impl/api')
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java71
1 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))