[java-shib-metadata] branch main updated: JSSH-27 Implement an ensureId method to help with nullability annotation
Rod Widdowson
rdw at steadingsoftware.com
Wed Apr 26 14:21:16 UTC 2023
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch main
in repository java-shib-metadata.
View the commit online:
http://git.shibboleth.net/view/?p=java-shib-metadata.git;a=commit;h=404b9854a72c7e24109ec0236aad63c9cb53c4a7
The following commit(s) were added to refs/heads/main by this push:
new 404b9854 JSSH-27 Implement an ensureId method to help with nullability annotation
404b9854 is described below
commit 404b9854a72c7e24109ec0236aad63c9cb53c4a7
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Wed Apr 26 15:19:55 2023 +0100
JSSH-27 Implement an ensureId method to help with nullability annotation
https://shibboleth.atlassian.net/browse/JSSH-27
Use EnsureId in the metadata-impl project.
Also some drive by warning removal (mostly for tests)
---
.../idp/saml/metadata/impl/MetadataProviderContainer.java | 7 ++++---
.../saml/metadata/impl/MetadataResolverServiceStrategy.java | 4 +++-
.../shibboleth/idp/saml/metadata/impl/ScopesNodeProcessor.java | 3 ++-
.../shibboleth/idp/saml/metadata/impl/UIInfoNodeProcessor.java | 3 ++-
.../idp/saml/security/impl/KeyAuthorityNodeProcessor.java | 2 +-
.../idp/saml/metadata/impl/BaseNodeProcessorTest.java | 8 ++++++--
.../idp/saml/metadata/impl/ScopesNodeProcessorTest.java | 4 +++-
.../idp/saml/metadata/impl/UIInfoNodeProcessorTest.java | 4 +++-
.../idp/saml/security/impl/KeyAuthorityNodeProcessorTest.java | 3 +++
.../impl/MetadataPKIXValidationInformationResolverTest.java | 10 ++++++++--
.../shibboleth/idp/saml/xmlobject/impl/KeyAuthorityTest.java | 3 +++
.../java/net/shibboleth/idp/saml/xmlobject/impl/ScopeTest.java | 2 ++
.../shibboleth/idp/saml/xmlobject/impl/ScopedValueTest.java | 2 ++
13 files changed, 42 insertions(+), 13 deletions(-)
diff --git a/shib-metadata-impl/src/main/java/net/shibboleth/idp/saml/metadata/impl/MetadataProviderContainer.java b/shib-metadata-impl/src/main/java/net/shibboleth/idp/saml/metadata/impl/MetadataProviderContainer.java
index 64267ee3..a59433f3 100644
--- a/shib-metadata-impl/src/main/java/net/shibboleth/idp/saml/metadata/impl/MetadataProviderContainer.java
+++ b/shib-metadata-impl/src/main/java/net/shibboleth/idp/saml/metadata/impl/MetadataProviderContainer.java
@@ -114,7 +114,7 @@ public class MetadataProviderContainer extends AbstractServiceableComponent<Meta
return 0;
}
- return getId().compareTo(other.getId());
+ return ensureId().compareTo(other.getId());
}
/**
@@ -141,7 +141,8 @@ public class MetadataProviderContainer extends AbstractServiceableComponent<Meta
/** {@inheritDoc} */
@Nonnull public MetadataResolver getComponent() {
checkComponentActive();
-
- return getEmbeddedResolver();
+ final MetadataResolver result = getEmbeddedResolver();
+ assert result != null;
+ return result;
}
}
diff --git a/shib-metadata-impl/src/main/java/net/shibboleth/idp/saml/metadata/impl/MetadataResolverServiceStrategy.java b/shib-metadata-impl/src/main/java/net/shibboleth/idp/saml/metadata/impl/MetadataResolverServiceStrategy.java
index 7935ea5a..2c69c11e 100644
--- a/shib-metadata-impl/src/main/java/net/shibboleth/idp/saml/metadata/impl/MetadataResolverServiceStrategy.java
+++ b/shib-metadata-impl/src/main/java/net/shibboleth/idp/saml/metadata/impl/MetadataResolverServiceStrategy.java
@@ -68,7 +68,9 @@ public class MetadataResolverServiceStrategy extends AbstractIdentifiableInitial
}
if (1 == containers.size()) {
// done
- return containers.iterator().next();
+ final AbstractServiceableComponent<MetadataResolver> result = containers.iterator().next();
+ assert result != null;
+ return result;
}
// initialize so we can sort
for (final MetadataProviderContainer resolver : containers) {
diff --git a/shib-metadata-impl/src/main/java/net/shibboleth/idp/saml/metadata/impl/ScopesNodeProcessor.java b/shib-metadata-impl/src/main/java/net/shibboleth/idp/saml/metadata/impl/ScopesNodeProcessor.java
index 7c65055c..0ab4336f 100644
--- a/shib-metadata-impl/src/main/java/net/shibboleth/idp/saml/metadata/impl/ScopesNodeProcessor.java
+++ b/shib-metadata-impl/src/main/java/net/shibboleth/idp/saml/metadata/impl/ScopesNodeProcessor.java
@@ -20,6 +20,7 @@ package net.shibboleth.idp.saml.metadata.impl;
import java.util.HashSet;
import java.util.List;
+import javax.annotation.Nonnull;
import javax.annotation.concurrent.NotThreadSafe;
import org.opensaml.core.xml.XMLObject;
@@ -42,7 +43,7 @@ import net.shibboleth.idp.saml.xmlobject.Scope;
public class ScopesNodeProcessor implements MetadataNodeProcessor {
/** {@inheritDoc} */
- @Override public void process(final XMLObject metadataNode) throws FilterException {
+ @Override public void process(final @Nonnull XMLObject metadataNode) throws FilterException {
final Extensions extensions;
if (metadataNode instanceof EntityDescriptor) {
diff --git a/shib-metadata-impl/src/main/java/net/shibboleth/idp/saml/metadata/impl/UIInfoNodeProcessor.java b/shib-metadata-impl/src/main/java/net/shibboleth/idp/saml/metadata/impl/UIInfoNodeProcessor.java
index 6a3444d0..1884edb0 100644
--- a/shib-metadata-impl/src/main/java/net/shibboleth/idp/saml/metadata/impl/UIInfoNodeProcessor.java
+++ b/shib-metadata-impl/src/main/java/net/shibboleth/idp/saml/metadata/impl/UIInfoNodeProcessor.java
@@ -17,6 +17,7 @@
package net.shibboleth.idp.saml.metadata.impl;
+import javax.annotation.Nonnull;
import javax.annotation.concurrent.NotThreadSafe;
import org.opensaml.core.xml.XMLObject;
@@ -39,7 +40,7 @@ import net.shibboleth.idp.saml.metadata.OrganizationUIInfo;
public class UIInfoNodeProcessor implements MetadataNodeProcessor {
/** {@inheritDoc} */
- @Override public void process(final XMLObject metadataNode) throws FilterException {
+ @Override public void process(final @Nonnull XMLObject metadataNode) throws FilterException {
if (metadataNode instanceof UIInfo) {
metadataNode.getObjectMetadata().put(new IdPUIInfo((UIInfo) metadataNode));
diff --git a/shib-metadata-impl/src/main/java/net/shibboleth/idp/saml/security/impl/KeyAuthorityNodeProcessor.java b/shib-metadata-impl/src/main/java/net/shibboleth/idp/saml/security/impl/KeyAuthorityNodeProcessor.java
index 73eb160a..d02f6649 100644
--- a/shib-metadata-impl/src/main/java/net/shibboleth/idp/saml/security/impl/KeyAuthorityNodeProcessor.java
+++ b/shib-metadata-impl/src/main/java/net/shibboleth/idp/saml/security/impl/KeyAuthorityNodeProcessor.java
@@ -47,7 +47,7 @@ public class KeyAuthorityNodeProcessor implements MetadataNodeProcessor {
/** {@inheritDoc} */
@Override
- public void process(final XMLObject metadataNode) throws FilterException {
+ public void process(final @Nonnull XMLObject metadataNode) throws FilterException {
if (metadataNode instanceof EntitiesDescriptor) {
handleEntitiesDescriptor((EntitiesDescriptor) metadataNode);
} else if (metadataNode instanceof EntityDescriptor) {
diff --git a/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/metadata/impl/BaseNodeProcessorTest.java b/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/metadata/impl/BaseNodeProcessorTest.java
index a3872c1e..50febfa9 100644
--- a/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/metadata/impl/BaseNodeProcessorTest.java
+++ b/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/metadata/impl/BaseNodeProcessorTest.java
@@ -22,6 +22,8 @@ import java.net.URISyntaxException;
import java.net.URL;
import java.util.List;
+import javax.annotation.Nonnull;
+
import org.opensaml.core.testing.XMLObjectBaseTestCase;
import org.opensaml.saml.metadata.resolver.MetadataResolver;
import org.opensaml.saml.metadata.resolver.filter.MetadataNodeProcessor;
@@ -29,6 +31,7 @@ import org.opensaml.saml.metadata.resolver.filter.impl.NodeProcessingMetadataFil
import org.opensaml.saml.metadata.resolver.impl.FilesystemMetadataResolver;
import org.testng.annotations.BeforeClass;
+import net.shibboleth.shared.collection.CollectionSupport;
import net.shibboleth.shared.component.ComponentInitializationException;
import net.shibboleth.shared.resolver.ResolverException;
@@ -43,13 +46,14 @@ public abstract class BaseNodeProcessorTest extends XMLObjectBaseTestCase {
.getResource("/net/shibboleth/idp/saml/impl/metadata/NodeProcessor-metadata.xml");
final File mdFile = new File(mdURL.toURI());
- final List<MetadataNodeProcessor> processors = List.of(getProcessor());
+ final List<MetadataNodeProcessor> processors = CollectionSupport.listOf(getProcessor());
final NodeProcessingMetadataFilter metadataFilter = new NodeProcessingMetadataFilter();
metadataFilter.setNodeProcessors(processors);
metadataFilter.initialize();
final FilesystemMetadataResolver fileResolver = new FilesystemMetadataResolver(mdFile);
+ assert parserPool!=null;
fileResolver.setParserPool(parserPool);
fileResolver.setMetadataFilter(metadataFilter);
fileResolver.setId("test");
@@ -57,5 +61,5 @@ public abstract class BaseNodeProcessorTest extends XMLObjectBaseTestCase {
resolver = fileResolver;
}
- protected abstract MetadataNodeProcessor getProcessor();
+ @Nonnull protected abstract MetadataNodeProcessor getProcessor();
}
diff --git a/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/metadata/impl/ScopesNodeProcessorTest.java b/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/metadata/impl/ScopesNodeProcessorTest.java
index 98bf7d8f..b70921ca 100644
--- a/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/metadata/impl/ScopesNodeProcessorTest.java
+++ b/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/metadata/impl/ScopesNodeProcessorTest.java
@@ -23,6 +23,8 @@ import static org.testng.Assert.assertTrue;
import java.util.List;
+import javax.annotation.Nonnull;
+
import org.opensaml.core.criterion.EntityIdCriterion;
import org.opensaml.saml.metadata.resolver.filter.MetadataNodeProcessor;
import org.opensaml.saml.saml2.metadata.AttributeAuthorityDescriptor;
@@ -99,7 +101,7 @@ public final class ScopesNodeProcessorTest extends BaseNodeProcessorTest {
}
/** {@inheritDoc} */
- protected MetadataNodeProcessor getProcessor() {
+ protected @Nonnull MetadataNodeProcessor getProcessor() {
return new ScopesNodeProcessor();
}
diff --git a/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/metadata/impl/UIInfoNodeProcessorTest.java b/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/metadata/impl/UIInfoNodeProcessorTest.java
index a6aa637e..7aa01cd0 100644
--- a/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/metadata/impl/UIInfoNodeProcessorTest.java
+++ b/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/metadata/impl/UIInfoNodeProcessorTest.java
@@ -21,6 +21,8 @@ import static org.testng.Assert.assertEquals;
import java.util.Locale;
+import javax.annotation.Nonnull;
+
import org.opensaml.core.criterion.EntityIdCriterion;
import org.opensaml.core.xml.XMLObject;
import org.opensaml.saml.ext.saml2mdui.UIInfo;
@@ -98,7 +100,7 @@ public final class UIInfoNodeProcessorTest extends BaseNodeProcessorTest {
/** {@inheritDoc} */
- protected MetadataNodeProcessor getProcessor() {
+ protected @Nonnull MetadataNodeProcessor getProcessor() {
return new UIInfoNodeProcessor();
}
diff --git a/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/security/impl/KeyAuthorityNodeProcessorTest.java b/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/security/impl/KeyAuthorityNodeProcessorTest.java
index 2852dd44..fc0054e1 100644
--- a/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/security/impl/KeyAuthorityNodeProcessorTest.java
+++ b/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/security/impl/KeyAuthorityNodeProcessorTest.java
@@ -57,10 +57,13 @@ public class KeyAuthorityNodeProcessorTest extends XMLObjectBaseTestCase {
processors.add(new KeyAuthorityNodeProcessor());
metadataFilter = new NodeProcessingMetadataFilter();
+ assert processors!=null;
metadataFilter.setNodeProcessors(processors);
metadataFilter.initialize();
+ assert mdFile!=null;
metadataProvider = new FilesystemMetadataResolver(mdFile);
+ assert parserPool!=null;
metadataProvider.setParserPool(parserPool);
metadataProvider.setMetadataFilter(metadataFilter);
metadataProvider.setId("test");
diff --git a/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/security/impl/MetadataPKIXValidationInformationResolverTest.java b/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/security/impl/MetadataPKIXValidationInformationResolverTest.java
index 3f8e8d11..de168587 100644
--- a/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/security/impl/MetadataPKIXValidationInformationResolverTest.java
+++ b/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/security/impl/MetadataPKIXValidationInformationResolverTest.java
@@ -17,6 +17,7 @@
package net.shibboleth.idp.saml.security.impl;
+import java.io.InputStream;
import java.security.cert.X509CRL;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
@@ -47,6 +48,7 @@ import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.w3c.dom.Document;
+import org.w3c.dom.Element;
import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.component.ComponentInitializationException;
@@ -396,9 +398,13 @@ public class MetadataPKIXValidationInformationResolverTest extends XMLObjectBase
Document mdDoc = null;
String mdFileName = "/net/shibboleth/idp/saml/impl/security/" + fileName;
- mdDoc = parserPool.parse(MetadataPKIXValidationInformationResolverTest.class.getResourceAsStream(mdFileName));
+ final InputStream inputStream = MetadataPKIXValidationInformationResolverTest.class.getResourceAsStream(mdFileName);
+ assert inputStream!=null;
+ mdDoc = parserPool.parse(inputStream);
- DOMMetadataResolver mdProvider = new DOMMetadataResolver(mdDoc.getDocumentElement());
+ final Element elem = mdDoc.getDocumentElement();
+ assert elem!=null;
+ DOMMetadataResolver mdProvider = new DOMMetadataResolver(elem);
List<MetadataNodeProcessor> processors = new ArrayList<>();
processors.add(new KeyAuthorityNodeProcessor());
diff --git a/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/xmlobject/impl/KeyAuthorityTest.java b/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/xmlobject/impl/KeyAuthorityTest.java
index c4be20f7..e03c6dc9 100644
--- a/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/xmlobject/impl/KeyAuthorityTest.java
+++ b/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/xmlobject/impl/KeyAuthorityTest.java
@@ -89,6 +89,7 @@ public class KeyAuthorityTest extends XMLObjectProviderBaseTestCase {
@Test
public void testSingleElementUnmarshall() {
+ assert singleElementFile != null;
KeyAuthority keyAuthority = (KeyAuthority) unmarshallElement(singleElementFile);
Assert.assertNotNull(keyAuthority, "Unmarshalled object was null");
@@ -102,6 +103,7 @@ public class KeyAuthorityTest extends XMLObjectProviderBaseTestCase {
@Test
public void testSingleElementOptionalAttributesUnmarshall() {
+ assert singleElementOptionalAttributesFile != null;
KeyAuthority keyAuthority = (KeyAuthority) unmarshallElement(singleElementOptionalAttributesFile);
Assert.assertNotNull(keyAuthority, "Unmarshalled object was null");
@@ -119,6 +121,7 @@ public class KeyAuthorityTest extends XMLObjectProviderBaseTestCase {
@Test
public void testChildElementsUnmarshall() {
+ assert childElementsFile != null;
KeyAuthority keyAuthority = (KeyAuthority) unmarshallElement(childElementsFile);
Assert.assertNotNull(keyAuthority, "Unmarshalled object was null");
diff --git a/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/xmlobject/impl/ScopeTest.java b/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/xmlobject/impl/ScopeTest.java
index 4d0f28de..d307368c 100644
--- a/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/xmlobject/impl/ScopeTest.java
+++ b/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/xmlobject/impl/ScopeTest.java
@@ -70,6 +70,7 @@ public class ScopeTest extends XMLObjectProviderBaseTestCase {
/** {@inheritDoc} */
@Test
public void testSingleElementUnmarshall() {
+ assert singleElementFile != null;
Scope scope = (Scope) unmarshallElement(singleElementFile);
Assert.assertNotNull(scope, "Unmarshalled object was null");
@@ -81,6 +82,7 @@ public class ScopeTest extends XMLObjectProviderBaseTestCase {
/** {@inheritDoc} */
@Test
public void testSingleElementOptionalAttributesUnmarshall() {
+ assert singleElementOptionalAttributesFile != null;
Scope scope = (Scope) unmarshallElement(singleElementOptionalAttributesFile);
Assert.assertNotNull(scope, "Unmarshalled object was null");
diff --git a/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/xmlobject/impl/ScopedValueTest.java b/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/xmlobject/impl/ScopedValueTest.java
index ee6c03a9..274b4ccc 100644
--- a/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/xmlobject/impl/ScopedValueTest.java
+++ b/shib-metadata-impl/src/test/java/net/shibboleth/idp/saml/xmlobject/impl/ScopedValueTest.java
@@ -88,6 +88,7 @@ public class ScopedValueTest extends XMLObjectProviderBaseTestCase {
/** {@inheritDoc} */
@Test
public void testSingleElementUnmarshall() {
+ assert singleElementFile != null;
ScopedValue sv = (ScopedValue) unmarshallElement(singleElementFile);
Assert.assertNotNull(sv, "Unmarshalled object was null");
@@ -98,6 +99,7 @@ public class ScopedValueTest extends XMLObjectProviderBaseTestCase {
/** {@inheritDoc} */
@Test
public void testSingleElementOptionalAttributesUnmarshall() {
+ assert singleElementOptionalAttributesFile != null;
ScopedValue sv = (ScopedValue) unmarshallElement(singleElementOptionalAttributesFile);
Assert.assertNotNull(sv, "Unmarshalled object was null");
assert(sv != null);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list