[java-plugin-shibd-saml] branch main updated: Implement the attrbute merging logic in the extraction step.

Scott Cantor cantor.2 at osu.edu
Wed Jul 2 14:28:34 UTC 2025


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch main
in repository java-plugin-shibd-saml.

View the commit online:
http://git.shibboleth.net/view/?p=java-plugin-shibd-saml.git;a=commit;h=c473f66f389b88045a3f8531c5fcc3b834d86c07

The following commit(s) were added to refs/heads/main by this push:
     new c473f66  Implement the attrbute merging logic in the extraction step.
c473f66 is described below

commit c473f66f389b88045a3f8531c5fcc3b834d86c07
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Jul 2 10:28:32 2025 -0400

    Implement the attrbute merging logic in the extraction step.
---
 .../saml2/profile/impl/ExtractSAMLAttributes.java  | 27 +++++++++++-----------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/sp-saml-impl/src/main/java/net/shibboleth/sp/saml/saml2/profile/impl/ExtractSAMLAttributes.java b/sp-saml-impl/src/main/java/net/shibboleth/sp/saml/saml2/profile/impl/ExtractSAMLAttributes.java
index b7d7e77..f1b0b49 100644
--- a/sp-saml-impl/src/main/java/net/shibboleth/sp/saml/saml2/profile/impl/ExtractSAMLAttributes.java
+++ b/sp-saml-impl/src/main/java/net/shibboleth/sp/saml/saml2/profile/impl/ExtractSAMLAttributes.java
@@ -17,6 +17,7 @@ package net.shibboleth.sp.saml.saml2.profile.impl;
 import java.time.Instant;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.function.Function;
 import java.util.stream.Collectors;
@@ -150,7 +151,7 @@ public class ExtractSAMLAttributes extends AbstractApplicationAction {
         issuerLookupStrategy = new RelyingPartyIdLookupFunction();
 
         // PRC -> SAMLTokenContext -> AttributeContext
-        attributeContextCreationStrategy = new ChildContextLookup<>(AttributeContext.class, true).compose( 
+        attributeContextCreationStrategy = new ChildContextLookup<>(AttributeContext.class, true).compose(
                 new ChildContextLookup<>(SAMLTokenContext.class));
     }
 
@@ -268,7 +269,9 @@ public class ExtractSAMLAttributes extends AbstractApplicationAction {
         
         processAttributes(profileRequestContext);
         
-        // TODO: figure out merging to handle all the dups
+        // Acumulator of all the merged results.
+        final Map<String,IdPAttribute> accumulator = new HashMap<>();
+        accumulator.putAll(attributeContext.getIdPAttributes());
         
         // Extract standard attributes.
         if (standardExtractionStrategy != null &&
@@ -281,9 +284,8 @@ public class ExtractSAMLAttributes extends AbstractApplicationAction {
                     log.debug("{} Extracted standard attributes: {}", getLogPrefix(),
                             standards.stream().map(IdPAttribute::getId).collect(Collectors.toUnmodifiableList()));
                 }
-                final Collection<IdPAttribute> attributes = new ArrayList<>(attributeContext.getIdPAttributes().values());
-                attributes.addAll(standards);
-                attributeContext.setIdPAttributes(attributes);
+                
+                IdPAttributeSupport.withMapMergeDuplicates(accumulator, standards);
             }
         }
 
@@ -297,9 +299,7 @@ public class ExtractSAMLAttributes extends AbstractApplicationAction {
                     log.debug("{} Extracted attributes with custom strategy: {}", getLogPrefix(),
                             newAttributes.stream().map(IdPAttribute::getId).collect(Collectors.toUnmodifiableList()));
                 }
-                final Collection<IdPAttribute> attributes = new ArrayList<>(attributeContext.getIdPAttributes().values());
-                attributes.addAll(newAttributes);
-                attributeContext.setIdPAttributes(attributes);
+                IdPAttributeSupport.withMapMergeDuplicates(accumulator, newAttributes);
             }
         }
         
@@ -311,11 +311,12 @@ public class ExtractSAMLAttributes extends AbstractApplicationAction {
                     log.debug("{} Resolved attributes internally: {}", getLogPrefix(),
                             newAttributes.stream().map(IdPAttribute::getId).collect(Collectors.toUnmodifiableList()));
                 }
-                final Collection<IdPAttribute> attributes = new ArrayList<>(attributeContext.getIdPAttributes().values());
-                attributes.addAll(newAttributes);
-                attributeContext.setIdPAttributes(attributes);
+                IdPAttributeSupport.withMapMergeDuplicates(accumulator, newAttributes);
             }
         }
+        
+        // Install the final result back.
+        attributeContext.setIdPAttributes(accumulator);
     }
     
     /**
@@ -471,7 +472,7 @@ public class ExtractSAMLAttributes extends AbstractApplicationAction {
             final AttributeFilter filter = filterComponent.getComponent();
             filter.filterAttributes(filterContext);
             filterContext.removeFromParent();
-            attributeContext.setIdPAttributes(filterContext.getFilteredIdPAttributes().values());
+            attributeContext.setIdPAttributes(filterContext.getFilteredIdPAttributes());
         } catch (final AttributeFilterException e) {
             log.error("{} Error while filtering inbound attributes", getLogPrefix(), e);
         } catch (final ServiceException e) {
@@ -489,7 +490,7 @@ public class ExtractSAMLAttributes extends AbstractApplicationAction {
             @Nonnull final AttributeFilterContext filterContext) {
         
         filterContext.setDirection(Direction.INBOUND)
-            .setPrefilteredIdPAttributes(attributeContext.getUnfilteredIdPAttributes().values())
+            .setPrefilteredIdPAttributes(attributeContext.getUnfilteredIdPAttributes())
             .setRequesterMetadataContextLookupStrategy(null)
             .setIssuerMetadataContextLookupStrategy(
                     new SAMLMetadataContextLookupFunction().compose(

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list