aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-pdfbox-2/src/main/java
diff options
context:
space:
mode:
authorThomas <>2023-12-19 14:34:22 +0100
committerThomas <>2023-12-19 14:34:22 +0100
commit9d00067f8f5910f246466bfbfabe0dfb713e7ff0 (patch)
tree721c37264e071456e4877e5a0921e696002a9b9f /pdf-as-pdfbox-2/src/main/java
parent1bf5a6f022837a28a41778f68c1b278bd2462512 (diff)
downloadpdf-as-4-9d00067f8f5910f246466bfbfabe0dfb713e7ff0.tar.gz
pdf-as-4-9d00067f8f5910f246466bfbfabe0dfb713e7ff0.tar.bz2
pdf-as-4-9d00067f8f5910f246466bfbfabe0dfb713e7ff0.zip
fix(core): optimize error-handling in case of errors during the raw signing steps
Diffstat (limited to 'pdf-as-pdfbox-2/src/main/java')
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java21
1 files changed, 19 insertions, 2 deletions
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 36d7dade..7aa46149 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
@@ -73,6 +73,8 @@ import org.apache.xmpbox.xml.DomXmpParser;
import at.gv.egiz.pdfas.common.exceptions.PDFASError;
import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
+import at.gv.egiz.pdfas.common.exceptions.PdfAsWrappedIOException;
+import at.gv.egiz.pdfas.common.exceptions.SLPdfAsException;
import at.gv.egiz.pdfas.common.messages.MessageResolver;
import at.gv.egiz.pdfas.common.settings.SignatureProfileSettings;
import at.gv.egiz.pdfas.lib.api.ByteArrayDataSource;
@@ -398,8 +400,13 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
runPDFAPreflight(new ByteArrayDataSource(pdfObject.getSignedDocument()));
}
- } catch (final IOException e1) {
- log.error("Can not save incremental update", e1);
+ } catch (PdfAsWrappedIOException e) {
+ logPdfUpdateError(e.getDecoratedException());
+ throw e.getDecoratedException();
+
+ } catch (final IOException e) {
+ logPdfUpdateError(e);
+ throw new PdfAsException("error.pdf.sig.06", e);
}
@@ -407,6 +414,16 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
}
+ private void logPdfUpdateError(Throwable e) {
+ if (e instanceof SLPdfAsException && !((SLPdfAsException) e).isCriticalError()) {
+ log.info("Can not save incremental update", e);
+
+ } else {
+ log.error("Can not save incremental update", e);
+
+ }
+ }
+
private void injectPdfUaContent(PDDocument doc, PDSignatureField signatureField, String sigFieldName,
SignatureProfileSettings signatureProfileSettings) throws PdfAsException {
try {