aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignaturePlaceholderExtractor.java11
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java15
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java6
3 files changed, 19 insertions, 13 deletions
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignaturePlaceholderExtractor.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignaturePlaceholderExtractor.java
index 9043aae7..0998a2eb 100644
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignaturePlaceholderExtractor.java
+++ b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignaturePlaceholderExtractor.java
@@ -106,8 +106,6 @@ public class SignaturePlaceholderExtractor extends PDFStreamEngine implements Pl
private static List<SignaturePlaceholderData> placeholders = new ArrayList<>();
private int currentPage = 0;
private PDDocument doc;
-
-
private SignaturePlaceholderExtractor(String placeholderId,
int placeholderMatchMode, PDDocument doc) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException {
@@ -128,13 +126,18 @@ public class SignaturePlaceholderExtractor extends PDFStreamEngine implements Pl
this.doc = doc;
}
- public static List<SignaturePlaceholderData> listPlaceholders() {
+ public static List<SignaturePlaceholderData> getPlaceholders() {
return placeholders;
}
- public static void clearPlaceholders(){
+ public void setPlaceholders(List<SignaturePlaceholderData> placeholders) {
+ this.placeholders = placeholders;
+ }
+
+ public static void clearPlaceholders() {
placeholders.clear();
}
+
/**
* Search the document for placeholder images and possibly included
* additional info.<br/>
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java
index 82c48d96..cff5fc7f 100644
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java
+++ b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java
@@ -107,6 +107,7 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
PDFASSignatureInterface genericSigner) throws PdfAsException {
PDFAsVisualSignatureProperties properties = null;
+ List<SignaturePlaceholderData> placeholders;
String placeholder_id = "";
if(PlaceholderWebConfiguration.getValue(PLACEHOLDER_WEB_ID) != null && !PlaceholderWebConfiguration.getValue(PLACEHOLDER_WEB_ID).equalsIgnoreCase("")){
@@ -155,11 +156,9 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
signature.setSubFilter(COSName.getPDFName(signer.getPDFSubFilter()));
SignaturePlaceholderData signaturePlaceholderDataInit = PlaceholderFilter.checkPlaceholderSignatureLocation(pdfObject.getStatus(), pdfObject.getStatus().getSettings(), placeholder_id);
- //gives a list of all placeholders
- List<SignaturePlaceholderData> placeholders = SignaturePlaceholderExtractor.listPlaceholders();
- if(placeholders!=null){
- SignaturePlaceholderExtractor.clearPlaceholders();
- }
+ placeholders = SignaturePlaceholderExtractor.getPlaceholders();
+
+
if(placeholder_id.equalsIgnoreCase("")){
if(checkAvailablePlaceholders(placeholders,existingSignatureLocations(doc))!=null)
{
@@ -177,7 +176,8 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
if (signaturePlaceholderData != null) {
// Placeholder found!
- logger.info("Placeholder data found.");
+ placeholders.clear();
+ logger.info("Placeholder data found.");
if (signaturePlaceholderData.getProfile() != null) {
logger.debug("Placeholder Profile set to: " + signaturePlaceholderData.getProfile());
requestedSignature.setSignatureProfileID(signaturePlaceholderData.getProfile());
@@ -900,12 +900,15 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
//find first available placeholder
public SignaturePlaceholderData checkAvailablePlaceholders(List<SignaturePlaceholderData> placeholders, List<String> existingPlaceholders) {
SignaturePlaceholderData result = null;
+
+ if(placeholders!=null){
for(int i = 0; i < placeholders.size(); ++i) {
if(!existingPlaceholders.contains(placeholders.get(i).getPlaceholderName())) {
result = placeholders.get(i);
break;
}
}
+ }
return result;
}
} \ No newline at end of file
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 8fe679f2..2c2af9a9 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
@@ -27,6 +27,7 @@ import at.gv.egiz.pdfas.common.exceptions.PDFASError;
import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
import at.gv.egiz.pdfas.common.exceptions.PdfAsSettingsValidationException;
import at.gv.egiz.pdfas.common.settings.ISettings;
+import at.gv.egiz.pdfas.common.utils.StringUtils;
import at.gv.egiz.pdfas.lib.api.IConfigurationConstants;
import at.gv.egiz.pdfas.lib.api.PdfAsFactory;
import at.gv.egiz.pdfas.lib.api.verify.VerifyParameter.SignatureVerificationLevel;
@@ -343,10 +344,9 @@ public class ExternSignServlet extends HttpServlet {
//read and set placholder web id
try{
String placeholder_id = PdfAsParameterExtractor.getPlaceholderId(request);
- if(!placeholder_id.equalsIgnoreCase("")) {
+ if(org.apache.commons.lang3.StringUtils.isNotEmpty(placeholder_id)) {
PlaceholderWebConfiguration.setValue(IConfigurationConstants.PLACEHOLDER_WEB_ID, placeholder_id);
- } else
- {
+ } else {
PlaceholderWebConfiguration.clear();
}