[java-plugin-shibd-saml] branch main updated: Add test using alternate signing key, fixing order of signing configs.

Codeberg noreply at shibboleth.net
Thu Nov 12 16:29:32 UTC 2026


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

codeberg pushed a commit to branch main
in repository java-plugin-shibd-saml.

View the commit online:
https://codeberg.org/Shibboleth/java-plugin-shibd-saml/commit/2f61efc921694ad13dcd569f93f7a518d6956366

The following commit(s) were added to refs/heads/main by this push:
     new 2f61efc  Add test using alternate signing key, fixing order of signing configs.
2f61efc is described below

commit 2f61efc921694ad13dcd569f93f7a518d6956366
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Thu Nov 12 11:28:58 2026 -0500

    Add test using alternate signing key, fixing order of signing configs.
---
 ...ignatureSigningConfigurationLookupFunction.java |  2 +-
 .../sp/saml/flows/saml2/MetadataFlowTest.java      | 39 ++++++++++++++++------
 .../idp/module/conf/sp/saml-test-agents.xml        | 20 +++++++++--
 .../idp/module/credentials/sp/metadata-signing.crt | 14 ++++++++
 .../idp/module/credentials/sp/metadata-signing.key |  5 +++
 .../net/shibboleth/sp/saml-test-beans.xml          | 12 +++++++
 6 files changed, 79 insertions(+), 13 deletions(-)

diff --git a/sp-saml-api/src/main/java/net/shibboleth/sp/saml/saml2/profile/config/navigate/MetadataSignatureSigningConfigurationLookupFunction.java b/sp-saml-api/src/main/java/net/shibboleth/sp/saml/saml2/profile/config/navigate/MetadataSignatureSigningConfigurationLookupFunction.java
index f7e7eb7..b689829 100644
--- a/sp-saml-api/src/main/java/net/shibboleth/sp/saml/saml2/profile/config/navigate/MetadataSignatureSigningConfigurationLookupFunction.java
+++ b/sp-saml-api/src/main/java/net/shibboleth/sp/saml/saml2/profile/config/navigate/MetadataSignatureSigningConfigurationLookupFunction.java
@@ -50,7 +50,7 @@ public class MetadataSignatureSigningConfigurationLookupFunction extends Signatu
                     final BasicSignatureSigningConfiguration special = new BasicSignatureSigningConfiguration();
                     special.setSigningCredentials(CollectionSupport.singletonList(cred));
                     if (configs != null) {
-                        configs.add(special);
+                        configs.add(0, special);
                     } else {
                         return CollectionSupport.singletonList(special);
                     }
diff --git a/sp-saml-conf-impl/src/test/java/net/shibboleth/sp/saml/flows/saml2/MetadataFlowTest.java b/sp-saml-conf-impl/src/test/java/net/shibboleth/sp/saml/flows/saml2/MetadataFlowTest.java
index b407ac9..541a764 100644
--- a/sp-saml-conf-impl/src/test/java/net/shibboleth/sp/saml/flows/saml2/MetadataFlowTest.java
+++ b/sp-saml-conf-impl/src/test/java/net/shibboleth/sp/saml/flows/saml2/MetadataFlowTest.java
@@ -54,7 +54,6 @@ import net.shibboleth.shared.xml.ParserPool;
 import net.shibboleth.sp.context.AgentRequestContext;
 import net.shibboleth.sp.ddf.DDF;
 import net.shibboleth.sp.flows.AbstractSPFlowTest;
-import net.shibboleth.sp.messaging.RemotedHttpServletRequest;
 import net.shibboleth.sp.messaging.RemotedHttpServletResponse;
 
 /**
@@ -87,10 +86,15 @@ public class MetadataFlowTest extends AbstractSPFlowTest {
     @Qualifier("shibboleth.ParserPool")
     protected ParserPool parserPool;
     
-    /** Dummy signing key. */
+    /** Default signing key. */
     @Autowired
     @Qualifier("default.sp.Credential")
     protected Credential spCredential;
