Browse Source

Merge branch '6.2.x'

pull/13082/head
Josh Cummings 2 years ago
parent
commit
01b7ad42ec
No known key found for this signature in database
GPG Key ID: A306A51F43B8E5A5
  1. 17
      oauth2/oauth2-jose/src/main/java/org/springframework/security/oauth2/jwt/NimbusReactiveJwtDecoder.java

17
oauth2/oauth2-jose/src/main/java/org/springframework/security/oauth2/jwt/NimbusReactiveJwtDecoder.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -144,20 +144,17 @@ public final class NimbusReactiveJwtDecoder implements ReactiveJwtDecoder { @@ -144,20 +144,17 @@ public final class NimbusReactiveJwtDecoder implements ReactiveJwtDecoder {
}
@Override
public Mono<Jwt> decode(String token) throws JwtException {
JWT jwt = parse(token);
public Mono<Jwt> decode(String token) {
try {
JWT jwt = JWTParser.parse(token);
if (jwt instanceof PlainJWT) {
throw new BadJwtException("Unsupported algorithm of " + jwt.getHeader().getAlgorithm());
return Mono.error(new BadJwtException("Unsupported algorithm of " + jwt.getHeader().getAlgorithm()));
}
return this.decode(jwt);
}
private JWT parse(String token) {
try {
return JWTParser.parse(token);
}
catch (Exception ex) {
throw new BadJwtException("An error occurred while attempting to decode the Jwt: " + ex.getMessage(), ex);
return Mono.error(new BadJwtException(
"An error occurred while attempting to decode the Jwt: " + ex.getMessage(), ex));
}
}

Loading…
Cancel
Save