[java-idp-oidc] branch main updated: Convert token auth methods setting to a Set.

Scott Cantor cantor.2 at osu.edu
Tue Dec 14 19:31:56 UTC 2021


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

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

View the commit online:
http://git.shibboleth.net/view/?p=java-idp-oidc.git;a=commit;h=530154cd73e42f53d400305abb7dc32c9e9ab2c0

The following commit(s) were added to refs/heads/main by this push:
     new 530154cd Convert token auth methods setting to a Set.
530154cd is described below

commit 530154cd73e42f53d400305abb7dc32c9e9ab2c0
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Dec 14 14:31:53 2021 -0500

    Convert token auth methods setting to a Set.
---
 ...AddTokenEndpointAuthMethodsToClientMetadata.java | 11 ++++++-----
 .../impl/ValidateEndpointAuthentication.java        | 10 +++++-----
 .../idp/service/relying-party/postconfig.xml        |  8 ++++----
 .../impl/ValidateEndpointAuthenticationTest.java    | 21 +++++++++------------
 4 files changed, 24 insertions(+), 26 deletions(-)

diff --git a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/AddTokenEndpointAuthMethodsToClientMetadata.java b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/AddTokenEndpointAuthMethodsToClientMetadata.java
index 67378551..e4840de2 100644
--- a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/AddTokenEndpointAuthMethodsToClientMetadata.java
+++ b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/AddTokenEndpointAuthMethodsToClientMetadata.java
@@ -17,7 +17,7 @@
 
 package net.shibboleth.idp.plugin.oidc.op.profile.impl;
 
-import java.util.List;
+import java.util.Set;
 import java.util.function.Function;
 
 import javax.annotation.Nonnull;
@@ -45,7 +45,7 @@ public class AddTokenEndpointAuthMethodsToClientMetadata extends AbstractOIDCCli
     @Nonnull private final Logger log = LoggerFactory.getLogger(AddTokenEndpointAuthMethodsToClientMetadata.class);
     
     /** Strategy to obtain enabled token endpoint authentication methods. */
-    @Nullable private Function<ProfileRequestContext, List<ClientAuthenticationMethod>> 
+    @Nullable private Function<ProfileRequestContext,Set<ClientAuthenticationMethod>> 
         tokenEndpointAuthMethodsLookupStrategy;
     
     /**
@@ -60,7 +60,7 @@ public class AddTokenEndpointAuthMethodsToClientMetadata extends AbstractOIDCCli
      * @param strategy What to set.
      */
     public void setTokenEndpointAuthMethodsLookupStrategy(@Nonnull final Function<ProfileRequestContext, 
-            List<ClientAuthenticationMethod>> strategy) {
+            Set<ClientAuthenticationMethod>> strategy) {
         tokenEndpointAuthMethodsLookupStrategy = Constraint.isNotNull(strategy, 
                 "Strategy to obtain enabled token endpoint authentication methods cannot be null");
         
@@ -71,7 +71,7 @@ public class AddTokenEndpointAuthMethodsToClientMetadata extends AbstractOIDCCli
     protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
         final ClientAuthenticationMethod requestedMethod = getInputMetadata().getTokenEndpointAuthMethod() != null ? 
                 getInputMetadata().getTokenEndpointAuthMethod() : ClientAuthenticationMethod.getDefault();
-        final List<ClientAuthenticationMethod> enabledMethods 
+        final Set<ClientAuthenticationMethod> enabledMethods 
             = tokenEndpointAuthMethodsLookupStrategy.apply(profileRequestContext);
         if (enabledMethods == null || !enabledMethods.contains(requestedMethod)) {
             log.warn("{} Non-supported token_endpoint_auth_method {}", getLogPrefix(), requestedMethod);
@@ -80,4 +80,5 @@ public class AddTokenEndpointAuthMethodsToClientMetadata extends AbstractOIDCCli
         }
         getOutputMetadata().setTokenEndpointAuthMethod(requestedMethod);
     }
-}
+
+}
\ No newline at end of file
diff --git a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/ValidateEndpointAuthentication.java b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/ValidateEndpointAuthentication.java
index 4473e7e4..cba47e49 100644
--- a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/ValidateEndpointAuthentication.java
+++ b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/ValidateEndpointAuthentication.java
@@ -17,7 +17,7 @@
 
 package net.shibboleth.idp.plugin.oidc.op.profile.impl;
 
-import java.util.List;
+import java.util.Set;
 import java.util.function.Function;
 
 import javax.annotation.Nonnull;
@@ -63,7 +63,7 @@ public class ValidateEndpointAuthentication extends AbstractOIDCRequestAction<Ab
     @Nonnull private Function<ProfileRequestContext, OIDCMetadataContext> oidcMetadataContextLookupStrategy;
     
     /** Strategy to obtain enabled token endpoint authentication methods. */
