Program: 30452
Project: 30452
Buggy source:
public boolean validate(HttpServletRequest request,String authorization,LoginConfig config){
  if (authorization == null) {
    return false;
  }
  if (!authorization.startsWith("String_Node_Str")) {
    return false;
  }
  authorization=authorization.substring(7).trim();
  String[] tokens=authorization.split("String_Node_Str");
  String opaque_client=null;
  for (int i=0; i < tokens.length; i++) {
    String currentToken=tokens[i];
    if (currentToken.length() == 0)     continue;
    int equalSign=currentToken.indexOf('=');
    if (equalSign < 0) {
      return false;
    }
    String currentTokenName=currentToken.substring(0,equalSign).trim();
    String currentTokenValue=currentToken.substring(equalSign + 1).trim();
    if ("String_Node_Str".equals(currentTokenName))     userName=removeQuotes(currentTokenValue);
    if ("String_Node_Str".equals(currentTokenName))     realmName=removeQuotes(currentTokenValue,true);
    if ("String_Node_Str".equals(currentTokenName))     nonce=removeQuotes(currentTokenValue);
    if ("String_Node_Str".equals(currentTokenName))     nc=removeQuotes(currentTokenValue);
    if ("String_Node_Str".equals(currentTokenName))     cnonce=removeQuotes(currentTokenValue);
    if ("String_Node_Str".equals(currentTokenName))     qop=removeQuotes(currentTokenValue);
    if ("String_Node_Str".equals(currentTokenName))     uri=removeQuotes(currentTokenValue);
    if ("String_Node_Str".equals(currentTokenName))     response=removeQuotes(currentTokenValue);
    if ("String_Node_Str".equals(currentTokenName))     opaque_client=removeQuotes(currentTokenValue);
  }
  if ((userName == null) || (realmName == null) || (nonce == null)|| (uri == null)|| (response == null)) {
    return false;
  }
  if (validateUri) {
    String uriQuery;
    String query=request.getQueryString();
    if (query == null) {
      uriQuery=request.getRequestURI();
    }
 else {
      uriQuery=request.getRequestURI() + "String_Node_Str" + query;
    }
    if (!uri.equals(uriQuery)) {
      return false;
    }
  }
  String lcRealm=config.getRealmName();
  if (lcRealm == null) {
    lcRealm=REALM_NAME;
  }
  if (!lcRealm.equals(realmName)) {
    return false;
  }
  if (!this.opaque.equals(opaque_client)) {
    return false;
  }
  int i=nonce.indexOf("String_Node_Str");
  if (i < 0 || (i + 1) == nonce.length()) {
    return false;
  }
  long nOnceTime;
  try {
    nOnceTime=Long.parseLong(nonce.substring(0,i));
  }
 catch (  NumberFormatException nfe) {
    return false;
  }
  String md5clientIpTimeKey=nonce.substring(i + 1);
  long currentTime=System.currentTimeMillis();
  if ((currentTime - nOnceTime) > nonceValidity) {
    nonceStale=true;
    return false;
  }
  String serverIpTimeKey=request.getRemoteAddr() + "String_Node_Str" + nOnceTime+ "String_Node_Str"+ key;
  byte[] buffer=digest(serverIpTimeKey.getBytes());
  String md5ServerIpTimeKey=new String(digestEncoder.encode(buffer));
  if (!md5ServerIpTimeKey.equals(md5clientIpTimeKey)) {
    return false;
  }
  if (qop != null && !QOP.equals(qop)) {
    return false;
  }
  if (qop == null) {
    if (cnonce != null || nc != null) {
      return false;
    }
  }
 else {
    if (cnonce == null || nc == null) {
      return false;
    }
    if (nc.length() != 8) {
      return false;
    }
    long count;
    try {
      count=Long.parseLong(nc,16);
    }
 catch (    NumberFormatException nfe) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
public boolean validate(HttpServletRequest request,String authorization,LoginConfig config){
  if (authorization == null) {
    return false;
  }
  if (!authorization.startsWith("String_Node_Str")) {
    return false;
  }
  authorization=authorization.substring(7).trim();
  String[] tokens=authorization.split("String_Node_Str");
  String opaque_client=null;
  for (int i=0; i < tokens.length; i++) {
    String currentToken=tokens[i];
    if (currentToken.length() == 0)     continue;
    int equalSign=currentToken.indexOf('=');
    if (equalSign < 0) {
      return false;
    }
    String currentTokenName=currentToken.substring(0,equalSign).trim();
    String currentTokenValue=currentToken.substring(equalSign + 1).trim();
    if ("String_Node_Str".equals(currentTokenName))     userName=removeQuotes(currentTokenValue);
    if ("String_Node_Str".equals(currentTokenName))     realmName=removeQuotes(currentTokenValue,true);
    if ("String_Node_Str".equals(currentTokenName))     nonce=removeQuotes(currentTokenValue);
    if ("String_Node_Str".equals(currentTokenName))     nc=removeQuotes(currentTokenValue);
    if ("String_Node_Str".equals(currentTokenName))     cnonce=removeQuotes(currentTokenValue);
    if ("String_Node_Str".equals(currentTokenName))     qop=removeQuotes(currentTokenValue);
    if ("String_Node_Str".equals(currentTokenName))     uri=removeQuotes(currentTokenValue);
    if ("String_Node_Str".equals(currentTokenName))     response=removeQuotes(currentTokenValue);
    if ("String_Node_Str".equals(currentTokenName))     opaque_client=removeQuotes(currentTokenValue);
  }
  if ((userName == null) || (realmName == null) || (nonce == null)|| (uri == null)|| (response == null)) {
    return false;
  }
  if (validateUri) {
    String uriQuery;
    String query=request.getQueryString();
    if (query == null) {
      uriQuery=request.getRequestURI();
    }
 else {
      uriQuery=request.getRequestURI() + "String_Node_Str" + query;
    }
    if (!uri.equals(uriQuery)) {
      return false;
    }
  }
  String lcRealm=config.getRealmName();
  if (lcRealm == null) {
    lcRealm=REALM_NAME;
  }
  if (!lcRealm.equals(realmName)) {
    return false;
  }
  if (!this.opaque.equals(opaque_client)) {
    return false;
  }
  int i=nonce.indexOf("String_Node_Str");
  if (i < 0 || (i + 1) == nonce.length()) {
    return false;
  }
  long nOnceTime;
  try {
    nOnceTime=Long.parseLong(nonce.substring(0,i));
  }
 catch (  NumberFormatException nfe) {
    return false;
  }
  String md5clientIpTimeKey=nonce.substring(i + 1);
  long currentTime=System.currentTimeMillis();
  if ((currentTime - nOnceTime) > nonceValidity) {
    nonceStale=true;
    return false;
  }
  String serverIpTimeKey=request.getRemoteAddr() + "String_Node_Str" + nOnceTime+ "String_Node_Str"+ key;
  byte[] buffer=digest(serverIpTimeKey.getBytes());
  String md5ServerIpTimeKey=new String(digestEncoder.encode(buffer));
  if (!md5ServerIpTimeKey.equals(md5clientIpTimeKey)) {
    return false;
  }
  if (qop != null && !QOP.equals(qop)) {
    return false;
  }
  if (qop == null) {
    if (cnonce != null || nc != null) {
      return false;
    }
  }
 else {
    if (cnonce == null || nc == null) {
      return false;
    }
    if (nc.length() != 8) {
      return false;
    }
    try {
      Long.parseLong(nc,16);
    }
 catch (    NumberFormatException nfe) {
      return false;
    }
  }
  return true;
}