Program: 84510
Project: 84510
Buggy source:
/** 
 * @see org.openmrs.api.db.ContextDAO#authenticate(java.lang.String,java.lang.String)
 */
public User authenticate(String login,String password) throws ContextAuthenticationException {
  String errorMsg="String_Node_Str" + login;
  Session session=sessionFactory.getCurrentSession();
  User candidateUser=null;
  if (login != null) {
    String loginWithDash=login;
    if (login.matches("String_Node_Str"))     loginWithDash=login.substring(0,login.length() - 1) + "String_Node_Str" + login.charAt(login.length() - 1);
    try {
      candidateUser=(User)session.createQuery("String_Node_Str").setString(0,login).setString(1,login).setString(2,loginWithDash).uniqueResult();
    }
 catch (    HibernateException he) {
      log.error("String_Node_Str" + login + "String_Node_Str",he);
    }
catch (    Exception e) {
      log.error("String_Node_Str" + login + "String_Node_Str",e);
    }
  }
  if (candidateUser != null && password != null) {
    if (log.isDebugEnabled())     log.debug("String_Node_Str" + candidateUser.getUserId());
    String lockoutTimeString=candidateUser.getUserProperty(OpenmrsConstants.USER_PROPERTY_LOCKOUT_TIMESTAMP,null);
    Long lockoutTime=null;
    if (lockoutTimeString != null && !lockoutTimeString.equals("String_Node_Str"))     lockoutTime=Long.valueOf(lockoutTimeString);
    if (lockoutTime != null) {
      if (new Date().getTime() - lockoutTime > 300000) {
        candidateUser.setUserProperty(OpenmrsConstants.USER_PROPERTY_LOGIN_ATTEMPTS,"String_Node_Str");
        candidateUser.removeUserProperty(OpenmrsConstants.USER_PROPERTY_LOCKOUT_TIMESTAMP);
        saveUserProperties(candidateUser);
      }
 else {
        candidateUser.setUserProperty(OpenmrsConstants.USER_PROPERTY_LOCKOUT_TIMESTAMP,String.valueOf(new Date().getTime()));
        throw new ContextAuthenticationException("String_Node_Str");
      }
    }
    String passwordOnRecord=(String)session.createSQLQuery("String_Node_Str").addScalar("String_Node_Str",Hibernate.STRING).setInteger(0,candidateUser.getUserId()).uniqueResult();
    String saltOnRecord=(String)session.createSQLQuery("String_Node_Str").addScalar("String_Node_Str",Hibernate.STRING).setInteger(0,candidateUser.getUserId()).uniqueResult();
    if (passwordOnRecord != null && Security.hashMatches(passwordOnRecord,password + saltOnRecord)) {
      candidateUser.getAllRoles().size();
      candidateUser.getUserProperties().size();
      candidateUser.getPrivileges().size();
      Integer attempts=getUsersLoginAttempts(candidateUser);
      if (attempts > 0) {
        candidateUser.setUserProperty(OpenmrsConstants.USER_PROPERTY_LOGIN_ATTEMPTS,"String_Node_Str");
        candidateUser.removeUserProperty(OpenmrsConstants.USER_PROPERTY_LOCKOUT_TIMESTAMP);
        saveUserProperties(candidateUser);
      }
      return candidateUser;
    }
 else {
      Integer attempts=getUsersLoginAttempts(candidateUser);
      attempts++;
      if (attempts >= 8) {
        candidateUser.setUserProperty(OpenmrsConstants.USER_PROPERTY_LOCKOUT_TIMESTAMP,String.valueOf(new Date().getTime()));
      }
 else {
        candidateUser.setUserProperty(OpenmrsConstants.USER_PROPERTY_LOGIN_ATTEMPTS,String.valueOf(attempts));
      }
      saveUserProperties(candidateUser);
    }
  }
  log.info("String_Node_Str" + login + "String_Node_Str"+ errorMsg);
  throw new ContextAuthenticationException(errorMsg);
}

