[java-opensaml] branch main updated: OSJ-392 - OpenSAML's strict processing mode does not load ADFS metadata

Scott Cantor cantor.2 at osu.edu
Tue Oct 17 12:43:17 UTC 2023


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch main
in repository java-opensaml.

View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=fc67491f6ebef8fcb6aa233209b99edd3aca11da

The following commit(s) were added to refs/heads/main by this push:
     new fc67491f6 OSJ-392 - OpenSAML's strict processing mode does not load ADFS metadata
fc67491f6 is described below

commit fc67491f6ebef8fcb6aa233209b99edd3aca11da
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Oct 17 08:43:14 2023 -0400

    OSJ-392 - OpenSAML's strict processing mode does not load ADFS metadata
    
    https://shibboleth.atlassian.net/browse/OSJ-392
    
    Disabled unit test that illustrates the bug.
---
 .../saml/saml2/metadata/tests/MetadataTest.java    | 47 +++++++++++++++++-----
 .../opensaml/saml/saml2/metadata/adfs-metadata.xml |  1 +
 2 files changed, 38 insertions(+), 10 deletions(-)

diff --git a/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/metadata/tests/MetadataTest.java b/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/metadata/tests/MetadataTest.java
index 4e91c9504..a544f7de1 100644
--- a/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/metadata/tests/MetadataTest.java
+++ b/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/metadata/tests/MetadataTest.java
@@ -14,6 +14,7 @@
 
 package org.opensaml.saml.saml2.metadata.tests;
 
+import java.io.IOException;
 import java.io.InputStream;
 
 import org.opensaml.core.testing.XMLObjectBaseTestCase;
@@ -31,7 +32,7 @@ import net.shibboleth.shared.xml.XMLParserException;
  * Test cases that parses real, "in-the-wild", metadata files. Currently uses the InCommon and SWITCH federation
  * metadata files (current as of the time this test was written).
  */
