diff options
8 files changed, 65 insertions, 17 deletions
diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/processing/DocumentToSign.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/processing/DocumentToSign.java index 6d92b312..7d1928df 100644 --- a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/processing/DocumentToSign.java +++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/processing/DocumentToSign.java @@ -18,7 +18,9 @@ public class DocumentToSign implements Serializable { String qrCodeContent; String profile; + + boolean placeholderSearchEnabled = true; String placeHolderId; - + } diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java index bd9e9d99..d031e2f7 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java @@ -46,10 +46,13 @@ public interface IConfigurationConstants { public static final String MIN_WIDTH = "minWidth"; public static final String PLACEHOLDER_ID = "placeholder_id"; - public static final String PLACEHOLDER_WEB_ID = "placeholder_web_id"; public static final String PLACEHOLDER_MODE = "placeholder_mode"; public static final String PLACEHOLDER_PROFILE_OVERWRITE = "placeholder_profile_overwrite"; + + public static final String PLACEHOLDER_WEB_ID = "placeholder_web_id"; + public static final String PLACEHOLDER_WEB_ENABLED = "placeholder_web_enabled"; + public static final String PLACEHOLDER_SEARCH_ENABLED = "enable_placeholder_search"; public static final String DEFAULT_SIGNATURE_PROFILE = SIG_OBJECT + SEPERATOR + TYPE + SEPERATOR + DEFAULT; diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/sign/SignParameter.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/sign/SignParameter.java index 3485c9ea..e123d453 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/sign/SignParameter.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/sign/SignParameter.java @@ -71,6 +71,23 @@ public interface SignParameter extends PdfAsParameter { void setPlaceHolderId(String id); /** + * Is QR-Code placeholder search enabled for this request. + * + * @return <code>true</code> if it's enabled, otherwise <code>false</code> + */ + boolean isPlaceHolderSearchEnabled(); + + + /** + * Enable / disable QR-Code placeholder search on request level. + * + * <p>Default value is <code>true</code></p> + * + * @param flag <code>true</code> to enable, <code>false</code> to disable + */ + void setPlaceHolderSearchEnabled(boolean flag); + + /** * Sets the signer to use * * diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/SignParameterImpl.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/SignParameterImpl.java index 2dc047f1..06b1b34f 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/SignParameterImpl.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/SignParameterImpl.java @@ -44,6 +44,10 @@ public class SignParameterImpl extends PdfAsParameterImpl implements SignParamet @Setter protected String placeHolderId; + @Getter + @Setter + protected boolean placeHolderSearchEnabled; + protected DataSource output = null; protected IPlainSigner signer = null; protected OutputStream outputStream = null; diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/PlaceholderFilter.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/PlaceholderFilter.java index 0d652b76..1615482f 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/PlaceholderFilter.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/PlaceholderFilter.java @@ -33,7 +33,9 @@ import at.gv.egiz.pdfas.common.exceptions.PdfAsException; import at.gv.egiz.pdfas.common.settings.ISettings; import at.gv.egiz.pdfas.lib.api.IConfigurationConstants; import at.gv.egiz.pdfas.lib.impl.status.OperationStatus; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class PlaceholderFilter implements IConfigurationConstants, PlaceholderExtractorConstants { @@ -42,19 +44,25 @@ public class PlaceholderFilter implements IConfigurationConstants, String signingProfile = status.getRequestedSignature().getSignatureProfileID(); - if (status.getPlaceholderConfiguration().isGlobalPlaceholderEnabled()) { - String defaultPlaceHolderId = settings.getValue(PLACEHOLDER_ID); - return status.getBackend().getPlaceholderExtractor().extract( - status.getPdfObject(), getPlaceHolderId(placeholderId, defaultPlaceHolderId) , - getPlaceHolderMode(settings, PLACEHOLDER_MATCH_MODE_SORTED)); + if (status.getSignParamter().isPlaceHolderSearchEnabled()) { + if (status.getPlaceholderConfiguration().isGlobalPlaceholderEnabled()) { + String defaultPlaceHolderId = settings.getValue(PLACEHOLDER_ID); + return status.getBackend().getPlaceholderExtractor().extract( + status.getPdfObject(), getPlaceHolderId(placeholderId, defaultPlaceHolderId) , + getPlaceHolderMode(settings, PLACEHOLDER_MATCH_MODE_SORTED)); - } else if (status.getPlaceholderConfiguration().isProfileConfigurationEnabled(signingProfile)) { - String defaultPlaceHolderId = status.getPlaceholderConfiguration().getProfilePlaceholderID(signingProfile); - return status.getBackend().getPlaceholderExtractor().extract( - status.getPdfObject(), getPlaceHolderId(placeholderId, defaultPlaceHolderId), - getPlaceHolderMode(settings, - StringUtils.isNotEmpty(defaultPlaceHolderId) ? PLACEHOLDER_MATCH_MODE_MODERATE : PLACEHOLDER_MATCH_MODE_SORTED)); - } + } else if (status.getPlaceholderConfiguration().isProfileConfigurationEnabled(signingProfile)) { + String defaultPlaceHolderId = status.getPlaceholderConfiguration().getProfilePlaceholderID(signingProfile); + return status.getBackend().getPlaceholderExtractor().extract( + status.getPdfObject(), getPlaceHolderId(placeholderId, defaultPlaceHolderId), + getPlaceHolderMode(settings, + StringUtils.isNotEmpty(defaultPlaceHolderId) ? PLACEHOLDER_MATCH_MODE_MODERATE : PLACEHOLDER_MATCH_MODE_SORTED)); + } + } else { + log.debug("Searching placeholders are disabled for this request"); + + } + return null; } diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java index 0de8ca71..5db82e3a 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java @@ -539,6 +539,7 @@ public class PdfAsHelper { // set Signature Position signParameter.setSignaturePosition(documentToSign.getPosition()); signParameter.setPlaceHolderId(documentToSign.getPlaceHolderId()); + signParameter.setPlaceHolderSearchEnabled(documentToSign.isPlaceholderSearchEnabled()); // Set Preprocessor if (coreParams.getPreprocessor() != null) { @@ -664,7 +665,7 @@ public class PdfAsHelper { // set Signature Position signParameter.setSignaturePosition(pdfToSign.getPosition()); signParameter.setPlaceHolderId(pdfToSign.getPlaceHolderId()); - + signParameter.setPlaceHolderSearchEnabled(pdfToSign.isPlaceholderSearchEnabled()); signParameter.setDynamicSignatureBlockArguments(coreSignParams.getSignatureBlockParameters()); return pdfAs.startSign(signParameter); diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java index 31fbf46d..1ed85e98 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java @@ -30,11 +30,13 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; -import at.gv.egiz.pdfas.lib.api.IConfigurationConstants; -import at.gv.egiz.pdfas.lib.api.verify.VerifyParameter.SignatureVerificationLevel; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import at.gv.egiz.pdfas.lib.api.IConfigurationConstants; +import at.gv.egiz.pdfas.lib.api.verify.VerifyParameter.SignatureVerificationLevel; + public class PdfAsParameterExtractor { public static final String PARAM_CONNECTOR = "connector"; @@ -118,6 +120,16 @@ public class PdfAsParameterExtractor { return (String)request.getAttribute(IConfigurationConstants.PLACEHOLDER_WEB_ID); } + public static boolean isPlaceholderSearchEnabled(HttpServletRequest request) { + String value = (String)request.getAttribute(IConfigurationConstants.PLACEHOLDER_WEB_ENABLED); + if (StringUtils.isNotEmpty(value)) { + return Boolean.valueOf(value); + + } else { + return true; + } + } + public static String getTransactionId(HttpServletRequest request) { String transactionId = (String)request.getAttribute(PARAM_TRANSACTION_ID); return transactionId; diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java index b9f3f3de..0123e30d 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java @@ -380,6 +380,7 @@ public class ExternSignServlet extends HttpServlet { document.setPosition(PdfAsHelper.buildPosString(request, response)); document.setProfile(PdfAsParameterExtractor.getSigType(request)); document.setPlaceHolderId(PdfAsParameterExtractor.getPlaceholderId(request)); + document.setPlaceholderSearchEnabled(PdfAsParameterExtractor.isPlaceholderSearchEnabled(request)); document.setQrCodeContent(qrcodeContent); document.setFileName(PdfAsHelper.getPDFFileName(request)); data.addDocumentToSign(document); |