aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJaven O'Neal <onealj@apache.org>2016-07-02 05:11:01 +0000
committerJaven O'Neal <onealj@apache.org>2016-07-02 05:11:01 +0000
commiteb9a3975e77a5c7b55240abb2d14b1758609c689 (patch)
tree350b2e098849b751caa7e4b8ded1a190fddfa01f /src
parentdb9af88db2f798014a91f002ab039b854bdee3b3 (diff)
downloadpoi-eb9a3975e77a5c7b55240abb2d14b1758609c689.tar.gz
poi-eb9a3975e77a5c7b55240abb2d14b1758609c689.zip
findbugs REC_CATCH_EXCEPTION: catch specific exception types and include more helpful reason rather than catching all Exceptions with one misleading reason
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1751023 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java
index c2fb8be2c4..4eb8e49513 100644
--- a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java
+++ b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java
@@ -47,6 +47,7 @@ import javax.xml.crypto.dsig.dom.DOMValidateContext;
import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -97,6 +98,7 @@ import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.w3c.dom.events.EventListener;
import org.w3c.dom.events.EventTarget;
+import org.xml.sax.SAXException;
/**
@@ -261,8 +263,24 @@ public class SignatureInfo implements SignatureConfigurable {
}
return valid;
- } catch (Exception e) {
- String s = "error in marshalling and validating the signature";
+ } catch (IOException e) {
+ String s = "error in reading document";
+ LOG.log(POILogger.ERROR, s, e);
+ throw new EncryptedDocumentException(s, e);
+ } catch (SAXException e) {
+ String s = "error in parsing document";
+ LOG.log(POILogger.ERROR, s, e);
+ throw new EncryptedDocumentException(s, e);
+ } catch (XPathExpressionException e) {
+ String s = "error in searching document with xpath expression";
+ LOG.log(POILogger.ERROR, s, e);
+ throw new EncryptedDocumentException(s, e);
+ } catch (MarshalException e) {
+ String s = "error in unmarshalling the signature";
+ LOG.log(POILogger.ERROR, s, e);
+ throw new EncryptedDocumentException(s, e);
+ } catch (XMLSignatureException e) {
+ String s = "error in validating the signature";
LOG.log(POILogger.ERROR, s, e);
throw new EncryptedDocumentException(s, e);
}