[java-plugin-shibd-saml] branch main updated: Add test using MetadataResolver and populate servlet request from Agent.

Codeberg noreply at shibboleth.net
Thu Nov 12 19:21:16 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/cf5801003f4a4d60483f79ea8d770791addd8e13

The following commit(s) were added to refs/heads/main by this push:
     new cf58010  Add test using MetadataResolver and populate servlet request from Agent.
cf58010 is described below

commit cf5801003f4a4d60483f79ea8d770791addd8e13
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Thu Nov 12 14:20:00 2026 -0500

    Add test using MetadataResolver and populate servlet request from Agent.
---
 .../idp/flows/sp/metadata/saml2/saml2-beans.xml    |  3 ++-
 .../sp/saml/flows/saml2/MetadataFlowTest.java      | 27 +++++++++++++++++++++-
 .../idp/module/conf/metadata-providers.xml         | 11 ++++++++-
 .../idp/module/conf/sp/saml-test-agents.xml        |  8 ++++++-
 .../sp/saml/saml2/profile/impl/AddMetadata.java    | 10 ++++++++
 5 files changed, 55 insertions(+), 4 deletions(-)

diff --git a/sp-saml-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/metadata/saml2/saml2-beans.xml b/sp-saml-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/metadata/saml2/saml2-beans.xml
index 477f721..c8e51d8 100644
--- a/sp-saml-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/metadata/saml2/saml2-beans.xml
+++ b/sp-saml-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/metadata/saml2/saml2-beans.xml
@@ -49,7 +49,8 @@
     <bean id="AddMetadata"
         class="net.shibboleth.sp.saml.saml2.profile.impl.AddMetadata" scope="prototype"
         p:velocityEngine-ref="shibboleth.VelocityEngine"
-        p:parserPool-ref="shibboleth.ParserPool" />
+        p:parserPool-ref="shibboleth.ParserPool"
+        p:httpServletRequestSupplier-ref="shibboleth.RemotedHttpServletRequestSupplier" />
         
     <bean id="SignMetadata"
             class="net.shibboleth.idp.profile.impl.WebFlowMessageHandlerAdaptor" scope="prototype"
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 541a764..5b81fd6 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
@@ -26,7 +26,9 @@ import org.opensaml.core.xml.XMLObject;
 import org.opensaml.core.xml.util.XMLObjectSupport;
 import org.opensaml.profile.action.EventIds;
 import org.opensaml.profile.context.ProfileRequestContext;
+import org.opensaml.saml.common.xml.SAMLConstants;
 import org.opensaml.saml.saml2.metadata.EntityDescriptor;
+import org.opensaml.saml.saml2.metadata.SPSSODescriptor;
 import org.opensaml.saml.security.impl.SAMLSignatureProfileValidator;
 import org.opensaml.security.credential.Credential;
 import org.opensaml.security.credential.UsageType;
@@ -197,6 +199,25 @@ public class MetadataFlowTest extends AbstractSPFlowTest {
         assertOutputMessageEvent(result, EventIds.IO_ERROR);
     }
 
