[java-opensaml COMMIT] in /trunk/opensaml-xmlsec-impl/src: main/java/org/opensaml/xmlsec/impl/AbstractSecurityParamet...

noreply at shibboleth.net noreply at shibboleth.net
Tue May 6 17:31:51 EDT 2014


Author: putmanb
Date: Tue May  6 17:31:50 2014
New Revision: 3839

URL: http://svn.shibboleth.net/view/java-opensaml?rev=3839&view=rev
Log:
Extract white- and blacklist predicates out to separate classes.  No need to be nested, and easier to test.

Added:
    trunk/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/BlacklistPredicate.java   (with props)
    trunk/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/WhitelistPredicate.java   (with props)
    trunk/opensaml-xmlsec-impl/src/test/java/org/opensaml/xmlsec/impl/
    trunk/opensaml-xmlsec-impl/src/test/java/org/opensaml/xmlsec/impl/BlacklistPredicateTest.java   (with props)
    trunk/opensaml-xmlsec-impl/src/test/java/org/opensaml/xmlsec/impl/WhitelistPredicateTest.java   (with props)
Modified:
    trunk/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/AbstractSecurityParametersResolver.java

Modified: trunk/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/AbstractSecurityParametersResolver.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/AbstractSecurityParametersResolver.java?rev=3839&r1=3838&r2=3839&view=diff
==============================================================================
--- trunk/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/AbstractSecurityParametersResolver.java (original)
+++ trunk/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/AbstractSecurityParametersResolver.java Tue May  6 17:31:50 2014
@@ -40,8 +40,6 @@
 
 import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.Lists;
 
 /**
  * Abstract base class for security parameters resolvers which supplies commonly used functionality for reuse.
@@ -222,64 +220,5 @@
         
         return configs.get(0).getWhitelistBlacklistPrecedence();
     }
-    
-    /**
-     * Predicate which implements an algorithm URI whitelist policy.
-     */
-    public class WhitelistPredicate implements Predicate<String> {
-        
-        /** Whitelisted algorithms. */
-        private Collection<String> whitelist;
-        
-        /**
-         * Constructor.
-         *
-         * @param algorithms collection of whitelisted algorithms
-         */
-        public WhitelistPredicate(@Nonnull Collection<String> algorithms) {
-            Constraint.isNotNull(algorithms, "Whitelist may not be null");
-            whitelist = Lists.newArrayList(Collections2.filter(algorithms, Predicates.notNull()));
-        }
-
-        /** {@inheritDoc} */
-        public boolean apply(@Nullable String input) {
-            if (input == null) {
-                throw new IllegalArgumentException("Algorithm URI to evaluate may not be null");
-            }
-            if (whitelist.isEmpty()) {
-                return true;
-            }
-            return whitelist.contains(input);
-        }
-        
-    }
-
-    /**
-     * Predicate which implements an algorithm URI blacklist policy.
-     */
-    public class BlacklistPredicate implements Predicate<String> {
-        
-        /** Blacklisted algorithms. */
-        private Collection<String> blacklist;
-        
-        /**
-         * Constructor.
-         *
-         * @param algorithms collection of blacklisted algorithms
-         */
-        public BlacklistPredicate(@Nonnull Collection<String> algorithms) {
-            Constraint.isNotNull(algorithms, "Blacklist may not be null");
-            blacklist = Lists.newArrayList(Collections2.filter(algorithms, Predicates.notNull()));
-        }
-
-        /** {@inheritDoc} */
-        public boolean apply(@Nullable String input) {
-            if (input == null) {
-                throw new IllegalArgumentException("Algorithm URI to evaluate may not be null");
-            }
-            return ! blacklist.contains(input);
-        }
-        
-    }
 
 }



More information about the commits mailing list