fix for #28827. make it so I can stuff a password into the single signon database.

now we can store the password from the user when creating the account with the wizard.
This commit is contained in:
sspitzer%netscape.com 2000-03-24 08:26:32 +00:00
Родитель 4c96138f64
Коммит d83ff54336
8 изменённых файлов: 102 добавлений и 4 удалений

Просмотреть файл

@ -59,6 +59,8 @@ interface nsIWalletService : nsISupports {
boolean PromptPasswordURL(in wstring text, out wstring pwd, in string urlname, in boolean stripUrl, in nsIPrompt dialog);
boolean PromptURL(in wstring text, in wstring defaultText, out wstring result, in string urlname, in boolean stripUrl, in nsIPrompt dialog);
void SI_RemoveUser(in string URLName, in boolean stripUrl, in wstring userName);
void SI_StorePassword(in string URLName, in boolean stripUrl, in wstring userName, in wstring pwd);
boolean haveData(in string url, in wstring userName, in boolean stripUrl);
[noscript] void WALLET_GetNopreviewListForViewer(in nsAutoStringRef aNopreviewList);

Просмотреть файл

@ -129,6 +129,12 @@ NS_IMETHODIMP nsWalletlibService::SI_RemoveUser(const char *URLName, PRBool stri
return NS_OK;
}
NS_IMETHODIMP nsWalletlibService::SI_StorePassword(const char *URLName, PRBool stripUrl, const PRUnichar *userName, const PRUnichar *password) {
::SINGSIGN_StorePassword(URLName, userName, password, stripUrl);
return NS_OK;
}
NS_IMETHODIMP nsWalletlibService::WALLET_GetNopreviewListForViewer(nsAutoString& aNopreviewList){
::WLLT_GetNopreviewListForViewer(aNopreviewList);
return NS_OK;

Просмотреть файл

@ -61,6 +61,8 @@ public:
const char *urlname, PRBool stripUrl, nsIPrompt* dialog, PRBool *_retval);
NS_IMETHOD SI_RemoveUser(const char *URLName, PRBool stripUrl, const PRUnichar *userName);
NS_IMETHOD SI_StorePassword(const char *URLName, PRBool stripUrl, const PRUnichar *userName, const PRUnichar *password);
NS_IMETHOD HaveData(const char *url, const PRUnichar *userName, PRBool stripUrl, PRBool *_retval);
NS_IMETHOD WALLET_GetNopreviewListForViewer(nsAutoString& aNopreviewList);

Просмотреть файл

@ -911,9 +911,10 @@ si_RemoveUser(const char *URLName, nsAutoString userName, PRBool save, PRBool st
PUBLIC PRBool
SINGSIGN_RemoveUser(const char *URLName, const PRUnichar *userName, PRBool strip) {
return si_RemoveUser((char *)URLName, userName, PR_TRUE, strip);
return si_RemoveUser(URLName, nsAutoString(userName), PR_TRUE, strip);
}
/* Determine if a specified url/user exists */
PRIVATE PRBool
si_CheckForUser(char *URLName, nsAutoString userName) {
@ -2484,6 +2485,54 @@ si_RestoreOldSignonDataFromBrowser
si_unlock_signon_list();
}
PUBLIC PRBool
SINGSIGN_StorePassword(const char *URLName, const PRUnichar *user, const PRUnichar *password, PRBool strip) {
nsresult res;
nsAutoString userName(user);
/* convert URLName to a uri so we can parse out the username and hostname */
nsXPIDLCString host;
if (strip) {
if (URLName) {
nsCOMPtr<nsIURL> uri;
nsComponentManager::CreateInstance(kStandardUrlCID, nsnull, NS_GET_IID(nsIURL), (void **) getter_AddRefs(uri));
res = uri->SetSpec(URLName);
if (NS_FAILED(res)) return PR_FALSE;
/* uri is of the form <scheme>://<username>:<password>@<host>:<portnumber>/<pathname>) */
/* get host part of the uri */
res = uri->GetHost(getter_Copies(host));
if (NS_FAILED(res)) {
return PR_FALSE;
}
/* if no username given, extract it from uri -- note: prehost is <username>:<password> */
if (userName.Length() == 0) {
nsXPIDLCString userName2;
res = uri->GetPreHost(getter_Copies(userName2));
if (NS_FAILED(res)) {
return PR_FALSE;
}
if ((const char *)userName2 && (PL_strlen((const char *)userName2))) {
userName = nsAutoString((const char *)userName2);
PRInt32 colon = userName.FindChar(':');
if (colon != -1) {
userName.Truncate(colon);
}
}
}
}
} else {
res = MangleUrl(URLName, getter_Copies(host));
if (NS_FAILED(res)) return PR_FALSE;
}
si_RememberSignonDataFromBrowser ((const char *)host, userName, nsAutoString(password));
return PR_TRUE;
}
/* The following comments apply to the three prompt routines that follow
*
* If a password was successfully obtain (either from the single-signon

Просмотреть файл

@ -65,6 +65,10 @@ extern PRBool
SINGSIGN_RemoveUser
(const char *URLName, const PRUnichar *userName, PRBool strip);
extern PRBool
SINGSIGN_StorePassword
(const char *URLName, const PRUnichar *userName, const PRUnichar *password, PRBool strip);
extern nsresult
SINGSIGN_HaveData(const char *url, const PRUnichar *userName, PRBool strip, PRBool *retval);

Просмотреть файл

@ -44,7 +44,6 @@ Rights Reserved.
</html:div>
</box>
<spring class="spacer"/>
<!-- not doing remember password in the wizard for beta 1
<box align="vertical">
<html:div class="title">&passwordTitle.label;</html:div>
<html:div>&savePasswordDesc.label;</html:div>
@ -66,5 +65,4 @@ Rights Reserved.
</html:div>
</html:div>
</box>
-->
</window>

Просмотреть файл

@ -541,6 +541,17 @@ nsMsgIncomingServer::ToString(PRUnichar** aResult) {
NS_IMETHODIMP nsMsgIncomingServer::SetPassword(const char * aPassword)
{
m_password = aPassword;
nsresult rv;
PRBool rememberPassword = PR_FALSE;
rv = GetRememberPassword(&rememberPassword);
if (NS_FAILED(rv)) return rv;
if (rememberPassword) {
rv = StorePassword();
if (NS_FAILED(rv)) return rv;
}
return NS_OK;
}
@ -619,6 +630,27 @@ nsMsgIncomingServer::GetPasswordWithUI(const PRUnichar * aPromptMessage, const
return rv;
}
nsresult
nsMsgIncomingServer::StorePassword()
{
nsresult rv;
nsXPIDLCString pwd;
rv = GetPassword(getter_Copies(pwd));
if (NS_FAILED(rv)) return rv;
NS_WITH_SERVICE(nsIWalletService, walletservice, kWalletServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
nsXPIDLCString serverUri;
rv = GetServerURI(getter_Copies(serverUri));
if (NS_FAILED(rv)) return rv;
nsAutoString password = pwd;
rv = walletservice->SI_StorePassword((const char *)serverUri, PR_FALSE, nsnull, password.GetUnicode());
return rv;
}
NS_IMETHODIMP
nsMsgIncomingServer::ForgetPassword()
{
@ -716,8 +748,12 @@ nsMsgIncomingServer::SetLocalPath(nsIFileSpec *spec)
NS_IMETHODIMP
nsMsgIncomingServer::SetRememberPassword(PRBool value)
{
if (!value)
if (!value) {
ForgetPassword();
}
else {
StorePassword();
}
return SetBoolValue("remember_password", value);
}

Просмотреть файл

@ -72,6 +72,7 @@ protected:
nsresult getDefaultIntPref(const char *pref, PRInt32 *);
nsresult CreateRootFolder();
nsresult StorePassword(); // stuff the password in the single signon database
// pref callback to clear the user prefs
static void clearPrefEnum(const char *aPref, void *aClosure);