Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Enumerations | Functions | Variables
singsign.cpp File Reference
#include "singsign.h"
#include "wallet.h"
#include "nsNetUtil.h"
#include "private/prpriv.h"
#include "nsIPref.h"
#include "nsIServiceManager.h"
#include "nsIIOService.h"
#include "nsIURL.h"
#include "nsIDOMHTMLDocument.h"
#include "prmem.h"
#include "prprf.h"
#include "nsXPIDLString.h"
#include "nsReadableUtils.h"
#include "nsIObserverService.h"
#include "nsIObserver.h"
#include "nsCRT.h"
#include "plstr.h"

Go to the source code of this file.

Classes

class  si_SignonUserStruct
class  si_SignonURLStruct
class  si_Reject
class  si_SignonCompositeURLStruct
 composite URL struct for handling the migration of legacy password entries. More...
class  nsSingleSignOnProfileObserver

Defines

#define alphabetize   1
#define LOG(args)
#define USERNAMEFIELD   "\\=username=\\"
#define PASSWORDFIELD   "\\=password=\\"
#define StrAllocCopy(dest, src)   Local_SACopy (&(dest), src)
#define LIST_COUNT(list)   (list ? list->Count() : 0)
#define BUFFER_SIZE   4096

Enumerations

enum  DialogType { promptUsernameAndPassword, promptPassword, prompt }

Functions

static void si_lock_signon_list (void)
static void si_unlock_signon_list (void)
void SI_RegisterCallback (const char *domain, PrefChangedFunc callback, void *instance_data)
void SI_UnregisterCallback (const char *domain, PrefChangedFunc callback, void *instance_data)
void SI_SetBoolPref (const char *prefname, PRBool prefvalue)
PRBool SI_GetBoolPref (const char *prefname, PRBool defaultvalue)
void SI_SetCharPref (const char *prefname, const char *prefvalue)
void SI_GetCharPref (const char *prefname, char **aPrefvalue)
void SI_GetLocalizedUnicharPref (const char *prefname, PRUnichar **aPrefvalue)
static int si_SaveSignonDataLocked (char *state, PRBool notify)
int SI_LoadSignonData ()
void SI_RemoveAllSignonData ()
static void si_SetSignonRememberingPref (PRBool x)
int PR_CALLBACK si_SignonRememberingPrefChanged (const char *newpref, void *data)
static void si_RegisterSignonPrefCallbacks (void)
static PRBool si_GetSignonRememberingPref (void)
void SI_InitSignonFileName ()
static PRInt32 si_3ButtonConfirm (PRUnichar *szMessage, nsIDOMWindowInternal *window)
static PRBool si_SelectDialog (const PRUnichar *szMessage, nsIPrompt *dialog, PRUnichar **pList, PRInt32 *pCount, PRUint32 formNumber)
static nsresult si_CheckGetPassword (PRUnichar **password, const PRUnichar *dialogTitle, const PRUnichar *szMessage, nsIPrompt *dialog, PRUint32 savePassword, PRBool *checkValue)
static nsresult si_CheckGetData (PRUnichar **data, const PRUnichar *dialogTitle, const PRUnichar *szMessage, nsIPrompt *dialog, PRUint32 savePassword, PRBool *checkValue)
static nsresult si_CheckGetUsernamePassword (PRUnichar **username, PRUnichar **password, const PRUnichar *dialogTitle, const PRUnichar *szMessage, nsIPrompt *dialog, PRUint32 savePassword, PRBool *checkValue)
static char * Local_SACopy (char **destination, const char *source)
static PRBool si_CompareEncryptedToCleartext (const nsString &crypt, const nsString &text)
static PRBool si_CompareEncryptedToEncrypted (const nsString &crypt1, const nsString &crypt2)
static PRUint32 SecondsFromPRTime (PRTime prTime)
static si_SignonURLStructsi_GetURL (const char *passwordRealm)
static si_SignonURLStructsi_GetCompositeURL (const char *primaryRealm, const char *legacyRealm)
static PRInt32 si_SetChosenUser (si_SignonURLStruct *url, si_SignonUserStruct *chosen_user)
static void si_ReleaseCompositeURL (si_SignonURLStruct *url)
static PRBool si_RemoveUser (const char *passwordRealm, const nsString &userName, PRBool save, PRBool loginFailure, PRBool notify, PRBool first=PR_FALSE)
nsresult SINGSIGN_RemoveUser (const char *host, const PRUnichar *user, PRBool notify)
nsresult SINGSIGN_RemoveUserAfterLoginFailure (const char *host, const PRUnichar *user, PRBool notify)
static void si_FreeReject (si_Reject *reject)
nsresult SINGSIGN_RemoveReject (const char *host)
static void si_PutReject (const char *passwordRealm, const nsString &userName, PRBool save)
nsresult SINGSIGN_AddReject (const char *host)
static PRBool si_CheckForUser (const char *passwordRealm, const nsString &userName)
static si_SignonDataStructsi_GetFirstNonPasswordData (si_SignonUserStruct *user)
static si_SignonUserStructsi_GetUser (nsIPrompt *dialog, const char *passwordRealm, const char *legacyRealm, PRBool pickFirstUser, const nsString &userText, PRUint32 formNumber)
static si_SignonUserStructsi_GetSpecificUser (const char *passwordRealm, const nsString &userName, const nsString &userText)
static si_SignonUserStructsi_GetURLAndUserForChangeForm (nsIPrompt *dialog, const nsString &password)
void SI_DeleteAll ()
void SI_ClearUserData ()
void SI_DeletePersistentUserData ()
static PRBool si_CheckForReject (const char *passwordRealm, const nsString &userName)
static void si_PutData (const char *passwordRealm, nsVoidArray *signonData, PRBool save)
static nsresult EnsureSingleSignOnProfileObserver ()
static PRInt32 si_ReadLine (nsIInputStream *strm, nsString &lineBuffer)
static PRBool si_ExtractRealm (nsIURI *uri, nsCString &realm)
static PRBool si_OkToSave (const char *passwordRealm, const char *legacyRealm, const nsString &userName, nsIDOMWindowInternal *window)
static void si_RememberSignonData (nsIPrompt *dialog, const char *passwordRealm, const char *legacyRealm, nsVoidArray *signonData, nsIDOMWindowInternal *window)
void SINGSIGN_RememberSignonData (nsIPrompt *dialog, nsIURI *passwordRealm, nsVoidArray *signonData, nsIDOMWindowInternal *window)
static void si_RestoreSignonData (nsIPrompt *dialog, const char *passwordRealm, const char *legacyRealm, const PRUnichar *name, PRUnichar **value, PRUint32 formNumber, PRUint32 elementNumber)
void SINGSIGN_RestoreSignonData (nsIPrompt *dialog, nsIURI *passwordRealm, const PRUnichar *name, PRUnichar **value, PRUint32 formNumber, PRUint32 elementNumber)
static void si_RememberSignonDataFromBrowser (const char *passwordRealm, const nsString &username, const nsString &password)
static void si_RestoreOldSignonDataFromBrowser (nsIPrompt *dialog, const char *passwordRealm, PRBool pickFirstUser, nsString &username, nsString &password)
PRBool SINGSIGN_StorePassword (const char *passwordRealm, const PRUnichar *user, const PRUnichar *password)
static nsresult si_DoDialogIfPrefIsOff (const PRUnichar *dialogTitle, const PRUnichar *text, PRUnichar **user, PRUnichar **pwd, const PRUnichar *defaultText, PRUnichar **resultText, const char *passwordRealm, nsIPrompt *dialog, PRBool *pressedOK, PRUint32 savePassword, DialogType dlg)
nsresult SINGSIGN_PromptUsernameAndPassword (const PRUnichar *dialogTitle, const PRUnichar *text, PRUnichar **user, PRUnichar **pwd, const char *passwordRealm, nsIPrompt *dialog, PRBool *pressedOK, PRUint32 savePassword)
nsresult SINGSIGN_PromptPassword (const PRUnichar *dialogTitle, const PRUnichar *text, PRUnichar **pwd, const char *passwordRealm, nsIPrompt *dialog, PRBool *pressedOK, PRUint32 savePassword)
nsresult SINGSIGN_Prompt (const PRUnichar *dialogTitle, const PRUnichar *text, const PRUnichar *defaultText, PRUnichar **resultText, const char *passwordRealm, nsIPrompt *dialog, PRBool *pressedOK, PRUint32 savePassword)
PRBool SI_InSequence (const nsString &sequence, PRInt32 number)
void SI_FindValueInArgs (const nsAString &results, const nsAString &name, nsAString &value)
PRBool SINGSIGN_ReencryptAll ()
nsresult SINGSIGN_HaveData (nsIPrompt *dialog, const char *passwordRealm, const PRUnichar *userName, PRBool *retval)
PRInt32 SINGSIGN_HostCount ()
PRInt32 SINGSIGN_UserCount (PRInt32 host)
nsresult SINGSIGN_Enumerate (PRInt32 hostNumber, PRInt32 userNumber, PRBool decrypt, char **host, PRUnichar **user, PRUnichar **pswd)
PRInt32 SINGSIGN_RejectCount ()
nsresult SINGSIGN_RejectEnumerate (PRInt32 rejectNumber, char **host)

Variables

static PRMonitorsignon_lock_monitor = NULL
static PRThreadsignon_lock_owner = NULL
static int signon_lock_count = 0
static PRBool si_PartiallyLoaded = PR_FALSE
static PRInt32 si_LastFormForWhichUserHasBeenSelected = -1
char * signonFileName = nsnull
static PRBool gLoadedUserData = PR_FALSE
static PRUint32 gSelectUserDialogCount = 0
static const char * pref_rememberSignons = "signon.rememberSignons"
static const char * pref_SignonFileName = "signon.SignonFileName"
static PRBool si_RememberSignons = PR_FALSE
static nsVoidArraysi_signon_list = 0
static nsVoidArraysi_reject_list = 0
static PRBool si_signon_list_changed = PR_FALSE
static
si_SignonCompositeURLStruct
si_composite_url = 0

Define Documentation

Definition at line 40 of file singsign.cpp.

#define BUFFER_SIZE   4096

Definition at line 1833 of file singsign.cpp.

#define LIST_COUNT (   list)    (list ? list->Count() : 0)

Definition at line 726 of file singsign.cpp.

#define LOG (   args)

Definition at line 74 of file singsign.cpp.

#define PASSWORDFIELD   "\\=password=\\"

Definition at line 106 of file singsign.cpp.

#define StrAllocCopy (   dest,
  src 
)    Local_SACopy (&(dest), src)

Definition at line 590 of file singsign.cpp.

#define USERNAMEFIELD   "\\=username=\\"

Definition at line 105 of file singsign.cpp.


Enumeration Type Documentation

enum DialogType
Enumerator:
promptUsernameAndPassword 
promptPassword 
prompt 

Definition at line 2552 of file singsign.cpp.


Function Documentation

Definition at line 1808 of file singsign.cpp.

