summaryrefslogtreecommitdiff
path: root/pdf-over-signer
diff options
context:
space:
mode:
authorJakob Heher <jakob.heher@iaik.tugraz.at>2022-10-04 15:02:43 +0200
committerJakob Heher <jakob.heher@iaik.tugraz.at>2022-10-04 15:02:43 +0200
commitd6f4b34eae2e977cdd0339fb17302976fdae0574 (patch)
tree3f7cb16ebb790e740698b07eb31308a47a54d6d0 /pdf-over-signer
parent69e427953c0a877762a1c89da266dba70195459a (diff)
downloadpdf-over-d6f4b34eae2e977cdd0339fb17302976fdae0574.tar.gz
pdf-over-d6f4b34eae2e977cdd0339fb17302976fdae0574.tar.bz2
pdf-over-d6f4b34eae2e977cdd0339fb17302976fdae0574.zip
QR code handling
Diffstat (limited to 'pdf-over-signer')
-rw-r--r--pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java b/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java
index 80a7e14d..c7be135f 100644
--- a/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java
+++ b/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java
@@ -11,8 +11,10 @@ import at.asit.pdfover.signer.ByteArrayDocumentSource;
import at.asit.pdfover.signer.SignResult;
import at.asit.pdfover.signer.SignatureException;
import at.asit.pdfover.signer.SignaturePosition;
+import at.asit.pdfover.signer.UserCancelledException;
import at.gv.egiz.pdfas.common.exceptions.PDFASError;
import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
+import at.gv.egiz.pdfas.common.exceptions.SLPdfAsException;
import at.gv.egiz.pdfas.lib.api.ByteArrayDataSource;
import at.gv.egiz.pdfas.lib.api.Configuration;
import at.gv.egiz.pdfas.lib.api.IConfigurationConstants;
@@ -104,7 +106,7 @@ public class PdfAs4Signer {
}
}
- public static SignResult sign(PdfAs4SigningState state) throws SignatureException {
+ public static SignResult sign(PdfAs4SigningState state) throws SignatureException, UserCancelledException {
try {
if (state == null) {
throw new SignatureException("Incorrect SigningState!");
@@ -154,6 +156,16 @@ public class PdfAs4Signer {
return result;
}
} catch (PdfAsException | PDFASError e) {
+ { // TODO hack around pdf-as not handling this error code properly cf. #124
+ Throwable rootCause = e;
+ while (rootCause.getCause() != null)
+ rootCause = rootCause.getCause();
+ try { /* error code 6001 is user cancellation */
+ if (((SLPdfAsException)rootCause).getMessage().startsWith("6001 :"))
+ throw new UserCancelledException();
+ } catch (ClassCastException e2) { /* fall through to wrapped throw */}
+ }
+
throw new SignatureException(e);
}
}