From 3cb09758602484629b06da3c67257c60692d9bb5 Mon Sep 17 00:00:00 2001 From: Tadaya Tsuyukubo Date: Sat, 8 Jun 2019 00:12:55 -0700 Subject: [PATCH] Accept Converter in ReactiveJwtAuthenticationConverterAdapter Currently, "ReactiveJwtAuthenticationConverterAdapter" takes "JwtAuthenticationConverter" as its constructor argument. However, this limits the usage of this adapter. In this commit, widen the constructor to take "Converter" and allow this adapter to be used by generic converters. --- .../ReactiveJwtAuthenticationConverterAdapter.java | 4 ++-- .../ReactiveJwtAuthenticationConverterAdapterTests.java | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/authentication/ReactiveJwtAuthenticationConverterAdapter.java b/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/authentication/ReactiveJwtAuthenticationConverterAdapter.java index 020086bc22..1727b67086 100644 --- a/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/authentication/ReactiveJwtAuthenticationConverterAdapter.java +++ b/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/authentication/ReactiveJwtAuthenticationConverterAdapter.java @@ -30,9 +30,9 @@ import org.springframework.util.Assert; * @since 5.1.1 */ public class ReactiveJwtAuthenticationConverterAdapter implements Converter> { - private final JwtAuthenticationConverter delegate; + private final Converter delegate; - public ReactiveJwtAuthenticationConverterAdapter(JwtAuthenticationConverter delegate) { + public ReactiveJwtAuthenticationConverterAdapter(Converter delegate) { Assert.notNull(delegate, "delegate cannot be null"); this.delegate = delegate; } diff --git a/oauth2/oauth2-resource-server/src/test/java/org/springframework/security/oauth2/server/resource/authentication/ReactiveJwtAuthenticationConverterAdapterTests.java b/oauth2/oauth2-resource-server/src/test/java/org/springframework/security/oauth2/server/resource/authentication/ReactiveJwtAuthenticationConverterAdapterTests.java index 66d9cc5db1..6eeaba6257 100644 --- a/oauth2/oauth2-resource-server/src/test/java/org/springframework/security/oauth2/server/resource/authentication/ReactiveJwtAuthenticationConverterAdapterTests.java +++ b/oauth2/oauth2-resource-server/src/test/java/org/springframework/security/oauth2/server/resource/authentication/ReactiveJwtAuthenticationConverterAdapterTests.java @@ -25,6 +25,7 @@ import java.util.Map; import org.junit.Test; +import org.springframework.core.convert.converter.Converter; import org.springframework.security.authentication.AbstractAuthenticationToken; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; @@ -39,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Josh Cummings */ public class ReactiveJwtAuthenticationConverterAdapterTests { - JwtAuthenticationConverter converter = new JwtAuthenticationConverter(); + Converter converter = new JwtAuthenticationConverter(); ReactiveJwtAuthenticationConverterAdapter jwtAuthenticationConverter = new ReactiveJwtAuthenticationConverterAdapter(converter);