You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by on...@apache.org on 2016/07/02 05:11:01 UTC
svn commit: r1751023 -
/poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java
Author: onealj
Date: Sat Jul 2 05:11:01 2016
New Revision: 1751023
URL: http://svn.apache.org/viewvc?rev=1751023&view=rev
Log:
findbugs REC_CATCH_EXCEPTION: catch specific exception types and include more helpful reason rather than catching all Exceptions with one misleading reason
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java
Modified: poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java?rev=1751023&r1=1751022&r2=1751023&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java Sat Jul 2 05:11:01 2016
@@ -47,6 +47,7 @@ import javax.xml.crypto.dsig.dom.DOMVali
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 Si
}
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);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org