[java-opensaml COMMIT] in /trunk: opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/EntityAttrib...

noreply at shibboleth.net noreply at shibboleth.net
Mon Sep 22 13:40:30 EDT 2014


Author: scantor
Date: Mon Sep 22 13:40:29 2014
New Revision: 4041

URL: http://svn.shibboleth.net/view/java-opensaml?rev=4041&view=rev
Log:
IDP-341 - Revised EntityAttributesPredicate with unit test.

Added:
    trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/common/profile/logic/
    trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/common/profile/logic/EntityAttributesPredicateTest.java   (with props)
Modified:
    trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/EntityAttributesPredicate.java
    trunk/opensaml-saml-impl/src/test/resources/data/org/opensaml/saml/metadata/resolver/filter/impl/EntitiesDescriptor-Name-metadata.xml

Modified: trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/EntityAttributesPredicate.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/EntityAttributesPredicate.java?rev=4041&r1=4040&r2=4041&view=diff
==============================================================================
--- trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/EntityAttributesPredicate.java (original)
+++ trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/EntityAttributesPredicate.java Mon Sep 22 13:40:29 2014
@@ -18,19 +18,21 @@
 package org.opensaml.saml.common.profile.logic;
 
 import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
 
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
-import javax.xml.namespace.QName;
 
 import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotLive;
+import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
 import net.shibboleth.utilities.java.support.logic.Constraint;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
 
 import org.joda.time.DateTime;
-import org.opensaml.core.xml.AttributeExtensibleXMLObject;
 import org.opensaml.core.xml.XMLObject;
 import org.opensaml.saml.ext.saml2mdattr.EntityAttributes;
 import org.opensaml.saml.saml2.common.Extensions;
@@ -40,7 +42,6 @@
 import org.opensaml.core.xml.schema.XSAny;
 import org.opensaml.core.xml.schema.XSBase64Binary;
 import org.opensaml.core.xml.schema.XSBoolean;
-import org.opensaml.core.xml.schema.XSBooleanValue;
 import org.opensaml.core.xml.schema.XSDateTime;
 import org.opensaml.core.xml.schema.XSInteger;
 import org.opensaml.core.xml.schema.XSString;
@@ -60,34 +61,28 @@
  */
 public class EntityAttributesPredicate implements Predicate<EntityDescriptor> {
 
-    /** QName of attribute used to signal regex evaluation. */
-    private static final QName REGEX_ATTR_NAME = new QName(null, "regex");
-
     /** Class logger. */
     @Nonnull private final Logger log = LoggerFactory.getLogger(EntityAttributesPredicate.class);
 
     /** Whether to trim the values in the metadata before comparison. */
     private final boolean trimTags;
     
-    /** Set of {@link Attribute} criteria to check for. */
-    @Nonnull @NonnullElements private final Collection<Attribute> tagCriteria;
+    /** Candidates to check for. */
+    @Nonnull @NonnullElements private final Collection<Candidate> candidateSet;
     
     /**
      * Constructor.
      * 
-     * @param tags the {@link Attribute} criteria to check for
+     * @param candidates the {@link Candidate} criteria to check for
      * @param trim true iff the values found in the metadata should be trimmed before comparison
      */
-    public EntityAttributesPredicate(@Nonnull @NonnullElements final Collection<Attribute> tags, final boolean trim) {
-        
-        Constraint.isNotNull(tags, "Attribute collection cannot be null");
-        
-        tagCriteria = Lists.newArrayListWithExpectedSize(tags.size());
-        for (final Attribute tag : Collections2.filter(tags, Predicates.notNull())) {
-            if (!tag.getAttributeValues().isEmpty()) {
-                tagCriteria.add(tag);
-            }
-        }
+    public EntityAttributesPredicate(@Nonnull @NonnullElements final Collection<Candidate> candidates,
+            final boolean trim) {
+        
+        Constraint.isNotNull(candidates, "Attribute collection cannot be null");
+        
+        candidateSet = Lists.newArrayListWithExpectedSize(candidates.size());
+        candidateSet.addAll(Collections2.filter(candidates, Predicates.notNull()));
         
         trimTags = trim;
     }
@@ -100,21 +95,17 @@
             return false;
         }
         
-        boolean extFound = false;
+        Collection<Attribute> entityAttributes = null;
 
         // Check for a tag match in the EntityAttributes extension of the entity and its parent(s).
         Extensions exts = input.getExtensions();
         if (exts != null) {

[... 336 lines stripped ...]


More information about the commits mailing list