Fixed version (ground truth):
/** 
 * @see org.openmrs.api.db.ContextDAO#authenticate(java.lang.String,java.lang.String)
 */
public User authenticate(String login,String password) throws ContextAuthenticationException {
  String errorMsg="String_Node_Str" + login;
  Session session=sessionFactory.getCurrentSession();
  User candidateUser=null;
  if (login != null) {
    if (StringUtils.isEmpty(login) || StringUtils.isWhitespace(login))     throw new ContextAuthenticationException(errorMsg);
    String loginWithDash=login;
    if (login.matches("String_Node_Str"))     loginWithDash=login.substring(0,login.length() - 1) + "String_Node_Str" + login.charAt(login.length() - 1);
    try {
      candidateUser=(User)session.createQuery("String_Node_Str").setString(0,login).setString(1,login).setString(2,loginWithDash).uniqueResult();
    }
 catch (    HibernateException he) {
      log.error("String_Node_Str" + login + "String_Node_Str",he);
    }
catch (    Exception e) {
      log.error("String_Node_Str" + login + "String_Node_Str",e);
    }
  }
  if (candidateUser != null && password != null) {
    if (log.isDebugEnabled())     log.debug("String_Node_Str" + candidateUser.getUserId());
    String lockoutTimeString=candidateUser.getUserProperty(OpenmrsConstants.USER_PROPERTY_LOCKOUT_TIMESTAMP,null);
    Long lockoutTime=null;
    if (lockoutTimeString != null && !lockoutTimeString.equals("String_Node_Str"))     lockoutTime=Long.valueOf(lockoutTimeString);
    if (lockoutTime != null) {
      if (new Date().getTime() - lockoutTime > 300000) {
        candidateUser.setUserProperty(OpenmrsConstants.USER_PROPERTY_LOGIN_ATTEMPTS,"String_Node_Str");
        candidateUser.removeUserProperty(OpenmrsConstants.USER_PROPERTY_LOCKOUT_TIMESTAMP);
        saveUserProperties(candidateUser);
      }
 else {
        candidateUser.setUserProperty(OpenmrsConstants.USER_PROPERTY_LOCKOUT_TIMESTAMP,String.valueOf(new Date().getTime()));
        throw new ContextAuthenticationException("String_Node_Str");
      }
    }
    String passwordOnRecord=(String)session.createSQLQuery("String_Node_Str").addScalar("String_Node_Str",Hibernate.STRING).setInteger(0,candidateUser.getUserId()).uniqueResult();
    String saltOnRecord=(String)session.createSQLQuery("String_Node_Str").addScalar("String_Node_Str",Hibernate.STRING).setInteger(0,candidateUser.getUserId()).uniqueResult();
    if (passwordOnRecord != null && Security.hashMatches(passwordOnRecord,password + saltOnRecord)) {
      candidateUser.getAllRoles().size();
      candidateUser.getUserProperties().size();
      candidateUser.getPrivileges().size();
      Integer attempts=getUsersLoginAttempts(candidateUser);
      if (attempts > 0) {
        candidateUser.setUserProperty(OpenmrsConstants.USER_PROPERTY_LOGIN_ATTEMPTS,"String_Node_Str");
        candidateUser.removeUserProperty(OpenmrsConstants.USER_PROPERTY_LOCKOUT_TIMESTAMP);
        saveUserProperties(candidateUser);
      }
      return candidateUser;
    }
 else {
      Integer attempts=getUsersLoginAttempts(candidateUser);
      attempts++;
      if (attempts >= 8) {
        candidateUser.setUserProperty(OpenmrsConstants.USER_PROPERTY_LOCKOUT_TIMESTAMP,String.valueOf(new Date().getTime()));
      }
 else {
        candidateUser.setUserProperty(OpenmrsConstants.USER_PROPERTY_LOGIN_ATTEMPTS,String.valueOf(attempts));
      }
      saveUserProperties(candidateUser);
    }
  }
  log.info("String_Node_Str" + login + "String_Node_Str"+ errorMsg);
  throw new ContextAuthenticationException(errorMsg);
}