[java-opensaml] branch master updated: More Guava cleanup.
Scott Cantor
cantor.2 at osu.edu
Thu Nov 14 21:00:10 EST 2019
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch master
in repository java-opensaml.
View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=7aa464a60f2f055ad795d88f95a9aa4a58443a3e
The following commit(s) were added to refs/heads/master by this push:
new 7aa464a More Guava cleanup.
7aa464a is described below
commit 7aa464a60f2f055ad795d88f95a9aa4a58443a3e
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Nov 14 21:00:07 2019 -0500
More Guava cleanup.
---
.../xml/persist/FilesystemLoadSaveManager.java | 24 ++++++++--------------
.../opensaml/saml/config/SAMLConfiguration.java | 19 ++++++++---------
.../impl/AbstractDynamicHTTPMetadataResolver.java | 11 +++++-----
.../resolver/impl/CompositeMetadataResolver.java | 16 ++++-----------
.../impl/BasicEncryptionParametersResolver.java | 24 +++++++++++-----------
.../BasicSignatureSigningParametersResolver.java | 9 ++++----
6 files changed, 43 insertions(+), 60 deletions(-)
diff --git a/opensaml-core/src/main/java/org/opensaml/core/xml/persist/FilesystemLoadSaveManager.java b/opensaml-core/src/main/java/org/opensaml/core/xml/persist/FilesystemLoadSaveManager.java
index b7404d2..4c7f9a2 100644
--- a/opensaml-core/src/main/java/org/opensaml/core/xml/persist/FilesystemLoadSaveManager.java
+++ b/opensaml-core/src/main/java/org/opensaml/core/xml/persist/FilesystemLoadSaveManager.java
@@ -31,6 +31,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;
+import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -45,8 +46,6 @@ import org.opensaml.core.xml.util.XMLObjectSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Predicates;
-import com.google.common.collect.Collections2;
import com.google.common.io.ByteStreams;
import com.google.common.io.Files;
@@ -379,8 +378,7 @@ public class FilesystemLoadSaveManager<T extends XMLObject> extends AbstractCond
* @param filenames Snapshot of filesystem keys at time of construction
*/
public FileIterable(@Nonnull final Collection<String> filenames) {
- keys = new HashSet<>();
- keys.addAll(Collections2.filter(filenames, Predicates.notNull()));
+ keys = filenames.stream().filter(s -> s != null).collect(Collectors.toSet());
}
/** {@inheritDoc} */
@@ -407,8 +405,7 @@ public class FilesystemLoadSaveManager<T extends XMLObject> extends AbstractCond
* @param filenames Snapshot of filesystem keys at time of construction
*/
public FileIterator(@Nonnull final Collection<String> filenames) {
- final Set<String> keys = new HashSet<>();
- keys.addAll(Collections2.filter(filenames, Predicates.notNull()));
+ final Set<String> keys = filenames.stream().filter(s -> s != null).collect(Collectors.toSet());
keysIter = keys.iterator();
}
@@ -429,14 +426,12 @@ public class FilesystemLoadSaveManager<T extends XMLObject> extends AbstractCond
final Pair<String, T> temp = current;
current = null;
return temp;
- } else {
- final Pair<String, T> temp = getNext();
- if (temp != null) {
- return temp;
- } else {
- throw new NoSuchElementException();
- }
}
+ final Pair<String, T> temp = getNext();
+ if (temp != null) {
+ return temp;
+ }
+ throw new NoSuchElementException();
}
/** {@inheritDoc} */
@@ -459,9 +454,8 @@ public class FilesystemLoadSaveManager<T extends XMLObject> extends AbstractCond
// This is to defensively guard against files being removed after files/keys are enumerated.
// Don't fail, just skip
return new Pair<>(key, xmlObject);
- } else {
- log.warn("Target file with key '{}' was removed since iterator creation, skipping", key);
}
+ log.warn("Target file with key '{}' was removed since iterator creation, skipping", key);
} catch (final IOException e) {
log.warn("Error loading target file with key '{}'", key, e);
}
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/config/SAMLConfiguration.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/config/SAMLConfiguration.java
index 3e276ab..71ebfa7 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/config/SAMLConfiguration.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/config/SAMLConfiguration.java
@@ -17,11 +17,10 @@
package org.opensaml.saml.config;
-import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.function.Function;
+import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -29,9 +28,6 @@ import javax.annotation.Nullable;
import org.opensaml.saml.saml1.binding.artifact.SAML1ArtifactBuilderFactory;
import org.opensaml.saml.saml2.binding.artifact.SAML2ArtifactBuilderFactory;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.Lists;
-
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.NotLive;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
@@ -59,7 +55,7 @@ public class SAMLConfiguration {
/** The list of schemes allowed to appear in binding URLs when encoding a message.
* Defaults to 'http' and 'https'. */
- private List<String> allowedBindingURLSchemes;
+ @Nonnull @NonnullElements @Unmodifiable @NotLive private List<String> allowedBindingURLSchemes;
/**
@@ -67,7 +63,7 @@ public class SAMLConfiguration {
*
*/
public SAMLConfiguration() {
- setAllowedBindingURLSchemes(Lists.newArrayList("http", "https"));
+ setAllowedBindingURLSchemes(List.of("http", "https"));
}
/**
@@ -121,7 +117,7 @@ public class SAMLConfiguration {
*/
@Nonnull @NonnullElements @Unmodifiable @NotLive
public List<String> getAllowedBindingURLSchemes() {
- return Collections.unmodifiableList(allowedBindingURLSchemes);
+ return allowedBindingURLSchemes;
}
/**
@@ -142,9 +138,10 @@ public class SAMLConfiguration {
if (schemes == null || schemes.isEmpty()) {
allowedBindingURLSchemes = Collections.emptyList();
} else {
- final Collection<String> normalized = Collections2.transform(
- StringSupport.normalizeStringCollection(schemes), lowercaseFunction::apply);
- allowedBindingURLSchemes = new ArrayList<>(normalized);
+ allowedBindingURLSchemes = StringSupport.normalizeStringCollection(schemes)
+ .stream()
+ .map(lowercaseFunction::apply)
+ .collect(Collectors.toUnmodifiableList());
}
}
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicHTTPMetadataResolver.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicHTTPMetadataResolver.java
index ee34d29..a63d74a 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicHTTPMetadataResolver.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicHTTPMetadataResolver.java
@@ -20,12 +20,12 @@ package org.opensaml.saml.metadata.resolver.impl;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.Timer;
+import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -48,7 +48,6 @@ import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import com.google.common.base.Strings;
-import com.google.common.collect.Collections2;
import com.google.common.io.ByteStreams;
import com.google.common.net.MediaType;
@@ -207,9 +206,11 @@ public abstract class AbstractDynamicHTTPMetadataResolver extends AbstractDynami
if (types == null) {
supportedContentTypes = Collections.emptyList();
} else {
- supportedContentTypes = new ArrayList<>(Collections2.transform(
- StringSupport.normalizeStringCollection(types),
- s -> s == null ? null : s.toLowerCase()));
+ supportedContentTypes = StringSupport.normalizeStringCollection(types)
+ .stream()
+ .filter(s -> s != null)
+ .map(String::toLowerCase)
+ .collect(Collectors.toUnmodifiableList());
}
}
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/CompositeMetadataResolver.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/CompositeMetadataResolver.java
index d566af7..dc9628e 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/CompositeMetadataResolver.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/CompositeMetadataResolver.java
@@ -18,7 +18,6 @@
package org.opensaml.saml.metadata.resolver.impl;
import java.time.Instant;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -43,10 +42,6 @@ import org.opensaml.saml.saml2.metadata.EntityDescriptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Predicates;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
/**
* A {@link MetadataResolver} implementation that answers requests by composing the answers of child
@@ -72,7 +67,7 @@ public class CompositeMetadataResolver extends AbstractIdentifiedInitializableCo
* @return list of currently registered resolvers
*/
@Nonnull @NonnullElements @Unmodifiable @NotLive public List<MetadataResolver> getResolvers() {
- return ImmutableList.copyOf(resolvers);
+ return resolvers;
}
/**
@@ -89,10 +84,9 @@ public class CompositeMetadataResolver extends AbstractIdentifiedInitializableCo
if (newResolvers == null || newResolvers.isEmpty()) {
resolvers = Collections.emptyList();
- return;
+ } else {
+ resolvers = List.copyOf(newResolvers);
}
-
- resolvers = new ArrayList<>(Collections2.filter(newResolvers, Predicates.notNull()));
}
/** {@inheritDoc} */
@@ -264,9 +258,7 @@ public class CompositeMetadataResolver extends AbstractIdentifiedInitializableCo
*/
public CompositeMetadataResolverIterable(final List<MetadataResolver> composedResolvers,
final CriteriaSet metadataCritiera) {
- resolvers =
- ImmutableList.<MetadataResolver> builder()
- .addAll(Iterables.filter(composedResolvers, Predicates.notNull())).build();
+ resolvers = List.copyOf(composedResolvers);
criteria = metadataCritiera;
}
diff --git a/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/BasicEncryptionParametersResolver.java b/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/BasicEncryptionParametersResolver.java
index 50b395f..f8a00c4 100644
--- a/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/BasicEncryptionParametersResolver.java
+++ b/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/BasicEncryptionParametersResolver.java
@@ -44,8 +44,6 @@ import org.opensaml.xmlsec.keyinfo.KeyInfoGenerator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.collect.Collections2;
-
import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
import net.shibboleth.utilities.java.support.logic.Constraint;
import net.shibboleth.utilities.java.support.logic.PredicateSupport;
@@ -585,12 +583,13 @@ public class BasicEncryptionParametersResolver extends AbstractSecurityParameter
@Nonnull final Predicate<String> whitelistBlacklistPredicate) {
final ArrayList<String> accumulator = new ArrayList<>();
- for (final EncryptionConfiguration config : criteria.get(EncryptionConfigurationCriterion.class)
- .getConfigurations()) {
-
- accumulator.addAll(Collections2.filter(config.getDataEncryptionAlgorithms(),
- PredicateSupport.and(getAlgorithmRuntimeSupportedPredicate(), whitelistBlacklistPredicate)::test));
+ for (final EncryptionConfiguration config
+ : criteria.get(EncryptionConfigurationCriterion.class).getConfigurations()) {
+ config.getDataEncryptionAlgorithms()
+ .stream()
+ .filter(PredicateSupport.and(getAlgorithmRuntimeSupportedPredicate(), whitelistBlacklistPredicate))
+ .forEach(accumulator::add);
}
return accumulator;
}
@@ -626,12 +625,13 @@ public class BasicEncryptionParametersResolver extends AbstractSecurityParameter
@Nonnull final Predicate<String> whitelistBlacklistPredicate) {
final ArrayList<String> accumulator = new ArrayList<>();
- for (final EncryptionConfiguration config : criteria.get(EncryptionConfigurationCriterion.class)
- .getConfigurations()) {
-
- accumulator.addAll(Collections2.filter(config.getKeyTransportEncryptionAlgorithms(),
- PredicateSupport.and(getAlgorithmRuntimeSupportedPredicate(), whitelistBlacklistPredicate)::test));
+ for (final EncryptionConfiguration config
+ : criteria.get(EncryptionConfigurationCriterion.class).getConfigurations()) {
+ config.getKeyTransportEncryptionAlgorithms()
+ .stream()
+ .filter(PredicateSupport.and(getAlgorithmRuntimeSupportedPredicate(), whitelistBlacklistPredicate))
+ .forEach(accumulator::add);
}
return accumulator;
}
diff --git a/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/BasicSignatureSigningParametersResolver.java b/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/BasicSignatureSigningParametersResolver.java
index 2701e9e..580ce7c 100644
--- a/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/BasicSignatureSigningParametersResolver.java
+++ b/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/BasicSignatureSigningParametersResolver.java
@@ -45,8 +45,6 @@ import org.opensaml.xmlsec.keyinfo.KeyInfoGenerator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.collect.Collections2;
-
/**
* Basic implementation of {@link SignatureSigningParametersResolver}.
*
@@ -296,9 +294,10 @@ public class BasicSignatureSigningParametersResolver
for (final SignatureSigningConfiguration config : criteria.get(SignatureSigningConfigurationCriterion.class)
.getConfigurations()) {
- accumulator.addAll(Collections2.filter(config.getSignatureAlgorithms(),
- PredicateSupport.and(getAlgorithmRuntimeSupportedPredicate(), whitelistBlacklistPredicate)::test));
-
+ config.getSignatureAlgorithms()
+ .stream()
+ .filter(PredicateSupport.and(getAlgorithmRuntimeSupportedPredicate(), whitelistBlacklistPredicate))
+ .forEach(accumulator::add);
}
return accumulator;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list