+
+    /** Alternate signing key. */
+    @Autowired
+    @Qualifier("MetadataSigningCredential")
+    protected Credential metadataCredential;
     
     /** Constructor. */
     protected MetadataFlowTest() {
@@ -113,7 +117,6 @@ public class MetadataFlowTest extends AbstractSPFlowTest {
         setDefaultAuth();
         
         final DDF input = new DDF(null).structure();
-        input.addmember(RemotedHttpServletRequest.STRUCTURE_NAME).structure();
         setApplicationRequest("no-profile", input);
 
         final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
@@ -132,7 +135,6 @@ public class MetadataFlowTest extends AbstractSPFlowTest {
         setDefaultAuth();
         
         final DDF input = new DDF(null).structure();
-        input.addmember(RemotedHttpServletRequest.STRUCTURE_NAME).structure();
         setApplicationRequest(APPLICATION_ID, input);
 
         final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
@@ -151,7 +153,6 @@ public class MetadataFlowTest extends AbstractSPFlowTest {
         setDefaultAuth();
         
         final DDF input = new DDF(null).structure();
-        input.addmember(RemotedHttpServletRequest.STRUCTURE_NAME).structure();
         setApplicationRequest("no-metadata", input);
 
         final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
@@ -170,7 +171,6 @@ public class MetadataFlowTest extends AbstractSPFlowTest {
         setDefaultAuth();
         
         final DDF input = new DDF(null).structure();
-        input.addmember(RemotedHttpServletRequest.STRUCTURE_NAME).structure();
         setApplicationRequest("no-authority", input);
 
         final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
@@ -189,7 +189,6 @@ public class MetadataFlowTest extends AbstractSPFlowTest {
         setDefaultAuth();
         
         final DDF input = new DDF(null).structure();
-        input.addmember(RemotedHttpServletRequest.STRUCTURE_NAME).structure();
         setApplicationRequest("metadata-template", input);
 
         final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
@@ -199,16 +198,15 @@ public class MetadataFlowTest extends AbstractSPFlowTest {
     }
 
     /**
-     * Test flow with no metadata via template.
+     * Test flow with metadata via template and self-signed.
      * 
      * @throws Exception 
      */
     @Test
-    public void testSuccessMetadataViaTemplate() throws Exception {
+    public void testSelfSignedMetadataViaTemplate() throws Exception {
         setBasicAuth("published.example.org", "foo");
         
         final DDF input = new DDF(null).structure();
-        input.addmember(RemotedHttpServletRequest.STRUCTURE_NAME).structure();
         setApplicationRequest(APPLICATION_ID, input);
 
         final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
@@ -217,6 +215,25 @@ public class MetadataFlowTest extends AbstractSPFlowTest {
         assertOutputMessageSuccess(result);
         validateOutputMessage(result, "https://published.example.org", spCredential);
     }
+
+    /**
+     * Test flow with metadata via template and self-signed.
+     * 
+     * @throws Exception 
+     */
+    @Test
+    public void testAltSignedMetadataViaTemplate() throws Exception {
+        setBasicAuth("published.example.org", "foo");
+        
+        final DDF input = new DDF(null).structure();
+        setApplicationRequest("alt-signing", input);
+
+        final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
+        assertFlowExecutionResult(result, FLOW_ID);
+        assertFlowExecutionOutcome(result.getOutcome());
+        assertOutputMessageSuccess(result);
+        validateOutputMessage(result, "https://published.example.org", metadataCredential);
+    }
     
     /**
      * Decode returned metadata and run sanity checks against it.
@@ -247,6 +264,8 @@ public class MetadataFlowTest extends AbstractSPFlowTest {
         final byte[] body = http.getmember("response.data").unsafe_string();
         Assert.assertNotNull(body);
         
+        //System.out.println(new String(body));
+        
         final EntityDescriptor entity;
         try (final ByteArrayInputStream in = new ByteArrayInputStream(body)) {
             final XMLObject xml = XMLObjectSupport.unmarshallFromInputStream(parserPool, in);
diff --git a/sp-saml-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/sp/saml-test-agents.xml b/sp-saml-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/sp/saml-test-agents.xml
index d59978c..b356ca2 100644
--- a/sp-saml-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/sp/saml-test-agents.xml
+++ b/sp-saml-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/sp/saml-test-agents.xml
@@ -52,13 +52,20 @@
                     
                 <bean p:id="metadata-template" parent="shibboleth.sp.Application"
                     p:profileConfigurations-ref="test.MetadataTemplateProfileConfigurations" />
-            </set>
+                                </set>
         </property>
     </bean>
 
     <bean p:id="published.example.org" parent="shibboleth.sp.Agent" p:credentials="#{ {null : 'foo'} }"
             p:issuer="https://published.example.org"
-            p:profileConfigurations-ref="test.MetadataTemplateProfileConfigurations" />
+            p:profileConfigurations-ref="test.MetadataTemplateProfileConfigurations">
+        <property name="applications">
+            <set>            
+                <bean p:id="alt-signing" parent="shibboleth.sp.Application"
+                    p:profileConfigurations-ref="test.AlternateMetadataSigningProfileConfigurations" />
+            </set>
+        </property>
+    </bean>
 
     <util:list id="test.NoProfileConfigurations">
     </util:list>
@@ -79,6 +86,15 @@
             p:cacheDuration="P1D" />
     </util:list>
 
+    <util:list id="test.AlternateMetadataSigningProfileConfigurations">
+        <bean parent="SAML2.Metadata"
+            p:templatePath="%{idp.home}/metadata/${agentID}-default.xml"
+            p:signMetadata="true"
+            p:signingCredential-ref="MetadataSigningCredential"
+            p:lifetime="P7D"
+            p:cacheDuration="P1D" />
+    </util:list>
+
     <util:list id="test.responseBindingProfileConfigurations">
         <bean parent="SAML2.SSO" p:responseBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact" />
         <ref bean="SAML2.ECP" />
diff --git a/sp-saml-conf-impl/src/test/resources/net/shibboleth/idp/module/credentials/sp/metadata-signing.crt b/sp-saml-conf-impl/src/test/resources/net/shibboleth/idp/module/credentials/sp/metadata-signing.crt
new file mode 100644
index 0000000..bc81629
--- /dev/null
+++ b/sp-saml-conf-impl/src/test/resources/net/shibboleth/idp/module/credentials/sp/metadata-signing.crt
@@ -0,0 +1,14 @@
+-----BEGIN CERTIFICATE-----
+MIICDzCCAbWgAwIBAgIUEkClBr2sEjrXGCpaMGmaxCzapbowCgYIKoZIzj0EAwIw
+XTELMAkGA1UEBhMCVVMxDTALBgNVBAgMBE9oaW8xHjAcBgNVBAoMFVNoaWJib2xl
+dGggQ29uc29ydGl1bTEfMB0GA1UEAwwWZmVkZXJhdGlvbi5leGFtcGxlLm9yZzAe
+Fw0yNjExMTIxNjIyMjRaFw0yNjEyMTIxNjIyMjRaMF0xCzAJBgNVBAYTAlVTMQ0w
+CwYDVQQIDARPaGlvMR4wHAYDVQQKDBVTaGliYm9sZXRoIENvbnNvcnRpdW0xHzAd
+BgNVBAMMFmZlZGVyYXRpb24uZXhhbXBsZS5vcmcwWTATBgcqhkjOPQIBBggqhkjO
+PQMBBwNCAASENFyOo4RFOutLDPDeomkpOrCXDxhsJ3YYke1AFP4ei9/0iiW1hb7E
+8vRoQvlGA6xjYgOfWx1rM1ItqcbgyqCho1MwUTAdBgNVHQ4EFgQUuQXCyOhlbE0q
+CkH19v0ajUUzpG0wHwYDVR0jBBgwFoAUuQXCyOhlbE0qCkH19v0ajUUzpG0wDwYD
+VR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAgNIADBFAiEA6rUuyqlhdM4k5g3qn/0v
+4PhwWTu7A7es7YKjLtVCySUCID52Gm+JAgW7MXoxdLVDtF4BP7B3oPwN0D22qzBc
+Vh1g
+-----END CERTIFICATE-----
diff --git a/sp-saml-conf-impl/src/test/resources/net/shibboleth/idp/module/credentials/sp/metadata-signing.key b/sp-saml-conf-impl/src/test/resources/net/shibboleth/idp/module/credentials/sp/metadata-signing.key
new file mode 100644
index 0000000..b044435
--- /dev/null
+++ b/sp-saml-conf-impl/src/test/resources/net/shibboleth/idp/module/credentials/sp/metadata-signing.key
@@ -0,0 +1,5 @@
+-----BEGIN EC PRIVATE KEY-----
+MHcCAQEEIIYY/mp1FkVU5A9FPogGDm40B5x/mZV3DY8MOu9ElGNZoAoGCCqGSM49
+AwEHoUQDQgAEhDRcjqOERTrrSwzw3qJpKTqwlw8YbCd2GJHtQBT+Hovf9IoltYW+
+xPL0aEL5RgOsY2IDn1sdazNSLanG4MqgoQ==
+-----END EC PRIVATE KEY-----
diff --git a/sp-saml-conf-impl/src/test/resources/net/shibboleth/sp/saml-test-beans.xml b/sp-saml-conf-impl/src/test/resources/net/shibboleth/sp/saml-test-beans.xml
index 21a44a1..9f863d9 100644
--- a/sp-saml-conf-impl/src/test/resources/net/shibboleth/sp/saml-test-beans.xml
+++ b/sp-saml-conf-impl/src/test/resources/net/shibboleth/sp/saml-test-beans.xml
@@ -38,4 +38,16 @@
      <bean id="default.sp.Credential" class="org.opensaml.security.x509.BasicX509Credential"
         c:entityCertificate-ref="default.sp.SigningCertificate" />
 
+    <!-- For metadata signing. -->
+    
+    <bean id="MetadataSigningPrivateKey" class="net.shibboleth.shared.spring.security.factory.PrivateKeyFactoryBean"
+        p:resource="%{idp.home}/credentials/sp/metadata-signing.key" />
+
+    <bean id="MetadataSigningCertificate" class="net.shibboleth.shared.spring.security.factory.X509CertificateFactoryBean"
+        p:resource="%{idp.home}/credentials/sp/metadata-signing.crt" />
+
+     <bean id="MetadataSigningCredential" class="org.opensaml.security.x509.BasicX509Credential"
+        c:entityCertificate-ref="MetadataSigningCertificate"
+        c:privateKey-ref="MetadataSigningPrivateKey" />
+
 </beans>

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


More information about the commits mailing list