Program: 189381
Project: 189381
Buggy source:
@Override public AuthenticationResult authenticate(Request request){
  if (Logger.isTraceEnabled() || logShib) {
    String log="String_Node_Str";
    for (    String name : request.headers.keySet()) {
      for (      String value : request.headers.get(name).values) {
        log+="String_Node_Str" + name + "String_Node_Str"+ value+ "String_Node_Str";
      }
    }
    String configuredLogLevel=Play.configuration.getProperty("String_Node_Str","String_Node_Str");
    if (!Logger.isTraceEnabled() && !Logger.configuredManually && !configuredLogLevel.isEmpty()) {
      Logger.setUp("String_Node_Str");
    }
 else {
      configuredLogLevel="String_Node_Str";
    }
    if (Logger.isTraceEnabled()) {
      Logger.trace(log);
    }
    if (!configuredLogLevel.isEmpty()) {
      Logger.setUp(configuredLogLevel);
    }
  }
  String netid=getSingleAttribute(request,headerNetId);
  String email=getSingleAttribute(request,headerEmail);
  String firstName=getSingleAttribute(request,headerFirstName);
  String lastName=getSingleAttribute(request,headerLastName);
  if (useNetIdAsIdentifier && netid == null) {
    Logger.error("String_Node_Str",headerNetId);
    return AuthenticationResult.MISSING_CREDENTIALS;
  }
  if (email == null) {
    Logger.error("String_Node_Str",headerEmail);
    return AuthenticationResult.MISSING_CREDENTIALS;
  }
  if (firstName == null && lastName == null) {
    Logger.error("String_Node_Str",headerFirstName,headerLastName);
    return AuthenticationResult.MISSING_CREDENTIALS;
  }
  Person person;
  try {
    context.turnOffAuthorization();
    if (useNetIdAsIdentifier) {
      person=personRepo.findPersonByNetId(netid);
    }
 else {
      person=personRepo.findPersonByEmail(email);
    }
    if (person == null) {
      try {
        person=personRepo.createPerson(netid,email,firstName,lastName,RoleType.STUDENT).save();
      }
 catch (      RuntimeException re) {
        Logger.error(re,"String_Node_Str");
        return AuthenticationResult.BAD_CREDENTIALS;
      }
    }
 else {
      if (netid != null)       person.setNetId(netid);
      person.setEmail(email);
      person.setFirstName(firstName);
      person.setLastName(lastName);
    }
    if (headerInstitutionalIdentifier != null) {
      String identifier=getSingleAttribute(request,headerInstitutionalIdentifier);
      if (!isEmpty(identifier))       person.setInstitutionalIdentifier(identifier);
    }
    if (headerMiddleName != null) {
      String middleName=getSingleAttribute(request,headerMiddleName);
      if (!isEmpty(middleName) && person.getMiddleName() == null)       person.setMiddleName(middleName);
    }
    if (headerBirthYear != null) {
      String birthYearString=getSingleAttribute(request,headerBirthYear);
      if (!isEmpty(birthYearString) && person.getBirthYear() == null) {
        try {
          Integer birthYear=Integer.valueOf(birthYearString);
          person.setBirthYear(birthYear);
        }
 catch (        NumberFormatException nfe) {
          Logger.warn("String_Node_Str" + headerBirthYear + "String_Node_Str"+ birthYearString+ "String_Node_Str");
        }
      }
    }
    if (headerAffiliations != null) {
      List<String> affiliations=getAttributes(request,headerAffiliations);
      if (affiliations != null && affiliations.size() > 0) {
        person.getAffiliations().clear();
        if (affiliations != null)         person.getAffiliations().addAll(affiliations);
      }
    }
    if (headerCurrentPhoneNumber != null) {
      String currentPhoneNumber=getSingleAttribute(request,headerCurrentPhoneNumber);
      if (!isEmpty(currentPhoneNumber) && person.getCurrentPhoneNumber() == null)       person.setCurrentPhoneNumber(currentPhoneNumber);
    }
    if (headerCurrentPostalAddress != null) {
      String currentPostalAddress=getSingleAttribute(request,headerCurrentPostalAddress);
      if (!isEmpty(currentPostalAddress) && person.getCurrentPostalAddress() == null)       person.setCurrentPostalAddress(currentPostalAddress);
    }
    if (headerCurrentEmailAddress != null) {
      String currentEmailAddress=getSingleAttribute(request,headerCurrentEmailAddress);
      if (!isEmpty(currentEmailAddress) && person.getCurrentEmailAddress() == null)       person.setCurrentEmailAddress(currentEmailAddress);
    }
    if (headerPermanentPhoneNumber != null) {
      String permanentPhoneNumber=getSingleAttribute(request,headerPermanentPhoneNumber);
      if (!isEmpty(permanentPhoneNumber) && person.getPermanentPhoneNumber() == null)       person.setPermanentPhoneNumber(permanentPhoneNumber);
    }
    if (headerPermanentPostalAddress != null) {
      String permanentPostalAddress=getSingleAttribute(request,headerPermanentPostalAddress);
      if (!isEmpty(permanentPostalAddress) && person.getPermanentPostalAddress() == null)       person.setPermanentPostalAddress(permanentPostalAddress);
    }
    if (headerPermanentEmailAddress != null) {
      String permanentEmailAddress=getSingleAttribute(request,headerPermanentEmailAddress);
      if (!isEmpty(permanentEmailAddress) && person.getPermanentEmailAddress() == null)       person.setPermanentEmailAddress(permanentEmailAddress);
    }
    if (headerCurrentDegree != null) {
      String currentDegree=getSingleAttribute(request,headerCurrentDegree);
      if (!isEmpty(currentDegree) && person.getCurrentDegree() == null)       person.setCurrentDegree(currentDegree);
    }
    if (headerCurrentDepartment != null) {
      String currentDepartment=getSingleAttribute(request,headerCurrentDepartment);
      if (!isEmpty(currentDepartment) && person.getCurrentDepartment() == null)       person.setCurrentDepartment(currentDepartment);
    }
    if (headerCurrentCollege != null) {
      String currentCollege=getSingleAttribute(request,headerCurrentCollege);
      if (!isEmpty(currentCollege) && person.getCurrentCollege() == null)       person.setCurrentCollege(currentCollege);
    }
    if (headerCurrentMajor != null) {
      String currentMajor=getSingleAttribute(request,headerCurrentMajor);
      if (!isEmpty(currentMajor) && person.getCurrentMajor() == null)       person.setCurrentMajor(currentMajor);
    }
    if (headerCurrentGraduationYear != null) {
      String currentGraduationYearString=getSingleAttribute(request,headerCurrentGraduationYear);
      if (!isEmpty(currentGraduationYearString) && person.getCurrentGraduationYear() == null) {
        try {
          Integer currentGraduationYear=Integer.valueOf(currentGraduationYearString);
          person.setCurrentGraduationYear(currentGraduationYear);
        }
 catch (        NumberFormatException nfe) {
          Logger.warn("String_Node_Str" + headerCurrentGraduationYear + "String_Node_Str"+ currentGraduationYearString+ "String_Node_Str");
        }
      }
    }
    if (headerCurrentGraduationMonth != null) {
      String currentGraduationMonthString=getSingleAttribute(request,headerCurrentGraduationMonth);
      if (!isEmpty(currentGraduationMonthString) && person.getCurrentGraduationMonth() == null) {
        try {
          Integer currentGraduationMonth=Integer.valueOf(currentGraduationMonthString);
          person.setCurrentGraduationMonth(currentGraduationMonth);
        }
 catch (        NumberFormatException nfe) {
          Logger.warn("String_Node_Str" + headerCurrentGraduationMonth + "String_Node_Str"+ currentGraduationMonthString+ "String_Node_Str");
        }
catch (        IllegalArgumentException iae) {
          Logger.warn("String_Node_Str" + headerCurrentGraduationMonth + "String_Node_Str"+ currentGraduationMonthString+ "String_Node_Str");
        }
      }
    }
    if (headerOrcid != null) {
      String orcidString=getSingleAttribute(request,headerOrcid);
      if (!isEmpty(orcidString) && person.getOrcid() == null)       person.setOrcid(orcidString);
    }
    person.save();
  }
  finally {
    context.restoreAuthorization();
  }
  context.login(person);
  return AuthenticationResult.SUCCESSFULL;
}

