From aa026f8526272274556e5dfb198766079f24bff3 Mon Sep 17 00:00:00 2001 From: Josh Cummings Date: Fri, 16 Aug 2019 14:49:19 -0600 Subject: [PATCH] Nimbus JWK Set Builders Take SignatureAlgorithm Fixes gh-7270 --- .../OidcIdTokenDecoderFactory.java | 22 +++++++++---------- .../ReactiveOidcIdTokenDecoderFactory.java | 22 +++++++++---------- .../security/oauth2/jwt/NimbusJwtDecoder.java | 9 ++++---- .../oauth2/jwt/NimbusReactiveJwtDecoder.java | 8 +++---- 4 files changed, 30 insertions(+), 31 deletions(-) diff --git a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/oidc/authentication/OidcIdTokenDecoderFactory.java b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/oidc/authentication/OidcIdTokenDecoderFactory.java index 0ca4312ebe..2ef5d81142 100644 --- a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/oidc/authentication/OidcIdTokenDecoderFactory.java +++ b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/oidc/authentication/OidcIdTokenDecoderFactory.java @@ -15,6 +15,16 @@ */ package org.springframework.security.oauth2.client.oidc.authentication; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.time.Instant; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Function; +import javax.crypto.spec.SecretKeySpec; + import org.springframework.core.convert.TypeDescriptor; import org.springframework.core.convert.converter.Converter; import org.springframework.security.oauth2.client.registration.ClientRegistration; @@ -37,16 +47,6 @@ import org.springframework.security.oauth2.jwt.NimbusJwtDecoder; import org.springframework.util.Assert; import org.springframework.util.StringUtils; -import javax.crypto.spec.SecretKeySpec; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.time.Instant; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.function.Function; - import static org.springframework.security.oauth2.jwt.NimbusJwtDecoder.withJwkSetUri; import static org.springframework.security.oauth2.jwt.NimbusJwtDecoder.withSecretKey; @@ -150,7 +150,7 @@ public final class OidcIdTokenDecoderFactory implements JwtDecoderFactoryalgorithm. * - * @param jwsAlgorithm the algorithm to use + * @param signatureAlgorithm the algorithm to use * @return a {@link JwkSetUriJwtDecoderBuilder} for further configurations */ - public JwkSetUriJwtDecoderBuilder jwsAlgorithm(JwsAlgorithm jwsAlgorithm) { - Assert.notNull(jwsAlgorithm, "jwsAlgorithm cannot be null"); - this.jwsAlgorithm = JWSAlgorithm.parse(jwsAlgorithm.getName()); + public JwkSetUriJwtDecoderBuilder jwsAlgorithm(SignatureAlgorithm signatureAlgorithm) { + Assert.notNull(signatureAlgorithm, "signatureAlgorithm cannot be null"); + this.jwsAlgorithm = JWSAlgorithm.parse(signatureAlgorithm.getName()); return this; } diff --git a/oauth2/oauth2-jose/src/main/java/org/springframework/security/oauth2/jwt/NimbusReactiveJwtDecoder.java b/oauth2/oauth2-jose/src/main/java/org/springframework/security/oauth2/jwt/NimbusReactiveJwtDecoder.java index 2679085111..1faf5e295d 100644 --- a/oauth2/oauth2-jose/src/main/java/org/springframework/security/oauth2/jwt/NimbusReactiveJwtDecoder.java +++ b/oauth2/oauth2-jose/src/main/java/org/springframework/security/oauth2/jwt/NimbusReactiveJwtDecoder.java @@ -245,12 +245,12 @@ public final class NimbusReactiveJwtDecoder implements ReactiveJwtDecoder { * Use the given signing * algorithm. * - * @param jwsAlgorithm the algorithm to use + * @param signatureAlgorithm the algorithm to use * @return a {@link JwkSetUriReactiveJwtDecoderBuilder} for further configurations */ - public JwkSetUriReactiveJwtDecoderBuilder jwsAlgorithm(JwsAlgorithm jwsAlgorithm) { - Assert.notNull(jwsAlgorithm, "jwsAlgorithm cannot be null"); - this.jwsAlgorithm = JWSAlgorithm.parse(jwsAlgorithm.getName()); + public JwkSetUriReactiveJwtDecoderBuilder jwsAlgorithm(SignatureAlgorithm signatureAlgorithm) { + Assert.notNull(signatureAlgorithm, "sig cannot be null"); + this.jwsAlgorithm = JWSAlgorithm.parse(signatureAlgorithm.getName()); return this; }