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 2021/03/29 09:52:31 UTC

[santuario-xml-security-java] branch master updated: SANTUARIO-565 - Registered Java class for http://www.w3.org/2007/05/xmldsig-more#ripemd160-rsa-MGF1 doesn't exist

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 13e4eee  SANTUARIO-565 - Registered Java class for http://www.w3.org/2007/05/xmldsig-more#ripemd160-rsa-MGF1 doesn't exist
13e4eee is described below

commit 13e4eee235c5fdb31fd43e111c251906c6d787fe
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Mon Mar 29 10:51:51 2021 +0100

    SANTUARIO-565 - Registered Java class for http://www.w3.org/2007/05/xmldsig-more#ripemd160-rsa-MGF1 doesn't exist
---
 .../org/apache/xml/security/resource/config.xml    |   2 -
 .../org/apache/xml/security/test/dom/InitTest.java | 111 ++++++++++++++++++++-
 2 files changed, 109 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/xml/security/resource/config.xml b/src/main/java/org/apache/xml/security/resource/config.xml
index 4444697..e460eb6 100644
--- a/src/main/java/org/apache/xml/security/resource/config.xml
+++ b/src/main/java/org/apache/xml/security/resource/config.xml
@@ -96,8 +96,6 @@
       <SignatureAlgorithm URI="http://www.w3.org/2001/04/xmldsig-more#rsa-sha512"
                           JAVACLASS="org.apache.xml.security.algorithms.implementations.SignatureBaseRSA$SignatureRSASHA512" />
                           
-      <SignatureAlgorithm URI="http://www.w3.org/2007/05/xmldsig-more#ripemd160-rsa-MGF1"
-                          JAVACLASS="org.apache.xml.security.algorithms.implementations.SignatureBaseRSA$SignatureRSARIPEMD160MGF1" />
       <SignatureAlgorithm URI="http://www.w3.org/2007/05/xmldsig-more#sha1-rsa-MGF1"
                           JAVACLASS="org.apache.xml.security.algorithms.implementations.SignatureBaseRSA$SignatureRSASHA1MGF1" />
       <SignatureAlgorithm URI="http://www.w3.org/2007/05/xmldsig-more#sha224-rsa-MGF1"
diff --git a/src/test/java/org/apache/xml/security/test/dom/InitTest.java b/src/test/java/org/apache/xml/security/test/dom/InitTest.java
index 65c8dfd..c7b7205 100644
--- a/src/test/java/org/apache/xml/security/test/dom/InitTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/InitTest.java
@@ -19,24 +19,42 @@
 package org.apache.xml.security.test.dom;
 
 
+import java.io.InputStream;
+
 import org.apache.xml.security.Init;
 import org.apache.xml.security.algorithms.JCEMapper;
 import org.apache.xml.security.algorithms.MessageDigestAlgorithm;
 import org.apache.xml.security.algorithms.SignatureAlgorithm;
+import org.apache.xml.security.algorithms.SignatureAlgorithmSpi;
+import org.apache.xml.security.c14n.Canonicalizer;
+import org.apache.xml.security.c14n.CanonicalizerSpi;
+import org.apache.xml.security.keys.keyresolver.KeyResolver;
+import org.apache.xml.security.keys.keyresolver.KeyResolverSpi;
 import org.apache.xml.security.signature.XMLSignature;
