[java-opensaml] 09/24: OSJ-173 - Audit Guava Collections transform and filter for problematic usage

Brent Putman putmanb at georgetown.edu
Wed Sep 27 16:46:03 EDT 2017


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

putmanb pushed a commit to branch maint-3.3
in repository java-opensaml.

View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=1391daf521c04e9c22a5a583286c8ab14067e361

commit 1391daf521c04e9c22a5a583286c8ab14067e361
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Fri Jan 13 21:56:07 2017 +0000

    OSJ-173 - Audit Guava Collections transform and filter for problematic usage
    
    https://issues.shibboleth.net/jira/browse/OSJ-173
---
 .../saml/common/profile/logic/EntityAttributesPredicate.java        | 3 +--
 .../saml/metadata/resolver/impl/AbstractBatchMetadataResolver.java  | 3 ++-
 .../java/org/opensaml/security/x509/tls/CertificateNameOptions.java | 3 ++-
 .../security/x509/impl/BasicX509CredentialNameEvaluator.java        | 3 ++-
 .../src/main/java/org/opensaml/xmlsec/impl/BlacklistPredicate.java  | 6 ++++--
 .../src/main/java/org/opensaml/xmlsec/impl/WhitelistPredicate.java  | 6 ++++--
 6 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/EntityAttributesPredicate.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/EntityAttributesPredicate.java
index 958c3c4..6db2e7b 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/EntityAttributesPredicate.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/EntityAttributesPredicate.java
@@ -305,8 +305,7 @@ public class EntityAttributesPredicate implements Predicate<EntityDescriptor> {
          */
         public void setRegexps(@Nonnull @NonnullElements final Collection<Pattern> exps) {
             Constraint.isNotNull(exps, "Regular expressions collection cannot be null");
-            regexps = new ArrayList<>(exps.size());
-            regexps.addAll(Collections2.filter(exps, Predicates.notNull()));
+            regexps = new ArrayList<>(Collections2.filter(exps, Predicates.notNull()));
         }
     }
     
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractBatchMetadataResolver.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractBatchMetadataResolver.java
index 9317ad7..7967bf7 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractBatchMetadataResolver.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractBatchMetadataResolver.java
@@ -125,7 +125,8 @@ public abstract class AbstractBatchMetadataResolver extends AbstractMetadataReso
         if (newIndexes == null) {
             indexes = Collections.emptySet();
         } else {
-            indexes = new HashSet<>(Collections2.filter(newIndexes, Predicates.notNull()));
+            indexes = new HashSet<>();
+            indexes.addAll(Collections2.filter(newIndexes, Predicates.notNull()));
         }
     }
 
diff --git a/opensaml-security-api/src/main/java/org/opensaml/security/x509/tls/CertificateNameOptions.java b/opensaml-security-api/src/main/java/org/opensaml/security/x509/tls/CertificateNameOptions.java
index 56df553..149ea0a 100644
--- a/opensaml-security-api/src/main/java/org/opensaml/security/x509/tls/CertificateNameOptions.java
+++ b/opensaml-security-api/src/main/java/org/opensaml/security/x509/tls/CertificateNameOptions.java
@@ -124,7 +124,8 @@ public class CertificateNameOptions implements Cloneable {
             return;
         }
         
-        subjectAltNames = new HashSet<>(Collections2.filter(names, Predicates.notNull()));
+        subjectAltNames = new HashSet<>();
+        subjectAltNames.addAll(Collections2.filter(names, Predicates.notNull()));
     }
 
     /**
diff --git a/opensaml-security-impl/src/main/java/org/opensaml/security/x509/impl/BasicX509CredentialNameEvaluator.java b/opensaml-security-impl/src/main/java/org/opensaml/security/x509/impl/BasicX509CredentialNameEvaluator.java
index 8d82b60..c76a1b9 100644
--- a/opensaml-security-impl/src/main/java/org/opensaml/security/x509/impl/BasicX509CredentialNameEvaluator.java
+++ b/opensaml-security-impl/src/main/java/org/opensaml/security/x509/impl/BasicX509CredentialNameEvaluator.java
@@ -138,7 +138,8 @@ public class BasicX509CredentialNameEvaluator implements X509CredentialNameEvalu
         if (nameTypes == null) {
             subjectAltNameTypes = Collections.emptySet();
         } else {
-            subjectAltNameTypes = new HashSet<>(Collections2.filter(nameTypes, Predicates.notNull()));
+            subjectAltNameTypes = new HashSet<>();
+            subjectAltNameTypes.addAll(Collections2.filter(nameTypes, Predicates.notNull()));
         }
     }
 
diff --git a/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/BlacklistPredicate.java b/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/BlacklistPredicate.java
index 9a61ba1..ffd43af 100644
--- a/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/BlacklistPredicate.java
+++ b/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/BlacklistPredicate.java
@@ -23,6 +23,7 @@ import java.util.HashSet;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
 import net.shibboleth.utilities.java.support.logic.Constraint;
 
 import com.google.common.base.Predicate;
@@ -35,7 +36,7 @@ import com.google.common.collect.Collections2;
 public class BlacklistPredicate implements Predicate<String> {
     
     /** Blacklisted algorithms. */
-    private Collection<String> blacklist;
+    @Nonnull @NonnullElements private Collection<String> blacklist;
     
     /**
      * Constructor.
@@ -44,7 +45,8 @@ public class BlacklistPredicate implements Predicate<String> {
      */
     public BlacklistPredicate(@Nonnull Collection<String> algorithms) {
         Constraint.isNotNull(algorithms, "Blacklist may not be null");
-        blacklist = new HashSet<>(Collections2.filter(algorithms, Predicates.notNull()));
+        blacklist = new HashSet<>();
+        blacklist.addAll(Collections2.filter(algorithms, Predicates.notNull()));
     }
 
     /** {@inheritDoc} */
diff --git a/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/WhitelistPredicate.java b/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/WhitelistPredicate.java
index 974b787..4689d7f 100644
--- a/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/WhitelistPredicate.java
+++ b/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/WhitelistPredicate.java
@@ -23,6 +23,7 @@ import java.util.HashSet;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
 import net.shibboleth.utilities.java.support.logic.Constraint;
 
 import com.google.common.base.Predicate;
@@ -36,7 +37,7 @@ import com.google.common.collect.Collections2;
 public class WhitelistPredicate implements Predicate<String> {
     
     /** Whitelisted algorithms. */
-    private Collection<String> whitelist;
+    @Nonnull @NonnullElements private Collection<String> whitelist;
     
     /**
      * Constructor.
@@ -45,7 +46,8 @@ public class WhitelistPredicate implements Predicate<String> {
      */
     public WhitelistPredicate(@Nonnull Collection<String> algorithms) {
         Constraint.isNotNull(algorithms, "Whitelist may not be null");
-        whitelist = new HashSet<>(Collections2.filter(algorithms, Predicates.notNull()));
+        whitelist = new HashSet<>();
+        whitelist.addAll(Collections2.filter(algorithms, Predicates.notNull()));
     }
 
     /** {@inheritDoc} */

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


More information about the commits mailing list