This commit captures and remaps the exception that Nimbus throws
when a PlainJWT is presented to it.
While the surrounding classes are likely only used today by the
oauth2Login flow, since they are public, we'll patch them at this
point for anyone who may be using them directly.
Fixes: gh-5457
@ -95,11 +96,26 @@ public final class NimbusJwtDecoderJwkSupport implements JwtDecoder {
@@ -95,11 +96,26 @@ public final class NimbusJwtDecoderJwkSupport implements JwtDecoder {
@Override
publicJwtdecode(Stringtoken)throwsJwtException{
Jwtjwt;
JWTjwt=this.parse(token);
if(jwtinstanceofSignedJWT){
returnthis.createJwt(token,jwt);
}
thrownewJwtException("Unsupported algorithm of "+jwt.getHeader().getAlgorithm());
}
privateJWTparse(Stringtoken){
try{
JWTparsedJwt=JWTParser.parse(token);
returnJWTParser.parse(token);
}catch(Exceptionex){
thrownewJwtException("An error occurred while attempting to decode the Jwt: "+ex.getMessage(),ex);