[java-identity-provider COMMIT] in /trunk/idp-consent-impl/src: main/java/net/shibboleth/idp/consent/logic/impl/Attri...

noreply at shibboleth.net noreply at shibboleth.net
Tue Oct 13 17:03:29 EDT 2015


Author: tzeller
Date: Tue Oct 13 17:03:28 2015
New Revision: 7816

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=7816&view=rev
Log:
IDP-765 - Use unfiltered attributes to lookup consent storage key.

Change attribute value lookup function to use unfiltered attributes by default.

Modified:
    trunk/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/AttributeValueLookupFunction.java
    trunk/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/AttributeValueLookupFunctionTest.java

Modified: trunk/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/AttributeValueLookupFunction.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/AttributeValueLookupFunction.java?rev=7816&r1=7815&r2=7816&view=diff
==============================================================================
--- trunk/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/AttributeValueLookupFunction.java	(original)
+++ trunk/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/AttributeValueLookupFunction.java	Tue Oct 13 17:03:28 2015
@@ -16,6 +16,8 @@
  */
 
 package net.shibboleth.idp.consent.logic.impl;
+
+import java.util.Map;
 
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
@@ -51,6 +53,9 @@
 
     /** Strategy used to find the {@link AttributeContext} from the {@link ProfileRequestContext}. */
     @Nonnull private Function<ProfileRequestContext, AttributeContext> attributeContextLookupStrategy;
+    
+    /** Whether to use filtered or unfiltered attributes. */
+    private boolean useUnfilteredAttributes;
 
     /**
      * Constructor.
@@ -65,6 +70,8 @@
         attributeContextLookupStrategy =
                 Functions.compose(new ChildContextLookup<>(AttributeContext.class),
                         new ChildContextLookup<ProfileRequestContext, RelyingPartyContext>(RelyingPartyContext.class));
+        
+        useUnfilteredAttributes = true;
     }
 
     /**
@@ -77,6 +84,17 @@
         attributeContextLookupStrategy =
                 Constraint.isNotNull(strategy, "Attribute context lookup strategy cannot be null");
     }
+    
+    /**
+     * Set whether to use filtered or unfiltered attributes.
+     * 
+     * <p>Defaults to true.</p>
+     * 
+     * @param flag flag to set
+     */
+    public void setUseUnfilteredAttributes(final boolean flag) {
+        useUnfilteredAttributes = flag;
+    }
 
     /** {@inheritDoc} */
     @Override
@@ -88,7 +106,11 @@
             return null;
         }
 
-        final IdPAttribute attribute = attributeContext.getIdPAttributes().get(attributeId);
+        final Map<String,IdPAttribute> attributes = useUnfilteredAttributes
+                ? attributeContext.getUnfilteredIdPAttributes()
+                : attributeContext.getIdPAttributes();
+
+        final IdPAttribute attribute = attributes.get(attributeId);
         if (attribute == null || attribute.getValues().isEmpty()) {
             log.debug("Attribute '{}' does not exist or has no values", attributeId);
             return null;

Modified: trunk/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/AttributeValueLookupFunctionTest.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/AttributeValueLookupFunctionTest.java?rev=7816&r1=7815&r2=7816&view=diff
==============================================================================
--- trunk/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/AttributeValueLookupFunctionTest.java	(original)
+++ trunk/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/AttributeValueLookupFunctionTest.java	Tue Oct 13 17:03:28 2015
@@ -18,9 +18,11 @@
 package net.shibboleth.idp.consent.logic.impl;
 
 import java.util.Collections;
+import java.util.Map;
 
 import net.shibboleth.idp.attribute.ByteAttributeValue;
 import net.shibboleth.idp.attribute.IdPAttribute;
+import net.shibboleth.idp.attribute.StringAttributeValue;
 import net.shibboleth.idp.attribute.context.AttributeContext;
 import net.shibboleth.idp.consent.impl.ConsentTestingSupport;
 import net.shibboleth.idp.profile.RequestContextBuilder;
@@ -48,9 +50,17 @@
         prc = new WebflowRequestContextProfileRequestContextLookup().apply(src);
 
         final AttributeContext attributeCtx = new AttributeContext();
-        attributeCtx.setIdPAttributes(ConsentTestingSupport.newAttributeMap().values());
+        
+        final Map<String, IdPAttribute> attributes = ConsentTestingSupport.newAttributeMap();
+        attributeCtx.setIdPAttributes(attributes.values());
+        
+        final Map<String, IdPAttribute> unfilteredAttributes = ConsentTestingSupport.newAttributeMap();
+        final IdPAttribute attribute4 = new IdPAttribute("attribute4");
+        attribute4.setValues(Collections.singleton(new StringAttributeValue("value4")));
+        unfilteredAttributes.put(attribute4.getId(), attribute4);

[... 24 lines stripped ...]


More information about the commits mailing list