[java-opensaml] branch main updated: OSJ-441 - Uri compliance validation with fragments

Codeberg noreply at shibboleth.net
Wed Apr 29 14:38:55 UTC 2026


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

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

View the commit online:
https://codeberg.org/Shibboleth/java-opensaml/commit/0b049d5b6dc4b6c50b6dc2764861934b556f85f8

The following commit(s) were added to refs/heads/main by this push:
     new 0b049d5b6 OSJ-441 - Uri compliance validation with fragments
0b049d5b6 is described below

commit 0b049d5b6dc4b6c50b6dc2764861934b556f85f8
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Wed Apr 29 10:38:45 2026 -0400

    OSJ-441 - Uri compliance validation with fragments
    
    https://shibboleth.atlassian.net/browse/OSJ-441
    
    Add canary test.
    Actual fix included in commit da8c93f.
---
 .../impl/HTTPRedirectDeflateEncoderTest.java       | 45 ++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/binding/encoding/impl/HTTPRedirectDeflateEncoderTest.java b/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/binding/encoding/impl/HTTPRedirectDeflateEncoderTest.java
index 342cfeea3..4c887e381 100644
--- a/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/binding/encoding/impl/HTTPRedirectDeflateEncoderTest.java
+++ b/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/binding/encoding/impl/HTTPRedirectDeflateEncoderTest.java
@@ -15,6 +15,7 @@
 package org.opensaml.saml.saml2.binding.encoding.impl;
 
 import java.io.ByteArrayInputStream;
+import java.io.IOException;
 import java.security.KeyPair;
 import java.time.Instant;
 import java.util.Map;
@@ -23,6 +24,7 @@ import java.util.zip.InflaterInputStream;
 
 import org.opensaml.core.testing.XMLObjectBaseTestCase;
 import org.opensaml.messaging.context.MessageContext;
+import org.opensaml.messaging.encoder.MessageEncodingException;
 import org.opensaml.saml.common.SAMLObjectBuilder;
 import org.opensaml.saml.common.SAMLVersion;
 import org.opensaml.saml.common.binding.SAMLBindingSupport;
@@ -54,6 +56,49 @@ import net.shibboleth.shared.testing.ConstantSupplier;
  */
 public class HTTPRedirectDeflateEncoderTest extends XMLObjectBaseTestCase {
     
+    /**
+     * Tests that the encoder catches a runtime exception.
+     * 
+     * @throws Exception if something goes wrong
+     */
+    @Test(expectedExceptions=MessageEncodingException.class)
+    public void testRuntimeException() throws Exception {
+        SAMLObjectBuilder<Response> responseBuilder =
+                (SAMLObjectBuilder<Response>) builderFactory.<Response>ensureBuilder(Response.DEFAULT_ELEMENT_NAME);
+        Response samlMessage = responseBuilder.buildObject();
+        samlMessage.setID("foo");
+        samlMessage.setVersion(SAMLVersion.VERSION_20);
+        samlMessage.setIssueInstant(Instant.ofEpochMilli(0));
+
+        final SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory
+                .<Endpoint>ensureBuilder(AssertionConsumerService.DEFAULT_ELEMENT_NAME);
+        final Endpoint samlEndpoint = endpointBuilder.buildObject();
+        samlEndpoint.setLocation("http://example.org");
+        samlEndpoint.setResponseLocation("http://example.org/response");
+        
+        final MessageContext messageContext = new MessageContext();
+        messageContext.setMessage(samlMessage);
+        SAMLBindingSupport.setRelayState(messageContext, "relay");
+        messageContext.ensureSubcontext(SAMLPeerEntityContext.class)
+            .ensureSubcontext(SAMLEndpointContext.class).setEndpoint(samlEndpoint);
+        
+        MockHttpServletResponse response = new MockHttpServletResponse() {
+            /** {@inheritDoc} */
+            @Override
+            public void sendRedirect(String url) throws IOException {
+                throw new IllegalArgumentException("Sanity check");
+            }
+        };
+        
+        final HTTPRedirectDeflateEncoder encoder = new HTTPRedirectDeflateEncoder();
+        encoder.setMessageContext(messageContext);
+        encoder.setHttpServletResponseSupplier(new ConstantSupplier<>(response));
+                        
+        encoder.initialize();
+        encoder.prepareContext();
+        encoder.encode();
+    }
+    
     /**
      * Tests encoding a SAML message to an servlet response.
      * 

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


More information about the commits mailing list