- at SuppressWarnings({"null", "javadoc"})
+ at SuppressWarnings({"null"})
 public class MetadataTest extends XMLObjectBaseTestCase {
 
     /**
@@ -51,8 +52,7 @@ public class MetadataTest extends XMLObjectBaseTestCase {
     public void testInCommonUnmarshall() throws XMLParserException, UnmarshallingException {
         String inCommonMDFile = "/org/opensaml/saml/saml2/metadata/InCommon-metadata.xml";
 
-        try {
-            InputStream in = MetadataTest.class.getResourceAsStream(inCommonMDFile);
+        try (final InputStream in = MetadataTest.class.getResourceAsStream(inCommonMDFile)) {
             Document inCommonMDDoc = parserPool.parse(in);
             Unmarshaller unmarshaller = XMLObjectProviderRegistrySupport.getUnmarshallerFactory().ensureUnmarshaller(
                     inCommonMDDoc.getDocumentElement());
@@ -65,6 +65,8 @@ public class MetadataTest extends XMLObjectBaseTestCase {
             Assert.fail("Unable to parse XML file: " + xe);
         } catch (UnmarshallingException ue) {
             Assert.fail("Unable to unmarshall XML: " + ue);
+        } catch (IOException ue) {
+            Assert.fail("Unable to close stream: " + ue);
         }
     }
 
@@ -75,8 +77,7 @@ public class MetadataTest extends XMLObjectBaseTestCase {
     public void testSWITCHUnmarshall() {
         String switchMDFile = "/org/opensaml/saml/saml2/metadata/metadata.switchaai_signed.xml";
 
-        try {
-            InputStream in = MetadataTest.class.getResourceAsStream(switchMDFile);
+        try (final InputStream in = MetadataTest.class.getResourceAsStream(switchMDFile)) {
             Document switchMDDoc = parserPool.parse(in);
             Unmarshaller unmarshaller = XMLObjectProviderRegistrySupport.getUnmarshallerFactory().ensureUnmarshaller(
                     switchMDDoc.getDocumentElement());
@@ -89,18 +90,19 @@ public class MetadataTest extends XMLObjectBaseTestCase {
             Assert.fail("Unable to parse XML file: " + xe);
         } catch (UnmarshallingException ue) {
             Assert.fail("Unable to unmarshall XML: " + ue);
+        } catch (final IOException ue) {
+            Assert.fail("Unable to close stream: " + ue);
         }
     }
     
     /**
-     * Tests unmarshalling an SWITCH metadata document.
+     * Tests unmarshalling a UKFed metadata document.
      */
     @Test
     public void testUKFedUnmarshall() {
-        String switchMDFile = "/org/opensaml/saml/saml2/metadata/ukfederation-metadata.xml";
+        String ukMDFile = "/org/opensaml/saml/saml2/metadata/ukfederation-metadata.xml";
 
-        try {
-            InputStream in = MetadataTest.class.getResourceAsStream(switchMDFile);
+        try (final InputStream in = MetadataTest.class.getResourceAsStream(ukMDFile)) {
             Document ukFedDoc = parserPool.parse(in);            
             Unmarshaller unmarshaller = XMLObjectProviderRegistrySupport.getUnmarshallerFactory().ensureUnmarshaller(
                     ukFedDoc.getDocumentElement());
@@ -112,6 +114,31 @@ public class MetadataTest extends XMLObjectBaseTestCase {
             Assert.fail("Unable to parse XML file: " + xe);
         } catch (UnmarshallingException ue) {
             Assert.fail("Unable to unmarshall XML: " + ue);
+        } catch (final IOException ue) {
+            Assert.fail("Unable to close stream: " + ue);
+        }
+    }
+
+    /** Tests unmarshalling an ADFS metadata document with their "fun" extensions. */
+    @Test(enabled=false)
+    public void testADFSUnmarshall() {
+        String adfsMDFile = "/org/opensaml/saml/saml2/metadata/adfs-metadata.xml";
+
+        try (final InputStream in = MetadataTest.class.getResourceAsStream(adfsMDFile)) {
+            Document adfsDoc = parserPool.parse(in);            
+            Unmarshaller unmarshaller = XMLObjectProviderRegistrySupport.getUnmarshallerFactory().ensureUnmarshaller(
+                    adfsDoc.getDocumentElement());
+            XMLObject ukFedMD = unmarshaller.unmarshall(adfsDoc.getDocumentElement());
+
+            Assert.assertEquals(ukFedMD.getElementQName().getLocalPart(), "EntityDescriptor",
+                    "First element of ADFS metadata was not expected EntityDescriptor");
+        } catch (XMLParserException xe) {
+            Assert.fail("Unable to parse XML file: " + xe);
+        } catch (UnmarshallingException ue) {
+            Assert.fail("Unable to unmarshall XML: " + ue);
+        } catch (final IOException ue) {
+            Assert.fail("Unable to close stream: " + ue);
         }
     }
-}
+    
+}
\ No newline at end of file
diff --git a/opensaml-saml-impl/src/test/resources/org/opensaml/saml/saml2/metadata/adfs-metadata.xml b/opensaml-saml-impl/src/test/resources/org/opensaml/saml/saml2/metadata/adfs-metadata.xml
new file mode 100644
index 000000000..8c3bd2a6e
--- /dev/null
+++ b/opensaml-saml-impl/src/test/resources/org/opensaml/saml/saml2/metadata/adfs-metadata.xml
@@ -0,0 +1 @@
+<EntityDescriptor ID="_762114d1-6c5f-4637-9feb-e3f001309047" entityID="http://adfs.example.org/adfs/services/trust" xmlns="urn:oasis:names:tc:SAML:2.0:metadata"><ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/><ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/><ds:Reference URI="#_762114d1-6c5f-4637-9feb-e3f001309047"><ds:Transforms><ds:Transform Algor [...]
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list