ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [ws-wss4j] branch master updated: Picking up some fixes from Santuario
Date Fri, 03 Apr 2020 15:13:14 GMT
This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ws-wss4j.git


The following commit(s) were added to refs/heads/master by this push:
     new deed5a3  Picking up some fixes from Santuario
deed5a3 is described below

commit deed5a3c90cc22f3c90638cdaabaf35bab5306a1
Author: Colm O hEigeartaigh <coheigea@apache.org>
AuthorDate: Fri Apr 3 16:12:55 2020 +0100

    Picking up some fixes from Santuario
---
 .../transform/AttachmentContentSignatureTransform.java    |  5 ++---
 .../java/org/apache/wss4j/dom/util/EncryptionUtils.java   | 15 +++++++++------
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/ws-security-dom/src/main/java/org/apache/wss4j/dom/transform/AttachmentContentSignatureTransform.java
b/ws-security-dom/src/main/java/org/apache/wss4j/dom/transform/AttachmentContentSignatureTransform.java
index 6f3c39a..f0c9e03 100644
--- a/ws-security-dom/src/main/java/org/apache/wss4j/dom/transform/AttachmentContentSignatureTransform.java
+++ b/ws-security-dom/src/main/java/org/apache/wss4j/dom/transform/AttachmentContentSignatureTransform.java
@@ -29,8 +29,8 @@ import org.apache.wss4j.dom.WSConstants;
 import org.apache.xml.security.c14n.CanonicalizationException;
 import org.apache.xml.security.c14n.Canonicalizer;
 import org.apache.xml.security.c14n.InvalidCanonicalizerException;
+import org.apache.xml.security.parser.XMLParserException;
 import org.apache.xml.security.signature.XMLSignatureInput;
-import org.xml.sax.SAXException;
 
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.CallbackHandler;
@@ -42,7 +42,6 @@ import javax.xml.crypto.XMLStructure;
 import javax.xml.crypto.dsig.TransformException;
 import javax.xml.crypto.dsig.TransformService;
 import javax.xml.crypto.dsig.spec.TransformParameterSpec;
-import javax.xml.parsers.ParserConfigurationException;
 
 import java.io.BufferedInputStream;
 import java.io.ByteArrayInputStream;
@@ -239,7 +238,7 @@ public class AttachmentContentSignatureTransform extends TransformService
{
             }
             return null;
         } catch (IOException | InvalidCanonicalizerException | CanonicalizationException
-            | ParserConfigurationException | SAXException e) {
+            | XMLParserException e) {
             throw new TransformException(e);
         }
     }
diff --git a/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/EncryptionUtils.java
b/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/EncryptionUtils.java
index b0a0063..98615c2 100644
--- a/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/EncryptionUtils.java
+++ b/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/EncryptionUtils.java
@@ -33,6 +33,7 @@ import org.apache.xml.security.algorithms.JCEMapper;
 import org.apache.xml.security.encryption.Serializer;
 import org.apache.xml.security.encryption.XMLCipher;
 import org.apache.xml.security.encryption.XMLEncryptionException;
+import org.apache.xml.security.parser.XMLParserException;
 import org.apache.xml.security.utils.JavaUtils;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
@@ -360,7 +361,7 @@ public final class EncryptionUtils {
        SecretKey symmetricKey, String symEncAlgo, CallbackHandler attachmentCallbackHandler,
        String xopURI, Element encData
    ) throws WSSecurityException, IOException, UnsupportedCallbackException, NoSuchAlgorithmException,
-        NoSuchPaddingException, ParserConfigurationException, SAXException {
+        NoSuchPaddingException, ParserConfigurationException, XMLParserException {
 
         if (attachmentCallbackHandler == null) {
             throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_CHECK);
@@ -395,11 +396,13 @@ public final class EncryptionUtils {
         Document document = null;
         try {
             document = org.apache.xml.security.utils.XMLUtils.read(new ByteArrayInputStream(bytes),
true);
-        } catch (SAXException ex) {
-            // A prefix may not have been bound, try to fix the DOM Element in this case.
-            String fixedElementStr = setParentPrefixes(encData, new String(bytes));
-            document = org.apache.xml.security.utils.XMLUtils.read(
-                new ByteArrayInputStream(fixedElementStr.getBytes()), true);
+        } catch (XMLParserException ex) {
+            if (ex.getCause() instanceof SAXException) {
+                // A prefix may not have been bound, try to fix the DOM Element in this case.
+                String fixedElementStr = setParentPrefixes(encData, new String(bytes));
+                document = org.apache.xml.security.utils.XMLUtils.read(
+                    new ByteArrayInputStream(fixedElementStr.getBytes()), true);
+            }
         }
 
         Node decryptedNode =


Mime
View raw message