Program: 105110
Project: 105110
Buggy source:
@Override public String authenticate(String command,Map<String,Object[]> params,HttpSession session,InetAddress remoteAddress,String responseType,StringBuilder auditTrailSb,final HttpServletRequest req,final HttpServletResponse resp) throws ServerApiException {
  if (HTTPMethod.valueOf(req.getMethod()) != HTTPMethod.POST) {
    throw new ServerApiException(ApiErrorCode.METHOD_NOT_ALLOWED,"String_Node_Str");
  }
  final String[] username=(String[])params.get(ApiConstants.USERNAME);
  final String[] password=(String[])params.get(ApiConstants.PASSWORD);
  String[] domainIdArr=(String[])params.get(ApiConstants.DOMAIN_ID);
  if (domainIdArr == null) {
    domainIdArr=(String[])params.get(ApiConstants.DOMAIN__ID);
  }
  final String[] domainName=(String[])params.get(ApiConstants.DOMAIN);
  Long domainId=null;
  if ((domainIdArr != null) && (domainIdArr.length > 0)) {
    try {
      domainId=_apiServer.fetchDomainId(domainIdArr[0]);
      if (domainId == null) {
        domainId=Long.parseLong(domainIdArr[0]);
      }
      auditTrailSb.append("String_Node_Str" + domainId);
    }
 catch (    final NumberFormatException e) {
      s_logger.warn("String_Node_Str");
      auditTrailSb.append("String_Node_Str" + HttpServletResponse.SC_UNAUTHORIZED + "String_Node_Str"+ "String_Node_Str");
      throw new ServerApiException(ApiErrorCode.UNAUTHORIZED,_apiServer.getSerializedApiError(HttpServletResponse.SC_UNAUTHORIZED,"String_Node_Str",params,responseType));
    }
  }
  String domain=null;
  if (domainName != null) {
    domain=domainName[0];
    auditTrailSb.append("String_Node_Str" + domain);
    if (domain != null) {
      if (!domain.endsWith("String_Node_Str")) {
        domain+='/';
      }
      if (!domain.startsWith("String_Node_Str")) {
        domain="String_Node_Str" + domain;
      }
    }
  }
  String serializedResponse=null;
  if (username != null) {
    final String pwd=((password == null) ? null : password[0]);
    try {
      final Domain userDomain=_domainService.findDomainByIdOrPath(domainId,domain);
      if (userDomain != null) {
        domainId=userDomain.getId();
      }
 else {
        throw new CloudAuthenticationException("String_Node_Str" + domain);
      }
      final UserAccount userAccount=_accountService.getActiveUserAccount(username[0],domainId);
      if (userAccount == null || !(User.Source.UNKNOWN.equals(userAccount.getSource()) || User.Source.LDAP.equals(userAccount.getSource()))) {
        throw new CloudAuthenticationException("String_Node_Str");
      }
      return ApiResponseSerializer.toSerializedString(_apiServer.loginUser(session,username[0],pwd,domainId,domain,remoteAddress,params),responseType);
    }
 catch (    final CloudAuthenticationException ex) {
      try {
        session.invalidate();
      }
 catch (      final IllegalStateException ise) {
      }
      auditTrailSb.append("String_Node_Str" + ApiErrorCode.ACCOUNT_ERROR + "String_Node_Str"+ ex.getMessage() != null ? ex.getMessage() : "String_Node_Str");
      serializedResponse=_apiServer.getSerializedApiError(ApiErrorCode.ACCOUNT_ERROR.getHttpCode(),ex.getMessage() != null ? ex.getMessage() : "String_Node_Str",params,responseType);
    }
  }
  throw new ServerApiException(ApiErrorCode.ACCOUNT_ERROR,serializedResponse);
}

Fixed version (ground truth):
@Override public String authenticate(String command,Map<String,Object[]> params,HttpSession session,InetAddress remoteAddress,String responseType,StringBuilder auditTrailSb,final HttpServletRequest req,final HttpServletResponse resp) throws ServerApiException {
  if (HTTPMethod.valueOf(req.getMethod()) != HTTPMethod.POST) {
    throw new ServerApiException(ApiErrorCode.METHOD_NOT_ALLOWED,"String_Node_Str");
  }
  final String[] username=(String[])params.get(ApiConstants.USERNAME);
  final String[] password=(String[])params.get(ApiConstants.PASSWORD);
  String[] domainIdArr=(String[])params.get(ApiConstants.DOMAIN_ID);
  if (domainIdArr == null) {
    domainIdArr=(String[])params.get(ApiConstants.DOMAIN__ID);
  }
  final String[] domainName=(String[])params.get(ApiConstants.DOMAIN);
  Long domainId=null;
  if ((domainIdArr != null) && (domainIdArr.length > 0)) {
    try {
      domainId=_apiServer.fetchDomainId(domainIdArr[0]);
      if (domainId == null) {
        domainId=Long.parseLong(domainIdArr[0]);
      }
      auditTrailSb.append("String_Node_Str" + domainId);
    }
 catch (    final NumberFormatException e) {
      s_logger.warn("String_Node_Str");
      auditTrailSb.append("String_Node_Str" + HttpServletResponse.SC_UNAUTHORIZED + "String_Node_Str"+ "String_Node_Str");
      throw new ServerApiException(ApiErrorCode.UNAUTHORIZED,_apiServer.getSerializedApiError(HttpServletResponse.SC_UNAUTHORIZED,"String_Node_Str",params,responseType));
    }
  }
  String domain=null;
  if (domainName != null) {
    domain=domainName[0];
    auditTrailSb.append("String_Node_Str" + domain);
    if (domain != null) {
      if (!domain.endsWith("String_Node_Str")) {
        domain+='/';
      }
      if (!domain.startsWith("String_Node_Str")) {
        domain="String_Node_Str" + domain;
      }
    }
  }
  String serializedResponse=null;
  if (username != null) {
    final String pwd=((password == null) ? null : password[0]);
    try {
      final Domain userDomain=_domainService.findDomainByIdOrPath(domainId,domain);
      if (userDomain != null) {
        domainId=userDomain.getId();
      }
 else {
        throw new CloudAuthenticationException("String_Node_Str" + domain);
      }
      final UserAccount userAccount=_accountService.getActiveUserAccount(username[0],domainId);
      if (userAccount != null && User.Source.SAML2 == userAccount.getSource()) {
        throw new CloudAuthenticationException("String_Node_Str");
      }
      return ApiResponseSerializer.toSerializedString(_apiServer.loginUser(session,username[0],pwd,domainId,domain,remoteAddress,params),responseType);
    }
 catch (    final CloudAuthenticationException ex) {
      try {
        session.invalidate();
      }
 catch (      final IllegalStateException ise) {
      }
      auditTrailSb.append("String_Node_Str" + ApiErrorCode.ACCOUNT_ERROR + "String_Node_Str"+ ex.getMessage() != null ? ex.getMessage() : "String_Node_Str");
      serializedResponse=_apiServer.getSerializedApiError(ApiErrorCode.ACCOUNT_ERROR.getHttpCode(),ex.getMessage() != null ? ex.getMessage() : "String_Node_Str",params,responseType);
    }
  }
  throw new ServerApiException(ApiErrorCode.ACCOUNT_ERROR,serializedResponse);
}