Pass interfaces to certs to the SSL dialogs through the new

nsIPKIParamBlock interface.

Clean up some inconsistencies in nsPKIParamBlock implementation.
This commit is contained in:
javi%netscape.com 2001-03-12 23:59:48 +00:00
Родитель 2bb54a9dae
Коммит 4eeba2b1f4
5 изменённых файлов: 27 добавлений и 24 удалений

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

@ -22,21 +22,23 @@
*/
const nsIDialogParamBlock = Components.interfaces.nsIDialogParamBlock;
const nsIPKIParamBlock = Components.interfaces.nsIPKIParamBlock;
const nsIX509Cert = Components.interfaces.nsIX509Cert;
var params;
function onLoad()
{
params = window.arguments[0].QueryInterface(nsIDialogParamBlock);
params = window.arguments[0].QueryInterface(nsIPKIParamBlock);
var connectURL = params.GetString(1);
var certURL = params.GetString(2);
var isupport = params.getISupportAtIndex(1);
var cert = isupport.QueryInterface(nsIX509Cert);
var bundle = srGetStrBundle("chrome://pippki/locale/pippki.properties");
var message1 = bundle.formatStringFromName("mismatchDomainMsg1",
[ connectURL, certURL ],
[ connectURL, cert.commonName ],
2);
var message2 = bundle.formatStringFromName("mismatchDomainMsg2",
[ connectURL ],

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

@ -22,25 +22,27 @@
*/
const nsIDialogParamBlock = Components.interfaces.nsIDialogParamBlock;
const nsIPKIParamBlock = Components.interfaces.nsIPKIParamBlock;
const nsIX509Cert = Components.interfaces.nsIX509Cert;
var params;
function onLoad()
{
params = window.arguments[0].QueryInterface(nsIDialogParamBlock);
serverName = params.GetString(1);
params = window.arguments[0].QueryInterface(nsIPKIParamBlock);
var isupport = params.getISupportAtIndex(1);
var cert = isupport.QueryInterface(nsIX509Cert);
var bundle = srGetStrBundle("chrome://pippki/locale/newserver.properties");
var gBundleBrand = srGetStrBundle("chrome://global/locale/brand.properties");
var brandName = gBundleBrand.GetStringFromName("brandShortName");
var message1 = bundle.formatStringFromName("newServerMessage1",
[ serverName, brandName ],
[ cert.commonName, brandName ],
2);
var message4 = bundle.formatStringFromName("newServerMessage4",
[ serverName ],
[ cert.commonName ],
1);
setText("message1", message1);
setText("message4", message4);

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

@ -22,14 +22,14 @@
*/
const nsIDialogParamBlock = Components.interfaces.nsIDialogParamBlock;
const nsIPKIParamBlock = Components.interfaces.nsIPKIParamBlock;
const nsIX509Cert = Components.interfaces.nsIX509Cert;
var params;
function onLoad()
{
params = window.arguments[0].QueryInterface(nsIDialogParamBlock);
params = window.arguments[0].QueryInterface(nsIPKIParamBlock);
var bundle = srGetStrBundle("chrome://pippki/locale/pippki.properties");
var message1 = params.GetString(1);

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

@ -281,10 +281,7 @@ nsNSSDialogs::UnknownIssuer(nsITransportSecurityInfo *socketInfo,
return NS_ERROR_FAILURE;
nsXPIDLString commonName;
rv = cert->GetCommonName(getter_Copies(commonName));
if (NS_FAILED(rv))
return rv;
rv = block->SetString(1, commonName);
rv = block->SetISupportAtIndex(1, cert);
if (NS_FAILED(rv))
return rv;
@ -344,15 +341,11 @@ nsNSSDialogs::MismatchDomain(nsITransportSecurityInfo *socketInfo,
if (!block)
return NS_ERROR_FAILURE;
nsXPIDLString commonName;
rv = cert->GetCommonName(getter_Copies(commonName));
if (NS_FAILED(rv))
return rv;
rv = block->SetString(1, targetURL);
if (NS_FAILED(rv))
return rv;
block->SetString(2, commonName);
rv = block->SetISupportAtIndex(1, cert);
if (NS_FAILED(rv))
return rv;
@ -436,6 +429,10 @@ nsNSSDialogs::CertExpired(nsITransportSecurityInfo *socketInfo,
rv = block->SetString(1,message1);
if (NS_FAILED(rv))
return rv;
rv = block->SetISupportAtIndex(1, cert);
if (NS_FAILED(rv))
return rv;

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

@ -115,6 +115,7 @@ nsPKIParamBlock::SetNumberISupports(PRInt32 numISupports)
mNumISupports = 0;
return NS_ERROR_OUT_OF_MEMORY;
}
memset(mSupports, 0, sizeof(nsISupports*)*mNumISupports);
return NS_OK;
}
@ -128,13 +129,14 @@ nsPKIParamBlock::SetISupportAtIndex(PRInt32 index, nsISupports *object)
if (mSupports == nsnull) {
return NS_ERROR_OUT_OF_MEMORY;
}
memset(mSupports, 0, sizeof(nsISupports*)*mNumISupports);
}
nsresult rv = InBounds(index, mNumISupports);
if (rv != NS_OK)
return rv;
mSupports[index-1] = object;
NS_ADDREF(mSupports[index-1]);
mSupports[index] = object;
NS_IF_ADDREF(mSupports[index]);
return NS_OK;
}
@ -147,7 +149,7 @@ nsPKIParamBlock::GetISupportAtIndex(PRInt32 index, nsISupports **_retval)
if (rv != NS_OK)
return rv;
*_retval = mSupports[index-1];
*_retval = mSupports[index];
NS_IF_ADDREF(*_retval);
return NS_OK;
}