[java-identity-provider COMMIT] in /trunk/idp-attribute-filter-impl/src: main/java/net/shibboleth/idp/attribute/filte...

noreply at shibboleth.net noreply at shibboleth.net
Wed Jun 10 20:42:14 EDT 2015


Author: scantor
Date: Wed Jun 10 20:42:13 2015
New Revision: 7556

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=7556&view=rev
Log:
IDP-734 - EntityAttribute-based PolicyRule doesn't handle split EntityAttributes

Modified:
    trunk/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AbstractEntityAttributePolicyRule.java
    trunk/idp-attribute-filter-impl/src/test/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AttributeRequesterEntityAttributeExactPolicyRuleTest.java
    trunk/idp-attribute-filter-impl/src/test/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AttributeRequesterEntityAttributeRegexPolicyRuleTest.java
    trunk/idp-attribute-filter-impl/src/test/resources/data/net/shibboleth/idp/filter/impl/saml/shibboleth.net-metadata.xml

Modified: trunk/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AbstractEntityAttributePolicyRule.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AbstractEntityAttributePolicyRule.java?rev=7556&r1=7555&r2=7556&view=diff
==============================================================================
--- trunk/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AbstractEntityAttributePolicyRule.java	(original)
+++ trunk/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/policyrule/saml/impl/AbstractEntityAttributePolicyRule.java	Wed Jun 10 20:42:13 2015
@@ -17,6 +17,7 @@
 
 package net.shibboleth.idp.attribute.filter.policyrule.saml.impl;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
 
@@ -26,6 +27,8 @@
 import net.shibboleth.idp.attribute.filter.context.AttributeFilterContext;
 import net.shibboleth.idp.attribute.filter.policyrule.impl.AbstractPolicyRule;
 import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
 import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
 import net.shibboleth.utilities.java.support.component.ComponentSupport;
 import net.shibboleth.utilities.java.support.logic.Constraint;
@@ -115,15 +118,9 @@
             return Tristate.FALSE;
         }
 
-        Attribute entityAttribute = getEntityAttribute(entityDescriptor);
-        if (entityAttribute == null) {
-            log.debug("{} No entityAttribute for the entity, returning FALSE", getLogPrefix());
-            return Tristate.FALSE;
-        }
-
-        List<XMLObject> attributeValues = entityAttribute.getAttributeValues();
+        final List<XMLObject> attributeValues = getEntityAttributeValues(entityDescriptor);
         if (attributeValues == null || attributeValues.isEmpty()) {
-            log.debug("{} Entity attribute {} for entity {} does not contain any values, returning FALSE",
+            log.debug("{} Entity attribute {} for entity {} does not exist or contains no values, returning FALSE",
                     getLogPrefix(), getAttributeName(), entityDescriptor.getEntityID());
             return Tristate.FALSE;
         }
@@ -131,7 +128,7 @@
         log.debug("{} Checking if entity attribute {} contains the required value.", getLogPrefix(),
                 getAttributeName());
         String valueString;
-        for (XMLObject attributeValue : attributeValues) {
+        for (final XMLObject attributeValue : attributeValues) {
             if (attributeValue instanceof XSAny) {
                 valueString = ((XSAny) attributeValue).getTextContent();
             } else if (attributeValue instanceof XSString) {
@@ -156,59 +153,6 @@
         return Tristate.FALSE;
     }
 
-    /**
-     * Gets the entity attribute from the given entity metadata. If both the attribute name and name format for this
-     * match functor is configured then both must match, otherwise only the attribute name must match.
-     * 
-     * @param entityDescriptor the metadata for the entity
-     * 
-     * @return the entity or null if the metadata does not contain such an entity attribute
-     */
-    // Checkstyle: CyclomaticComplexity OFF
-    @Nullable protected Attribute getEntityAttribute(EntityDescriptor entityDescriptor) {
-        List<XMLObject> entityAttributesCollection = null;
-        if (entityDescriptor.getExtensions() != null) {
-            entityAttributesCollection =
-                    entityDescriptor.getExtensions().getUnknownXMLObjects(EntityAttributes.DEFAULT_ELEMENT_NAME);
-        }
-        if (entityAttributesCollection == null || entityAttributesCollection.isEmpty()) {
-            log.debug("{} Descriptor for {} does not contain any EntityAttributes", getLogPrefix(),
-                    entityDescriptor.getEntityID());
-            return null;
-        }
-

[... 171 lines stripped ...]


More information about the commits mailing list