[java-opensaml] branch main updated: Null cleanup.
Codeberg
noreply at shibboleth.net
Tue Nov 25 15:23:23 UTC 2025
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/8eaaf5a8afc456b5466591f3008a64b0b7bec215
The following commit(s) were added to refs/heads/main by this push:
new 8eaaf5a8a Null cleanup.
8eaaf5a8a is described below
commit 8eaaf5a8afc456b5466591f3008a64b0b7bec215
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Nov 25 10:23:11 2025 -0500
Null cleanup.
---
.../org/opensaml/core/config/ConfigurationService.java | 3 +--
.../xml/persist/impl/FilesystemLoadSaveManagerTest.java | 2 +-
.../servlet/BaseHttpServletResponseXMLMessageEncoder.java | 5 +----
.../saml2/binding/decoding/impl/HTTPArtifactDecoder.java | 1 +
.../saml/saml2/binding/decoding/impl/HTTPPostDecoder.java | 1 +
.../binding/decoding/impl/HTTPPostSimpleSignDecoder.java | 6 +++++-
.../binding/decoding/impl/HTTPRedirectDeflateDecoder.java | 10 ++++++++--
.../saml2/binding/encoding/impl/HTTPArtifactEncoder.java | 6 +++++-
.../org/opensaml/saml/saml2/encryption/tests/ECDHTest.java | 4 ++--
.../encoder/http/impl/HttpClientRequestSOAP11Encoder.java | 14 ++++++++++----
.../encryption/support/tests/DHWithExplicitKDFTest.java | 5 +++--
.../encryption/support/tests/DHWithLegacyKDFTest.java | 5 +++--
.../opensaml/xmlsec/encryption/support/tests/ECDHTest.java | 5 +++--
13 files changed, 44 insertions(+), 23 deletions(-)
diff --git a/opensaml-core-api/src/main/java/org/opensaml/core/config/ConfigurationService.java b/opensaml-core-api/src/main/java/org/opensaml/core/config/ConfigurationService.java
index 3b0bb975e..8894babe9 100644
--- a/opensaml-core-api/src/main/java/org/opensaml/core/config/ConfigurationService.java
+++ b/opensaml-core-api/src/main/java/org/opensaml/core/config/ConfigurationService.java
@@ -24,7 +24,6 @@ import javax.annotation.Nullable;
import org.opensaml.core.config.provider.EmptyConfigurationProperties;
import org.opensaml.core.config.provider.MapBasedConfiguration;
import org.opensaml.core.config.provider.PropertiesAdapter;
-import org.opensaml.core.config.provider.SystemPropertyConfigurationPropertiesSource;
import org.slf4j.Logger;
import net.shibboleth.shared.annotation.constraint.NotEmpty;
@@ -280,7 +279,7 @@ public class ConfigurationService {
*/
@Nonnull @NotEmpty protected static String getPartitionName() {
final ConfigurationProperties configProperties = getConfigurationProperties();
- String partitionName = configProperties.getProperty(PROPERTY_PARTITION_NAME, DEFAULT_PARTITION_NAME);
+ final String partitionName = configProperties.getProperty(PROPERTY_PARTITION_NAME, DEFAULT_PARTITION_NAME);
LOG.trace("Resolved effective configuration partition name '{}'", partitionName);
return partitionName;
}
diff --git a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/persist/impl/FilesystemLoadSaveManagerTest.java b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/persist/impl/FilesystemLoadSaveManagerTest.java
index 3cc1571f6..87ac1737f 100644
--- a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/persist/impl/FilesystemLoadSaveManagerTest.java
+++ b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/persist/impl/FilesystemLoadSaveManagerTest.java
@@ -440,7 +440,7 @@ public class FilesystemLoadSaveManagerTest extends XMLObjectBaseTestCase {
for (String expectedKey : expectedKeys) {
Assert.assertTrue(manager.exists(expectedKey));
SimpleXMLObject sxo = manager.load(expectedKey);
- Assert.assertNotNull(sxo);
+ assert sxo != null;
Assert.assertEquals(sxo.getObjectMetadata().get(XMLObjectSource.class).size(), 1);
}
diff --git a/opensaml-messaging-api/src/main/java/org/opensaml/messaging/encoder/servlet/BaseHttpServletResponseXMLMessageEncoder.java b/opensaml-messaging-api/src/main/java/org/opensaml/messaging/encoder/servlet/BaseHttpServletResponseXMLMessageEncoder.java
index 77a2318b8..42049497c 100644
--- a/opensaml-messaging-api/src/main/java/org/opensaml/messaging/encoder/servlet/BaseHttpServletResponseXMLMessageEncoder.java
+++ b/opensaml-messaging-api/src/main/java/org/opensaml/messaging/encoder/servlet/BaseHttpServletResponseXMLMessageEncoder.java
@@ -33,9 +33,6 @@ import net.shibboleth.shared.xml.SerializeSupport;
* Base class for message encoders which encode XML messages to HttpServletResponse.
*/
public abstract class BaseHttpServletResponseXMLMessageEncoder extends AbstractHttpServletResponseMessageEncoder {
-
- /** Used to log protocol messages. */
- @Nonnull private Logger protocolMessageLog = LoggerFactory.getLogger("PROTOCOL_MESSAGE");
/** Class logger. */
@Nonnull private final Logger log = LoggerFactory.getLogger(BaseHttpServletResponseXMLMessageEncoder.class);
@@ -67,7 +64,7 @@ public abstract class BaseHttpServletResponseXMLMessageEncoder extends Abstract
try {
final Element dom = XMLObjectSupport.marshall(XMLObject.class.cast(message));
return SerializeSupport.prettyPrintXML(dom);
- } catch (MarshallingException e) {
+ } catch (final MarshallingException e) {
log.error("Unable to marshall message for logging purposes", e);
return null;
}
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/decoding/impl/HTTPArtifactDecoder.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/decoding/impl/HTTPArtifactDecoder.java
index 3bacf4702..be5b2302d 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/decoding/impl/HTTPArtifactDecoder.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/decoding/impl/HTTPArtifactDecoder.java
@@ -358,6 +358,7 @@ public class HTTPArtifactDecoder extends BaseSAMLHttpServletRequestDecoder imple
protected void doDecode() throws MessageDecodingException {
final MessageContext messageContext = new MessageContext();
final HttpServletRequest request = getHttpServletRequest();
+ assert request != null;
final String relayState = StringSupport.trim(request.getParameter("RelayState"));
log.debug("Decoded SAML relay state of: {}", relayState);
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/decoding/impl/HTTPPostDecoder.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/decoding/impl/HTTPPostDecoder.java
index f74d0668a..d0e7c8cb1 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/decoding/impl/HTTPPostDecoder.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/decoding/impl/HTTPPostDecoder.java
@@ -76,6 +76,7 @@ public class HTTPPostDecoder extends BaseSAMLHttpServletRequestDecoder implement
protected void doDecode() throws MessageDecodingException {
final MessageContext messageContext = new MessageContext();
final HttpServletRequest request = getHttpServletRequest();
+ assert request != null;
if (!"POST".equalsIgnoreCase(request.getMethod())) {
throw new MessageDecodingException("This message decoder only supports the HTTP POST method");
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 dac75508e..f71c3a50c 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
@@ -51,11 +51,14 @@ public class HTTPPostSimpleSignDecoder extends HTTPPostDecoder {
* @param messageContext the current message context
*/
protected void populateBindingContext(@Nonnull final MessageContext messageContext) {
+ final HttpServletRequest request = getHttpServletRequest();
+ assert request != null;
+
final SAMLBindingContext bindingContext = messageContext.ensureSubcontext(SAMLBindingContext.class);
bindingContext.setBindingUri(getBindingURI());
bindingContext.setBindingDescriptor(getBindingDescriptor());
bindingContext.setHasBindingSignature(
- !Strings.isNullOrEmpty(getHttpServletRequest().getParameter("Signature")));
+ !Strings.isNullOrEmpty(request.getParameter("Signature")));
bindingContext.setIntendedDestinationEndpointURIRequired(SAMLBindingSupport.isMessageSigned(messageContext));
}
@@ -84,6 +87,7 @@ public class HTTPPostSimpleSignDecoder extends HTTPPostDecoder {
*/
@Nullable protected byte[] getSignedContent() throws MessageDecodingException {
final HttpServletRequest request = getHttpServletRequest();
+ assert request != null;
final StringBuilder builder = new StringBuilder();
final String samlMsg;
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 c5832294b..134f0fd56 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
@@ -89,6 +89,7 @@ public class HTTPRedirectDeflateDecoder extends BaseSAMLHttpServletRequestDecode
protected void doDecode() throws MessageDecodingException {
final MessageContext messageContext = new MessageContext();
final HttpServletRequest request = getHttpServletRequest();
+ assert request != null;
if (!"GET".equalsIgnoreCase(request.getMethod())) {
throw new MessageDecodingException("This message decoder only supports the HTTP GET method");
@@ -169,7 +170,9 @@ public class HTTPRedirectDeflateDecoder extends BaseSAMLHttpServletRequestDecode
// We have to construct a string containing the signature input by accessing the
// request directly. We can't use the decoded parameters because we need the raw
// data and URL-encoding isn't canonical.
- final String queryString = getHttpServletRequest().getQueryString();
+ final HttpServletRequest request = getHttpServletRequest();
+ assert request != null;
+ final String queryString = request.getQueryString();
log.debug("Constructing signed content string from URL query string {}", queryString);
final String constructed = buildSignedContentString(queryString, samlMessageParamName, samlMessage);
@@ -306,11 +309,14 @@ public class HTTPRedirectDeflateDecoder extends BaseSAMLHttpServletRequestDecode
* @param messageContext the current message context
*/
protected void populateBindingContext(@Nonnull final MessageContext messageContext) {
+ final HttpServletRequest request = getHttpServletRequest();
+ assert request != null;
+
final SAMLBindingContext bindingContext = messageContext.ensureSubcontext(SAMLBindingContext.class);
bindingContext.setBindingUri(getBindingURI());
bindingContext.setBindingDescriptor(bindingDescriptor);
bindingContext.setHasBindingSignature(
- !Strings.isNullOrEmpty(getHttpServletRequest().getParameter("Signature")));
+ !Strings.isNullOrEmpty(request.getParameter("Signature")));
bindingContext.setIntendedDestinationEndpointURIRequired(SAMLBindingSupport.isMessageSigned(messageContext));
}
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/encoding/impl/HTTPArtifactEncoder.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/encoding/impl/HTTPArtifactEncoder.java
index 20cd05454..cf43dafcf 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/encoding/impl/HTTPArtifactEncoder.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/encoding/impl/HTTPArtifactEncoder.java
@@ -214,7 +214,9 @@ public class HTTPArtifactEncoder extends BaseSAML2MessageEncoder implements HTML
/** {@inheritDoc} */
@Override
protected void doEncode() throws MessageEncodingException {
- getHttpServletResponse().setCharacterEncoding("UTF-8");
+ final HttpServletResponse response = getHttpServletResponse();
+ assert response != null;
+ response.setCharacterEncoding("UTF-8");
if (postEncoding) {
postEncode();
@@ -267,6 +269,7 @@ public class HTTPArtifactEncoder extends BaseSAML2MessageEncoder implements HTML
}
final HttpServletResponse response = getHttpServletResponse();
+ assert response != null;
context.put("response", response);
try {
@@ -321,6 +324,7 @@ public class HTTPArtifactEncoder extends BaseSAML2MessageEncoder implements HTML
}
final HttpServletResponse response = getHttpServletResponse();
+ assert response != null;
try {
response.sendRedirect(urlBuilder.buildURL());
} catch (final IOException e) {
diff --git a/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/encryption/tests/ECDHTest.java b/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/encryption/tests/ECDHTest.java
index 7a1299779..deb09ec23 100644
--- a/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/encryption/tests/ECDHTest.java
+++ b/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/encryption/tests/ECDHTest.java
@@ -147,7 +147,7 @@ public class ECDHTest extends XMLObjectBaseTestCase {
encConfig = new BasicEncryptionConfiguration();
EncryptionConfigurationCriterion encConfCrit = new EncryptionConfigurationCriterion(encConfig,
- ConfigurationService.get(EncryptionConfiguration.class));
+ Constraint.isNotNull(ConfigurationService.get(EncryptionConfiguration.class), "EncryptionConfiguration absent"));
encCriteria = new CriteriaSet(encConfCrit, roleDescCriterion);
decryptConfig = new BasicDecryptionConfiguration();
@@ -155,7 +155,7 @@ public class ECDHTest extends XMLObjectBaseTestCase {
decryptConfig.setKEKKeyInfoCredentialResolver(localKeyInfoResolver);
decryptCriteria = new CriteriaSet(new DecryptionConfigurationCriterion(decryptConfig,
- ConfigurationService.get(DecryptionConfiguration.class)));
+ Constraint.isNotNull(ConfigurationService.get(DecryptionConfiguration.class), "DecryptionConfiguration absent")));
}
@Test
diff --git a/opensaml-soap-impl/src/main/java/org/opensaml/soap/client/soap11/encoder/http/impl/HttpClientRequestSOAP11Encoder.java b/opensaml-soap-impl/src/main/java/org/opensaml/soap/client/soap11/encoder/http/impl/HttpClientRequestSOAP11Encoder.java
index 07a8db75d..2fcede750 100644
--- a/opensaml-soap-impl/src/main/java/org/opensaml/soap/client/soap11/encoder/http/impl/HttpClientRequestSOAP11Encoder.java
+++ b/opensaml-soap-impl/src/main/java/org/opensaml/soap/client/soap11/encoder/http/impl/HttpClientRequestSOAP11Encoder.java
@@ -16,6 +16,7 @@ package org.opensaml.soap.client.soap11.encoder.http.impl;
import java.io.ByteArrayOutputStream;
import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.util.List;
import javax.annotation.Nonnull;
@@ -114,8 +115,10 @@ public class HttpClientRequestSOAP11Encoder extends BaseHttpClientRequestXMLMess
}
prepareHttpRequest();
-
- getHttpRequest().setEntity(createRequestEntity(envelope, Charset.forName("UTF-8")));
+
+ final HttpPost request = getHttpRequest();
+ assert request != null;
+ request.setEntity(createRequestEntity(envelope, StandardCharsets.UTF_8));
}
/**
@@ -200,12 +203,15 @@ public class HttpClientRequestSOAP11Encoder extends BaseHttpClientRequestXMLMess
* @throws MessageEncodingException thrown if there is a problem preprocessing the transport
*/
protected void prepareHttpRequest() throws MessageEncodingException {
+ final HttpPost request = getHttpRequest();
+ assert request != null;
+
//TODO - need to do more here?
final String soapAction = getSOAPAction();
if (soapAction != null) {
- getHttpRequest().setHeader("SOAPAction", soapAction);
+ request.setHeader("SOAPAction", soapAction);
} else {
- getHttpRequest().setHeader("SOAPAction", "");
+ request.setHeader("SOAPAction", "");
}
}
diff --git a/opensaml-xmlsec-impl/src/test/java/org/opensaml/xmlsec/encryption/support/tests/DHWithExplicitKDFTest.java b/opensaml-xmlsec-impl/src/test/java/org/opensaml/xmlsec/encryption/support/tests/DHWithExplicitKDFTest.java
index c8ea73b4e..1fe576670 100644
--- a/opensaml-xmlsec-impl/src/test/java/org/opensaml/xmlsec/encryption/support/tests/DHWithExplicitKDFTest.java
+++ b/opensaml-xmlsec-impl/src/test/java/org/opensaml/xmlsec/encryption/support/tests/DHWithExplicitKDFTest.java
@@ -70,6 +70,7 @@ import org.testng.annotations.Test;
import org.w3c.dom.Element;
import net.shibboleth.shared.collection.CollectionSupport;
+import net.shibboleth.shared.logic.Constraint;
import net.shibboleth.shared.resolver.CriteriaSet;
import net.shibboleth.shared.xml.ParserPool;
import net.shibboleth.shared.xml.SerializeSupport;
@@ -118,7 +119,7 @@ public class DHWithExplicitKDFTest extends XMLObjectBaseTestCase {
encConfig = new BasicEncryptionConfiguration();
encConfig2 = new BasicEncryptionConfiguration();
encCriteria = new CriteriaSet(new EncryptionConfigurationCriterion(encConfig, encConfig2,
- ConfigurationService.get(EncryptionConfiguration.class)));
+ Constraint.isNotNull(ConfigurationService.get(EncryptionConfiguration.class), "EncryptionConfiguration absent")));
// Configure the middle slot explicitly so that we aren't relying on whichever DH variant the library wide config has.
KeyAgreementEncryptionConfiguration kaConfig = new KeyAgreementEncryptionConfiguration();
@@ -136,7 +137,7 @@ public class DHWithExplicitKDFTest extends XMLObjectBaseTestCase {
decryptConfig.setKEKKeyInfoCredentialResolver(localKeyInfoResolver);
decryptCriteria = new CriteriaSet(new DecryptionConfigurationCriterion(decryptConfig,
- ConfigurationService.get(DecryptionConfiguration.class)));
+ Constraint.isNotNull(ConfigurationService.get(DecryptionConfiguration.class), "DecryptionConfiguration absent")));
}
@Test
diff --git a/opensaml-xmlsec-impl/src/test/java/org/opensaml/xmlsec/encryption/support/tests/DHWithLegacyKDFTest.java b/opensaml-xmlsec-impl/src/test/java/org/opensaml/xmlsec/encryption/support/tests/DHWithLegacyKDFTest.java
index 7e39b9adf..796d7105c 100644
--- a/opensaml-xmlsec-impl/src/test/java/org/opensaml/xmlsec/encryption/support/tests/DHWithLegacyKDFTest.java
+++ b/opensaml-xmlsec-impl/src/test/java/org/opensaml/xmlsec/encryption/support/tests/DHWithLegacyKDFTest.java
@@ -70,6 +70,7 @@ import org.testng.annotations.Test;
import org.w3c.dom.Element;
import net.shibboleth.shared.collection.CollectionSupport;
+import net.shibboleth.shared.logic.Constraint;
import net.shibboleth.shared.resolver.CriteriaSet;
import net.shibboleth.shared.xml.ParserPool;
import net.shibboleth.shared.xml.SerializeSupport;
@@ -118,7 +119,7 @@ public class DHWithLegacyKDFTest extends XMLObjectBaseTestCase {
encConfig = new BasicEncryptionConfiguration();
encConfig2 = new BasicEncryptionConfiguration();
encCriteria = new CriteriaSet(new EncryptionConfigurationCriterion(encConfig, encConfig2,
- ConfigurationService.get(EncryptionConfiguration.class)));
+ Constraint.isNotNull(ConfigurationService.get(EncryptionConfiguration.class), "EncryptionConfiguration absent")));
// Configure the middle slot explicitly so that we aren't relying on whichever DH variant the library wide config has.
KeyAgreementEncryptionConfiguration kaConfig = new KeyAgreementEncryptionConfiguration();
@@ -136,7 +137,7 @@ public class DHWithLegacyKDFTest extends XMLObjectBaseTestCase {
decryptConfig.setKEKKeyInfoCredentialResolver(localKeyInfoResolver);
decryptCriteria = new CriteriaSet(new DecryptionConfigurationCriterion(decryptConfig,
- ConfigurationService.get(DecryptionConfiguration.class)));
+ Constraint.isNotNull(ConfigurationService.get(DecryptionConfiguration.class), "DecryptionConfiguration absent")));
}
@Test
diff --git a/opensaml-xmlsec-impl/src/test/java/org/opensaml/xmlsec/encryption/support/tests/ECDHTest.java b/opensaml-xmlsec-impl/src/test/java/org/opensaml/xmlsec/encryption/support/tests/ECDHTest.java
index 8d70e4a29..78e7e7a90 100644
--- a/opensaml-xmlsec-impl/src/test/java/org/opensaml/xmlsec/encryption/support/tests/ECDHTest.java
+++ b/opensaml-xmlsec-impl/src/test/java/org/opensaml/xmlsec/encryption/support/tests/ECDHTest.java
@@ -69,6 +69,7 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.w3c.dom.Element;
+import net.shibboleth.shared.logic.Constraint;
import net.shibboleth.shared.resolver.CriteriaSet;
import net.shibboleth.shared.xml.ParserPool;
import net.shibboleth.shared.xml.SerializeSupport;
@@ -116,14 +117,14 @@ public class ECDHTest extends XMLObjectBaseTestCase {
public void beforeMethod() throws Exception {
encConfig = new BasicEncryptionConfiguration();
encCriteria = new CriteriaSet(new EncryptionConfigurationCriterion(encConfig,
- ConfigurationService.get(EncryptionConfiguration.class)));
+ Constraint.isNotNull(ConfigurationService.get(EncryptionConfiguration.class), "EncryptionConfiguration absent")));
decryptConfig = new BasicDecryptionConfiguration();
decryptConfig.setDataKeyInfoCredentialResolver(localKeyInfoResolver);
decryptConfig.setKEKKeyInfoCredentialResolver(localKeyInfoResolver);
decryptCriteria = new CriteriaSet(new DecryptionConfigurationCriterion(decryptConfig,
- ConfigurationService.get(DecryptionConfiguration.class)));
+ Constraint.isNotNull(ConfigurationService.get(DecryptionConfiguration.class), "DecryptionConfiguration absent")));
}
@Test
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list