mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-05-31 09:12:14 +00:00
Add Type Parameter
Closes gh-8412
This commit is contained in:
parent
54d3839f63
commit
2566abec31
@ -58,11 +58,12 @@ public final class JwtDecoders {
|
||||
* @return a {@link JwtDecoder} that was initialized by the OpenID Provider
|
||||
* Configuration.
|
||||
*/
|
||||
public static JwtDecoder fromOidcIssuerLocation(String oidcIssuerLocation) {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends JwtDecoder> T fromOidcIssuerLocation(String oidcIssuerLocation) {
|
||||
Assert.hasText(oidcIssuerLocation, "oidcIssuerLocation cannot be empty");
|
||||
Map<String, Object> configuration = JwtDecoderProviderConfigurationUtils
|
||||
.getConfigurationForOidcIssuerLocation(oidcIssuerLocation);
|
||||
return withProviderConfiguration(configuration, oidcIssuerLocation);
|
||||
return (T) withProviderConfiguration(configuration, oidcIssuerLocation);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -93,11 +94,12 @@ public final class JwtDecoders {
|
||||
* "https://openid.net/specs/openid-connect-core-1_0.html#IssuerIdentifier">Issuer</a>
|
||||
* @return a {@link JwtDecoder} that was initialized by one of the described endpoints
|
||||
*/
|
||||
public static JwtDecoder fromIssuerLocation(String issuer) {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends JwtDecoder> T fromIssuerLocation(String issuer) {
|
||||
Assert.hasText(issuer, "issuer cannot be empty");
|
||||
Map<String, Object> configuration = JwtDecoderProviderConfigurationUtils
|
||||
.getConfigurationForIssuerLocation(issuer);
|
||||
return withProviderConfiguration(configuration, issuer);
|
||||
return (T) withProviderConfiguration(configuration, issuer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -141,7 +141,8 @@ public class JwtDecodersTests {
|
||||
public void issuerWhenContainsTrailingSlashThenSuccess() {
|
||||
this.issuer += "/";
|
||||
prepareConfigurationResponse();
|
||||
assertThat(JwtDecoders.fromOidcIssuerLocation(this.issuer)).isNotNull();
|
||||
JwtDecoder jwtDecoder = JwtDecoders.fromOidcIssuerLocation(this.issuer);
|
||||
assertThat(jwtDecoder).isNotNull();
|
||||
assertThat(this.issuer).endsWith("/");
|
||||
}
|
||||
|
||||
@ -149,7 +150,8 @@ public class JwtDecodersTests {
|
||||
public void issuerWhenOidcFallbackContainsTrailingSlashThenSuccess() {
|
||||
this.issuer += "/";
|
||||
prepareConfigurationResponseOidc();
|
||||
assertThat(JwtDecoders.fromIssuerLocation(this.issuer)).isNotNull();
|
||||
JwtDecoder jwtDecoder = JwtDecoders.fromIssuerLocation(this.issuer);
|
||||
assertThat(jwtDecoder).isNotNull();
|
||||
assertThat(this.issuer).endsWith("/");
|
||||
}
|
||||
|
||||
@ -157,7 +159,8 @@ public class JwtDecodersTests {
|
||||
public void issuerWhenOAuth2ContainsTrailingSlashThenSuccess() {
|
||||
this.issuer += "/";
|
||||
prepareConfigurationResponseOAuth2();
|
||||
assertThat(JwtDecoders.fromIssuerLocation(this.issuer)).isNotNull();
|
||||
JwtDecoder jwtDecoder = JwtDecoders.fromIssuerLocation(this.issuer);
|
||||
assertThat(jwtDecoder).isNotNull();
|
||||
assertThat(this.issuer).endsWith("/");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user