oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/authentication/JwtAuthenticationProvider.java
@Override
	public Authentication authenticate(Authentication authentication) throws AuthenticationException {
		BearerTokenAuthenticationToken bearer = (BearerTokenAuthenticationToken) authentication;

		Jwt jwt;
		try {
			jwt = this.jwtDecoder.decode(bearer.getToken());
		} catch (JwtException failed) {
			OAuth2Error invalidToken = invalidToken(failed.getMessage());
			throw new OAuth2AuthenticationException(invalidToken, invalidToken.getDescription(), failed);
		}

		AbstractAuthenticationToken token = this.jwtAuthenticationConverter.convert(jwt);
		token.setDetails(bearer.getDetails());

		return token;
	}
@Override
	public Authentication authenticate(Authentication authentication) throws AuthenticationException {
		BearerTokenAuthenticationToken bearer = (BearerTokenAuthenticationToken) authentication;

		Jwt jwt;
		try {
			jwt = this.jwtDecoder.decode(bearer.getToken());
		} catch (JwtException failed) {
			OAuth2Error invalidToken = invalidToken(failed.getMessage());
			throw new OAuth2AuthenticationException(invalidToken, invalidToken.getDescription(), failed);
		}

		AbstractAuthenticationToken token = this.jwtAuthenticationConverter.convert(jwt);
		token.setDetails(bearer.getDetails());

		return token;
	}
@ Override public Authentication authenticate ( Authentication authentication ) throws AuthenticationException { BearerTokenAuthenticationToken bearer = ( BearerTokenAuthenticationToken ) authentication ; Jwt jwt ; try { jwt = this . jwtDecoder . decode ( bearer . getToken ( ) ) ; } catch ( JwtException failed ) { OAuth2Error invalidToken = invalidToken ( failed . getMessage ( ) ) ; throw new OAuth2AuthenticationException ( invalidToken , invalidToken . getDescription ( ) , failed ) ; } AbstractAuthenticationToken token = this . jwtAuthenticationConverter . convert ( jwt ) ; token . setDetails ( bearer . getDetails ( ) ) ; return token ; }
Decode and validate the
<a href="https://tools.ietf.org/html/rfc6750#section-1.2" target="_blank">Bearer Token</a>.

@param authentication the authentication request object.

@return A successful authentication
@throws AuthenticationException if authentication failed for some reason
Decode and validate the <a href = https : // tools . ietf . org / html / rfc6750#section - 1 . 2 target = _blank > Bearer Token< / a > .