Program: 79689
Project: 79689
Buggy source:
/** 
 * Writes a log record.
 * @param s Array of data information for the log record.
 * @param type Type of log either <code>LOG_ERROR</code> or<code>LOG_ACCESS</code>.
 * @param messageName Message ID for the log record.
 * @param ssoProperties Single Sign On Properties to be written to thelog record. If this is <code>null</code>, properties will be retrieved from administrator Single Sign On Token.
 */
public void logIt(String[] s,int type,String messageName,Hashtable ssoProperties){
  LogMessageProviderBase provider=null;
  if (logStatus && (s != null)) {
    try {
      provider=(LogMessageProviderBase)MessageProviderFactory.getProvider("String_Node_Str");
      com.sun.identity.log.LogRecord lr=null;
      SSOToken ssot=AccessController.doPrivileged(AdminTokenAction.getInstance());
      if (ssoProperties == null) {
        lr=provider.createLogRecord(messageName,s,ssot);
      }
 else {
        lr=provider.createLogRecord(messageName,s,ssoProperties);
      }
      com.sun.identity.log.Logger logger;
switch (type) {
case LOG_ACCESS:
        logger=(com.sun.identity.log.Logger)Logger.getLogger("String_Node_Str");
      logger.log(lr,ssot);
    break;
case LOG_ERROR:
  logger=(com.sun.identity.log.Logger)Logger.getLogger("String_Node_Str");
logger.log(lr,ssot);
break;
default :
logger=(com.sun.identity.log.Logger)Logger.getLogger("String_Node_Str");
logger.log(lr,ssot);
break;
}
}
 catch (IOException ex) {
ex.printStackTrace();
debug.error("String_Node_Str" + ex.getMessage());
}
}
initializeAuditor();
String orgName=(String)ssoProperties.get("String_Node_Str");
String realmName=DNMapper.orgNameToRealmName(orgName);
boolean isAuditing=false;
if (isAuthenticationOnlyEvent(messageName)) {
if (auditor.isAuditing(realmName,AuditConstants.AUTHENTICATION_TOPIC)) {
isAuditing=true;
}
}
if (isActivityOnlyEvent(messageName)) {
if (auditor.isAuditing(realmName,AuditConstants.ACTIVITY_TOPIC)) {
isAuditing=true;
}
}
if (isAuditing) {
if (!auditor.isLogoutEvent(messageName)) {
String description=null;
if (provider != null) {
description=provider.getAllHashMessageIDs().get(messageName).getDescription();
}
String userName=(String)ssoProperties.get("String_Node_Str");
String contextID=(String)ssoProperties.get(LogConstants.CONTEXT_ID);
String LoginIDSid=(String)ssoProperties.get(LogConstants.LOGIN_ID_SID);
Set<String> trackingIds=null;
if (StringUtils.isNotEmpty(contextID)) {
trackingIds=new HashSet<>();
trackingIds.add(contextID);
}
if (StringUtils.isNotEmpty(LoginIDSid)) {
InternalSession session=AuthD.getSession(new SessionID(LoginIDSid));
String sessionContext;
if (session != null) {
if (trackingIds == null) {
trackingIds=new HashSet<>();
}
sessionContext=session.getProperty(Constants.AM_CTX_ID);
trackingIds.add(sessionContext);
}
}
AMIdentity identity=IdUtils.getIdentity(userName,realmName);
String authentication=null;
String principal;
if (identity != null) {
authentication=identity.getUniversalId();
if (contextID != null) {
principal=getPrincipalFromUniversalId(identity.getName());
}
 else {
principal=identity.getName();
}
}
 else {
principal=userName;
}
String moduleName=(String)ssoProperties.get("String_Node_Str");
AuthenticationAuditEventBuilder.Status result=null;
List<AuthenticationAuditEntry> entries=null;
if (StringUtils.isNotEmpty(moduleName)) {
Map<String,String> info=null;
String ip=(String)ssoProperties.get(LogConstants.IP_ADDR);
if (StringUtils.isNotEmpty(ip)) {
info=new HashMap<>();
info.put(IP_ADDRESS.toString(),ip);
}
if (StringUtils.isNotEmpty(description)) {
if (info == null) {
info=new HashMap<>();
}
info.put(EVENT_DATA.toString(),description);
}
AuthenticationAuditEntry authenticationAuditEntry=new AuthenticationAuditEntry();
authenticationAuditEntry.setModuleId(moduleName);
messageName=AM_LOGIN_CHAIN_COMPLETED.toString();
if (info != null) {
authenticationAuditEntry.setInfo(info);
}
entries=Collections.singletonList(authenticationAuditEntry);
if (contextID == null) {
result=FAILED;
}
 else {
result=SUCCESSFUL;
}
}
auditor.audit(messageName,AuditRequestContext.getTransactionIdValue(),authentication,principal,realmName,trackingIds,entries,result);
}
}
}

