[java-identity-provider COMMIT] in /trunk/idp-consent/src: main/java/net/shibboleth/idp/consent/flow/ar/PopulateAttri...

noreply at shibboleth.net noreply at shibboleth.net
Thu Mar 19 13:30:19 EDT 2015


Author: tzeller
Date: Thu Mar 19 13:30:19 2015
New Revision: 7436

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=7436&view=rev
Log:
IDP-624 Support ordering attributes displayed to user during attribute release consent.

Added:
    trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/PreferExplicitOrderComparator.java   (with props)
    trunk/idp-consent/src/test/java/net/shibboleth/idp/consent/logic/PreferExplicitOrderComparatorTest.java   (with props)
Modified:
    trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/flow/ar/PopulateAttributeReleaseContext.java
    trunk/idp-consent/src/test/java/net/shibboleth/idp/consent/flow/ar/PopulateAttributeReleaseContextTest.java

Modified: trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/flow/ar/PopulateAttributeReleaseContext.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/flow/ar/PopulateAttributeReleaseContext.java?rev=7436&r1=7435&r2=7436&view=diff
==============================================================================
--- trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/flow/ar/PopulateAttributeReleaseContext.java (original)
+++ trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/flow/ar/PopulateAttributeReleaseContext.java Thu Mar 19 13:30:19 2015
@@ -17,10 +17,12 @@
 
 package net.shibboleth.idp.consent.flow.ar;
 
-import java.util.HashMap;
+import java.util.Comparator;
 import java.util.Map;
+import java.util.TreeMap;
 
 import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
 
 import net.shibboleth.idp.attribute.IdPAttribute;
 import net.shibboleth.idp.profile.context.ProfileInterceptorContext;
@@ -48,6 +50,9 @@
 
     /** Predicate to determine whether consent should be obtained for an attribute. */
     @Nonnull private Predicate<IdPAttribute> attributePredicate;
+    
+    /** Comparator used to sort attributes displayed to user. */
+    @Nullable private Comparator<String> attributeIdComparator;
 
     /**
      * Set the predicate to determine whether consent should be obtained for an attribute.
@@ -56,6 +61,15 @@
      */
     public void setAttributePredicate(@Nonnull final Predicate<IdPAttribute> predicate) {
         attributePredicate = Constraint.isNotNull(predicate, "Attribute predicate cannot be null");
+    }
+
+    /**
+     * Set the comparator used to sort attributes displayed to user.
+     * 
+     * @param comparator comparator used to sort attributes displayed to user
+     */
+    public void setAttributeIdComparator(@Nullable final Comparator<String> comparator) {
+        attributeIdComparator = comparator;
     }
 
     /** {@inheritDoc} */
@@ -73,7 +87,7 @@
 
         final Map<String, IdPAttribute> attributes = getAttributeContext().getIdPAttributes();
 
-        final Map<String, IdPAttribute> consentableAttributes = new HashMap<>(attributes.size());
+        final Map<String, IdPAttribute> consentableAttributes = new TreeMap<>(attributeIdComparator);
         for (final IdPAttribute attribute : attributes.values()) {
             if (attributePredicate.apply(attribute)) {
                 consentableAttributes.put(attribute.getId(), attribute);

Modified: trunk/idp-consent/src/test/java/net/shibboleth/idp/consent/flow/ar/PopulateAttributeReleaseContextTest.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-consent/src/test/java/net/shibboleth/idp/consent/flow/ar/PopulateAttributeReleaseContextTest.java?rev=7436&r1=7435&r2=7436&view=diff
==============================================================================
--- trunk/idp-consent/src/test/java/net/shibboleth/idp/consent/flow/ar/PopulateAttributeReleaseContextTest.java (original)
+++ trunk/idp-consent/src/test/java/net/shibboleth/idp/consent/flow/ar/PopulateAttributeReleaseContextTest.java Thu Mar 19 13:30:19 2015
@@ -17,12 +17,24 @@
 
 package net.shibboleth.idp.consent.flow.ar;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
 import javax.annotation.Nullable;
 
 import net.shibboleth.idp.attribute.IdPAttribute;
+import net.shibboleth.idp.attribute.StringAttributeValue;
+import net.shibboleth.idp.attribute.context.AttributeContext;
 import net.shibboleth.idp.consent.ConsentTestingSupport;
 import net.shibboleth.idp.consent.context.AttributeReleaseContext;
+import net.shibboleth.idp.consent.logic.PreferExplicitOrderComparator;
 import net.shibboleth.idp.profile.ActionTestingSupport;
+import net.shibboleth.idp.profile.context.RelyingPartyContext;
 import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
 
 import org.springframework.webflow.execution.Event;
@@ -31,6 +43,7 @@
 
 import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;
+import com.google.common.collect.Ordering;
 
 /** {@link PopulateAttributeReleaseContext} unit test. */

[... 82 lines stripped ...]


More information about the commits mailing list