From ca7b9d0863dcc1c02849a23db66310146f91c104 Mon Sep 17 00:00:00 2001
From: Thomas <>
Date: Tue, 27 Jun 2023 08:56:21 +0200
Subject: feat(web): add request parameter to enable/disable QR-code
placeholder searching on request level
---
.../pdfas/lib/api/IConfigurationConstants.java | 5 +++-
.../gv/egiz/pdfas/lib/api/sign/SignParameter.java | 17 ++++++++++++
.../gv/egiz/pdfas/lib/impl/SignParameterImpl.java | 4 +++
.../lib/impl/placeholder/PlaceholderFilter.java | 32 ++++++++++++++--------
4 files changed, 45 insertions(+), 13 deletions(-)
(limited to 'pdf-as-lib/src/main/java')
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
@@ -70,6 +70,23 @@ public interface SignParameter extends PdfAsParameter {
*/
void setPlaceHolderId(String id);
+ /**
+ * Is QR-Code placeholder search enabled for this request.
+ *
+ * @return true
if it's enabled, otherwise false
+ */
+ boolean isPlaceHolderSearchEnabled();
+
+
+ /**
+ * Enable / disable QR-Code placeholder search on request level.
+ *
+ *
Default value is true
true
to enable, false
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;
}
--
cgit v1.2.3