{
  static nsSingleSignOnProfileObserver *gSignOnProfileObserver;
  
  if (!gSignOnProfileObserver) {      
    nsCOMPtr<nsIObserverService> observerService(do_GetService("@mozilla.org/observer-service;1"));
    if (!observerService)
      return NS_ERROR_FAILURE;
      
    gSignOnProfileObserver = new nsSingleSignOnProfileObserver;
    if (!gSignOnProfileObserver)
      return NS_ERROR_OUT_OF_MEMORY;

    // The observer service holds the only ref to the observer
    // It thus has the lifespan of the observer service
    nsresult rv = observerService->AddObserver(gSignOnProfileObserver, "profile-before-change", PR_FALSE);
    if (NS_FAILED(rv)) {
      delete gSignOnProfileObserver;
      gSignOnProfileObserver = nsnull; 
      return rv;
    }
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static char* Local_SACopy ( char **  destination,
const char *  source 
) [static]

Definition at line 592 of file singsign.cpp.

                                                     {
  if(*destination) {
    PL_strfree(*destination);
  }
  *destination = PL_strdup(source);
  return *destination;
}
static PRUint32 SecondsFromPRTime ( PRTime  prTime) [static]

Definition at line 650 of file singsign.cpp.

                                 {
  PRInt64 microSecondsPerSecond, intermediateResult;
  PRUint32 seconds;
  
  LL_I2L(microSecondsPerSecond, PR_USEC_PER_SEC);
  LL_DIV(intermediateResult, prTime, microSecondsPerSecond);
  LL_L2UI(seconds, intermediateResult);
  return seconds;
}

Here is the caller graph for this function:

static PRInt32 si_3ButtonConfirm ( PRUnichar szMessage,
nsIDOMWindowInternal window 
) [static]

Definition at line 386 of file singsign.cpp.

                                                                       {
  return Wallet_3ButtonConfirm(szMessage, window);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool si_CheckForReject ( const char *  passwordRealm,
const nsString userName 
) [static]

Definition at line 1457 of file singsign.cpp.

                                                                        {
  si_Reject * reject;

  si_lock_signon_list();
  if (si_reject_list) {
    PRInt32 rejectCount = LIST_COUNT(si_reject_list);
    for (PRInt32 i=0; i<rejectCount; i++) {
      reject = NS_STATIC_CAST(si_Reject*, si_reject_list->ElementAt(i));
      if(!PL_strcmp(passwordRealm, reject->passwordRealm)) {
// No need for username check on a rejectlist entry.  URL check is sufficient
//    if(!PL_strcmp(userName, reject->userName) && !PL_strcmp(passwordRealm, reject->passwordRealm)) {
        si_unlock_signon_list();
        return PR_TRUE;
      }
    }
  }
  si_unlock_signon_list();
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool si_CheckForUser ( const char *  passwordRealm,
const nsString userName 
) [static]

Definition at line 1027 of file singsign.cpp.

                                                                     {
  si_SignonURLStruct * url;
  si_SignonUserStruct * user;
  si_SignonDataStruct * data;

  /* do nothing if signon preference is not enabled */
  if (!si_GetSignonRememberingPref()) {
    return PR_FALSE;
  }

  si_lock_signon_list();

  /* get URL corresponding to passwordRealm */
  url = si_GetURL(passwordRealm);
  if (!url) {
    /* URL not found */
    si_unlock_signon_list();
    return PR_FALSE;
  }

  /* find the specified user */
  PRInt32 userCount = url->signonUser_list.Count();
  for (PRInt32 i=0; i<userCount; i++) {
    user = NS_STATIC_CAST(si_SignonUserStruct*, url->signonUser_list.ElementAt(i));
    PRInt32 dataCount = user->signonData_list.Count();
    for (PRInt32 ii=0; ii<dataCount; ii++) {
      data = NS_STATIC_CAST(si_SignonDataStruct*, user->signonData_list.ElementAt(ii));
      if (si_CompareEncryptedToCleartext(data->value, userName)) {
        si_unlock_signon_list();
        return PR_TRUE;
      }
    }
  }
  si_unlock_signon_list();
  return PR_FALSE; /* user not found */
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsresult si_CheckGetData ( PRUnichar **  data,
const PRUnichar dialogTitle,
const PRUnichar szMessage,
nsIPrompt dialog,
PRUint32  savePassword,
PRBool checkValue 
) [static]

Definition at line 480 of file singsign.cpp.

{
  nsresult res;  

  PRUnichar * prompt_string = (PRUnichar*)dialogTitle;
  if (dialogTitle == nsnull || dialogTitle[0] == 0)
    prompt_string = Wallet_Localize("PromptForData");
  PRUnichar * check_string;

  // According to nsIPrompt spec, the checkbox is shown or not
  // depending on whether or not checkValue == nsnull, not checkMsg.
  PRBool * check_value = checkValue;
  if (savePassword != SINGSIGN_SAVE_PASSWORD_PERMANENTLY) {
    check_string = nsnull;
    check_value = nsnull;
  } else if (SI_GetBoolPref(pref_Crypto, PR_FALSE)) {
    check_string = Wallet_Localize("SaveThisValueEncrypted");
  } else {
    check_string = Wallet_Localize("SaveThisValueObscured");
  }

  PRBool confirmed = PR_FALSE;  
  res = dialog->Prompt(prompt_string,
                       szMessage,
                       data,
                       check_string,
                       check_value,
                       &confirmed);

  if (dialogTitle == nsnull || dialogTitle[0] == 0)
    Recycle(prompt_string);
  if (check_string)
    Recycle(check_string);

  if (NS_FAILED(res)) {
    return res;
  }
  if (confirmed) {
    return NS_OK;
  } else {
    return NS_ERROR_FAILURE; /* user pressed cancel */
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsresult si_CheckGetPassword ( PRUnichar **  password,
const PRUnichar dialogTitle,
const PRUnichar szMessage,
nsIPrompt dialog,
PRUint32  savePassword,
PRBool checkValue 
) [static]

Definition at line 429 of file singsign.cpp.

{
  nsresult res;

  PRUnichar * prompt_string = (PRUnichar*)dialogTitle;
  if (dialogTitle == nsnull || dialogTitle[0] == 0)
    prompt_string = Wallet_Localize("PromptForPassword");
  PRUnichar * check_string;
  
  // According to nsIPrompt spec, the checkbox is shown or not
  // depending on whether or not checkValue == nsnull, not checkMsg.
  PRBool * check_value = checkValue;
  if (savePassword != SINGSIGN_SAVE_PASSWORD_PERMANENTLY) {
    check_string = nsnull;
    check_value = nsnull;
  } else if (SI_GetBoolPref(pref_Crypto, PR_FALSE)) {
    check_string = Wallet_Localize("SaveThisPasswordEncrypted");
  } else {
    check_string = Wallet_Localize("SaveThisPasswordObscured");
  }

  PRBool confirmed = PR_FALSE;  
  res = dialog->PromptPassword(prompt_string,
                               szMessage,
                               password,
                               check_string,
                               check_value,
                               &confirmed);

  if (dialogTitle == nsnull)
    Recycle(prompt_string);
  if (check_string)
    Recycle(check_string);

  if (NS_FAILED(res)) {
    return res;
  }
  if (confirmed) {
    return NS_OK;
  } else {
    return NS_ERROR_FAILURE; /* user pressed cancel */
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsresult si_CheckGetUsernamePassword ( PRUnichar **  username,
PRUnichar **  password,
const PRUnichar dialogTitle,
const PRUnichar szMessage,
nsIPrompt dialog,
PRUint32  savePassword,
PRBool checkValue 
) [static]

Definition at line 531 of file singsign.cpp.

{
  nsresult res;  
  PRUnichar * check_string;
  PRUnichar * prompt_string = (PRUnichar*)dialogTitle;
  if (dialogTitle == nsnull || dialogTitle[0] == 0)
    prompt_string = Wallet_Localize("PromptForPassword");
  
  // According to nsIPrompt spec, the checkbox is shown or not
  // depending on whether or not checkValue == nsnull, not checkMsg.
  PRBool * check_value = checkValue;
  if (savePassword != SINGSIGN_SAVE_PASSWORD_PERMANENTLY) {
    check_string = nsnull;
    check_value = nsnull;
  } else if (SI_GetBoolPref(pref_Crypto, PR_FALSE)) {
    check_string = Wallet_Localize("SaveTheseValuesEncrypted");
  } else {
    check_string = Wallet_Localize("SaveTheseValuesObscured");
  }

  PRBool confirmed = PR_FALSE;  
  res = dialog->PromptUsernameAndPassword(prompt_string,
                                          szMessage,
                                          username, password,
                                          check_string,
                                          check_value,
                                          &confirmed);

  if (dialogTitle == nsnull || dialogTitle[0] == 0)
    Recycle(prompt_string);
  if (check_string)
    Recycle(check_string);
  
  if (NS_FAILED(res)) {
    return res;
  }
  if (confirmed) {
    return NS_OK;
  } else {
    return NS_ERROR_FAILURE; /* user pressed cancel */
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1417 of file singsign.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool si_CompareEncryptedToCleartext ( const nsString crypt,
const nsString text 
) [static]

Definition at line 623 of file singsign.cpp.

                                                                            {
  nsAutoString decrypted;
  if (NS_FAILED(Wallet_Decrypt(crypt, decrypted))) {
    return PR_FALSE;
  }
  return (decrypted == text);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool si_CompareEncryptedToEncrypted ( const nsString crypt1,
const nsString crypt2 
) [static]

Definition at line 632 of file singsign.cpp.

                                                                               {
  nsAutoString decrypted1;
  nsAutoString decrypted2;
  if (NS_FAILED(Wallet_Decrypt(crypt1, decrypted1))) {
    return PR_FALSE;
  }
  if (NS_FAILED(Wallet_Decrypt(crypt2, decrypted2))) {
    return PR_FALSE;
  }
  return (decrypted1 == decrypted2);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1405 of file singsign.cpp.

               {
  if (si_PartiallyLoaded) {
    /* repeatedly remove first user node of first URL node */
    while (si_RemoveUser(NULL, EmptyString(), PR_FALSE, PR_FALSE, PR_TRUE, PR_TRUE)) {
    }
  }
  si_PartiallyLoaded = PR_FALSE;
  si_signon_list_changed = PR_TRUE;
  si_SaveSignonDataLocked("signons", PR_TRUE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1423 of file singsign.cpp.

                              {

  if (signonFileName && signonFileName[0]) {
    nsCOMPtr<nsIFile> file;
    nsresult rv = Wallet_ProfileDirectory(getter_AddRefs(file));
    if (NS_SUCCEEDED(rv)) {
      rv = file->AppendNative(nsDependentCString(signonFileName));
      if (NS_SUCCEEDED(rv))
        file->Remove(PR_FALSE);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsresult si_DoDialogIfPrefIsOff ( const PRUnichar dialogTitle,
const PRUnichar text,
PRUnichar **  user,
PRUnichar **  pwd,
const PRUnichar defaultText,
PRUnichar **  resultText,
const char *  passwordRealm,
nsIPrompt dialog,
PRBool pressedOK,
PRUint32  savePassword,
DialogType  dlg 
) [static]

Definition at line 2555 of file singsign.cpp.

                    {

  nsresult res = NS_ERROR_FAILURE;
  const PRUnichar * prompt_string = dialogTitle;
  if (dialogTitle == nsnull || !dialogTitle[0]) {
    prompt_string = Wallet_Localize("PromptForData");
  }

  nsAutoString data(defaultText);
  switch (dlg) {
    case promptUsernameAndPassword:
      res = dialog->PromptUsernameAndPassword(prompt_string,
                                              text,
                                              user,
                                              pwd,
                                              nsnull, nsnull,
                                              pressedOK);
      break;
    case promptPassword:
      res = dialog->PromptPassword(prompt_string,
                                   text,
                                   pwd,
                                   nsnull, nsnull,
                                   pressedOK);
      break;
    case prompt:
      *resultText = ToNewUnicode(data);
      res = dialog->Prompt(prompt_string,
                           text,
                           resultText,
                           nsnull, nsnull,
                           pressedOK);
#ifdef DEBUG
      break;
    default:
      NS_ERROR("Undefined DialogType in si_DoDialogIfPrefIsOff");
#endif
  }

  if (dialogTitle != prompt_string) {
    Recycle(NS_CONST_CAST(PRUnichar*, prompt_string));
  }
  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool si_ExtractRealm ( nsIURI uri,
nsCString realm 
) [static]

Definition at line 2128 of file singsign.cpp.

{
  nsCAutoString hostPort;

  /* Security check: if URI is of a scheme that doesn't support hostnames,
   * we have no host to get the signon data from, so we must not attempt to
   * build a valid realm from the URI (bug 159484) */
  nsresult rv = uri->GetHostPort(hostPort);
  if (NS_FAILED(rv) || hostPort.IsEmpty())
    return PR_FALSE;

  nsCAutoString scheme;
  rv = uri->GetScheme(scheme);
  if (NS_FAILED(rv) || scheme.IsEmpty())
    return PR_FALSE;

  realm = scheme + NS_LITERAL_CSTRING("://") + hostPort;
  return PR_TRUE;
}

Here is the caller graph for this function:

void SI_FindValueInArgs ( const nsAString &  results,
const nsAString &  name,
nsAString &  value 
)

Definition at line 2824 of file singsign.cpp.

{
  /* note: name must start and end with a vertical bar */
  nsReadingIterator<PRUnichar> start, end, barPos;
  results.BeginReading(start);
  results.EndReading(end);

  FindInReadable(name, start, end);
  if (start == end) {
    return;
  }
  start.advance(name.Length()); /* get past the |name| part */
  barPos = start;
  results.EndReading(end);
  FindCharInReadable(PRUnichar('|'), barPos, end);
  value = Substring(start, barPos);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void si_FreeReject ( si_Reject reject) [static]

Definition at line 1441 of file singsign.cpp.

                                  {

  /*
   * This routine should only be called while holding the
   * signon list lock
   */

  if(!reject) {
      return;
  }
  si_reject_list->RemoveElement(reject);
  PR_FREEIF(reject->passwordRealm);
  delete reject;
}

Here is the caller graph for this function:

PRBool SI_GetBoolPref ( const char *  prefname,
PRBool  defaultvalue 
)

Definition at line 196 of file singsign.cpp.

                                                           {
  nsresult ret;
  PRBool prefvalue = defaultvalue;
  nsCOMPtr<nsIPref> pPrefService = do_GetService(NS_PREF_CONTRACTID, &ret);
  if (NS_SUCCEEDED(ret)) {
    ret = pPrefService->GetBoolPref(prefname, &prefvalue);
  }
  return prefvalue;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SI_GetCharPref ( const char *  prefname,
char **  aPrefvalue 
)

Definition at line 222 of file singsign.cpp.

                                                         {
  nsresult ret;
  nsCOMPtr<nsIPref> pPrefService = do_GetService(NS_PREF_CONTRACTID, &ret);
  if (NS_SUCCEEDED(ret)) {
    ret = pPrefService->CopyCharPref(prefname, aPrefvalue);
    if (NS_FAILED(ret)) {
      *aPrefvalue = nsnull;
    }
  } else {
    *aPrefvalue = nsnull;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static si_SignonURLStruct* si_GetCompositeURL ( const char *  primaryRealm,
const char *  legacyRealm 
) [static]

Definition at line 797 of file singsign.cpp.

{
  si_SignonURLStruct *primaryUrl, *legacyUrl;

  primaryUrl = si_GetURL(primaryRealm);

  if (legacyRealm)
    legacyUrl = si_GetURL(legacyRealm);
  else
    legacyUrl = nsnull;

  if (primaryUrl && legacyUrl) {
    LOG((">>> building composite URL struct\n"));
    if (si_composite_url) {
      NS_ERROR("si_composite_url already in use");
      return NULL;
    }
    si_composite_url = new si_SignonCompositeURLStruct;
    if (!si_composite_url)
      return NULL;

    si_composite_url->primaryUrl = primaryUrl;
    si_composite_url->legacyUrl = legacyUrl;

    si_composite_url->signonUser_list.AppendElements(primaryUrl->signonUser_list);
    si_composite_url->signonUser_list.AppendElements(legacyUrl->signonUser_list);

#if defined(SINGSIGN_LOGGING)
    si_DumpUserList(si_composite_url->signonUser_list);
#endif

    /* need to transfer the chosen_user state variable */
    if (primaryUrl->chosen_user)
      si_composite_url->chosen_user = primaryUrl->chosen_user;
    else if (legacyUrl->chosen_user) {
      si_SignonUserStruct *chosen_user = legacyUrl->chosen_user;
      PRInt32 index;
      /* XXX fixup chosen_user -- THIS SHOULD NOT BE NECESSARY */
      index = legacyUrl->signonUser_list.IndexOf(chosen_user);
      if (index < 0) {
        index = primaryUrl->signonUser_list.IndexOf(chosen_user);
        if (index >= 0)
          primaryUrl->chosen_user = chosen_user;
        legacyUrl->chosen_user = NULL;
      }
      /* move first element of legacy user list to front */
      index = si_composite_url->signonUser_list.IndexOf(chosen_user);
      if (index > 0)
        si_composite_url->signonUser_list.MoveElement(index, 0);
      si_composite_url->chosen_user = chosen_user;
    }
    else
      si_composite_url->chosen_user = NULL;

#if defined(SINGSIGN_LOGGING)
    LOG(("after chosen_user fixup [chosen_user=%x]:\n", si_composite_url->chosen_user));
    si_DumpUserList(si_composite_url->signonUser_list);
#endif

    return si_composite_url;
  }

  if (primaryUrl)
    return primaryUrl;

  return legacyUrl;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1069 of file singsign.cpp.

                                                      {
  PRInt32 dataCount = user->signonData_list.Count();
  for (PRInt32 j=0; j<dataCount; j++) {
    si_SignonDataStruct * data =
      NS_STATIC_CAST(si_SignonDataStruct *, user->signonData_list.ElementAt(j));
    if (!data->isPassword) {
      return data;
    }
  }
  return nsnull;
}

Here is the caller graph for this function:

void SI_GetLocalizedUnicharPref ( const char *  prefname,
PRUnichar **  aPrefvalue 
)

Definition at line 236 of file singsign.cpp.

                                                                          {
  nsresult ret;
  nsCOMPtr<nsIPref> pPrefService = do_GetService(NS_PREF_CONTRACTID, &ret);
  if (NS_SUCCEEDED(ret)) {
    ret = pPrefService->GetLocalizedUnicharPref(prefname, aPrefvalue);
    if (NS_FAILED(ret)) {
      *aPrefvalue = nsnull;
    }
  } else {
      *aPrefvalue = nsnull;
  }
}

Here is the call graph for this function:

static PRBool si_GetSignonRememberingPref ( void  ) [static]

Definition at line 330 of file singsign.cpp.

                                  {
#ifdef APPLE_KEYCHAIN
  /* If the Keychain has been locked or an item deleted or updated,
   * we need to reload the signon data
   */
  if (si_list_invalid) {
    /*
     * set si_list_invalid to PR_FALSE first because SI_RemoveAllSignonData
     * calls si_GetSignonRememberingPref
     */
    si_list_invalid = PR_FALSE;
    SI_LoadSignonData();
  }
#endif

  si_RegisterSignonPrefCallbacks();

#ifdef WALLET_PASSWORDMANAGER_DEFAULT_IS_OFF
  /*
   * We initially want the rememberSignons pref to be PR_FALSE.  But this will
   * prevent the notification message from ever occurring.  To get around
   * this problem, if the signon pref is PR_FALSE and no notification has
   * ever been given, we will treat this as if the signon pref were PR_TRUE.
   */
  if (!si_RememberSignons && !si_GetNotificationPref()) {
    return PR_TRUE;
  } else {
    return si_RememberSignons;
  }
#else
  return si_RememberSignons;
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

static si_SignonUserStruct* si_GetSpecificUser ( const char *  passwordRealm,
const nsString userName,
const nsString userText 
) [static]

Definition at line 1221 of file singsign.cpp.

                                                                                                  {
  si_SignonURLStruct* url;
  si_SignonUserStruct* user;
  si_SignonDataStruct* data;

  /* get to node for this URL */
  url = si_GetURL(passwordRealm);
  if (url != NULL) {

    /* step through set of user nodes for this URL looking for specified username */
    PRInt32 userCount2 = url->signonUser_list.Count();
    for (PRInt32 i2=0; i2<userCount2; i2++) {
      user = NS_STATIC_CAST(si_SignonUserStruct*, url->signonUser_list.ElementAt(i2));
      /* consider first data node to be the identifying item */
      data = NS_STATIC_CAST(si_SignonDataStruct *,
                            user->signonData_list.ElementAt(0));
      if (data->name != userText) {
        /* desired username text does not match name in data node */
        continue;
      }
      if (!si_CompareEncryptedToCleartext(data->value, userName)) {
        /* desired username value does not match value in data node */
        continue;
      }
      return user;
    }

    /* if we don't remove the URL from the cache at this point, the
     * cached copy will be brought containing the last-used username
     * rather than the username that was just selected
     */

#ifdef junk
    NET_RemoveURLFromCache(NET_CreateURLStruct((char *)passwordRealm, NET_DONT_RELOAD));
#endif

  }
  return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static si_SignonURLStruct* si_GetURL ( const char *  passwordRealm) [static]

Definition at line 735 of file singsign.cpp.

                                      {
  si_SignonURLStruct * url;
  if (!passwordRealm) {
    /* no passwordRealm specified, return first URL (returns NULL if not URLs) */
    if (LIST_COUNT(si_signon_list)==0) {
      return NULL;
    }
    /* XXX how can this be right -- seems wrong to give back a random password */
    LOG(("  returning first element in the signon list\n"));
    return (si_SignonURLStruct *) (si_signon_list->ElementAt(0));
  }

  PRInt32 urlCount = LIST_COUNT(si_signon_list);
  if (urlCount) {
    // If the last char of passwordRealm is '/' then strip it before making comparison.
    nsCAutoString realmWithoutTrailingSlash(passwordRealm);
    if (!realmWithoutTrailingSlash.IsEmpty() && realmWithoutTrailingSlash.Last() == '/')
      realmWithoutTrailingSlash.Truncate(realmWithoutTrailingSlash.Length()-1);

    for (PRInt32 i=0; i<urlCount; i++) {
      url = NS_STATIC_CAST(si_SignonURLStruct*, si_signon_list->ElementAt(i));
      if(url->passwordRealm && !PL_strcmp(realmWithoutTrailingSlash.get(), url->passwordRealm)) {
        return url;
      }
    }
  }
  return (NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static si_SignonUserStruct* si_GetURLAndUserForChangeForm ( nsIPrompt dialog,
const nsString password 
) [static]

Definition at line 1269 of file singsign.cpp.

{
  si_SignonURLStruct* url;
  si_SignonUserStruct* user;
  si_SignonDataStruct * data;
  PRInt32 user_count;

  PRUnichar ** list;
  PRUnichar ** list2;
  si_SignonUserStruct** users;
  si_SignonUserStruct** users2;
  si_SignonURLStruct** urls;
  si_SignonURLStruct** urls2;

  /* get count of total number of user nodes at all url nodes */
  user_count = 0;
  PRInt32 urlCount = LIST_COUNT(si_signon_list);
  for (PRInt32 i=0; i<urlCount; i++) {
    url = NS_STATIC_CAST(si_SignonURLStruct*, si_signon_list->ElementAt(i));
    PRInt32 userCount = url->signonUser_list.Count();
    for (PRInt32 ii=0; ii<userCount; ii++) {
      user = NS_STATIC_CAST(si_SignonUserStruct*, url->signonUser_list.ElementAt(ii));
      user_count++;
    }
  }

  /* avoid malloc of zero */
  if( user_count == 0 )
  {
    return NULL;
  }
  
  /* allocate lists for maximumum possible url and user names */
  list = (PRUnichar**)PR_Malloc(user_count*sizeof(PRUnichar*));
  users = (si_SignonUserStruct **) PR_Malloc(user_count*sizeof(si_SignonUserStruct*));
  urls = (si_SignonURLStruct **)PR_Malloc(user_count*sizeof(si_SignonUserStruct*));
  list2 = list;
  users2 = users;
  urls2 = urls;
    
  /* step through set of URLs and users and create list of each */
  user_count = 0;
  PRInt32 urlCount2 = LIST_COUNT(si_signon_list);
  for (PRInt32 i2=0; i2<urlCount2; i2++) {
    url = NS_STATIC_CAST(si_SignonURLStruct*, si_signon_list->ElementAt(i2));
    PRInt32 userCount = url->signonUser_list.Count();
    for (PRInt32 i3=0; i3<userCount; i3++) {
      user = NS_STATIC_CAST(si_SignonUserStruct*, url->signonUser_list.ElementAt(i3));
      /* find saved password and see if it matches password user just entered */
      PRInt32 dataCount = user->signonData_list.Count();
      for (PRInt32 i4=0; i4<dataCount; i4++) {
        data = NS_STATIC_CAST(si_SignonDataStruct*, user->signonData_list.ElementAt(i4));
        if (data->isPassword && si_CompareEncryptedToCleartext(data->value, password)) {
          /* passwords match so add entry to list */
          /* consider first data node to be the identifying item */
          data = NS_STATIC_CAST(si_SignonDataStruct *,
                                user->signonData_list.ElementAt(0));

          nsAutoString userName;
          if (NS_SUCCEEDED(Wallet_Decrypt (data->value, userName))) {
            nsAutoString temp; temp.AssignASCII(url->passwordRealm); // XXX non-ascii realms?
            temp.AppendLiteral(":");
            temp.Append(userName);

            *list2 = ToNewUnicode(temp);
            list2++;
            *(users2++) = user;
            *(urls2++) = url;
            user_count++;
          }
          break;
        }
      }
    }
  }

  /* query user */
  PRUnichar * msg = Wallet_Localize("SelectUserWhosePasswordIsBeingChanged");
//@@@@ is 0 correct?
  if (user_count && si_SelectDialog(msg, dialog, list, &user_count, 0)) {
    user = users[user_count];
    url = urls[user_count];
    /*
     * since this user node is now the most-recently-used one, move it
     * to the head of the user list so that it can be favored for
     * re-use the next time this form is encountered
     */
    url->signonUser_list.RemoveElement(user);
    url->signonUser_list.InsertElementAt(user, 0);
    si_signon_list_changed = PR_TRUE;
    si_SaveSignonDataLocked("signons", PR_TRUE);
  } else {
    user = NULL;
  }
  Recycle(msg);

  /* free allocated strings */
  while (--list2 > list) {
    Recycle(*list2);
  }
  PR_Free(list);
  PR_Free(users);
  PR_Free(urls);
  return user;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static si_SignonUserStruct* si_GetUser ( nsIPrompt dialog,
const char *  passwordRealm,
const char *  legacyRealm,
PRBool  pickFirstUser,
const nsString userText,
PRUint32  formNumber 
) [static]

Definition at line 1089 of file singsign.cpp.

                                                                                {
  si_SignonURLStruct* url;
  si_SignonUserStruct* user = nsnull;
  si_SignonDataStruct* data;

  /* get to node for this URL */
  url = si_GetCompositeURL(passwordRealm, legacyRealm);

  if (url != NULL) {

    /* node for this URL was found */
    PRInt32 user_count;
    if ((user_count = url->signonUser_list.Count()) == 1) {

      /* only one set of data exists for this URL so select it */
      user = NS_STATIC_CAST(si_SignonUserStruct *,
                            url->signonUser_list.ElementAt(0));
      url->chosen_user = user;

    } else if (pickFirstUser) {
      PRInt32 userCount = url->signonUser_list.Count();
      for (PRInt32 i=0; i<userCount; i++) {
        user = NS_STATIC_CAST(si_SignonUserStruct*, url->signonUser_list.ElementAt(i));
        /* consider first data node to be the identifying item */
        data = NS_STATIC_CAST(si_SignonDataStruct *,
                              user->signonData_list.ElementAt(0));
        if (data->name != userText) {
          /* name of current data item does not match name in data node */
          continue;
        }
        break;
      }
      url->chosen_user = user;

    } else {
      /* multiple users for this URL so a choice needs to be made */
      PRUnichar ** list;
      PRUnichar ** list2;
      si_SignonUserStruct** users;
      si_SignonUserStruct** users2;
      list = (PRUnichar**)PR_Malloc(user_count*sizeof(PRUnichar*));
      users = (si_SignonUserStruct **) PR_Malloc(user_count*sizeof(si_SignonUserStruct*));
      list2 = list;
      users2 = users;

      /* step through set of user nodes for this URL and create list of
       * first data node of each (presumably that is the user name).
       * Note that the user nodes are already ordered by
       * most-recently-used so the first one in the list is the most
       * likely one to be chosen.
       */
      user_count = 0;
      PRInt32 userCount = url->signonUser_list.Count();
      for (PRInt32 i=0; i<userCount; i++) {
        user = NS_STATIC_CAST(si_SignonUserStruct*, url->signonUser_list.ElementAt(i));
        /* consider first data node to be the identifying item */
        data = NS_STATIC_CAST(si_SignonDataStruct *,
                              user->signonData_list.ElementAt(0));
        if (data->name != userText) {
          /* name of current data item does not match name in data node */
          continue;
        }
        nsAutoString userName;
        data = si_GetFirstNonPasswordData(user);
        if (NS_SUCCEEDED(Wallet_Decrypt (data->value, userName))) {
          *(list2++) = ToNewUnicode(userName);
          *(users2++) = user;
          user_count++;
        } else {
          break;
        }
      }

      /* have user select a username from the list */
      PRUnichar * selectUser = Wallet_Localize("SelectUser");
      if (user_count == 0) {
        /* not first data node for any saved user, so simply pick first user */
        if (url->chosen_user) {
          user = url->chosen_user;
        } else {
          /* no user selection had been made for first data node */
          user = NULL;
        } 
      } else if (user_count == 1) {
        /* only one user for this form at this url, so select it */
        user = users[0];
      } else if ((user_count > 1) && si_SelectDialog(selectUser, dialog, list, &user_count, formNumber)) {
        /* user pressed OK */
        if (user_count == -1) {
          user_count = 0; /* user didn't select, so use first one */
        }
        user = users[user_count]; /* this is the selected item */
        /* item selected is now most-recently used, put at head of list */
        url->signonUser_list.RemoveElement(user);
        url->signonUser_list.InsertElementAt(user, 0);
      } else {
        user = NULL;
      }
      Recycle(selectUser);
      url->chosen_user = user;
      while (--list2 > list) {
        Recycle(*list2);
      }
      PR_Free(list);
      PR_Free(users);

      /* if we don't remove the URL from the cache at this point, the
       * cached copy will be brought containing the last-used username
       * rather than the username that was just selected
       */

#ifdef junk
      NET_RemoveURLFromCache(NET_CreateURLStruct((char *)passwordRealm, NET_DONT_RELOAD));
#endif

    }
    si_ReleaseCompositeURL(url);
  } else {
    user = NULL;
  }
  return user;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 365 of file singsign.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool SI_InSequence ( const nsString sequence,
PRInt32  number 
)

Definition at line 2796 of file singsign.cpp.

{
  nsAutoString tail( sequence );
  nsAutoString head, temp;
  PRInt32 separator;

  for (;;) {
    /* get next item in list */
    separator = tail.FindChar(',');
    if (-1 == separator) {
      return PR_FALSE;
    }
    tail.Left(head, separator);
    tail.Mid(temp, separator+1, tail.Length() - (separator+1));
    tail = temp;

    /* test item to see if it equals our number */
    PRInt32 error;
    PRInt32 numberInList = head.ToInteger(&error);
    if (!error && numberInList == number) {
      return PR_TRUE;
    }
  }
  /* NOTREACHED */
  return PR_FALSE;
}

Here is the caller graph for this function:

Definition at line 1860 of file singsign.cpp.

                    {
  char * passwordRealm;
  nsAutoString buffer;
  PRBool badInput = PR_FALSE;

#ifdef APPLE_KEYCHAIN
  if (KeychainManagerAvailable()) {
    SI_RemoveAllSignonData();
    return si_LoadSignonDataFromKeychain();
  }
#endif
  
  /* open the signon file */
  nsCOMPtr<nsIFile> file;
  nsresult rv = Wallet_ProfileDirectory(getter_AddRefs(file));
  if (NS_FAILED(rv)) {
    return -1;
  }


  rv = EnsureSingleSignOnProfileObserver();
  NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to register profile change observer");

  SI_InitSignonFileName();
  file->AppendNative(nsDependentCString(signonFileName));

  nsCOMPtr<nsIInputStream> strm;
  rv = NS_NewLocalFileInputStream(getter_AddRefs(strm), file);
  if (NS_FAILED(rv)) {
    si_PartiallyLoaded = PR_TRUE;
    return 0;
  }

  SI_RemoveAllSignonData();

  /* read the format information */
  nsAutoString format;
  if (NS_FAILED(si_ReadLine(strm, format))) {
    return -1;
  }
  if (!format.EqualsLiteral(HEADER_VERSION)) {
    /* something's wrong */
    return -1;
  }

  /* read the reject list */
  si_lock_signon_list();
  while (NS_SUCCEEDED(si_ReadLine(strm, buffer))) {
    /* a blank line is perfectly valid here -- corresponds to a local file */
    if (!buffer.IsEmpty() && buffer.CharAt(0) == '.') {
      break; /* end of reject list */
    }
    passwordRealm = ToNewCString(buffer);
    si_PutReject(passwordRealm, buffer, PR_FALSE); /* middle parameter is obsolete */
    Recycle (passwordRealm);
  }

  /* read the URL line */
  while (NS_SUCCEEDED(si_ReadLine(strm, buffer))) {
    /* a blank line is perfectly valid here -- corresponds to a local file */
    passwordRealm = ToNewCString(buffer);
    if (!passwordRealm) {
      si_unlock_signon_list();
      return -1;
    }

    /* prepare to read the name/value pairs */
    badInput = PR_FALSE;

    nsVoidArray signonData;
    si_SignonDataStruct * data;
    while(NS_SUCCEEDED(si_ReadLine(strm, buffer))) {

      /* line starting with . terminates the pairs for this URL entry */
      if (buffer.CharAt(0) == '.') {
        break; /* end of URL entry */
      }

      /* line just read is the name part */

      /* save the name part and determine if it is a password */
      PRBool ret;
      nsAutoString name;
      nsAutoString value;
      PRBool isPassword;
      if (buffer.CharAt(0) == '*') {
        isPassword = PR_TRUE;
        buffer.Mid(name, 1, buffer.Length()-1);
        ret = si_ReadLine(strm, buffer);
      } else {
        isPassword = PR_FALSE;
        name = buffer;
        ret = si_ReadLine(strm, buffer);
      }

      /* read in and save the value part */
      if(NS_FAILED(ret)) {
        /* error in input file so give up */
        badInput = PR_TRUE;
        break;
      }
      value = buffer;

      data = new si_SignonDataStruct;
      data->name = name;
      data->value = value;
      data->isPassword = isPassword;
      signonData.AppendElement(data);
    }

    /* store the info for this URL into memory-resident data structure */
    PRInt32 count = signonData.Count();
    if (count) {
      si_PutData(passwordRealm, &signonData, PR_FALSE);
    }

    /* free up all the allocations done for processing this URL */
    Recycle(passwordRealm);
    for (PRInt32 i=count-1; i>=0; i--) {
      data = NS_STATIC_CAST(si_SignonDataStruct*, signonData.ElementAt(i));
      delete data;
    }
  }

  si_unlock_signon_list();
  si_PartiallyLoaded = PR_TRUE;
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void si_lock_signon_list ( void  ) [static]

Definition at line 122 of file singsign.cpp.

                          {
  if(!signon_lock_monitor) {
    signon_lock_monitor = PR_NewNamedMonitor("signon-lock");
  }
  PR_EnterMonitor(signon_lock_monitor);
  while(PR_TRUE) {

    /* no current owner or owned by this thread */
    PRThread * t = PR_GetCurrentThread();
    if(signon_lock_owner == NULL || signon_lock_owner == t) {
      signon_lock_owner = t;
      signon_lock_count++;
      PR_ExitMonitor(signon_lock_monitor);
      return;
    }

    /* owned by someone else -- wait till we can get it */
    PR_Wait(signon_lock_monitor, PR_INTERVAL_NO_TIMEOUT);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool si_OkToSave ( const char *  passwordRealm,
const char *  legacyRealm,
const nsString userName,
nsIDOMWindowInternal window 
) [static]

Definition at line 2150 of file singsign.cpp.

                                                                    {

  /* if url/user already exists, then it is safe to save it again */
  if (si_CheckForUser(passwordRealm, userName)) {
    return PR_TRUE;
  }
  if (legacyRealm && si_CheckForUser(legacyRealm, userName)) {
    return PR_TRUE;
  }

#ifdef WALLET_PASSWORDMANAGER_DEFAULT_IS_OFF
  if (!si_RememberSignons && !si_GetNotificationPref()) {
    PRUnichar * notification = Wallet_Localize("PasswordNotification");
    si_SetNotificationPref(PR_TRUE);
    if (!si_ConfirmYN(notification, window)) {
      Recycle(notification);
      SI_SetBoolPref(pref_rememberSignons, PR_FALSE);
      return PR_FALSE;
    }
    Recycle(notification);
    SI_SetBoolPref(pref_rememberSignons, PR_TRUE);
  }
#endif

  if (si_CheckForReject(passwordRealm, userName)) {
    return PR_FALSE;
  }
  if (legacyRealm && si_CheckForReject(legacyRealm, userName)) {
    return PR_FALSE;
  }

  PRUnichar * message;
  if (SI_GetBoolPref(pref_Crypto, PR_FALSE)) {
    message = Wallet_Localize("WantToSavePasswordEncrypted?");
  } else {
    message = Wallet_Localize("WantToSavePasswordObscured?");
  }

  PRInt32 button = si_3ButtonConfirm(message, window);
  if (button == NEVER_BUTTON) {
    si_PutReject(passwordRealm, userName, PR_TRUE);
  }
  Recycle(message);
  return (button == YES_BUTTON);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void si_PutData ( const char *  passwordRealm,
nsVoidArray signonData,
PRBool  save 
) [static]

Definition at line 1551 of file singsign.cpp.

                                                                            {
  PRBool added_to_list = PR_FALSE;
  si_SignonURLStruct * url;
  si_SignonUserStruct * user;
  si_SignonDataStruct * data;
  si_SignonDataStruct * data2;
  PRBool mismatch = PR_FALSE;

  /* discard this if the password is empty */
  PRInt32 count = signonData->Count();
  for (PRInt32 i=0; i<count; i++) {
    data2 = NS_STATIC_CAST(si_SignonDataStruct*, signonData->ElementAt(i));
    if (data2->isPassword && data2->value.IsEmpty()) {
      return;
    }
  }

  /* make sure the signon list exists */
  if (!si_signon_list) {
    si_signon_list = new nsVoidArray();
    if (!si_signon_list) {
      return;
    }
  }

  /*
   * lock the signon list
   *   Note that, for efficiency, SI_LoadSignonData already sets the lock
   *   before calling this routine whereas none of the other callers do.
   *   So we need to determine whether or not we were called from
   *   SI_LoadSignonData before setting or clearing the lock.  We can
   *   determine this by testing "save" since only SI_LoadSignonData passes
   *   in a value of PR_FALSE for "save".
   */
  if (save) {
    si_lock_signon_list();
  }

  /* find node in signon list having the same URL */
  if ((url = si_GetURL(passwordRealm)) == NULL) {

    /* doesn't exist so allocate new node to be put into signon list */
    url = new si_SignonURLStruct;
    if (!url) {
      if (save) {
        si_unlock_signon_list();
      }
      return;
    }

    /* fill in fields of new node */
       url->passwordRealm = nsnull;
       if (passwordRealm) {
       url->passwordRealm = PL_strdup(passwordRealm);
       }

    if (!url->passwordRealm) {
      if (save) {
        si_unlock_signon_list();
      }
      return;
    }

    /* put new node into signon list */

#ifdef alphabetize
    /* add it to the list in alphabetical order */
    si_SignonURLStruct * tmp_URL;
    PRInt32 urlCount = LIST_COUNT(si_signon_list);
    for (PRInt32 ii = 0; ii<urlCount; ++ii) {
      tmp_URL = NS_STATIC_CAST(si_SignonURLStruct *, si_signon_list->ElementAt(ii));
      if (tmp_URL) {
        if (PL_strcasecmp(url->passwordRealm, tmp_URL->passwordRealm)<0) {
          si_signon_list->InsertElementAt(url, ii);
          added_to_list = PR_TRUE;
          break;
        }
      }
    }
    if (!added_to_list) {
      si_signon_list->AppendElement(url);
    }
#else
    /* add it to the end of the list */
    si_signon_list->AppendElement(url);
#endif
  }

  /* initialize state variables in URL node */
  url->chosen_user = NULL;

  /*
   * see if a user node with data list matching new data already exists
   * (password fields will not be checked for in this matching)
   */
  PRInt32 userCount = url->signonUser_list.Count();
  for (PRInt32 i2=0; i2<userCount; i2++) {
    if (!save) {
      break; /* otherwise we could be asked for master password when loading signon data */
    }
    user = NS_STATIC_CAST(si_SignonUserStruct*, url->signonUser_list.ElementAt(i2));
    PRInt32 j = 0;
    PRInt32 dataCount = user->signonData_list.Count();
    for (PRInt32 i3=0; i3<dataCount; i3++) {
      data = NS_STATIC_CAST(si_SignonDataStruct*, user->signonData_list.ElementAt(i3));
      mismatch = PR_FALSE;

      /* check for match on name field and type field */
      if (j < signonData->Count()) {
        data2 = NS_STATIC_CAST(si_SignonDataStruct*, signonData->ElementAt(j));
        if ((data->isPassword == data2->isPassword) &&
            (data->name == data2->name)) {

          /* success, now check for match on value field if not password */
          if (si_CompareEncryptedToEncrypted(data->value, data2->value) || data->isPassword) {
            j++; /* success */
          } else {
            mismatch = PR_TRUE;
            break; /* value mismatch, try next user */
          }
        } else {
          mismatch = PR_TRUE;
          break; /* name or type mismatch, try next user */
        }
      }
    }
    if (!mismatch) {

      /* all names and types matched and all non-password values matched */

      /*
       * note: it is ok for password values not to match; it means
       * that the user has either changed his password behind our
       * back or that he previously mis-entered the password
       */

      /* update the saved password values */
      j = 0;
      PRInt32 dataCount2 = user->signonData_list.Count();
      for (PRInt32 i4=0; i4<dataCount2; i4++) {
        data = NS_STATIC_CAST(si_SignonDataStruct*, user->signonData_list.ElementAt(i4));

        /* update saved password */
        if ((j < signonData->Count()) && data->isPassword) {
          data2 = NS_STATIC_CAST(si_SignonDataStruct*, signonData->ElementAt(j));
          if (!si_CompareEncryptedToEncrypted(data->value, data2->value)) {
            si_signon_list_changed = PR_TRUE;
            data->value = data2->value;
            user->time = SecondsFromPRTime(PR_Now()); 
/* commenting out because I don't see how such randomizing could ever have worked. */
//          si_Randomize(data->value);
          }
        }
        j++;
      }

      /*
       * since this user node is now the most-recently-used one, move it
       * to the head of the user list so that it can be favored for
       * re-use the next time this form is encountered
       */
      url->signonUser_list.RemoveElement(user);
      url->signonUser_list.InsertElementAt(user, 0);

      /* return */
      if (save) {
        si_signon_list_changed = PR_TRUE;
        si_SaveSignonDataLocked("signons", PR_TRUE);
        si_unlock_signon_list();
      }
      return; /* nothing more to do since data already exists */
    }
  }

  /* user node with current data not found so create one */
  user = new si_SignonUserStruct;
  if (!user) {
    if (save) {
      si_unlock_signon_list();
    }
    return;
  }

  /* create and fill in data nodes for new user node */
  for (PRInt32 k=0; k<signonData->Count(); k++) {

    /* create signon data node */
    data = new si_SignonDataStruct;
    if (!data) {
      delete user;
      if (save) {
        si_unlock_signon_list();
      }
      return;
    }
    data2 = NS_STATIC_CAST(si_SignonDataStruct*, signonData->ElementAt(k));
    data->isPassword = data2->isPassword;
    data->name = data2->name;
    data->value = data2->value;
/* commenting out because I don't see how such randomizing could ever have worked. */
//  if (data->isPassword) {
//    si_Randomize(data->value);
//  }
    /* append new data node to end of data list */
    user->signonData_list.AppendElement(data);
  }

  /* append new user node to front of user list for matching URL */
    /*
     * Note that by appending to the front, we assure that if there are
     * several users, the most recently used one will be favored for
     * reuse the next time this form is encountered.  But don't do this
     * when reading in the saved signons (i.e., when save is PR_FALSE), otherwise
     * we will be reversing the order when reading in.
     */
  if (save) {
    user->time = SecondsFromPRTime(PR_Now());
    url->signonUser_list.InsertElementAt(user, 0);
    si_signon_list_changed = PR_TRUE;
    si_SaveSignonDataLocked("signons", PR_TRUE);
    si_unlock_signon_list();
  } else {
    user->time = 0;
    url->signonUser_list.AppendElement(user);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void si_PutReject ( const char *  passwordRealm,
const nsString userName,
PRBool  save 
) [static]

Definition at line 1478 of file singsign.cpp.

                                                                                {
  char * passwordRealm2=NULL;
  nsAutoString userName2;
  si_Reject * reject = new si_Reject;

  if (reject) {
    if(!si_reject_list) {
      si_reject_list = new nsVoidArray();
      if(!si_reject_list) {
        delete reject;
        return;
      }
    }

    /*
     * lock the signon list
     *  Note that, for efficiency, SI_LoadSignonData already sets the lock
     *  before calling this routine whereas none of the other callers do.
     *  So we need to determine whether or not we were called from
     *  SI_LoadSignonData before setting or clearing the lock.  We can
     *  determine this by testing "save" since only SI_LoadSignonData
     *  passes in a value of PR_FALSE for "save".
     */
    if (save) {
      si_lock_signon_list();
    }

    StrAllocCopy(passwordRealm2, passwordRealm);
    userName2 = userName;
    reject->passwordRealm = passwordRealm2;
    reject->userName = userName2;

#ifdef alphabetize
    /* add it to the list in alphabetical order */
    si_Reject * tmp_reject;
    PRBool rejectAdded = PR_FALSE;
    PRInt32 rejectCount = LIST_COUNT(si_reject_list);
    for (PRInt32 i = 0; i<rejectCount; ++i) {
      tmp_reject = NS_STATIC_CAST(si_Reject *, si_reject_list->ElementAt(i));
      if (tmp_reject) {
        if (PL_strcasecmp(reject->passwordRealm, tmp_reject->passwordRealm)<0) {
          si_reject_list->InsertElementAt(reject, i);
          rejectAdded = PR_TRUE;
          break;
        }
      }
    }
    if (!rejectAdded) {
      si_reject_list->AppendElement(reject);
    }
#else
    /* add it to the end of the list */
    si_reject_list->AppendElement(reject);
#endif

    if (save) {
      si_signon_list_changed = PR_TRUE;
      si_lock_signon_list();
      si_SaveSignonDataLocked("rejects", PR_TRUE);
      si_unlock_signon_list();
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRInt32 si_ReadLine ( nsIInputStream strm,
nsString lineBuffer 
) [static]

Definition at line 1841 of file singsign.cpp.

{
  nsCAutoString line;
  nsresult rv = wallet_GetLine(strm, line);
  if (NS_FAILED(rv))
    return -1;
  
  CopyUTF8toUTF16(line, lineBuffer);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SI_RegisterCallback ( const char *  domain,
PrefChangedFunc  callback,
void instance_data 
)

Definition at line 166 of file singsign.cpp.

                                                                                       {
  nsresult ret;
  nsCOMPtr<nsIPref> pPrefService = do_GetService(NS_PREF_CONTRACTID, &ret);
  if (NS_SUCCEEDED(ret)) {
    ret = pPrefService->RegisterCallback(domain, callback, instance_data);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void si_RegisterSignonPrefCallbacks ( void  ) [static]

Definition at line 309 of file singsign.cpp.

                                     {
  PRBool x;
  static PRBool first_time = PR_TRUE;
  if(first_time) {
    first_time = PR_FALSE;
    SI_RegisterCallback(pref_rememberSignons, si_SignonRememberingPrefChanged, NULL);
  }
  
  if (!gLoadedUserData) {
    gLoadedUserData = PR_TRUE;
    SI_LoadSignonData();
#ifdef WALLET_PASSWORDMANAGER_DEFAULT_IS_OFF
    x = SI_GetBoolPref(pref_Notified, PR_FALSE);
    si_SetNotificationPref(x);        
#endif
    x = SI_GetBoolPref(pref_rememberSignons, PR_FALSE);
    si_SetSignonRememberingPref(x);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void si_ReleaseCompositeURL ( si_SignonURLStruct url) [static]

Definition at line 881 of file singsign.cpp.

{
  if (url == si_composite_url) {
    si_SignonUserStruct *chosen_user = url->chosen_user;
    /* need to transfer the chosen_user state variable */
    if (chosen_user) {
      PRInt32 index;

      /* store chosen_user */
      index = si_SetChosenUser(url = si_composite_url->primaryUrl, chosen_user);
      if (index >= 0)
        si_composite_url->legacyUrl->chosen_user = NULL;
      else
        index = si_SetChosenUser(url = si_composite_url->legacyUrl, chosen_user);
      NS_ASSERTION(index >= 0, "chosen_user not found");

      /* need to move chosen_user to front of list */
      url->signonUser_list.MoveElement(index, 0);
    }
    else {
      si_composite_url->primaryUrl->chosen_user = NULL;
      si_composite_url->legacyUrl->chosen_user = NULL;
    }
    si_composite_url->primaryUrl = NULL;
    si_composite_url->legacyUrl = NULL;
    si_composite_url->chosen_user = NULL;
    si_composite_url->signonUser_list.Clear();

    delete si_composite_url;
    si_composite_url = NULL;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void si_RememberSignonData ( nsIPrompt dialog,
const char *  passwordRealm,
const char *  legacyRealm,
nsVoidArray signonData,
nsIDOMWindowInternal window 
) [static]

Definition at line 2202 of file singsign.cpp.

{
  int passwordCount = 0;
  int pswd[3];
  si_SignonDataStruct * data = nsnull;  // initialization only to avoid warning message
  si_SignonDataStruct * data0;
  si_SignonDataStruct * data1;
  si_SignonDataStruct * data2;

  /* do nothing if signon preference is not enabled */
  if (!si_GetSignonRememberingPref()){
    return;
  }

  /* determine how many passwords are in the form and where they are */
  for (PRInt32 i=0; i<signonData->Count(); i++) {
    data = NS_STATIC_CAST(si_SignonDataStruct*, signonData->ElementAt(i));
    if (data->isPassword) {
      if (passwordCount < 3 ) {
        pswd[passwordCount] = i;
      }
      passwordCount++;
    }
  }

  /* process the form according to how many passwords it has */
  if (passwordCount == 1) {
    /* one-password form is a log-in so remember it */

    /* obtain the index of the first input field (that is the username) */
    PRInt32 j;
    for (j=0; j<signonData->Count(); j++) {
      data = NS_STATIC_CAST(si_SignonDataStruct*, signonData->ElementAt(j));
      if (!data->isPassword) {
        break;
      }
    }

    if (j<signonData->Count()) {
      data2 = NS_STATIC_CAST(si_SignonDataStruct*, signonData->ElementAt(j));

      if (si_OkToSave(passwordRealm, legacyRealm, data2->value, window)) {
        // remove legacy password entry if found
        if (legacyRealm && si_CheckForUser(legacyRealm, data2->value)) {
          si_RemoveUser(legacyRealm, data2->value, PR_TRUE, PR_FALSE, PR_TRUE);
        }
        Wallet_GiveCaveat(window, nsnull);
        for (j=0; j<signonData->Count(); j++) {
          data2 = NS_STATIC_CAST(si_SignonDataStruct*, signonData->ElementAt(j));
          nsAutoString value(data2->value);
          if (NS_FAILED(Wallet_Encrypt(value, data2->value))) {
            return;
          }
        }
        si_PutData(passwordRealm, signonData, PR_TRUE);
      }
    }
  } else if (passwordCount == 2) {
    /* two-password form is a registration */

  } else if (passwordCount == 3) {
    /* three-password form is a change-of-password request */

    si_SignonUserStruct* user;

    /* make sure all passwords are non-null and 2nd and 3rd are identical */
    data0 = NS_STATIC_CAST(si_SignonDataStruct*, signonData->ElementAt(pswd[0]));
    data1 = NS_STATIC_CAST(si_SignonDataStruct*, signonData->ElementAt(pswd[1]));
    data2 = NS_STATIC_CAST(si_SignonDataStruct*, signonData->ElementAt(pswd[2]));
    if (data0->value.IsEmpty() || data1->value.IsEmpty() ||
        data2->value.IsEmpty() || data1->value != data2->value) {
      return;
    }

    /* ask user if this is a password change */
    si_lock_signon_list();
    user = si_GetURLAndUserForChangeForm(dialog, data0->value);

    /* return if user said no */
    if (!user) {
      si_unlock_signon_list();
      return;
    }

    /* get to password being saved */
    PRInt32 dataCount = user->signonData_list.Count();
    for (PRInt32 k=0; k<dataCount; k++) {
      data = NS_STATIC_CAST(si_SignonDataStruct*, user->signonData_list.ElementAt(k));
      if (data->isPassword) {
        break;
      }
    }

    /*
     * if second password is "********" then generate a random
     * password for it and use same random value for third password
     * as well (Note: this all works because we already know that
     * second and third passwords are identical so third password
     * must also be "********".  Furthermore si_Randomize() will
     * create a random password of exactly eight characters -- the
     * same length as "********".)
     */

/* commenting out because I don't see how such randomizing could ever have worked. */
//    si_Randomize(data1->value);
//    data2->value = data1->value;

    if (NS_SUCCEEDED(Wallet_Encrypt(data1->value, data->value))) {
      user->time = SecondsFromPRTime(PR_Now()); 
      si_signon_list_changed = PR_TRUE;
      si_SaveSignonDataLocked("signons", PR_TRUE);
      si_unlock_signon_list();
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void si_RememberSignonDataFromBrowser ( const char *  passwordRealm,
const nsString username,
const nsString password 
) [static]

Definition at line 2476 of file singsign.cpp.

                                                                                                                {
  /* do nothing if signon preference is not enabled */
  if (!si_GetSignonRememberingPref()){
    return;
  }

  nsVoidArray signonData;
  si_SignonDataStruct data1;
  data1.name.AssignLiteral(USERNAMEFIELD);
  if (NS_FAILED(Wallet_Encrypt(username, data1.value))) {
    return;
  }
  data1.isPassword = PR_FALSE;
  signonData.AppendElement(&data1);
  si_SignonDataStruct data2;
  data2.name.AssignLiteral(PASSWORDFIELD);
  if (NS_FAILED(Wallet_Encrypt(password, data2.value))) {
    return;
  }
  data2.isPassword = PR_TRUE;
  signonData.AppendElement(&data2);

  /* Save the signon data */
  si_PutData(passwordRealm, &signonData, PR_TRUE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1380 of file singsign.cpp.

                         {
  if (si_PartiallyLoaded) {
    /* repeatedly remove first user node of first URL node */
    while (si_RemoveUser(NULL, EmptyString(), PR_FALSE, PR_FALSE, PR_FALSE, PR_TRUE)) {
    }
  }
  si_PartiallyLoaded = PR_FALSE;

  if (si_reject_list) {
    si_Reject * reject;
    while (LIST_COUNT(si_reject_list)>0) {
      reject = NS_STATIC_CAST(si_Reject*, si_reject_list->ElementAt(0));
      if (reject) {
        si_FreeReject(reject);
        si_signon_list_changed = PR_TRUE;
      }
    }
    delete si_reject_list;
    si_reject_list = nsnull;
  }
  delete si_signon_list;
  si_signon_list = nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool si_RemoveUser ( const char *  passwordRealm,
const nsString userName,
PRBool  save,
PRBool  loginFailure,
PRBool  notify,
PRBool  first = PR_FALSE 
) [static]

Definition at line 916 of file singsign.cpp.

                                                                                                                                             {
  si_SignonURLStruct * url;
  si_SignonUserStruct * user;
  si_SignonDataStruct * data;

  si_lock_signon_list();

  /* get URL corresponding to host */
  url = si_GetURL(passwordRealm);
  if (!url) {
    /* URL not found */
    si_unlock_signon_list();
    return PR_FALSE;
  }

  /* free the data in each node of the specified user node for this URL */
  if (first) {

    /* remove the first user */
    user = NS_STATIC_CAST(si_SignonUserStruct *,
                          url->signonUser_list.ElementAt(0));

  } else {

    /* find the specified user */
    PRInt32 userCount = url->signonUser_list.Count();
    for (PRInt32 i=0; i<userCount; i++) {
      user = NS_STATIC_CAST(si_SignonUserStruct*, url->signonUser_list.ElementAt(i));
      PRInt32 dataCount = user->signonData_list.Count();
      for (PRInt32 ii=0; ii<dataCount; ii++) {
        data = NS_STATIC_CAST(si_SignonDataStruct*, user->signonData_list.ElementAt(ii));
        if (si_CompareEncryptedToCleartext(data->value, userName)) {
          goto foundUser;
        }
      }
    }
    si_unlock_signon_list();
    return PR_FALSE; /* user not found so nothing to remove */
    foundUser: ;
  }

  /* free the user node */
  url->signonUser_list.RemoveElement(user);
  delete user;

  /* remove this URL if it contains no more users */
  if (url->signonUser_list.Count() == 0) {
    PR_Free(url->passwordRealm);
    si_signon_list->RemoveElement(url);
    delete url;
  }

  /* write out the change to disk */
  if (save) {
    si_signon_list_changed = PR_TRUE;
    si_SaveSignonDataLocked("signons", notify);
  }

  si_unlock_signon_list();
  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void si_RestoreOldSignonDataFromBrowser ( nsIPrompt dialog,
const char *  passwordRealm,
PRBool  pickFirstUser,
nsString username,
nsString password 
) [static]

Definition at line 2508 of file singsign.cpp.

                                                                                                                 {
  si_SignonUserStruct* user;
  si_SignonDataStruct* data;

  /* get the data from previous time this URL was visited */
  si_lock_signon_list();
  if (!username.IsEmpty()) {
    user = si_GetSpecificUser(passwordRealm, username, NS_ConvertASCIItoUCS2(USERNAMEFIELD));
  } else {
    si_LastFormForWhichUserHasBeenSelected = -1;
    user = si_GetUser(dialog, passwordRealm, nsnull, pickFirstUser, NS_ConvertASCIItoUCS2(USERNAMEFIELD), 0);
  }
  if (!user) {
    /* leave original username and password from caller unchanged */
    /* username = 0; */
    /* *password = 0; */
    si_unlock_signon_list();
    return;
  }

  /* restore the data from previous time this URL was visited */
  PRInt32 dataCount = user->signonData_list.Count();
  for (PRInt32 i=0; i<dataCount; i++) {
    data = NS_STATIC_CAST(si_SignonDataStruct*, user->signonData_list.ElementAt(i));
    nsAutoString decrypted;
    if (NS_SUCCEEDED(Wallet_Decrypt(data->value, decrypted))) {
      if(data->name.EqualsLiteral(USERNAMEFIELD)) {
        username = decrypted;
      } else if(data->name.EqualsLiteral(PASSWORDFIELD)) {
        password = decrypted;
      }
    }
  }
  si_unlock_signon_list();
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void si_RestoreSignonData ( nsIPrompt dialog,
const char *  passwordRealm,
const char *  legacyRealm,
const PRUnichar name,
PRUnichar **  value,
PRUint32  formNumber,
PRUint32  elementNumber 
) [static]

Definition at line 2340 of file singsign.cpp.

                                                                  {
  si_SignonUserStruct* user;
  si_SignonDataStruct* data;
  nsAutoString correctedName;

  /* do nothing if signon preference is not enabled */
  if (!si_GetSignonRememberingPref()){
    return;
  }

  si_lock_signon_list();
  if (elementNumber == 0) {
    si_LastFormForWhichUserHasBeenSelected = -1;
  }

  /* Correct the field name to avoid mistaking for fields in browser-generated form
   *
   *   Note that data saved for browser-generated logins (e.g. http authentication)
   *   use artificial field names starting with * \= (see USERNAMEFIELD and PASSWORDFIELD.
   *   To avoid mistakes whereby saved logins for http authentication is then prefilled
   *   into a field on the html form at the same URL, we will prevent html field names
   *   from starting with \=.  We do that by doubling up a backslash if it appears in the
   *   first character position
   */
  if (*name == '\\') {
    correctedName = NS_LITERAL_STRING("\\") + nsDependentString(name);
  } else {
    correctedName = name;
  }

  /* determine if name has been saved (avoids unlocking the database if not) */
  PRBool nameFound = PR_FALSE;
  user = si_GetUser(dialog, passwordRealm, legacyRealm, PR_FALSE, correctedName, formNumber);
  if (user) {
    PRInt32 dataCount = user->signonData_list.Count();
    for (PRInt32 i=0; i<dataCount; i++) {
      data = NS_STATIC_CAST(si_SignonDataStruct*, user->signonData_list.ElementAt(i));
      LOG(("  got [name=%s value=%s]\n",
              NS_LossyConvertUCS2toASCII(data->name).get(),
              NS_LossyConvertUCS2toASCII(data->value).get()));
      if(!correctedName.IsEmpty() && (data->name == correctedName)) {
        nameFound = PR_TRUE;
      }
    }
  }
  if (!nameFound) {
    si_unlock_signon_list();
    return;
  }

#ifdef xxx
  /*
   * determine if it is a change-of-password field
   *    the heuristic that we will use is that if this is the first
   *    item on the form and it is a password, this is probably a
   *    change-of-password form
   */
  /* see if this is first item in form and is a password */
  /* get first saved user just so we can see the name of the first item on the form */
  user = si_GetUser(passwordRealm, PR_TRUE, NULL, formNumber); /* this is the first saved user */
  if (user) {
    data = NS_STATIC_CAST(si_SignonDataStruct *,
                    user->signonData_list.ElementAt(0)); /* 1st item on form */
    if(data->isPassword && !correctedName.IsEmpty() && (data->name == correctedName)) {
      /* current item is first item on form and is a password */
      user = (passwordRealm, MK_SIGNON_PASSWORDS_FETCH);
      if (user) {
        /* user has confirmed it's a change-of-password form */
        PRInt32 dataCount = user->signonData_list.Count();
        for (PRInt32 i=1; i<dataCount; i++) {
          data = NS_STATIC_CAST(si_SignonDataStruct*, user->signonData_list.ElementAt(i));
          if (data->isPassword) {
            nsAutoString password;
            if (NS_SUCCEEDED(Wallet_Decrypt(data->value, password))) {
              *value = ToNewUnicode(password);
            }
            si_unlock_signon_list();
            return;
          }
        }
      }
    }
  }
#endif

  /* restore the data from previous time this URL was visited */

  user = si_GetUser(dialog, passwordRealm, legacyRealm, PR_FALSE, correctedName, formNumber);
  if (user) {
    PRInt32 dataCount = user->signonData_list.Count();
    for (PRInt32 i=0; i<dataCount; i++) {
      data = NS_STATIC_CAST(si_SignonDataStruct*, user->signonData_list.ElementAt(i));
      LOG(("  got [name=%s value=%s]\n",
              NS_LossyConvertUCS2toASCII(data->name).get(),
              NS_LossyConvertUCS2toASCII(data->value).get()));
      if(!correctedName.IsEmpty() && (data->name == correctedName)) {
        nsAutoString password;
        if (NS_SUCCEEDED(Wallet_Decrypt(data->value, password))) {
          *value = ToNewUnicode(password);
        }
        si_unlock_signon_list();
        return;
      }
    }
  }
  si_unlock_signon_list();
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int si_SaveSignonDataLocked ( char *  state,
PRBool  notify 
) [static]

Definition at line 1999 of file singsign.cpp.

                                                     {
  si_SignonURLStruct * url;
  si_SignonUserStruct * user;
  si_SignonDataStruct * data;
  si_Reject * reject;

  /* do nothing if signon list has not changed */
  if(!si_signon_list_changed) {
    return(-1);
  }

#ifdef APPLE_KEYCHAIN
  if (KeychainManagerAvailable()) {
    return si_SaveSignonDataInKeychain();
  }
#endif

  /* do nothing if we are unable to open file that contains signon list */
  nsCOMPtr<nsIFile> file;
  nsresult rv = Wallet_ProfileDirectory(getter_AddRefs(file));
  if (NS_FAILED(rv)) {
    return 0;
  }

  file->AppendNative(nsDependentCString(signonFileName));

  nsCOMPtr<nsIOutputStream> fileOutputStream;
  rv = NS_NewSafeLocalFileOutputStream(getter_AddRefs(fileOutputStream),
                                       file,
                                       -1,
                                       0600);
  if (NS_FAILED(rv))
    return 0;

  nsCOMPtr<nsIOutputStream> strm;
  rv = NS_NewBufferedOutputStream(getter_AddRefs(strm), fileOutputStream, 4096);
  if (NS_FAILED(rv))
    return 0;

  /* write out the format revision number */

  wallet_PutLine(strm, HEADER_VERSION);

  /* format for next part of file shall be:
   * passwordRealm -- first url/username on reject list
   * userName
   * passwordRealm -- second url/username on reject list
   * userName
   * ...     -- etc.
   * .       -- end of list
   */

  /* write out reject list */
  if (si_reject_list) {
    PRInt32 rejectCount = LIST_COUNT(si_reject_list);
    for (PRInt32 i=0; i<rejectCount; i++) {
      reject = NS_STATIC_CAST(si_Reject*, si_reject_list->ElementAt(i));
      wallet_PutLine(strm, reject->passwordRealm);
    }
  }
  wallet_PutLine(strm, ".");

  /* format for cached logins shall be:
   * url LINEBREAK {name LINEBREAK value LINEBREAK}*  . LINEBREAK
   * if type is password, name is preceded by an asterisk (*)
   */

  /* write out each URL node */
  if((si_signon_list)) {
    PRInt32 urlCount = LIST_COUNT(si_signon_list);
    for (PRInt32 i2=0; i2<urlCount; i2++) {
      url = NS_STATIC_CAST(si_SignonURLStruct*, si_signon_list->ElementAt(i2));

      /* write out each user node of the URL node */
      PRInt32 userCount = url->signonUser_list.Count();
      for (PRInt32 i3=0; i3<userCount; i3++) {
        user = NS_STATIC_CAST(si_SignonUserStruct*, url->signonUser_list.ElementAt(i3));
        wallet_PutLine(strm, url->passwordRealm);

        /* write out each data node of the user node */
        PRInt32 dataCount = user->signonData_list.Count();
        for (PRInt32 i4=0; i4<dataCount; i4++) {
          data = NS_STATIC_CAST(si_SignonDataStruct*, user->signonData_list.ElementAt(i4));
          if (data->isPassword) {
            static const char asterisk = '*';
            PRUint32 dummy;
            strm->Write(&asterisk, 1, &dummy);
          }
          wallet_PutLine(strm, NS_ConvertUTF16toUTF8(data->name).get());
          wallet_PutLine(strm, NS_ConvertUTF16toUTF8(data->value).get());
        }
        wallet_PutLine(strm, ".");
      }
    }
  }
  si_signon_list_changed = PR_FALSE;

  // All went ok. Maybe except for problems in Write(), but the stream detects
  // that for us
  nsCOMPtr<nsISafeOutputStream> safeStream = do_QueryInterface(strm);
  NS_ASSERTION(safeStream, "expected a safe output stream!");
  if (safeStream) {
    rv = safeStream->Finish();
    if (NS_FAILED(rv)) {
      NS_WARNING("failed to save wallet file! possible dataloss");
      return 0;
    }
  }
  strm = nsnull;
  fileOutputStream = nsnull;


  /* Notify signon manager dialog to update its display */
  if (notify) {
    nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1"));
    if (os) {
      os->NotifyObservers(nsnull, "signonChanged", NS_ConvertASCIItoUCS2(state).get());
    }
  }

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool si_SelectDialog ( const PRUnichar szMessage,
nsIPrompt dialog,
PRUnichar **  pList,
PRInt32 pCount,
PRUint32  formNumber 
) [static]

Definition at line 391 of file singsign.cpp.

                                                                                                                        {
  if (si_LastFormForWhichUserHasBeenSelected == (PRInt32)formNumber) {
    /* a user was already selected for this form, use same one again */
    *pCount = 0; /* last user selected is now at head of list */
    return PR_TRUE;
  }
  nsresult rv;
  PRInt32 selectedIndex;
  PRBool rtnValue;
  PRUnichar * title_string = Wallet_Localize("SelectUserTitleLine");

  /* Notify signon manager dialog to update its display */
  nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1"));
  gSelectUserDialogCount++;
  if (os) {
    os->NotifyObservers(nsnull, "signonSelectUser", NS_LITERAL_STRING("suspend").get());
  }

  rv = dialog->Select( title_string, szMessage, *pCount, NS_CONST_CAST(const PRUnichar**, pList), &selectedIndex, &rtnValue );

  gSelectUserDialogCount--;
  if (os) {
    os->NotifyObservers(nsnull, "signonSelectUser", NS_LITERAL_STRING("resume").get());
  }

  Recycle(title_string);
  if (selectedIndex >= *pCount) {
    return PR_FALSE; // out-of-range selection
  }
  *pCount = selectedIndex;
  if (rtnValue) {
    si_LastFormForWhichUserHasBeenSelected = formNumber;
  }
  return rtnValue;  
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SI_SetBoolPref ( const char *  prefname,
PRBool  prefvalue 
)

Definition at line 184 of file singsign.cpp.

                                                        {
  nsresult ret;
  nsCOMPtr<nsIPref> pPrefService = do_GetService(NS_PREF_CONTRACTID, &ret);
  if (NS_SUCCEEDED(ret)) {
    ret = pPrefService->SetBoolPref(prefname, prefvalue);
    if (NS_SUCCEEDED(ret)) {
      ret = pPrefService->SavePrefFile(nsnull); 
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SI_SetCharPref ( const char *  prefname,
const char *  prefvalue 
)

Definition at line 207 of file singsign.cpp.

                                                              {
  if (!prefvalue) {
    return; /* otherwise the SetCharPref routine called below will crash */
  }
  nsresult ret;
  nsCOMPtr<nsIPref> pPrefService = do_GetService(NS_PREF_CONTRACTID, &ret);
  if (NS_SUCCEEDED(ret)) {
    ret = pPrefService->SetCharPref(prefname, prefvalue);
    if (NS_SUCCEEDED(ret)) {
      ret = pPrefService->SavePrefFile(nsnull); 
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRInt32 si_SetChosenUser ( si_SignonURLStruct url,
si_SignonUserStruct chosen_user 
) [static]

Definition at line 866 of file singsign.cpp.

{
  PRInt32 index;

  index = url->signonUser_list.IndexOf(chosen_user);
  if (index < 0) {
      url->chosen_user = NULL;
      return -1;
  }

  url->chosen_user = chosen_user;
  return index; 
}

Here is the caller graph for this function:

static void si_SetSignonRememberingPref ( PRBool  x) [static]

Definition at line 288 of file singsign.cpp.

                                      {
#ifdef APPLE_KEYCHAIN
  if (x == 0) {
    /* We no longer need the Keychain callback installed */
    KCRemoveCallback( si_kcUPP );
    DisposeRoutineDescriptor( si_kcUPP );
    si_kcUPP = NULL;
  }
#endif
  si_RememberSignons = x;
}

Here is the caller graph for this function:

int PR_CALLBACK si_SignonRememberingPrefChanged ( const char *  newpref,
void data 
)

Definition at line 301 of file singsign.cpp.

                                                                   {
    PRBool x;
    x = SI_GetBoolPref(pref_rememberSignons, PR_TRUE);
    si_SetSignonRememberingPref(x);
    return 0; /* this is PREF_NOERROR but we no longer include prefapi.h */
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void si_unlock_signon_list ( void  ) [static]

Definition at line 144 of file singsign.cpp.

                            {
    PR_EnterMonitor(signon_lock_monitor);

#ifdef DEBUG
    /* make sure someone doesn't try to free a lock they don't own */
    PR_ASSERT(signon_lock_owner == PR_GetCurrentThread());
#endif

    signon_lock_count--;
    if(signon_lock_count == 0) {
        signon_lock_owner = NULL;
        PR_Notify(signon_lock_monitor);
    }
    PR_ExitMonitor(signon_lock_monitor);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SI_UnregisterCallback ( const char *  domain,
PrefChangedFunc  callback,
void instance_data 
)

Definition at line 175 of file singsign.cpp.

                                                                                         {
  nsresult ret;
  nsCOMPtr<nsIPref> pPrefService = do_GetService(NS_PREF_CONTRACTID, &ret);
  if (NS_SUCCEEDED(ret)) {
    ret = pPrefService->UnregisterCallback(domain, callback, instance_data);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult SINGSIGN_AddReject ( const char *  host)

Definition at line 1019 of file singsign.cpp.

                                       {
  si_PutReject(host, nsString(/*thisParameter_isObsolete*/), PR_TRUE);
// @see http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/extensions/wallet/src/singsign.cpp&rev=1.212&mark=1693#1650
  return NS_OK;
}

Here is the call graph for this function:

nsresult SINGSIGN_Enumerate ( PRInt32  hostNumber,
PRInt32  userNumber,
PRBool  decrypt,
char **  host,
PRUnichar **  user,
PRUnichar **  pswd 
)

Definition at line 2927 of file singsign.cpp.

                                           {

  if (gSelectUserDialogCount>0 && hostNumber==0 && userNumber==0) {
    // starting to enumerate over all saved logins
    // notify recipients if login list is in use by SelectUserDialog
    nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1"));
    if (os) {
      os->NotifyObservers(nsnull, "signonSelectUser", NS_LITERAL_STRING("inUse").get());
    }
  }

  if (hostNumber > SINGSIGN_HostCount() || userNumber > SINGSIGN_UserCount(hostNumber)) {
    return NS_ERROR_FAILURE;
  }
  si_SignonURLStruct *hostStruct;
  si_SignonUserStruct * userStruct;
  si_SignonDataStruct* data = nsnull;

  hostStruct = NS_STATIC_CAST(si_SignonURLStruct*, si_signon_list->ElementAt(hostNumber));
  NS_ASSERTION(hostStruct, "corrupt singlesignon list");
  *host = (char *) nsMemory::Clone
    (hostStruct->passwordRealm, strlen(hostStruct->passwordRealm) + 1);
  NS_ENSURE_ARG_POINTER(host);
  userStruct = NS_STATIC_CAST
    (si_SignonUserStruct*, hostStruct->signonUser_list.ElementAt(userNumber));

  /* first non-password data item for user is the username */
  PRInt32 dataCount = userStruct->signonData_list.Count();
  PRInt32 k;
  for (k=0; k<dataCount; k++) {
    data = NS_STATIC_CAST(si_SignonDataStruct *, userStruct->signonData_list.ElementAt(k));
    if (!(data->isPassword)) {
      break;
    }
  }

  nsresult rv;
  nsAutoString userName;
  if (decrypt) {
    rv = Wallet_Decrypt(data->value, userName);
    if (NS_FAILED(rv)) {
      /* don't display saved signons if user couldn't unlock the database */
    return rv;
    }
  } else {
    userName = data->value;
  }
  if (!(*user = ToNewUnicode(userName))) {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  /* first password data item for user is the password */
  for (k=0; k<dataCount; k++) {
    data = NS_STATIC_CAST(si_SignonDataStruct *, userStruct->signonData_list.ElementAt(k));
    if ((data->isPassword)) {
      break;
    }
  }

  nsAutoString passWord;
  if (decrypt) {
    rv = Wallet_Decrypt(data->value, passWord);
    if (NS_FAILED(rv)) {
      /* don't display saved signons if user couldn't unlock the database */
      Recycle(*user);
      return rv;
    }
  } else {
    passWord = data->value;
  }  
  if (!(*pswd = ToNewUnicode(passWord))) {
    Recycle(*user);
    return NS_ERROR_OUT_OF_MEMORY;
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult SINGSIGN_HaveData ( nsIPrompt dialog,
const char *  passwordRealm,
const PRUnichar userName,
PRBool retval 
)

Definition at line 2883 of file singsign.cpp.

{
  nsAutoString data, usernameForLookup;

  *retval = PR_FALSE;

  if (!si_GetSignonRememberingPref()) {
    return NS_OK;
  }

  /* get previous data used with this username, pick first user if no username found */
  si_RestoreOldSignonDataFromBrowser(dialog, passwordRealm, usernameForLookup.IsEmpty(), usernameForLookup, data);

  if (!data.IsEmpty()) {
    *retval = PR_TRUE;
  }

  return NS_OK;
}

Here is the call graph for this function:

Definition at line 2904 of file singsign.cpp.

                     {
  /* force loading of the signons file */
  si_RegisterSignonPrefCallbacks();

  if (!si_signon_list) {
    return 0;
  }
  return si_signon_list->Count();
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult SINGSIGN_Prompt ( const PRUnichar dialogTitle,
const PRUnichar text,
const PRUnichar defaultText,
PRUnichar **  resultText,
const char *  passwordRealm,
nsIPrompt dialog,
PRBool pressedOK,
PRUint32  savePassword 
)

Definition at line 2738 of file singsign.cpp.

{
  nsresult res;
  nsAutoString data, emptyUsername;

  /* do only the dialog if signon preference is not enabled */
  if (!si_GetSignonRememberingPref()){
    return si_DoDialogIfPrefIsOff(dialogTitle,
                                  text,
                                  nsnull,
                                  nsnull,
                                  defaultText,
                                  resultText,
                                  passwordRealm,
                                  dialog,
                                  pressedOK, 
                                  savePassword,
                                  prompt);
  }

  /* get previous data used with this hostname */
  si_RestoreOldSignonDataFromBrowser(dialog, passwordRealm, PR_TRUE, emptyUsername, data);

  /* return if data was found */
  if (!data.IsEmpty()) {
    *resultText = ToNewUnicode(data);
    *pressedOK = PR_TRUE;
    return NS_OK;
  }

  /* no data found, get new data from user */
  data = defaultText;
  *resultText = ToNewUnicode(data);
  PRBool checked = PR_FALSE;
  res = si_CheckGetData(resultText, dialogTitle, text, dialog, savePassword, &checked);
  if (NS_FAILED(res)) {
    /* user pressed Cancel */
    PR_FREEIF(*resultText);
    *pressedOK = PR_FALSE;
    return NS_OK;
  }
  if (checked) {
    Wallet_GiveCaveat(nsnull, dialog);
    si_RememberSignonDataFromBrowser(passwordRealm, emptyUsername, nsDependentString(*resultText));
  }

  /* cleanup and return */
  *pressedOK = PR_TRUE;
  return NS_OK;
}

Here is the call graph for this function:

nsresult SINGSIGN_PromptPassword ( const PRUnichar dialogTitle,
const PRUnichar text,
PRUnichar **  pwd,
const char *  passwordRealm,
nsIPrompt dialog,
PRBool pressedOK,
PRUint32  savePassword 
)

Definition at line 2685 of file singsign.cpp.

{

  nsresult res;
  nsAutoString password, username;

  /* do only the dialog if signon preference is not enabled */
  if (!si_GetSignonRememberingPref()){
    return si_DoDialogIfPrefIsOff(dialogTitle,
                                  text,
                                  nsnull,
                                  pwd,
                                  nsnull,
                                  nsnull,
                                  passwordRealm,
                                  dialog,
                                  pressedOK, 
                                  savePassword,
                                  promptPassword);
  }

  /* get previous password used with this username, pick first user if no username found */
  si_RestoreOldSignonDataFromBrowser(dialog, passwordRealm, username.IsEmpty(), username, password);

  /* return if a password was found */
  if (!password.IsEmpty()) {
    *pwd = ToNewUnicode(password);
    *pressedOK = PR_TRUE;
    return NS_OK;
  }

  /* no password found, get new password from user */
  PRBool checked = PR_FALSE;
  res = si_CheckGetPassword(pwd, dialogTitle, text, dialog, savePassword, &checked);
  if (NS_FAILED(res)) {
    /* user pressed Cancel */
    PR_FREEIF(*pwd);
    *pressedOK = PR_FALSE;
    return NS_OK;
  }
  if (checked) {
    Wallet_GiveCaveat(nsnull, dialog);
    si_RememberSignonDataFromBrowser(passwordRealm, username, nsDependentString(*pwd));
  }

  /* cleanup and return */
  *pressedOK = PR_TRUE;
  return NS_OK;
}

Here is the call graph for this function:

nsresult SINGSIGN_PromptUsernameAndPassword ( const PRUnichar dialogTitle,
const PRUnichar text,
PRUnichar **  user,
PRUnichar **  pwd,
const char *  passwordRealm,
nsIPrompt dialog,
PRBool pressedOK,
PRUint32  savePassword 
)

Definition at line 2627 of file singsign.cpp.

                                                                                             {

  nsresult res;

  /* do only the dialog if signon preference is not enabled */
  if (!si_GetSignonRememberingPref()){
    return si_DoDialogIfPrefIsOff(dialogTitle,
                                  text,
                                  user,
                                  pwd,
                                  nsnull,
                                  nsnull,
                                  passwordRealm,
                                  dialog,
                                  pressedOK, 
                                  savePassword,
                                  promptUsernameAndPassword);
  }

  /* prefill with previous username/password if any */
  nsAutoString username, password;
  si_RestoreOldSignonDataFromBrowser(dialog, passwordRealm, PR_FALSE, username, password);

  /* get new username/password from user */
  if (!(*user = ToNewUnicode(username))) {
    return NS_ERROR_OUT_OF_MEMORY;
  }
  if (!(*pwd = ToNewUnicode(password))) {
    PR_Free(*user);
    return NS_ERROR_OUT_OF_MEMORY;
  }

  PRBool checked = (**user != 0);
  PRBool remembered = checked;
  res = si_CheckGetUsernamePassword(user, pwd, dialogTitle, text, dialog, savePassword, &checked);
  if (NS_FAILED(res)) {
    /* user pressed Cancel */
    PR_FREEIF(*user);
    PR_FREEIF(*pwd);
    *pressedOK = PR_FALSE;
    return NS_OK;
  }
  if (checked) {
    Wallet_GiveCaveat(nsnull, dialog);
    si_RememberSignonDataFromBrowser (passwordRealm, nsDependentString(*user), nsDependentString(*pwd));
  } else if (remembered) {
    /* a login was remembered but user unchecked the box; we forget the remembered login */
    si_RemoveUser(passwordRealm, username, PR_TRUE, PR_FALSE, PR_TRUE);  
  }

  /* cleanup and return */
  *pressedOK = PR_TRUE;
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 2843 of file singsign.cpp.

{
  /* force loading of the signons file */
  si_RegisterSignonPrefCallbacks();

  nsAutoString buffer;
  si_SignonURLStruct *url;
  si_SignonUserStruct * user;
  si_SignonDataStruct* data = nsnull;

  si_lock_signon_list();
  PRInt32 urlCount = LIST_COUNT(si_signon_list);
  for (PRInt32 i=0; i<urlCount; i++) {
    url = NS_STATIC_CAST(si_SignonURLStruct*, si_signon_list->ElementAt(i));
    PRInt32 userCount = url->signonUser_list.Count();
    for (PRInt32 j=0; j<userCount; j++) {
      user = NS_STATIC_CAST(si_SignonUserStruct*, url->signonUser_list.ElementAt(j));

      PRInt32 dataCount = user->signonData_list.Count();
      for (PRInt32 k=0; k<dataCount; k++) {
        data = NS_STATIC_CAST(si_SignonDataStruct *,
                              user->signonData_list.ElementAt(k));
        nsAutoString userName;
        if (NS_FAILED(Wallet_Decrypt(data->value, userName))) {
          //Don't try to re-encrypt. Just go to the next one.
          continue;
        }
        if (NS_FAILED(Wallet_Encrypt(userName, data->value))) {
          return PR_FALSE;
        }
      }
    }
  }
  si_signon_list_changed = PR_TRUE;
  si_SaveSignonDataLocked("signons", PR_TRUE);
  si_unlock_signon_list();
  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3006 of file singsign.cpp.

                       {
  if (!si_reject_list) {
    return 0;
  }
  return si_reject_list->Count();
}

Here is the caller graph for this function:

nsresult SINGSIGN_RejectEnumerate ( PRInt32  rejectNumber,
char **  host 
)

Definition at line 3015 of file singsign.cpp.

                                        {

  si_Reject *reject;
  reject = NS_STATIC_CAST(si_Reject*, si_reject_list->ElementAt(rejectNumber));
  NS_ASSERTION(reject, "corrupt reject list");

  *host = (char *) nsMemory::Clone
    (reject->passwordRealm, strlen(reject->passwordRealm) + 1);
  NS_ENSURE_ARG_POINTER(host);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SINGSIGN_RememberSignonData ( nsIPrompt dialog,
nsIURI passwordRealm,
nsVoidArray signonData,
nsIDOMWindowInternal window 
)

Definition at line 2321 of file singsign.cpp.

{
  if (!passwordRealm)
    return;      

  nsCAutoString realm, legacyRealm;
  if (!si_ExtractRealm(passwordRealm, realm))
    return;

  if (NS_FAILED(passwordRealm->GetHost(legacyRealm)))
    return;

  if (!realm.IsEmpty()) {
    si_RememberSignonData(dialog, realm.get(), legacyRealm.get(), signonData, window);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 994 of file singsign.cpp.

                                        {
  si_Reject* reject;
  nsresult rv = NS_ERROR_FAILURE;

  /* step backwards through all rejects */
  si_lock_signon_list();
  PRInt32 rejectCount = LIST_COUNT(si_reject_list);
  while (rejectCount>0) {
    rejectCount--;
    reject = NS_STATIC_CAST(si_Reject*, si_reject_list->ElementAt(rejectCount));
    if (reject && !PL_strcmp(reject->passwordRealm, host)) {
      si_FreeReject(reject);
      si_signon_list_changed = PR_TRUE;
      rv = NS_OK;
    }
  }
  si_SaveSignonDataLocked("rejects", PR_FALSE);
  si_unlock_signon_list();
  return rv;
}

Here is the call graph for this function:

nsresult SINGSIGN_RemoveUser ( const char *  host,
const PRUnichar user,
PRBool  notify 
)

Definition at line 979 of file singsign.cpp.

Here is the call graph for this function:

nsresult SINGSIGN_RemoveUserAfterLoginFailure ( const char *  host,
const PRUnichar user,
PRBool  notify 
)

Definition at line 985 of file singsign.cpp.

Here is the call graph for this function:

void SINGSIGN_RestoreSignonData ( nsIPrompt dialog,
nsIURI passwordRealm,
const PRUnichar name,
PRUnichar **  value,
PRUint32  formNumber,
PRUint32  elementNumber 
)

Definition at line 2452 of file singsign.cpp.

                                                                                                                                                            {
  LOG(("enter SINGSIGN_RestoreSignonData\n"));

  if (!passwordRealm)
    return;  

  nsCAutoString realm;
  if (!si_ExtractRealm(passwordRealm, realm))
    return;

  nsCAutoString legacyRealm;
  if (NS_FAILED(passwordRealm->GetHost(legacyRealm)))
    return;

  si_RestoreSignonData(dialog, realm.get(), legacyRealm.get(), name, value, formNumber, elementNumber);

  LOG(("exit SINGSIGN_RestoreSignonData [value=%s]\n",
      *value ? NS_LossyConvertUCS2toASCII(*value).get() : "(null)"));
}

Here is the call graph for this function:

PRBool SINGSIGN_StorePassword ( const char *  passwordRealm,
const PRUnichar user,
const PRUnichar password 
)

Definition at line 2545 of file singsign.cpp.

{
//  Wallet_GiveCaveat(nsnull, dialog); ??? what value to use for dialog?
  si_RememberSignonDataFromBrowser(passwordRealm, nsDependentString(user), nsDependentString(password));
  return PR_TRUE;
}

Here is the call graph for this function:

Definition at line 2915 of file singsign.cpp.

                                 {
  if (!si_signon_list) {
    return 0;
  }

  si_SignonURLStruct *hostStruct;
  hostStruct = NS_STATIC_CAST(si_SignonURLStruct*, si_signon_list->ElementAt(host));
  return hostStruct->signonUser_list.Count();
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 113 of file singsign.cpp.

Definition at line 114 of file singsign.cpp.

const char* pref_rememberSignons = "signon.rememberSignons" [static]

Definition at line 254 of file singsign.cpp.

const char* pref_SignonFileName = "signon.SignonFileName" [static]

Definition at line 258 of file singsign.cpp.

Definition at line 774 of file singsign.cpp.

Definition at line 94 of file singsign.cpp.

Definition at line 93 of file singsign.cpp.

nsVoidArray* si_reject_list = 0 [static]

Definition at line 725 of file singsign.cpp.

Definition at line 260 of file singsign.cpp.

nsVoidArray* si_signon_list = 0 [static]

Definition at line 724 of file singsign.cpp.

Definition at line 727 of file singsign.cpp.

int signon_lock_count = 0 [static]

Definition at line 89 of file singsign.cpp.

Definition at line 87 of file singsign.cpp.

Definition at line 88 of file singsign.cpp.

Definition at line 112 of file singsign.cpp.