You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by co...@apache.org on 2020/05/20 06:59:53 UTC

[santuario-xml-security-java] branch master updated: Some final refactoring

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/santuario-xml-security-java.git


The following commit(s) were added to refs/heads/master by this push:
     new 80ebe0a  Some final refactoring
80ebe0a is described below

commit 80ebe0a519ffb402e840ba9ecb0f58c4ce3fe576
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Wed May 20 07:59:14 2020 +0100

    Some final refactoring
---
 .../internal/dom/DOMRSAPSSSignatureMethod.java     |  6 +--
 .../jcp/xml/dsig/internal/dom/DOMReference.java    | 11 +-----
 .../apache/jcp/xml/dsig/internal/dom/DOMUtils.java | 43 ----------------------
 .../xml/crypto/test/dsig/XMLSignatureTest.java     |  1 +
 4 files changed, 5 insertions(+), 56 deletions(-)

diff --git a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMRSAPSSSignatureMethod.java b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMRSAPSSSignatureMethod.java
index 7764621..ba98427 100644
--- a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMRSAPSSSignatureMethod.java
+++ b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMRSAPSSSignatureMethod.java
@@ -267,10 +267,8 @@ public abstract class DOMRSAPSSSignatureMethod extends AbstractDOMSignatureMetho
             ((DOMSignedInfo)si).canonicalize(context, outputStream);
 
             return signature.sign();
-        } catch (SignatureException se) {
-            throw new XMLSignatureException(se);
-        } catch (IOException ioe) {
-            throw new XMLSignatureException(ioe);
+        } catch (SignatureException | IOException e) {
+            throw new XMLSignatureException(e);
         }
     }
 
diff --git a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMReference.java b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMReference.java
index 317e35b..86c799f 100644
--- a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMReference.java
+++ b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMReference.java
@@ -532,15 +532,8 @@ public final class DOMReference extends DOMStructure
                 this.dis = dos.getInputStream();
             }
             return dos.getDigestValue();
-        } catch (NoSuchAlgorithmException e) {
-            throw new XMLSignatureException(e);
-        } catch (TransformException e) {
-            throw new XMLSignatureException(e);
-        } catch (MarshalException e) {
-            throw new XMLSignatureException(e);
-        } catch (IOException e) {
-            throw new XMLSignatureException(e);
-        } catch (org.apache.xml.security.c14n.CanonicalizationException e) {
+        } catch (NoSuchAlgorithmException | TransformException | MarshalException
+                | IOException | org.apache.xml.security.c14n.CanonicalizationException e) {
             throw new XMLSignatureException(e);
         } finally { //NOPMD
             if (dos != null) {
diff --git a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMUtils.java b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMUtils.java
index 137a198..6955c0d 100644
--- a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMUtils.java
+++ b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMUtils.java
@@ -22,11 +22,7 @@
 package org.apache.jcp.xml.dsig.internal.dom;
 
 import java.security.spec.AlgorithmParameterSpec;
-import java.util.AbstractSet;
-import java.util.Iterator;
 import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Set;
 
 import javax.xml.XMLConstants;
 import javax.xml.crypto.MarshalException;
@@ -43,7 +39,6 @@ import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
 
 /**
  * Useful static DOM utility methods.
@@ -277,44 +272,6 @@ public final class DOMUtils {
     }
 
     /**
-     * Returns a Set of <code>Node</code>s, backed by the specified
-     * <code>NodeList</code>.
-     *
-     * @param nl the NodeList
-     * @return a Set of Nodes
-     */
-    public static Set<Node> nodeSet(NodeList nl) {
-        return new NodeSet(nl);
-    }
-
-    static class NodeSet extends AbstractSet<Node> {
-        private NodeList nl;
-        public NodeSet(NodeList nl) {
-            this.nl = nl;
-        }
-
-        public int size() { return nl.getLength(); }
-        public Iterator<Node> iterator() {
-            return new Iterator<Node>() {
-                private int index;
-
-                public void remove() {
-                    throw new UnsupportedOperationException();
-                }
-                public Node next() {
-                    if (!hasNext()) {
-                        throw new NoSuchElementException();
-                    }
-                    return nl.item(index++);
-                }
-                public boolean hasNext() {
-                    return index < nl.getLength();
-                }
-            };
-        }
-    }
-
-    /**
      * Returns the prefix associated with the specified namespace URI
      *
      * @param context contains the namespace map
diff --git a/src/test/java/javax/xml/crypto/test/dsig/XMLSignatureTest.java b/src/test/java/javax/xml/crypto/test/dsig/XMLSignatureTest.java
index 580c3d4..ae46e3b 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/XMLSignatureTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/XMLSignatureTest.java
@@ -295,6 +295,7 @@ public class XMLSignatureTest {
 
         DOMValidateContext dvc = new DOMValidateContext
             (VALIDATE_KEYS[1], doc.getDocumentElement());
+        dvc.setProperty("org.jcp.xml.dsig.validateManifests", Boolean.TRUE);
         XMLSignature sig2 = fac.unmarshalXMLSignature(dvc);
 
         if (!sig.equals(sig2)) {