[java-shib-metadata] branch main updated: Replace Collections/Arrays methods where possible.

Scott Cantor cantor.2 at osu.edu
Thu Apr 20 18:09:55 UTC 2023


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

scantor 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=a0e89b7b56b2ab14c907dcaa877981b0eaa2e032

The following commit(s) were added to refs/heads/main by this push:
     new a0e89b7b Replace Collections/Arrays methods where possible.
a0e89b7b is described below

commit a0e89b7b56b2ab14c907dcaa877981b0eaa2e032
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Apr 20 14:09:53 2023 -0400

    Replace Collections/Arrays methods where possible.
---
 .../idp/saml/metadata/ScopesContainerTest.java     |  2 +-
 .../idp/saml/xmlobject/impl/KeyAuthorityImpl.java  | 28 ++++++++--------------
 .../DynamicHTTPMetadataProviderParserTest.java     |  6 ++---
 .../security/AbstractSecurityParserTest.java       |  8 +++----
 4 files changed, 18 insertions(+), 26 deletions(-)

diff --git a/shib-metadata-api/src/test/java/net/shibboleth/idp/saml/metadata/ScopesContainerTest.java b/shib-metadata-api/src/test/java/net/shibboleth/idp/saml/metadata/ScopesContainerTest.java
index 30a38300..e100272d 100644
--- a/shib-metadata-api/src/test/java/net/shibboleth/idp/saml/metadata/ScopesContainerTest.java
+++ b/shib-metadata-api/src/test/java/net/shibboleth/idp/saml/metadata/ScopesContainerTest.java
@@ -36,7 +36,7 @@ public class ScopesContainerTest {
         final ScopesContainer scopes = new ScopesContainer();
         assertFalse(scopes.matchesScope("foo"));
         scopes.setRegexpScopes(null);
-        scopes.setSimpleScopes(Collections.emptySet());
+        scopes.setSimpleScopes(CollectionSupport.emptySet());
         assertFalse(scopes.matchesScope("foo"));
         scopes.setRegexpScopes(CollectionSupport.singleton(""));
         scopes.setSimpleScopes(Collections.singleton((String)null));
diff --git a/shib-metadata-impl/src/main/java/net/shibboleth/idp/saml/xmlobject/impl/KeyAuthorityImpl.java b/shib-metadata-impl/src/main/java/net/shibboleth/idp/saml/xmlobject/impl/KeyAuthorityImpl.java
index 9fcd5fc9..943c55d9 100644
--- a/shib-metadata-impl/src/main/java/net/shibboleth/idp/saml/xmlobject/impl/KeyAuthorityImpl.java
+++ b/shib-metadata-impl/src/main/java/net/shibboleth/idp/saml/xmlobject/impl/KeyAuthorityImpl.java
@@ -17,8 +17,6 @@
 
 package net.shibboleth.idp.saml.xmlobject.impl;
 
-import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 
 import javax.annotation.Nonnull;
@@ -26,6 +24,10 @@ import javax.annotation.Nullable;
 import javax.annotation.concurrent.NotThreadSafe;
 
 import net.shibboleth.idp.saml.xmlobject.KeyAuthority;
+import net.shibboleth.shared.annotation.constraint.Live;
+import net.shibboleth.shared.annotation.constraint.NotLive;
+import net.shibboleth.shared.annotation.constraint.Unmodifiable;
+import net.shibboleth.shared.collection.CollectionSupport;
 
 import org.opensaml.core.xml.AbstractXMLObject;
 import org.opensaml.core.xml.XMLObject;
@@ -61,38 +63,28 @@ public class KeyAuthorityImpl extends AbstractXMLObject implements KeyAuthority
     }
 
     /** {@inheritDoc} */
