[java-identity-provider COMMIT] /trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/ResolveAttribut...

noreply at shibboleth.net noreply at shibboleth.net
Wed May 25 20:06:54 EDT 2016


Author: scantor
Date: Wed May 25 20:06:54 2016
New Revision: 8258

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=8258&view=rev
Log:
Give resolver action the ability to derive the attribute list dynamically.

Modified:
    trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/ResolveAttributes.java

Modified: trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/ResolveAttributes.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/ResolveAttributes.java?rev=8258&r1=8257&r2=8258&view=diff
==============================================================================
--- trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/ResolveAttributes.java	(original)
+++ trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/ResolveAttributes.java	Wed May 25 20:06:54 2016
@@ -39,6 +39,7 @@
 import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
 import net.shibboleth.utilities.java.support.component.ComponentSupport;
 import net.shibboleth.utilities.java.support.logic.Constraint;
+import net.shibboleth.utilities.java.support.logic.FunctionSupport;
 import net.shibboleth.utilities.java.support.primitive.StringSupport;
 import net.shibboleth.utilities.java.support.service.ReloadableService;
 import net.shibboleth.utilities.java.support.service.ServiceableComponent;
@@ -85,8 +86,8 @@
     /** Strategy used to locate or create the {@link AttributeContext} to populate. */
     @Nonnull private Function<ProfileRequestContext,AttributeContext> attributeContextCreationStrategy;
     
-    /** Attribute IDs to pass into resolver. */
-    @Nonnull @NonnullElements private Collection<String> attributesToResolve;
+    /** Strategy used to determine the attributes to resolve. */
+    @Nonnull private Function<ProfileRequestContext,Collection<String>> attributesLookupStrategy;
     
     /** Whether to treat resolver errors as equivalent to resolving no attributes. */
     private boolean maskFailures;
@@ -115,7 +116,8 @@
         attributeContextCreationStrategy = Functions.compose(new ChildContextLookup<>(AttributeContext.class, true),
                 new ChildContextLookup<ProfileRequestContext,RelyingPartyContext>(RelyingPartyContext.class));
         
-        attributesToResolve = Collections.emptyList();
+        attributesLookupStrategy = FunctionSupport.<ProfileRequestContext,Collection<String>>constant(
+                Collections.<String>emptyList());
         
         maskFailures = true;
     }
@@ -181,6 +183,18 @@
     }
     
     /**
+     * Set a strategy to use to obtain the names of the attributes to resolve.
+     * 
+     * @param strategy lookup strategy
+     */
+    public void setAttributesLookupStrategy(
+            @Nonnull final Function<ProfileRequestContext,Collection<String>> strategy) {
+        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+        
+        attributesLookupStrategy = Constraint.isNotNull(strategy, "Attributes lookup strategy cannot be null");
+    }
+    
+    /**
      * Set the attribute IDs to pass into the resolver.
      * 
      * @param attributeIds  attribute ID collection
@@ -189,7 +203,8 @@
         ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
         
         Constraint.isNotNull(attributeIds, "Attribute ID collection cannot be null");
-        attributesToResolve = StringSupport.normalizeStringCollection(attributeIds);
+        attributesLookupStrategy = FunctionSupport.<ProfileRequestContext,Collection<String>>constant(
+                StringSupport.normalizeStringCollection(attributeIds));
     }
     
     /**
@@ -279,7 +294,7 @@
         // Populate requested attributes, if not already set.
         if (resolutionContext.getRequestedIdPAttributeNames() == null
                 || resolutionContext.getRequestedIdPAttributeNames().isEmpty()) {
-            resolutionContext.setRequestedIdPAttributeNames(attributesToResolve);
+            resolutionContext.setRequestedIdPAttributeNames(attributesLookupStrategy.apply(profileRequestContext));
         }
         
         if (null != principalNameLookupStrategy) {



More information about the commits mailing list