[java-shib-attribute] branch main updated: JSATTR-47 - AttributesMapContainer multimap regression on duplicates
Codeberg
noreply at shibboleth.net
Thu Mar 12 13:57:41 UTC 2026
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch main
in repository java-shib-attribute.
View the commit online:
https://codeberg.org/Shibboleth/java-shib-attribute/commit/f6b5c6fda77f66d66f211ce0ff3787b4aed576e4
The following commit(s) were added to refs/heads/main by this push:
new f6b5c6fda JSATTR-47 - AttributesMapContainer multimap regression on duplicates
f6b5c6fda is described below
commit f6b5c6fda77f66d66f211ce0ff3787b4aed576e4
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Mar 12 09:57:30 2026 -0400
JSATTR-47 - AttributesMapContainer multimap regression on duplicates
https://shibboleth.atlassian.net/browse/JSATTR-47
Convert to ListMultimap
Add unit test
---
.../spring/AttributeMappingNodeProcessorTest.java | 36 ++++++++++++++++++++++
.../idp/saml/attribute/impl/metadata.xml | 8 +++++
.../impl/AttributeMappingNodeProcessor.java | 6 ++--
3 files changed, 47 insertions(+), 3 deletions(-)
diff --git a/shib-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/AttributeMappingNodeProcessorTest.java b/shib-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/AttributeMappingNodeProcessorTest.java
index 3a3474723..8cf50fef5 100644
--- a/shib-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/AttributeMappingNodeProcessorTest.java
+++ b/shib-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/AttributeMappingNodeProcessorTest.java
@@ -17,6 +17,7 @@ package net.shibboleth.idp.attribute.resolver.spring;
import static org.testng.Assert.*;
import java.util.Collection;
+import java.util.Iterator;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -131,6 +132,41 @@ public class AttributeMappingNodeProcessorTest extends XMLObjectBaseTestCase {
CollectionSupport.singletonList("http://id.incommon.org/category/research-and-scholarship"));
}
+ // Regression test for JSATTR-47.
+ @Test public void duplicateAttributes() throws FilterException {
+ final EntityDescriptor localEntityDescriptor = entityDescriptor;
+ assert localEntityDescriptor != null;
+ assertTrue(localEntityDescriptor.getObjectMetadata().get(AttributesMapContainer.class).isEmpty());
+
+ assert processor != null;
+ processor.process(localEntityDescriptor);
+
+ final AttributesMapContainer container =
+ localEntityDescriptor.getObjectMetadata().get(AttributesMapContainer.class).get(0);
+
+ final Multimap<String, IdPAttribute> map = container.get();
+ assert map != null;
+
+ assertFalse(map.isEmpty());
+ Collection<IdPAttribute> attribute = map.get("http://shibboleth.net/duptest");
+ assertEquals(attribute.size(), 2);
+
+ final Iterator<IdPAttribute> i = attribute.iterator();
+
+ IdPAttribute attr = i.next();
+ assertEquals(attr.getValues().size(), 1);
+ StringAttributeValue sav = (StringAttributeValue) attr.getValues().iterator().next();
+ assertEquals(sav.getValue(), "foo");
+
+ attr = i.next();
+ assertEquals(attr.getValues().size(), 1);
+ sav = (StringAttributeValue) attr.getValues().iterator().next();
+ assertEquals(sav.getValue(), "bar");
+
+ assertEquals(container.getStringValues("http://shibboleth.net/duptest"),
+ CollectionSupport.listOf("foo", "bar"));
+ }
+
@Test public void requiredAttributes() throws FilterException {
assert entityDescriptor != null;
diff --git a/shib-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/saml/attribute/impl/metadata.xml b/shib-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/saml/attribute/impl/metadata.xml
index 980aa3aef..e3a641337 100644
--- a/shib-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/saml/attribute/impl/metadata.xml
+++ b/shib-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/saml/attribute/impl/metadata.xml
@@ -37,6 +37,14 @@
<saml:AttributeValue>
<RequestedAttribute Name="bar" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic" />
</saml:AttributeValue>
+ </saml:Attribute>
+ <saml:Attribute Name="http://shibboleth.net/duptest"
+ NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
+ <saml:AttributeValue>foo</saml:AttributeValue>
+ </saml:Attribute>
+ <saml:Attribute Name="http://shibboleth.net/duptest"
+ NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
+ <saml:AttributeValue>bar</saml:AttributeValue>
</saml:Attribute>
</mdattr:EntityAttributes>
</Extensions>
diff --git a/shib-saml-attribute-impl/src/main/java/net/shibboleth/idp/saml/attribute/impl/AttributeMappingNodeProcessor.java b/shib-saml-attribute-impl/src/main/java/net/shibboleth/idp/saml/attribute/impl/AttributeMappingNodeProcessor.java
index e17c0e22b..7d3f45390 100644
--- a/shib-saml-attribute-impl/src/main/java/net/shibboleth/idp/saml/attribute/impl/AttributeMappingNodeProcessor.java
+++ b/shib-saml-attribute-impl/src/main/java/net/shibboleth/idp/saml/attribute/impl/AttributeMappingNodeProcessor.java
@@ -35,7 +35,7 @@ import org.opensaml.saml.saml2.metadata.Extensions;
import org.opensaml.saml.saml2.metadata.RequestedAttribute;
import org.slf4j.Logger;
-import com.google.common.collect.HashMultimap;
+import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import net.shibboleth.idp.attribute.AttributeDecodingException;
@@ -126,7 +126,7 @@ public class AttributeMappingNodeProcessor implements MetadataNodeProcessor {
return;
}
- final Multimap<String,IdPAttribute> results = HashMultimap.create();
+ final Multimap<String,IdPAttribute> results = ArrayListMultimap.create();
assert results != null;
for (final RequestedAttribute req : requestedAttributes) {
@@ -169,7 +169,7 @@ public class AttributeMappingNodeProcessor implements MetadataNodeProcessor {
}
- final Multimap<String,IdPAttribute> results = HashMultimap.create();
+ final Multimap<String,IdPAttribute> results = ArrayListMultimap.create();
assert results != null;
for (final XMLObject xmlObj : entityAttributesList) {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list