Fixed version (ground truth):
@Override public AuthenticationResult authenticate(Request request){
  if (Logger.isTraceEnabled() || logShib) {
    String log="String_Node_Str";
    if (request != null) {
      for (      String name : request.headers.keySet()) {
        for (        String value : request.headers.get(name).values) {
          log+="String_Node_Str" + name + "String_Node_Str"+ value+ "String_Node_Str";
        }
      }
    }
 else {
      log+="String_Node_Str";
    }
    String configuredLogLevel=Play.configuration.getProperty("String_Node_Str","String_Node_Str");
    if (!Logger.isTraceEnabled() && !Logger.configuredManually && !configuredLogLevel.isEmpty()) {
      Logger.setUp("String_Node_Str");
    }
 else {
      configuredLogLevel="String_Node_Str";
    }
    if (Logger.isTraceEnabled()) {
      Logger.trace(log);
    }
    if (!configuredLogLevel.isEmpty()) {
      Logger.setUp(configuredLogLevel);
    }
  }
  String netid=getSingleAttribute(request,headerNetId);
  String email=getSingleAttribute(request,headerEmail);
  String firstName=getSingleAttribute(request,headerFirstName);
  String lastName=getSingleAttribute(request,headerLastName);
  if (useNetIdAsIdentifier && netid == null) {
    Logger.error("String_Node_Str",headerNetId);
    return AuthenticationResult.MISSING_CREDENTIALS;
  }
  if (email == null) {
    Logger.error("String_Node_Str",headerEmail);
    return AuthenticationResult.MISSING_CREDENTIALS;
  }
  if (firstName == null && lastName == null) {
    Logger.error("String_Node_Str",headerFirstName,headerLastName);
    return AuthenticationResult.MISSING_CREDENTIALS;
  }
  Person person;
  try {
    context.turnOffAuthorization();
    if (useNetIdAsIdentifier) {
      person=personRepo.findPersonByNetId(netid);
    }
 else {
      person=personRepo.findPersonByEmail(email);
    }
    if (person == null) {
      try {
        person=personRepo.createPerson(netid,email,firstName,lastName,RoleType.STUDENT).save();
      }
 catch (      RuntimeException re) {
        Logger.error(re,"String_Node_Str");
        return AuthenticationResult.BAD_CREDENTIALS;
      }
    }
 else {
      if (netid != null)       person.setNetId(netid);
      person.setEmail(email);
      person.setFirstName(firstName);
      person.setLastName(lastName);
    }
    if (headerInstitutionalIdentifier != null) {
      String identifier=getSingleAttribute(request,headerInstitutionalIdentifier);
      if (!isEmpty(identifier))       person.setInstitutionalIdentifier(identifier);
    }
    if (headerMiddleName != null) {
      String middleName=getSingleAttribute(request,headerMiddleName);
      if (!isEmpty(middleName) && person.getMiddleName() == null)       person.setMiddleName(middleName);
    }
    if (headerBirthYear != null) {
      String birthYearString=getSingleAttribute(request,headerBirthYear);
      if (!isEmpty(birthYearString) && person.getBirthYear() == null) {
        try {
          Integer birthYear=Integer.valueOf(birthYearString);
          person.setBirthYear(birthYear);
        }
 catch (        NumberFormatException nfe) {
          Logger.warn("String_Node_Str" + headerBirthYear + "String_Node_Str"+ birthYearString+ "String_Node_Str");
        }
      }
    }
    if (headerAffiliations != null) {
      List<String> affiliations=getAttributes(request,headerAffiliations);
      if (affiliations != null && affiliations.size() > 0) {
        person.getAffiliations().clear();
        if (affiliations != null)         person.getAffiliations().addAll(affiliations);
      }
    }
    if (headerCurrentPhoneNumber != null) {
      String currentPhoneNumber=getSingleAttribute(request,headerCurrentPhoneNumber);
      if (!isEmpty(currentPhoneNumber) && person.getCurrentPhoneNumber() == null)       person.setCurrentPhoneNumber(currentPhoneNumber);
    }
    if (headerCurrentPostalAddress != null) {
      String currentPostalAddress=getSingleAttribute(request,headerCurrentPostalAddress);
      if (!isEmpty(currentPostalAddress) && person.getCurrentPostalAddress() == null)       person.setCurrentPostalAddress(currentPostalAddress);
    }
    if (headerCurrentEmailAddress != null) {
      String currentEmailAddress=getSingleAttribute(request,headerCurrentEmailAddress);
      if (!isEmpty(currentEmailAddress) && person.getCurrentEmailAddress() == null)       person.setCurrentEmailAddress(currentEmailAddress);
    }
    if (headerPermanentPhoneNumber != null) {
      String permanentPhoneNumber=getSingleAttribute(request,headerPermanentPhoneNumber);
      if (!isEmpty(permanentPhoneNumber) && person.getPermanentPhoneNumber() == null)       person.setPermanentPhoneNumber(permanentPhoneNumber);
    }
    if (headerPermanentPostalAddress != null) {
      String permanentPostalAddress=getSingleAttribute(request,headerPermanentPostalAddress);
      if (!isEmpty(permanentPostalAddress) && person.getPermanentPostalAddress() == null)       person.setPermanentPostalAddress(permanentPostalAddress);
    }
    if (headerPermanentEmailAddress != null) {
      String permanentEmailAddress=getSingleAttribute(request,headerPermanentEmailAddress);
      if (!isEmpty(permanentEmailAddress) && person.getPermanentEmailAddress() == null)       person.setPermanentEmailAddress(permanentEmailAddress);
    }
    if (headerCurrentDegree != null) {
      String currentDegree=getSingleAttribute(request,headerCurrentDegree);
      if (!isEmpty(currentDegree) && person.getCurrentDegree() == null)       person.setCurrentDegree(currentDegree);
    }
    if (headerCurrentDepartment != null) {
      String currentDepartment=getSingleAttribute(request,headerCurrentDepartment);
      if (!isEmpty(currentDepartment) && person.getCurrentDepartment() == null)       person.setCurrentDepartment(currentDepartment);
    }
    if (headerCurrentCollege != null) {
      String currentCollege=getSingleAttribute(request,headerCurrentCollege);
      if (!isEmpty(currentCollege) && person.getCurrentCollege() == null)       person.setCurrentCollege(currentCollege);
    }
    if (headerCurrentMajor != null) {
      String currentMajor=getSingleAttribute(request,headerCurrentMajor);
      if (!isEmpty(currentMajor) && person.getCurrentMajor() == null)       person.setCurrentMajor(currentMajor);
    }
    if (headerCurrentGraduationYear != null) {
      String currentGraduationYearString=getSingleAttribute(request,headerCurrentGraduationYear);
      if (!isEmpty(currentGraduationYearString) && person.getCurrentGraduationYear() == null) {
        try {
          Integer currentGraduationYear=Integer.valueOf(currentGraduationYearString);
          person.setCurrentGraduationYear(currentGraduationYear);
        }
 catch (        NumberFormatException nfe) {
          Logger.warn("String_Node_Str" + headerCurrentGraduationYear + "String_Node_Str"+ currentGraduationYearString+ "String_Node_Str");
        }
      }
    }
    if (headerCurrentGraduationMonth != null) {
      String currentGraduationMonthString=getSingleAttribute(request,headerCurrentGraduationMonth);
      if (!isEmpty(currentGraduationMonthString) && person.getCurrentGraduationMonth() == null) {
        try {
          Integer currentGraduationMonth=Integer.valueOf(currentGraduationMonthString);
          person.setCurrentGraduationMonth(currentGraduationMonth);
        }
 catch (        NumberFormatException nfe) {
          Logger.warn("String_Node_Str" + headerCurrentGraduationMonth + "String_Node_Str"+ currentGraduationMonthString+ "String_Node_Str");
        }
catch (        IllegalArgumentException iae) {
          Logger.warn("String_Node_Str" + headerCurrentGraduationMonth + "String_Node_Str"+ currentGraduationMonthString+ "String_Node_Str");
        }
      }
    }
    if (headerOrcid != null) {
      String orcidString=getSingleAttribute(request,headerOrcid);
      if (!isEmpty(orcidString) && person.getOrcid() == null)       person.setOrcid(orcidString);
    }
    person.save();
  }
  finally {
    context.restoreAuthorization();
  }
  context.login(person);
  return AuthenticationResult.SUCCESSFULL;
}