[java-opensaml] branch main updated: Fix null checker issues.

Brent Putman putmanb at georgetown.edu
Sat Mar 22 03:28:52 UTC 2025


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

putmanb 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=512a91f43b249811bf8978f316ba19bf4d07d432

The following commit(s) were added to refs/heads/main by this push:
     new 512a91f43 Fix null checker issues.
512a91f43 is described below

commit 512a91f43b249811bf8978f316ba19bf4d07d432
Author: Brent Putman <putmanb at georgetown.edu>
AuthorDate: Fri Mar 21 23:24:32 2025 -0400

    Fix null checker issues.
---
 .../binding/decoding/impl/HTTPPostSimpleSignDecoder.java   | 14 ++++++++++----
 .../binding/decoding/impl/HTTPRedirectDeflateDecoder.java  |  4 +++-
 .../decoding/impl/HTTPPostSimpleSignDecoderTest.java       |  7 +++++--
 3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/decoding/impl/HTTPPostSimpleSignDecoder.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/decoding/impl/HTTPPostSimpleSignDecoder.java
index fc61db6cc..fea706cc4 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/decoding/impl/HTTPPostSimpleSignDecoder.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/decoding/impl/HTTPPostSimpleSignDecoder.java
@@ -69,8 +69,10 @@ public class HTTPPostSimpleSignDecoder extends HTTPPostDecoder {
             log.warn("Failed to build signed content data, signature evaluation will be skipped");
             return;
         }
-
-        getMessageContext().ensureSubcontext(SimpleSignatureContext.class).setSignedContent(signedContent);
+        
+        final MessageContext messageContext = getMessageContext();
+        assert messageContext != null;
+        messageContext.ensureSubcontext(SimpleSignatureContext.class).setSignedContent(signedContent);
     }
 
     /**
@@ -87,10 +89,14 @@ public class HTTPPostSimpleSignDecoder extends HTTPPostDecoder {
         final String samlMsg;
         try {
             if (request.getParameter("SAMLRequest") != null) {
-                samlMsg = new String(Base64Support.decode(request.getParameter("SAMLRequest")), "UTF-8");
+                final String paramValue = request.getParameter("SAMLRequest");
+                assert paramValue != null;
+                samlMsg = new String(Base64Support.decode(paramValue), "UTF-8");
                 builder.append("SAMLRequest=" + samlMsg);
             } else if (request.getParameter("SAMLResponse") != null) {
-                samlMsg = new String(Base64Support.decode(request.getParameter("SAMLResponse")), "UTF-8");
+                final String paramValue = request.getParameter("SAMLResponse");
+                assert paramValue != null;
+                samlMsg = new String(Base64Support.decode(paramValue), "UTF-8");
                 builder.append("SAMLResponse=" + samlMsg);
             } else {
                 log.warn("Could not extract either a SAMLRequest or a SAMLResponse from the form control data");
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/decoding/impl/HTTPRedirectDeflateDecoder.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/decoding/impl/HTTPRedirectDeflateDecoder.java
index c30baa982..bd6dd8b3e 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/decoding/impl/HTTPRedirectDeflateDecoder.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/decoding/impl/HTTPRedirectDeflateDecoder.java
@@ -112,6 +112,7 @@ public class HTTPRedirectDeflateDecoder extends BaseSAMLHttpServletRequestDecode
             samlMessageParamName = "SAMLResponse";
             samlMessageEncoded = request.getParameter("SAMLResponse");
         }
+        assert samlMessageParamName != null;
 
         if (samlMessageEncoded != null) {
             try (final InputStream samlMessageIns = decodeMessage(samlMessageEncoded)) {
@@ -176,6 +177,7 @@ public class HTTPRedirectDeflateDecoder extends BaseSAMLHttpServletRequestDecode
             log.warn("Could not extract signed content string from query string");
             return null;
         }
+        assert constructed != null;
         log.debug("Constructed signed content string for HTTP-Redirect DEFLATE {}", constructed);
 
         try {
@@ -197,7 +199,7 @@ public class HTTPRedirectDeflateDecoder extends BaseSAMLHttpServletRequestDecode
      * 
      * @throws MessageDecodingException thrown if there is an error during request processing
      */
-    @Nonnull @NotEmpty private String buildSignedContentString(@Nullable final String queryString,
+    @Nullable @NotEmpty private String buildSignedContentString(@Nullable final String queryString,
             @Nonnull final String samlMessageParamName, @Nonnull final String samlMessage)
                     throws MessageDecodingException {
 
diff --git a/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/binding/decoding/impl/HTTPPostSimpleSignDecoderTest.java b/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/binding/decoding/impl/HTTPPostSimpleSignDecoderTest.java
index d2218daf8..8aee74284 100644
--- a/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/binding/decoding/impl/HTTPPostSimpleSignDecoderTest.java
+++ b/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/binding/decoding/impl/HTTPPostSimpleSignDecoderTest.java
@@ -29,7 +29,6 @@ import org.testng.annotations.Test;
 
 import net.shibboleth.shared.codec.Base64Support;
 import net.shibboleth.shared.codec.DecodingException;
-import net.shibboleth.shared.net.URISupport;
 import net.shibboleth.shared.testing.ConstantSupplier;
 
 /**
@@ -50,9 +49,11 @@ public class HTTPPostSimpleSignDecoderTest extends XMLObjectBaseTestCase {
     protected void setUp() throws Exception {
         httpRequest = new MockHttpServletRequest();
         httpRequest.setMethod("POST");
+        assert expectedRelayValue != null;
         httpRequest.setParameter("RelayState", expectedRelayValue);
         
         decoder = new HTTPPostSimpleSignDecoder();
+        assert parserPool != null;
         decoder.setParserPool(parserPool);
         decoder.setHttpServletRequestSupplier(new ConstantSupplier<>(httpRequest));
         decoder.initialize();
@@ -102,8 +103,10 @@ public class HTTPPostSimpleSignDecoderTest extends XMLObjectBaseTestCase {
         Assert.assertEquals(SAMLBindingSupport.getRelayState(messageContext), expectedRelayValue);
         Assert.assertNotNull(messageContext.ensureSubcontext(SimpleSignatureContext.class).getSignedContent());
         
+        final String requestValue = httpRequest.getParameter("SAMLRequest");
+        assert requestValue != null;
         final byte[] expectedSignedContent = new StringBuilder()
-                .append("SAMLRequest=" + new String(Base64Support.decode(httpRequest.getParameter("SAMLRequest")), "UTF-8"))
+                .append("SAMLRequest=" + new String(Base64Support.decode(requestValue), "UTF-8"))
                 .append("&")
                 .append("RelayState=" + httpRequest.getParameter("RelayState"))
                 .append("&")

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


More information about the commits mailing list