+import org.apache.xml.security.transforms.Transform;
+import org.apache.xml.security.transforms.TransformSpi;
+import org.apache.xml.security.utils.ClassLoaderUtils;
+import org.apache.xml.security.utils.XMLUtils;
+import org.apache.xml.security.utils.resolver.ResourceResolver;
+import org.apache.xml.security.utils.resolver.ResourceResolverSpi;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class InitTest {
 
+    private static final String CONFIG_FILE = "org/apache/xml/security/resource/config.xml";
+
     @BeforeAll
     public static void setup() {
-        System.setProperty("org.apache.xml.security.resource.config",
-                "org/apache/xml/security/resource/config.xml");
+        System.setProperty("org.apache.xml.security.resource.config", CONFIG_FILE);
     }
 
     @AfterAll
@@ -55,4 +73,93 @@ public class InitTest {
         assertEquals("MessageDigest", JCEMapper.getAlgorithmClassFromURI(MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA256));
     }
 
+    @org.junit.jupiter.api.Test
+    public void checkConfigFileImplementationsExist() throws Exception {
+        try (InputStream is = ClassLoaderUtils.getResourceAsStream(CONFIG_FILE, InitTest.class)) {
+            /* read library configuration file */
+            Document doc = XMLUtils.read(is, true);
+            Node config = doc.getFirstChild();
+            for (; config != null; config = config.getNextSibling()) {
+                if ("Configuration".equals(config.getLocalName())) {
+                    break;
+                }
+            }
+
+            for (Node el = config.getFirstChild(); el != null; el = el.getNextSibling()) {
+                if (Node.ELEMENT_NODE != el.getNodeType()) {
+                    continue;
+                }
+                String tag = el.getLocalName();
+
+                if ("CanonicalizationMethods".equals(tag)) {
+                    Element[] list =
+                            XMLUtils.selectNodes(el.getFirstChild(), Init.CONF_NS, "CanonicalizationMethod");
+
+                    for (Element element : list) {
+                        String javaClass =
+                                element.getAttributeNS(null, "JAVACLASS");
+
+                        Class<? extends CanonicalizerSpi> clazz =
+                                (Class<? extends CanonicalizerSpi>)
+                                        ClassLoaderUtils.loadClass(javaClass, Canonicalizer.class);
+                        assertNotNull(clazz);
+                    }
+                }
+
+                if ("TransformAlgorithms".equals(tag)) {
+                    Element[] tranElem =
+                            XMLUtils.selectNodes(el.getFirstChild(), Init.CONF_NS, "TransformAlgorithm");
+
+                    for (Element element : tranElem) {
+                        String javaClass =
+                                element.getAttributeNS(null, "JAVACLASS");
+
+                        Class<? extends TransformSpi> transformSpiClass =
+                                (Class<? extends TransformSpi>)
+                                        ClassLoaderUtils.loadClass(javaClass, Transform.class);
+                        assertNotNull(transformSpiClass);
+                    }
+                }
+
+                if ("SignatureAlgorithms".equals(tag)) {
+                    Element[] sigElems =
+                            XMLUtils.selectNodes(el.getFirstChild(), Init.CONF_NS, "SignatureAlgorithm");
+
+                    for (Element sigElem : sigElems) {
+                        String javaClass =
+                                sigElem.getAttributeNS(null, "JAVACLASS");
+
+                        Class<? extends SignatureAlgorithmSpi> clazz =
+                                (Class<? extends SignatureAlgorithmSpi>)
+                                        ClassLoaderUtils.loadClass(javaClass, SignatureAlgorithm.class);
+                        assertNotNull(clazz);
+                    }
+                }
+
+                if ("ResourceResolvers".equals(tag)) {
+                    Element[] resolverElem =
+                            XMLUtils.selectNodes(el.getFirstChild(), Init.CONF_NS, "Resolver");
+                    for (Element element : resolverElem) {
+                        String javaClass =
+                                element.getAttributeNS(null, "JAVACLASS");
+                        ResourceResolverSpi resourceResolverSpi =
+                                (ResourceResolverSpi)ClassLoaderUtils.loadClass(javaClass, ResourceResolver.class).newInstance();
+                        assertNotNull(resourceResolverSpi);
+                    }
+                }
+
+                if ("KeyResolver".equals(tag)){
+                    Element[] resolverElem =
+                            XMLUtils.selectNodes(el.getFirstChild(), Init.CONF_NS, "Resolver");
+                    for (Element element : resolverElem) {
+                        String javaClass =
+                                element.getAttributeNS(null, "JAVACLASS");
+                        KeyResolverSpi keyResolverSpi =
+                                (KeyResolverSpi) ClassLoaderUtils.loadClass(javaClass, KeyResolver.class).newInstance();
+                        assertNotNull(keyResolverSpi);
+                    }
+                }
+            }
+        }
+    }
 }