diff options
author | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2014-10-15 18:07:20 +0200 |
---|---|---|
committer | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2014-10-15 18:07:20 +0200 |
commit | 0b663afa4d0167df1e838e1f37bb5862e8951037 (patch) | |
tree | 1b962dedd3c2e1eba042c89fbf6191b42218bd36 /pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/util | |
parent | d9dcd54eae2b3a8e46dce69c96eca7c97f1be429 (diff) | |
download | pdf-as-4-0b663afa4d0167df1e838e1f37bb5862e8951037.tar.gz pdf-as-4-0b663afa4d0167df1e838e1f37bb5862e8951037.tar.bz2 pdf-as-4-0b663afa4d0167df1e838e1f37bb5862e8951037.zip |
PDF-AS Errorhandling redesign only PDFASError Exceptions are returned
!
Diffstat (limited to 'pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/util')
-rw-r--r-- | pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/util/SignatureUtils.java | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/util/SignatureUtils.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/util/SignatureUtils.java index 608818f9..3b992e46 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/util/SignatureUtils.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/util/SignatureUtils.java @@ -16,11 +16,12 @@ import org.apache.pdfbox.pdmodel.PDDocument; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import at.gv.egiz.pdfas.common.exceptions.PdfAsSignatureException; +import at.gv.egiz.pdfas.common.exceptions.ErrorConstants; +import at.gv.egiz.pdfas.common.exceptions.PDFASError; import at.gv.egiz.pdfas.lib.api.verify.VerifyResult; import at.gv.egiz.pdfas.lib.impl.verify.VerifyResultImpl; -public class SignatureUtils { +public class SignatureUtils implements ErrorConstants { private static final Logger logger = LoggerFactory .getLogger(SignatureUtils.class); @@ -68,7 +69,7 @@ public class SignatureUtils { } - public static VerifyResult verifySignature(byte[] signature, byte[] input) throws PdfAsSignatureException { + public static VerifyResult verifySignature(byte[] signature, byte[] input) throws PDFASError { //List<VerifyResult> results = new ArrayList<VerifyResult>(); try { SignedData signedData = new SignedData(new ByteArrayInputStream( @@ -79,11 +80,13 @@ public class SignatureUtils { // get the signer infos SignerInfo[] signerInfos = signedData.getSignerInfos(); if (signerInfos.length == 0) { - throw new PdfAsSignatureException("Invalid Signature (no signer info created!)", null); + logger.error("Invalid signature (no signer information)"); + throw new PDFASError(ERROR_SIG_INVALID_BKU_SIG); } if (signerInfos.length != 1) { - throw new PdfAsSignatureException("Invalid Signature (multiple signer infos found!)", null); + logger.error("Invalid signature (multiple signer information)"); + throw new PDFASError(ERROR_SIG_INVALID_BKU_SIG); } // verify the signatures //for (int i = 0; i < signerInfos.length; i++) { @@ -114,15 +117,15 @@ public class SignatureUtils { verifyResult.setSignerCertificate(signedData .getCertificate(signerInfos[0] .getSignerIdentifier())); - throw new PdfAsSignatureException("error.pdf.sig.08", ex); + throw new PDFASError(ERROR_SIG_INVALID_BKU_SIG, ex); } return verifyResult; //} } catch (CMSException e) { - throw new PdfAsSignatureException("error.pdf.sig.08", e); + throw new PDFASError(ERROR_SIG_INVALID_BKU_SIG, e); } catch (IOException e) { - throw new PdfAsSignatureException("error.pdf.sig.08", e); + throw new PDFASError(ERROR_SIG_INVALID_BKU_SIG, e); } |