code: @Override
      public Authentication authenticate(Authentication authentication) throws AuthenticationException {
          if (!supports(authentication.getClass())) {
              return null;
          }
  
          LOGGER.debug("OAuth2Authentication authentication request: " + authentication);
  
          if (authentication.getCredentials() == null) {
              LOGGER.debug("No credentials found in request.");
  
              if (throwExceptionWhenTokenRejected) {
                  throw new BadCredentialsException("No pre-authenticated credentials found in request.");
              }
              return null;
          }
  
          String token = getAccessToken(authentication);
  
          OAuth2AuthenticationToken tmpToken = new OAuth2AuthenticationToken(token);
  
          UserDetails ud = authenticatedUserDetailsService.loadUserDetails(tmpToken);
  
          userDetailsChecker.check(ud);
  
          OAuth2AuthenticationToken result =
                  new OAuth2AuthenticationToken(ud, token, ud.getAuthorities());
          result.setDetails(authentication.getDetails());
  
          return result;
      }
docs: Performs authentication with the same contract as {@link
  org.springframework.security.authentication.AuthenticationManager#authenticate(org.springframework.security.core.Authentication)}.
  
  @param authentication the authentication request object.
  @return a fully authenticated object including credentials. May return <code>null</code> if the
  <code>AuthenticationProvider</code> is unable to support authentication of the passed
  <code>Authentication</code> object. In such a case, the next <code>AuthenticationProvider</code> that
  supports the presented <code>Authentication</code> class will be tried.
  @throws org.springframework.security.core.AuthenticationException
  if authentication fails.