Fixed version (ground truth):
/** 
 * Writes a log record.
 * @param s Array of data information for the log record.
 * @param type Type of log either <code>LOG_ERROR</code> or<code>LOG_ACCESS</code>.
 * @param messageName Message ID for the log record.
 * @param ssoProperties Single Sign On Properties to be written to thelog record. If this is <code>null</code>, properties will be retrieved from administrator Single Sign On Token.
 */
public void logIt(String[] s,int type,String messageName,Hashtable ssoProperties){
  LogMessageProviderBase provider=null;
  if (logStatus && (s != null)) {
    try {
      provider=(LogMessageProviderBase)MessageProviderFactory.getProvider("String_Node_Str");
      com.sun.identity.log.LogRecord lr=null;
      SSOToken ssot=AccessController.doPrivileged(AdminTokenAction.getInstance());
      if (ssoProperties == null) {
        lr=provider.createLogRecord(messageName,s,ssot);
      }
 else {
        lr=provider.createLogRecord(messageName,s,ssoProperties);
      }
      com.sun.identity.log.Logger logger;
switch (type) {
case LOG_ACCESS:
        logger=(com.sun.identity.log.Logger)Logger.getLogger("String_Node_Str");
      logger.log(lr,ssot);
    break;
case LOG_ERROR:
  logger=(com.sun.identity.log.Logger)Logger.getLogger("String_Node_Str");
logger.log(lr,ssot);
break;
default :
logger=(com.sun.identity.log.Logger)Logger.getLogger("String_Node_Str");
logger.log(lr,ssot);
break;
}
}
 catch (IOException ex) {
ex.printStackTrace();
debug.error("String_Node_Str" + ex.getMessage());
}
}
initializeAuditor();
String orgName=(String)ssoProperties.get("String_Node_Str");
String realmName=DNMapper.orgNameToRealmName(orgName);
boolean isAuditing=false;
if (isAuthenticationOnlyEvent(messageName)) {
if (auditor.isAuditing(realmName,AuditConstants.AUTHENTICATION_TOPIC)) {
isAuditing=true;
}
}
if (isActivityOnlyEvent(messageName)) {
if (auditor.isAuditing(realmName,AuditConstants.ACTIVITY_TOPIC)) {
isAuditing=true;
}
}
if (isAuditing) {
if (!auditor.isLogoutEvent(messageName)) {
String description=null;
if (provider != null) {
description=provider.getAllHashMessageIDs().get(messageName).getDescription();
}
String userName=(String)ssoProperties.get("String_Node_Str");
String contextID=(String)ssoProperties.get(LogConstants.CONTEXT_ID);
String LoginIDSid=(String)ssoProperties.get(LogConstants.LOGIN_ID_SID);
Set<String> trackingIds=null;
if (StringUtils.isNotEmpty(contextID)) {
trackingIds=new HashSet<>();
trackingIds.add(contextID);
}
if (StringUtils.isNotEmpty(LoginIDSid)) {
InternalSession session=AuthD.getSession(new SessionID(LoginIDSid));
String sessionContext;
if (session != null) {
if (trackingIds == null) {
trackingIds=new HashSet<>();
}
sessionContext=session.getProperty(Constants.AM_CTX_ID);
trackingIds.add(sessionContext);
}
}
AMIdentity identity=null;
if (StringUtils.isNotEmpty(userName) && StringUtils.isNotEmpty(realmName)) {
identity=IdUtils.getIdentity(userName,realmName);
}
String authentication=null;
String principal;
if (identity != null) {
authentication=identity.getUniversalId();
if (contextID != null) {
principal=getPrincipalFromUniversalId(identity.getName());
}
 else {
principal=identity.getName();
}
}
 else {
principal=userName;
}
String moduleName=(String)ssoProperties.get("String_Node_Str");
AuthenticationAuditEventBuilder.Status result=null;
List<AuthenticationAuditEntry> entries=null;
if (StringUtils.isNotEmpty(moduleName)) {
Map<String,String> info=null;
String ip=(String)ssoProperties.get(LogConstants.IP_ADDR);
if (StringUtils.isNotEmpty(ip)) {
info=new HashMap<>();
info.put(IP_ADDRESS.toString(),ip);
}
if (StringUtils.isNotEmpty(description)) {
if (info == null) {
info=new HashMap<>();
}
info.put(EVENT_DATA.toString(),description);
}
AuthenticationAuditEntry authenticationAuditEntry=new AuthenticationAuditEntry();
authenticationAuditEntry.setModuleId(moduleName);
messageName=AM_LOGIN_CHAIN_COMPLETED.toString();
if (info != null) {
authenticationAuditEntry.setInfo(info);
}
entries=Collections.singletonList(authenticationAuditEntry);
if (contextID == null) {
result=FAILED;
}
 else {
result=SUCCESSFUL;
}
}
auditor.audit(messageName,AuditRequestContext.getTransactionIdValue(),authentication,principal,realmName,trackingIds,entries,result);
}
}
}