Program: 79617
Project: 79617
Buggy source:
/** 
 * {@inheritDoc}
 */
public AccessToken handle(OAuth2Request request,ClientRegistration clientRegistration,OAuth2ProviderSettings providerSettings) throws RedirectUriMismatchException, InvalidClientException, InvalidRequestException, InvalidCodeException, InvalidGrantException, ServerException, NotFoundException {
  for (  final AuthorizationCodeRequestValidator requestValidator : requestValidators) {
    requestValidator.validateRequest(request,clientRegistration);
  }
  final String code=request.getParameter(OAuth2Constants.Params.CODE);
  final String redirectUri=request.getParameter(OAuth2Constants.Params.REDIRECT_URI);
  final AuthorizationCode authorizationCode=tokenStore.readAuthorizationCode(request,code);
  if (authorizationCode == null) {
    logger.error("String_Node_Str" + code);
    throw new InvalidRequestException("String_Node_Str");
  }
  final String codeVerifier=request.getParameter(OAuth2Constants.Custom.CODE_VERIFIER);
  if (providerSettings.isCodeVerifierRequired()) {
    if (codeVerifier == null) {
      String message="String_Node_Str";
      throw new InvalidRequestException(message);
    }
  }
  AccessToken accessToken;
  Set<String> authorizationScope;
synchronized (code.intern()) {
    if (authorizationCode.isIssued()) {
      String clientId=authorizationCode.getClientId();
      String userName=authorizationCode.getResourceOwnerId();
      String authGrantId=authorizationCode.getAuthGrantId();
      tokenInvalidator.invalidateTokens(request,clientId,userName,authGrantId);
      logger.error("String_Node_Str" + code);
      throw new InvalidGrantException();
    }
    if (!authorizationCode.getRedirectUri().equalsIgnoreCase(redirectUri)) {
      logger.error("String_Node_Str" + code + "String_Node_Str"+ authorizationCode.getRedirectUri()+ "String_Node_Str"+ redirectUri);
      throw new InvalidGrantException();
    }
    if (!authorizationCode.getClientId().equalsIgnoreCase(clientRegistration.getClientId())) {
      logger.error("String_Node_Str" + code + "String_Node_Str"+ authorizationCode.getClientId()+ "String_Node_Str"+ clientRegistration.getClientId());
      throw new InvalidGrantException();
    }
    if (authorizationCode.isExpired()) {
      logger.error("String_Node_Str" + code);
      throw new InvalidCodeException("String_Node_Str");
    }
    if (providerSettings.isCodeVerifierRequired()) {
      checkCodeVerifier(authorizationCode,codeVerifier);
    }
    final String grantType=request.getParameter(OAuth2Constants.Params.GRANT_TYPE);
    authorizationScope=authorizationCode.getScope();
    final String resourceOwnerId=authorizationCode.getResourceOwnerId();
    final String validatedClaims=providerSettings.validateRequestedClaims(authorizationCode.getStringProperty(OAuth2Constants.Custom.CLAIMS));
    accessToken=accessTokenGenerator.generateAccessToken(providerSettings,grantType,clientRegistration.getClientId(),resourceOwnerId,redirectUri,authorizationScope,validatedClaims,code,authorizationCode.getNonce(),request);
    authorizationCode.setIssued();
    tokenStore.updateAuthorizationCode(request,authorizationCode);
  }
  final String nonce=authorizationCode.getNonce();
  accessToken.addExtraData(OAuth2Constants.Custom.NONCE,nonce);
  accessToken.addExtraData(OAuth2Constants.Custom.SSO_TOKEN_ID,authorizationCode.getSessionId());
  providerSettings.additionalDataToReturnFromTokenEndpoint(accessToken,request);
  accessToken.addExtraData(OAuth2Constants.Custom.SSO_TOKEN_ID,null);
  if (authorizationScope != null && !authorizationScope.isEmpty()) {
    accessToken.addExtraData(OAuth2Constants.Params.SCOPE,joinScope(authorizationScope));
  }
  return accessToken;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public AccessToken handle(OAuth2Request request,ClientRegistration clientRegistration,OAuth2ProviderSettings providerSettings) throws RedirectUriMismatchException, InvalidClientException, InvalidRequestException, InvalidCodeException, InvalidGrantException, ServerException, NotFoundException {
  for (  final AuthorizationCodeRequestValidator requestValidator : requestValidators) {
    requestValidator.validateRequest(request,clientRegistration);
  }
  final String code=request.getParameter(OAuth2Constants.Params.CODE);
  final String redirectUri=request.getParameter(OAuth2Constants.Params.REDIRECT_URI);
  final AuthorizationCode authorizationCode=tokenStore.readAuthorizationCode(request,code);
  if (authorizationCode == null) {
    logger.error("String_Node_Str" + code);
    throw new InvalidRequestException("String_Node_Str");
  }
  final String codeVerifier=request.getParameter(OAuth2Constants.Custom.CODE_VERIFIER);
  if (providerSettings.isCodeVerifierRequired()) {
    if (codeVerifier == null) {
      String message="String_Node_Str";
      throw new InvalidRequestException(message);
    }
  }
  AccessToken accessToken;
  Set<String> authorizationScope;
synchronized (code.intern()) {
    if (authorizationCode.isIssued()) {
      String clientId=authorizationCode.getClientId();
      String userName=authorizationCode.getResourceOwnerId();
      String authGrantId=authorizationCode.getAuthGrantId();
      tokenInvalidator.invalidateTokens(request,clientId,userName,authGrantId);
      logger.error("String_Node_Str" + code);
      throw new InvalidGrantException();
    }
    if (!authorizationCode.getRedirectUri().equalsIgnoreCase(redirectUri)) {
      logger.error("String_Node_Str" + code + "String_Node_Str"+ authorizationCode.getRedirectUri()+ "String_Node_Str"+ redirectUri);
      throw new InvalidGrantException();
    }
    if (!authorizationCode.getClientId().equalsIgnoreCase(clientRegistration.getClientId())) {
      logger.error("String_Node_Str" + code + "String_Node_Str"+ authorizationCode.getClientId()+ "String_Node_Str"+ clientRegistration.getClientId());
      throw new InvalidGrantException();
    }
    if (authorizationCode.isExpired()) {
      logger.error("String_Node_Str" + code);
      throw new InvalidGrantException("String_Node_Str");
    }
    if (providerSettings.isCodeVerifierRequired()) {
      checkCodeVerifier(authorizationCode,codeVerifier);
    }
    final String grantType=request.getParameter(OAuth2Constants.Params.GRANT_TYPE);
    authorizationScope=authorizationCode.getScope();
    final String resourceOwnerId=authorizationCode.getResourceOwnerId();
    final String validatedClaims=providerSettings.validateRequestedClaims(authorizationCode.getStringProperty(OAuth2Constants.Custom.CLAIMS));
    accessToken=accessTokenGenerator.generateAccessToken(providerSettings,grantType,clientRegistration.getClientId(),resourceOwnerId,redirectUri,authorizationScope,validatedClaims,code,authorizationCode.getNonce(),request);
    authorizationCode.setIssued();
    tokenStore.updateAuthorizationCode(request,authorizationCode);
  }
  final String nonce=authorizationCode.getNonce();
  accessToken.addExtraData(OAuth2Constants.Custom.NONCE,nonce);
  accessToken.addExtraData(OAuth2Constants.Custom.SSO_TOKEN_ID,authorizationCode.getSessionId());
  providerSettings.additionalDataToReturnFromTokenEndpoint(accessToken,request);
  accessToken.addExtraData(OAuth2Constants.Custom.SSO_TOKEN_ID,null);
  if (authorizationScope != null && !authorizationScope.isEmpty()) {
    accessToken.addExtraData(OAuth2Constants.Params.SCOPE,joinScope(authorizationScope));
  }
  return accessToken;
}