[java-identity-provider] branch main updated: IDP-2424 - Accessing user attrs via authnContextTranslationStrategyEx

Codeberg noreply at shibboleth.net
Thu Feb 12 19:46:34 UTC 2026


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

codeberg pushed a commit to branch main
in repository java-identity-provider.

View the commit online:
https://codeberg.org/Shibboleth/java-identity-provider/commit/8224a1dcf8c673e940d48fd6043d4e1672ed144d

The following commit(s) were added to refs/heads/main by this push:
     new 8224a1dcf IDP-2424 - Accessing user attrs via authnContextTranslationStrategyEx
8224a1dcf is described below

commit 8224a1dcf8c673e940d48fd6043d4e1672ed144d
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Feb 11 12:49:47 2026 -0500

    IDP-2424 - Accessing user attrs via authnContextTranslationStrategyEx
    
    https://shibboleth.atlassian.net/browse/IDP-2424
    
    Adjusted original class so the mappings can be to any Principal type.
---
 ...buteSourcedAuthnContextTranslationStrategy.java | 47 ++++++++++++++++++----
 1 file changed, 40 insertions(+), 7 deletions(-)

diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/saml2/profile/config/AttributeSourcedAuthnContextTranslationStrategy.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/saml2/profile/config/AttributeSourcedAuthnContextTranslationStrategy.java
index 3c0ce1880..d043eace3 100644
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/saml2/profile/config/AttributeSourcedAuthnContextTranslationStrategy.java
+++ b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/saml2/profile/config/AttributeSourcedAuthnContextTranslationStrategy.java
@@ -62,7 +62,7 @@ public class AttributeSourcedAuthnContextTranslationStrategy extends AbstractIni
     @Nonnull private Set<String> attributeSourceIDs;
     
     /** Translation map to convert values if necessary. */
-    @Nonnull private Map<String,String> valueMappings;
+    @Nonnull private Map<String,Principal> valueMappings;
     
     /** Constructor. */
     public AttributeSourcedAuthnContextTranslationStrategy() {
@@ -98,14 +98,19 @@ public class AttributeSourcedAuthnContextTranslationStrategy extends AbstractIni
     
     /**
      * Sets the mappings to transform {@link StringAttributeValue} data into different values for use as
-     * context class references.
+     * {@link AuthnContextClassRefPrincipal} objects.
      * 
      * <p>Note that null keys are ignored, but null values are allowed, which suppresses the mapping
      * of a value caising it to be skipped. Also, keys are not trimmed, but values are, to ensure
      * the result is a valid context class reference.</p>
+     *
+     *<p>This is deprecated in favor of the type-neutral variant.</p>
      * 
      * @param mappings the value mappings
+     * 
+     * @deprecated
      */
+    @Deprecated(since="5.2.0", forRemoval=true)
     public void setValueMappings(@Nullable final Map<String,String> mappings) {
         checkSetterPreconditions();
         
@@ -114,7 +119,35 @@ public class AttributeSourcedAuthnContextTranslationStrategy extends AbstractIni
             // Needs to allow for null values.
             for (final Map.Entry<String,String> entry : mappings.entrySet()) {
                 if (entry.getKey() != null) {
-                    valueMappings.put(entry.getKey(), StringSupport.trimOrNull(entry.getValue()));
+                    final String trimmed = StringSupport.trimOrNull(entry.getValue());
+                    valueMappings.put(entry.getKey(),
+                            trimmed != null ? new AuthnContextClassRefPrincipal(trimmed) : null);
+                }
+            }
+        } else {
+            valueMappings = CollectionSupport.emptyMap();
+        }
+    }
+
+    /**
+     * Sets the mappings to transform {@link StringAttributeValue} data into different values for use as
+     * {@link Principal} objects.
+     * 
+     * <p>Note that null keys are ignored, but null values are allowed, which suppresses the mapping
+     * of a value caising it to be skipped. Also, keys are not trimmed, but values are, to ensure
+     * the result is a valid context class reference.</p>
+     * 
+     * @param mappings the value mappings
+     */
+    public void setMappings(@Nullable final Map<String,Principal> mappings) {
+        checkSetterPreconditions();
+        
+        if (mappings != null) {
+            valueMappings = new HashMap<>();
+            // Needs to allow for null values.
+            for (final Map.Entry<String,Principal> entry : mappings.entrySet()) {
+                if (entry.getKey() != null) {
+                    valueMappings.put(entry.getKey(), entry.getValue());
                 }
             }
         } else {
@@ -153,17 +186,17 @@ public class AttributeSourcedAuthnContextTranslationStrategy extends AbstractIni
             .map(StringAttributeValue::getValue)
             .forEach(v -> {
                 if (valueMappings.containsKey(v)) {
-                    final String mapped = valueMappings.get(v);
+                    final Principal mapped = valueMappings.get(v);
                     if (mapped != null) {
-                        log.debug("Attrbute value for {} mapped to AuthnContextClassRef {}", source.getId(), mapped);
-                        results.add(new AuthnContextClassRefPrincipal(mapped));
+                        log.debug("Attrbute value for {} mapped to Principal {}", source.getId(), mapped);
+                        results.add(mapped);
                     } else {
                         log.debug("Skipping suppressed attribute value for {}", source.getId());
                     }
                 } else {
                     final String trimmed = StringSupport.trimOrNull(v);
                     if (trimmed != null) {
-                        log.debug("Attrbute value for {} passed through as AuthnContextClassRef {}", source.getId(),
+                        log.debug("Attrbute value for {} passed through as SAML AuthnContextClassRef {}", source.getId(),
                                 trimmed);
                         results.add(new AuthnContextClassRefPrincipal(trimmed));
                     }

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


More information about the commits mailing list