-    @Override
-    public List<KeyInfo> getKeyInfos() {
+    @Nonnull @Live public List<KeyInfo> getKeyInfos() {
         return keyInfos;
     }
 
     /** {@inheritDoc} */
-    @Override
-    public Integer getVerifyDepth() {
+    @Nullable public Integer getVerifyDepth() {
         return verifyDepth;
     }
 
     /** {@inheritDoc} */
-    @Override
-    public void setVerifyDepth(final Integer newVerifyDepth) {
+    public void setVerifyDepth(@Nullable final Integer newVerifyDepth) {
         verifyDepth = prepareForAssignment(verifyDepth, newVerifyDepth);
     }
 
     /** {@inheritDoc} */
-    @Override
     @Nonnull public AttributeMap getUnknownAttributes() {
         return unknownAttributes;
     }
 
     /** {@inheritDoc} */
-    @Override
-    public List<XMLObject> getOrderedChildren() {
-        if (keyInfos.isEmpty()) {
-            return Collections.emptyList();
-        }
-        
-        final ArrayList<XMLObject> children = new ArrayList<>();
-        children.addAll(keyInfos);
-        return Collections.unmodifiableList(children);
+    @Nullable @Unmodifiable @NotLive public List<XMLObject> getOrderedChildren() {
+        return CollectionSupport.copyToList(keyInfos);
     }
+
 }
\ No newline at end of file
diff --git a/shib-metadata-spring/src/test/java/net/shibboleth/spring/metadata/DynamicHTTPMetadataProviderParserTest.java b/shib-metadata-spring/src/test/java/net/shibboleth/spring/metadata/DynamicHTTPMetadataProviderParserTest.java
index 393d11f4..7fe3ebca 100644
--- a/shib-metadata-spring/src/test/java/net/shibboleth/spring/metadata/DynamicHTTPMetadataProviderParserTest.java
+++ b/shib-metadata-spring/src/test/java/net/shibboleth/spring/metadata/DynamicHTTPMetadataProviderParserTest.java
@@ -21,7 +21,6 @@ import java.security.MessageDigest;
 import java.security.SecureRandom;
 import java.time.Duration;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.List;
 import java.util.function.Function;
 import java.util.function.Predicate;
@@ -43,6 +42,7 @@ import org.testng.Assert;
 import org.testng.annotations.Test;
 
 import net.shibboleth.idp.saml.metadata.impl.MetadataProviderContainer;
+import net.shibboleth.shared.collection.CollectionSupport;
 import net.shibboleth.shared.resolver.CriteriaSet;
 import net.shibboleth.shared.testing.RepositorySupport;
 
@@ -209,7 +209,7 @@ public class DynamicHTTPMetadataProviderParserTest extends AbstractMetadataParse
         Assert.assertEquals(resolver.getCleanupTaskInterval(), Duration.ofMinutes(20));
         Assert.assertEquals(resolver.getExpirationWarningThreshold(), Duration.ofHours(3));
         
-        Assert.assertEquals(resolver.getSupportedContentTypes(), Collections.singletonList("text/xml"));
+        Assert.assertEquals(resolver.getSupportedContentTypes(), CollectionSupport.singletonList("text/xml"));
         
         Assert.assertEquals(resolver.getRequestURLBuilder().getClass(), HTTPEntityIDRequestURLBuilder.class);
     }
@@ -254,7 +254,7 @@ public class DynamicHTTPMetadataProviderParserTest extends AbstractMetadataParse
         final FunctionDrivenDynamicHTTPMetadataResolver resolver = getBean(FunctionDrivenDynamicHTTPMetadataResolver.class, 
                 "dynamicMetadataQueryProtocol.xml", "beans.xml");
         
-        Assert.assertEquals(resolver.getSupportedContentTypes(), Collections.singletonList("application/samlmetadata+xml"));
+        Assert.assertEquals(resolver.getSupportedContentTypes(), CollectionSupport.singletonList("application/samlmetadata+xml"));
 
         final String entityID = "urn:mace:incommon:osu.edu";
         
diff --git a/shib-metadata-spring/src/test/java/net/shibboleth/spring/security/AbstractSecurityParserTest.java b/shib-metadata-spring/src/test/java/net/shibboleth/spring/security/AbstractSecurityParserTest.java
index d67065b3..280e1307 100644
--- a/shib-metadata-spring/src/test/java/net/shibboleth/spring/security/AbstractSecurityParserTest.java
+++ b/shib-metadata-spring/src/test/java/net/shibboleth/spring/security/AbstractSecurityParserTest.java
@@ -19,8 +19,6 @@
 package net.shibboleth.spring.security;
 
 import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collections;
 
 import org.springframework.context.support.GenericApplicationContext;
 import org.springframework.core.io.ClassPathResource;
@@ -29,6 +27,7 @@ import org.springframework.mock.env.MockPropertySource;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeSuite;
 
+import net.shibboleth.shared.collection.CollectionSupport;
 import net.shibboleth.shared.spring.util.ApplicationContextBuilder;
 
 /**
@@ -81,9 +80,9 @@ public class AbstractSecurityParserTest {
         
         final MockPropertySource mockEnvVars = new MockPropertySource();
         mockEnvVars.setProperty("DIR", workspaceDirName);
-        builder.setPropertySources(Collections.singletonList(mockEnvVars));
+        builder.setPropertySources(CollectionSupport.singletonList(mockEnvVars));
         
-        builder.setServiceConfigurations(Arrays.asList(resources));
+        builder.setServiceConfigurations(CollectionSupport.listOf(resources));
 
         final GenericApplicationContext context = builder.build();
         
@@ -94,4 +93,5 @@ public class AbstractSecurityParserTest {
         }
         return context.getBean(claz);
     }
+
 }
\ No newline at end of file

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


More information about the commits mailing list