[java-oidc-common] branch main updated: Tighten up attribute value checking and add resolutionPhase to setup.

Scott Cantor cantor.2 at osu.edu
Wed Feb 17 18:13:54 UTC 2021


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

scantor pushed a commit to branch main
in repository java-oidc-common.

View the commit online:
http://git.shibboleth.net/view/?p=java-oidc-common.git;a=commit;h=7bbcc528b7fb2ca16e019d54a3594db0f3936b1b

The following commit(s) were added to refs/heads/main by this push:
       new  7bbcc52   Tighten up attribute value checking and add resolutionPhase to setup.
7bbcc52 is described below

commit 7bbcc528b7fb2ca16e019d54a3594db0f3936b1b
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Feb 17 13:13:52 2021 -0500

    Tighten up attribute value checking and add resolutionPhase to setup.
---
 .../impl/ResolverServiceClientSecretValueResolver.java | 18 ++++++++++++++----
 .../metadata/impl/attribute-resolver-clientsecrets.xml |  4 +++-
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/metadata/impl/ResolverServiceClientSecretValueResolver.java b/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/metadata/impl/ResolverServiceClientSecretValueResolver.java
index 649f95b..d8e665b 100644
--- a/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/metadata/impl/ResolverServiceClientSecretValueResolver.java
+++ b/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/metadata/impl/ResolverServiceClientSecretValueResolver.java
@@ -26,10 +26,13 @@ import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
 import org.opensaml.core.criterion.EntityIdCriterion;
+import org.opensaml.profile.context.ProfileRequestContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import net.shibboleth.idp.attribute.IdPAttribute;
+import net.shibboleth.idp.attribute.IdPAttributeValue;
+import net.shibboleth.idp.attribute.StringAttributeValue;
 import net.shibboleth.idp.attribute.resolver.AttributeResolver;
 import net.shibboleth.idp.attribute.resolver.context.AttributeResolutionContext;
 import net.shibboleth.oidc.metadata.criterion.ClientSecretReferenceCriterion;
@@ -116,8 +119,11 @@ public class ResolverServiceClientSecretValueResolver extends AbstractClientSecr
         Constraint.isNotNull(referenceCriterion,
                 "The client secret reference criterion must be included in the criteria.");
 
-        final AttributeResolutionContext resolutionContext = new AttributeResolutionContext();
+        final ProfileRequestContext profileRequestContext = new ProfileRequestContext();
+        final AttributeResolutionContext resolutionContext =
+                profileRequestContext.getSubcontext(AttributeResolutionContext.class, true);
         resolutionContext.setPrincipal(referenceCriterion.getSecretReference());
+        resolutionContext.setResolutionLabel(getClass().getSimpleName());
         if (criteria.contains(EntityIdCriterion.class)) {
             resolutionContext.setAttributeRecipientID(criteria.get(EntityIdCriterion.class).getEntityId());
         }
@@ -126,9 +132,13 @@ public class ResolverServiceClientSecretValueResolver extends AbstractClientSecr
         final LazySet<String> result = new LazySet<>();
         for (final String attributeId : attributeIds) {
             if (resolvedAttributes.containsKey(attributeId)) {
-                log.debug("Found a value for reference '{}' via attribute ID {}",
-                        referenceCriterion.getSecretReference(), attributeId);
-                result.add((String) resolvedAttributes.get(attributeId).getValues().get(0).getNativeValue());
+                for (final IdPAttributeValue value : resolvedAttributes.get(attributeId).getValues()) {
+                    if (value instanceof StringAttributeValue) {
+                        log.debug("Found a value for reference '{}' via attribute ID {}",
+                                referenceCriterion.getSecretReference(), attributeId);
+                        result.add(((StringAttributeValue) value).getValue());
+                    }
+                }
             }
         }
         return result;
diff --git a/oidc-common-metadata-impl/src/test/resources/net/shibboleth/oidc/metadata/impl/attribute-resolver-clientsecrets.xml b/oidc-common-metadata-impl/src/test/resources/net/shibboleth/oidc/metadata/impl/attribute-resolver-clientsecrets.xml
index 69e60d1..699a936 100644
--- a/oidc-common-metadata-impl/src/test/resources/net/shibboleth/oidc/metadata/impl/attribute-resolver-clientsecrets.xml
+++ b/oidc-common-metadata-impl/src/test/resources/net/shibboleth/oidc/metadata/impl/attribute-resolver-clientsecrets.xml
@@ -21,7 +21,8 @@
 
     <!-- Example Relational Database Connector -->
 
-    <DataConnector id="myDB" xsi:type="RelationalDatabase">
+    <DataConnector id="myDB" xsi:type="RelationalDatabase"
+            resolutionPhases="ResolverServiceClientSecretValueResolver">
         <SimpleManagedConnection
 	        jdbcDriver="org.hsqldb.jdbc.JDBCDriver"
 	        jdbcURL="jdbc:hsqldb:mem:myTestDB"
@@ -37,6 +38,7 @@
 
     <!-- Example LDAP Connector -->
     <DataConnector id="myLDAP" xsi:type="LDAPDirectory"
+        resolutionPhases="ResolverServiceClientSecretValueResolver"
         ldapURL="ldap://localhost:10391" 
         baseDN="dc=shibboleth,dc=net"
         connectTimeout="PT6S"

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


More information about the commits mailing list