+    /**
+     * Test flow with metadata via template and self-signed.
+     * 
+     * @throws Exception 
+     */
+    @Test
+    public void testMetadataViaResolver() throws Exception {
+        setBasicAuth("published.example.org", "foo");
+        
+        final DDF input = new DDF(null).structure();
+        setApplicationRequest("use-resolver", 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", null);
+    }
+    
     /**
      * Test flow with metadata via template and self-signed.
      * 
@@ -215,7 +236,7 @@ public class MetadataFlowTest extends AbstractSPFlowTest {
         assertOutputMessageSuccess(result);
         validateOutputMessage(result, "https://published.example.org", spCredential);
     }
-
+    
     /**
      * Test flow with metadata via template and self-signed.
      * 
@@ -276,6 +297,10 @@ public class MetadataFlowTest extends AbstractSPFlowTest {
             Assert.assertEquals(entity.getCacheDuration(), Duration.ofDays(1));
             Assert.assertTrue(Instant.now().plus(Duration.ofDays(6)).isBefore(entity.getValidUntil()));
             
+            final SPSSODescriptor role = entity.getSPSSODescriptor(SAMLConstants.SAML20P_NS);
+            assert role != null;
+            Assert.assertEquals(role.getAssertionConsumerServices().size(), 1);
+            
             if (signingKey != null) {
                 Assert.assertTrue(entity.isSigned());
                 final Signature sig = entity.getSignature();
diff --git a/sp-saml-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/metadata-providers.xml b/sp-saml-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/metadata-providers.xml
index 09fd1df..2bc9f2e 100644
--- a/sp-saml-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/metadata-providers.xml
+++ b/sp-saml-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/metadata-providers.xml
@@ -112,7 +112,16 @@ i8V7gp9HK+EimdSbgu7xktKlrqA2Rsn+dBoPSgOUs/LOGtCS9/biF0w=
                         Location="https://idp.example.org/idp/profile/SAML2/Artifact/SSO" />
                 </md:IDPSSODescriptor>
             </md:EntityDescriptor>
-        </md:EntitiesDescriptor>    
+            
+            <md:EntityDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata" entityID="https://published.example.org">
+                <md:SPSSODescriptor protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
+                    <md:AssertionConsumerService
+                        Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
+                        Location="https://published.example.org/Shibboleth.sso/Validate" index="1"/>
+                </md:SPSSODescriptor>
+            </md:EntityDescriptor>
+            
+        </md:EntitiesDescriptor>
     </MetadataProvider>
 
 </MetadataProvider>
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 b356ca2..29b3b6c 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
@@ -63,6 +63,9 @@
             <set>            
                 <bean p:id="alt-signing" parent="shibboleth.sp.Application"
                     p:profileConfigurations-ref="test.AlternateMetadataSigningProfileConfigurations" />
+                    
+                <bean p:id="use-resolver" parent="shibboleth.sp.Application"
+                    p:profileConfigurations-ref="shibboleth.sp.DefaultProfileConfigurations" />
             </set>
         </property>
     </bean>
@@ -89,6 +92,7 @@
     <util:list id="test.AlternateMetadataSigningProfileConfigurations">
         <bean parent="SAML2.Metadata"
             p:templatePath="%{idp.home}/metadata/${agentID}-default.xml"
+            p:useVelocity="true"
             p:signMetadata="true"
             p:signingCredential-ref="MetadataSigningCredential"
             p:lifetime="P7D"
@@ -147,7 +151,9 @@
         <ref bean="SAML2.ECP" />
         <!-- Turn off encryption so tests are easier to validate. -->
         <bean parent="SAML2.Logout" p:encryptNameIDs="false" />
-        <ref bean="SAML2.Metadata" />
+        <bean parent="SAML2.Metadata"
+            p:lifetime="P7D"
+            p:cacheDuration="P1D" />
     </util:list>
 
     <!--
diff --git a/sp-saml-impl/src/main/java/net/shibboleth/sp/saml/saml2/profile/impl/AddMetadata.java b/sp-saml-impl/src/main/java/net/shibboleth/sp/saml/saml2/profile/impl/AddMetadata.java
index b3f919d..f1b38ef 100644
--- a/sp-saml-impl/src/main/java/net/shibboleth/sp/saml/saml2/profile/impl/AddMetadata.java
+++ b/sp-saml-impl/src/main/java/net/shibboleth/sp/saml/saml2/profile/impl/AddMetadata.java
@@ -38,6 +38,7 @@ import net.shibboleth.sp.Agent;
 import net.shibboleth.sp.Application;
 import net.shibboleth.sp.context.AgentRequestContext;
 import net.shibboleth.sp.ddf.DDF;
+import net.shibboleth.sp.messaging.RemotedHttpServletRequestResponseContext;
 import net.shibboleth.sp.profile.AbstractApplicationAction;
 import net.shibboleth.sp.saml.saml2.SAML2ProtocolSupportService;
 import net.shibboleth.sp.saml.saml2.profile.config.MetadataPublishingProfileConfiguration;
@@ -59,6 +60,7 @@ import org.slf4j.Logger;
 import org.springframework.core.io.Resource;
 import org.springframework.webflow.execution.RequestContext;
 
+import jakarta.servlet.http.HttpServletRequest;
 import net.shibboleth.shared.primitive.LoggerFactory;
 import net.shibboleth.shared.resolver.CriteriaSet;
 import net.shibboleth.shared.resolver.ResolverException;
@@ -104,6 +106,9 @@ public class AddMetadata extends AbstractApplicationAction {
     
     /** The Velocity context variable name for the {@link ProfileRequestContext}. */
     @Nonnull @NotEmpty public static final String CONTEXT_KEY_PRC = "profileRequestContext";
+
+    /** The Velocity context variable name for the {@link HttpServletRequest}. */
+    @Nonnull @NotEmpty public static final String CONTEXT_KEY_REQUEST = "request";
     
     /** Class logger. */
     @Nonnull private Logger log = LoggerFactory.getLogger(AddMetadata.class);
@@ -359,6 +364,11 @@ public class AddMetadata extends AbstractApplicationAction {
         ctx.put(CONTEXT_KEY_PRC, profileRequestContext);
         
         final AgentRequestContext arc = ensureAgentRequestContext();
+        
+        if (arc.getRemotedHttpServletRequest() != null) {
+            ctx.put(CONTEXT_KEY_REQUEST, arc.getRemotedHttpServletRequest());
+        }
+        
         final Agent agent = arc.getAgent();
         final Application app = arc.getApplication();
         

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


More information about the commits mailing list