-    @Nullable private Function<ProfileRequestContext, List<ClientAuthenticationMethod>> 
+    @Nullable private Function<ProfileRequestContext, Set<ClientAuthenticationMethod>> 
         tokenEndpointAuthMethodsLookupStrategy;
     
     /** The attached OIDC metadata context. */
@@ -106,7 +106,7 @@ public class ValidateEndpointAuthentication extends AbstractOIDCRequestAction<Ab
      * @param strategy What to set.
      */
     public void setTokenEndpointAuthMethodsLookupStrategy(@Nonnull final Function<ProfileRequestContext, 
-            List<ClientAuthenticationMethod>> strategy) {
+            Set<ClientAuthenticationMethod>> strategy) {
         tokenEndpointAuthMethodsLookupStrategy = Constraint.isNotNull(strategy, 
                 "Strategy to obtain enabled token endpoint authentication methods cannot be null");
         
@@ -152,7 +152,7 @@ public class ValidateEndpointAuthentication extends AbstractOIDCRequestAction<Ab
         final ClientAuthenticationMethod clientAuthMethod = clientMetadata.getTokenEndpointAuthMethod() != null ? 
                 clientMetadata.getTokenEndpointAuthMethod() : ClientAuthenticationMethod.CLIENT_SECRET_BASIC;
         final ClientAuthentication clientAuth = request.getClientAuthentication();
-        final List<ClientAuthenticationMethod> enabledMethods = 
+        final Set<ClientAuthenticationMethod> enabledMethods = 
                 tokenEndpointAuthMethodsLookupStrategy.apply(profileRequestContext);
                 
         if (enabledAndEquals(enabledMethods, clientAuthMethod, ClientAuthenticationMethod.NONE)) {
@@ -203,7 +203,7 @@ public class ValidateEndpointAuthentication extends AbstractOIDCRequestAction<Ab
      * @param desiredMethod The desired authentication method.
      * @return True if enabled and matching, false otherwise.
      */
-    protected boolean enabledAndEquals(final List<ClientAuthenticationMethod> enabledMethods, 
+    protected boolean enabledAndEquals(final Set<ClientAuthenticationMethod> enabledMethods, 
             final ClientAuthenticationMethod requestedMethod, final ClientAuthenticationMethod desiredMethod) {
         if (requestedMethod.equals(desiredMethod)) {
             if (enabledMethods == null || enabledMethods.isEmpty()) {
diff --git a/idp-oidc-extension-impl/src/main/resources/META-INF/net/shibboleth/idp/service/relying-party/postconfig.xml b/idp-oidc-extension-impl/src/main/resources/META-INF/net/shibboleth/idp/service/relying-party/postconfig.xml
index fbb9bb3c..1a68ea14 100644
--- a/idp-oidc-extension-impl/src/main/resources/META-INF/net/shibboleth/idp/service/relying-party/postconfig.xml
+++ b/idp-oidc-extension-impl/src/main/resources/META-INF/net/shibboleth/idp/service/relying-party/postconfig.xml
@@ -117,7 +117,7 @@
             <bean parent="shibboleth.MDDrivenStringProperty" p:propertyName="issuer" p:defaultValue-ref="issuer" />
         </property>
         <property name="tokenEndpointAuthMethodsLookupStrategy">
-            <bean parent="shibboleth.MDDrivenListProperty" p:propertyName="tokenEndpointAuthMethods">
+            <bean parent="shibboleth.MDDrivenSetProperty" p:propertyName="tokenEndpointAuthMethods">
                 <property name="defaultValue">
                     <bean parent="shibboleth.CommaDelimStringArray">
                         <constructor-arg type="java.lang.String"
@@ -286,7 +286,7 @@
             <bean parent="shibboleth.MDDrivenStringProperty" p:propertyName="issuer" p:defaultValue-ref="issuer" />
         </property>
         <property name="tokenEndpointAuthMethodsLookupStrategy">
-            <bean parent="shibboleth.MDDrivenListProperty" p:propertyName="tokenEndpointAuthMethods">
+            <bean parent="shibboleth.MDDrivenSetProperty" p:propertyName="tokenEndpointAuthMethods">
                 <property name="defaultValue">
                     <bean parent="shibboleth.CommaDelimStringArray">
                         <constructor-arg type="java.lang.String"
@@ -324,7 +324,7 @@
     <bean id="OAUTH2.Revocation.MDDriven" parent="AbstractMDDrivenOIDCProfile" lazy-init="true"
             class="net.shibboleth.oidc.profile.oauth2.config.OAuth2TokenRevocationConfiguration">
         <property name="tokenEndpointAuthMethodsLookupStrategy">
-            <bean parent="shibboleth.MDDrivenListProperty" p:propertyName="tokenEndpointAuthMethods">
+            <bean parent="shibboleth.MDDrivenSetProperty" p:propertyName="tokenEndpointAuthMethods">
                 <property name="defaultValue">
                     <bean parent="shibboleth.CommaDelimStringArray">
                         <constructor-arg type="java.lang.String"
@@ -338,7 +338,7 @@
     <bean id="OAUTH2.Introspection.MDDriven" parent="AbstractMDDrivenOIDCProfile" lazy-init="true"
             class="net.shibboleth.oidc.profile.oauth2.config.OAuth2TokenIntrospectionConfiguration">
         <property name="tokenEndpointAuthMethodsLookupStrategy">
-            <bean parent="shibboleth.MDDrivenListProperty" p:propertyName="tokenEndpointAuthMethods">
+            <bean parent="shibboleth.MDDrivenSetProperty" p:propertyName="tokenEndpointAuthMethods">
                 <property name="defaultValue">
                     <bean parent="shibboleth.CommaDelimStringArray">
                         <constructor-arg type="java.lang.String"
diff --git a/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/ValidateEndpointAuthenticationTest.java b/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/ValidateEndpointAuthenticationTest.java
index 35aca11d..4b3b267b 100644
--- a/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/ValidateEndpointAuthenticationTest.java
+++ b/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/ValidateEndpointAuthenticationTest.java
@@ -24,17 +24,14 @@ import java.security.KeyPairGenerator;
 import java.security.NoSuchAlgorithmException;
 import java.security.interfaces.RSAPrivateKey;
 import java.security.interfaces.RSAPublicKey;
-import java.util.Arrays;
 import java.util.Date;
-import java.util.List;
+import java.util.Set;
 import java.util.function.Function;
 
 import javax.crypto.spec.SecretKeySpec;
 
 import org.opensaml.profile.action.EventIds;
 import org.opensaml.profile.context.ProfileRequestContext;
-import org.opensaml.storage.ReplayCache;
-import org.opensaml.storage.impl.MemoryStorageService;
 import org.opensaml.xmlsec.context.SecurityParametersContext;
 import org.springframework.webflow.execution.Event;
 import org.springframework.webflow.execution.RequestContext;
@@ -62,7 +59,6 @@ import com.nimbusds.openid.connect.sdk.rp.OIDCClientInformation;
 import com.nimbusds.openid.connect.sdk.rp.OIDCClientMetadata;
 
 import net.shibboleth.idp.plugin.oidc.op.messaging.context.OIDCMetadataContext;
-import net.shibboleth.idp.plugin.oidc.op.profile.impl.ValidateEndpointAuthentication;
 import net.shibboleth.idp.profile.context.navigate.AbstractRelyingPartyLookupFunction;
 import net.shibboleth.idp.profile.context.navigate.WebflowRequestContextProfileRequestContextLookup;
 import net.shibboleth.idp.profile.testing.ActionTestingSupport;
@@ -166,7 +162,7 @@ public class ValidateEndpointAuthenticationTest {
     }
     
     protected ValidateEndpointAuthentication constructAction(final Function<ProfileRequestContext, 
-            List<ClientAuthenticationMethod>> newFunction) throws ComponentInitializationException {
+            Set<ClientAuthenticationMethod>> newFunction) throws ComponentInitializationException {
         final ValidateEndpointAuthentication action = new ValidateEndpointAuthentication();
         if (newFunction != null) {
             action.setTokenEndpointAuthMethodsLookupStrategy(newFunction);
@@ -245,17 +241,18 @@ public class ValidateEndpointAuthenticationTest {
         testFailingClientAuth(ClientAuthenticationMethod.PRIVATE_KEY_JWT);
     }
 
-    class ListMethodsFunction extends AbstractRelyingPartyLookupFunction<List<ClientAuthenticationMethod>> {
+    class ListMethodsFunction extends AbstractRelyingPartyLookupFunction<Set<ClientAuthenticationMethod>> {
 
-        private List<ClientAuthenticationMethod> list;
+        private Set<ClientAuthenticationMethod> set;
         
         public ListMethodsFunction(ClientAuthenticationMethod... methods) {
-            list = Arrays.asList(methods);
+            set = Set.of(methods);
         }
         
         @Override
-        public List<ClientAuthenticationMethod> apply(ProfileRequestContext input) {
-            return list;
-        }   
+        public Set<ClientAuthenticationMethod> apply(ProfileRequestContext input) {
+            return set;
+        }
     }
+
 }
\ No newline at end of file

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


More information about the commits mailing list