Program: 29152
Project: 29152
Buggy source:
/** 
 * A special case login for X500Name credentials. This is invoked for certificate login because the containers extract the X.500 name from the X.509 certificate before calling into this class.
 */
public static void doX500Login(Subject s,String appModuleID) throws LoginException {
  if (_logger.isLoggable(Level.FINE)) {
    _logger.fine("String_Node_Str");
  }
  String user=null;
  String realm_name=null;
  try {
    X500Name x500name=(X500Name)getPublicCredentials(s,X500Name.class);
    user=x500name.getName();
    Realm realm=Realm.getInstance(CertificateRealm.AUTH_TYPE);
    if (realm instanceof CertificateRealm) {
      CertificateRealm certRealm=(CertificateRealm)realm;
      String jaasCtx=certRealm.getJAASContext();
      if (jaasCtx != null) {
        LoginContext lg=new LoginContext(jaasCtx,s,new ServerLoginCallbackHandler(user,null,appModuleID));
        lg.login();
      }
      certRealm.authenticate(s,x500name);
      realm_name=CertificateRealm.AUTH_TYPE;
      if (getAuditManager().isAuditOn()) {
        getAuditManager().authentication(user,realm_name,true);
      }
    }
 else {
      _logger.warning("String_Node_Str");
      setSecurityContext(user,s,realm_name);
      realm_name=realm.getName();
    }
    if (_logger.isLoggable(Level.FINE)) {
      _logger.fine("String_Node_Str" + user);
    }
  }
 catch (  LoginException le) {
    if (getAuditManager().isAuditOn()) {
      getAuditManager().authentication(user,realm_name,false);
    }
    throw le;
  }
catch (  Exception ex) {
    throw (LoginException)new LoginException(ex.toString()).initCause(ex);
  }
}

Fixed version (ground truth):
/** 
 * A special case login for X500Name credentials. This is invoked for certificate login because the containers extract the X.500 name from the X.509 certificate before calling into this class.
 */
public static void doX500Login(Subject s,String appModuleID) throws LoginException {
  if (_logger.isLoggable(Level.FINE)) {
    _logger.fine("String_Node_Str");
  }
  String user=null;
  String realm_name=null;
  try {
    X500Name x500name=(X500Name)getPublicCredentials(s,X500Name.class);
    user=x500name.getName();
    Realm realm=Realm.getInstance(CertificateRealm.AUTH_TYPE);
    if (realm instanceof CertificateRealm) {
      CertificateRealm certRealm=(CertificateRealm)realm;
      String jaasCtx=certRealm.getJAASContext();
      if (jaasCtx != null) {
        LoginContext lg=new LoginContext(jaasCtx,s,new ServerLoginCallbackHandler(user,null,appModuleID));
        lg.login();
      }
      certRealm.authenticate(s,x500name);
      realm_name=CertificateRealm.AUTH_TYPE;
      if (getAuditManager().isAuditOn()) {
        getAuditManager().authentication(user,realm_name,true);
      }
    }
 else {
      _logger.warning("String_Node_Str");
      realm_name=realm.getName();
      setSecurityContext(user,s,realm_name);
    }
    if (_logger.isLoggable(Level.FINE)) {
      _logger.fine("String_Node_Str" + user);
    }
  }
 catch (  LoginException le) {
    if (getAuditManager().isAuditOn()) {
      getAuditManager().authentication(user,realm_name,false);
    }
    throw le;
  }
catch (  Exception ex) {
    throw (LoginException)new LoginException(ex.toString()).initCause(ex);
  }
}