зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset eea9639048b8, bug 326628 main patch, due to regression bug 494899
This commit is contained in:
Родитель
5a7f33d593
Коммит
48077de5cc
|
@ -332,6 +332,7 @@
|
|||
#include "nsIDOMXULCommandDispatcher.h"
|
||||
#include "nsIDOMCrypto.h"
|
||||
#include "nsIDOMCRMFObject.h"
|
||||
#include "nsIDOMPkcs11.h"
|
||||
#include "nsIControllers.h"
|
||||
#include "nsISelection.h"
|
||||
#include "nsIBoxObject.h"
|
||||
|
@ -858,6 +859,8 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
|||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(CRMFObject, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(Pkcs11, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
// DOM Traversal classes
|
||||
NS_DEFINE_CLASSINFO_DATA(TreeWalker, nsDOMGenericSH,
|
||||
|
@ -2645,6 +2648,10 @@ nsDOMClassInfo::Init()
|
|||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCRMFObject)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(Pkcs11, nsIDOMPkcs11)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMPkcs11)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(XMLStylesheetProcessingInstruction, nsIDOMProcessingInstruction)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMProcessingInstruction)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMLinkStyle)
|
||||
|
|
|
@ -189,6 +189,7 @@ enum nsDOMClassInfoID {
|
|||
// Crypto classes
|
||||
eDOMClassInfo_Crypto_id,
|
||||
eDOMClassInfo_CRMFObject_id,
|
||||
eDOMClassInfo_Pkcs11_id,
|
||||
|
||||
// DOM Traversal classes
|
||||
eDOMClassInfo_TreeWalker_id,
|
||||
|
|
|
@ -106,6 +106,7 @@
|
|||
#include "nsIDOMKeyEvent.h"
|
||||
#include "nsIDOMMessageEvent.h"
|
||||
#include "nsIDOMPopupBlockedEvent.h"
|
||||
#include "nsIDOMPkcs11.h"
|
||||
#include "nsIDOMOfflineResourceList.h"
|
||||
#include "nsIDOMGeoGeolocation.h"
|
||||
#include "nsDOMString.h"
|
||||
|
@ -2934,7 +2935,14 @@ nsGlobalWindow::GetCrypto(nsIDOMCrypto** aCrypto)
|
|||
NS_IMETHODIMP
|
||||
nsGlobalWindow::GetPkcs11(nsIDOMPkcs11** aPkcs11)
|
||||
{
|
||||
*aPkcs11 = nsnull;
|
||||
FORWARD_TO_OUTER(GetPkcs11, (aPkcs11), NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
if (!mPkcs11) {
|
||||
mPkcs11 = do_CreateInstance(kPkcs11ContractID);
|
||||
}
|
||||
|
||||
NS_IF_ADDREF(*aPkcs11 = mPkcs11);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -84,6 +84,7 @@
|
|||
#include "nsIEventListenerManager.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMCrypto.h"
|
||||
#include "nsIDOMPkcs11.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsPluginArray.h"
|
||||
#include "nsMimeTypeArray.h"
|
||||
|
@ -707,6 +708,7 @@ protected:
|
|||
nsGlobalWindowObserver* mObserver;
|
||||
|
||||
nsCOMPtr<nsIDOMCrypto> mCrypto;
|
||||
nsCOMPtr<nsIDOMPkcs11> mPkcs11;
|
||||
|
||||
nsCOMPtr<nsIDOMStorage2> mLocalStorage;
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ XPIDLSRCS = \
|
|||
nsIDOMMimeType.idl \
|
||||
nsIDOMMimeTypeArray.idl \
|
||||
nsIDOMNavigator.idl \
|
||||
nsIDOMPkcs11.idl \
|
||||
nsIDOMPlugin.idl \
|
||||
nsIDOMPluginArray.idl \
|
||||
nsIDOMScreen.idl \
|
||||
|
|
|
@ -38,12 +38,12 @@
|
|||
|
||||
#include "domstubs.idl"
|
||||
|
||||
[scriptable, uuid(bd6dbe50-b902-435e-90a4-4a10b1122440)]
|
||||
interface nsIPKCS11 : nsISupports
|
||||
[scriptable, uuid(9fd42950-25e7-11d4-8a7d-006008c844c3)]
|
||||
interface nsIDOMPkcs11 : nsISupports
|
||||
{
|
||||
void deleteModule(in DOMString moduleName);
|
||||
void addModule(in DOMString moduleName,
|
||||
in DOMString libraryFullPath,
|
||||
in long cryptoMechanismFlags,
|
||||
in long cipherFlags);
|
||||
long deletemodule(in DOMString moduleName);
|
||||
long addmodule(in DOMString moduleName,
|
||||
in DOMString libraryFullPath,
|
||||
in long cryptoMechanismFlags,
|
||||
in long cipherFlags);
|
||||
};
|
|
@ -71,7 +71,6 @@ XPIDLSRCS = \
|
|||
nsIX509Cert3.idl \
|
||||
nsIX509CertDB2.idl \
|
||||
nsIX509CertList.idl \
|
||||
nsIPKCS11.idl \
|
||||
nsIPKCS11Slot.idl \
|
||||
nsIPK11TokenDB.idl \
|
||||
nsICertPickDialogs.idl \
|
||||
|
|
|
@ -251,8 +251,9 @@ NS_IMPL_RELEASE(nsCRMFObject)
|
|||
|
||||
// QueryInterface implementation for nsPkcs11
|
||||
NS_INTERFACE_MAP_BEGIN(nsPkcs11)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIPKCS11)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMPkcs11)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Pkcs11)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_ADDREF(nsPkcs11)
|
||||
|
@ -2944,18 +2945,33 @@ confirm_user(const PRUnichar *message)
|
|||
|
||||
//Delete a PKCS11 module from the user's profile.
|
||||
NS_IMETHODIMP
|
||||
nsPkcs11::DeleteModule(const nsAString& aModuleName)
|
||||
nsPkcs11::Deletemodule(const nsAString& aModuleName, PRInt32* aReturn)
|
||||
{
|
||||
nsNSSShutDownPreventionLock locker;
|
||||
nsresult rv;
|
||||
nsString errorMessage;
|
||||
|
||||
nsCOMPtr<nsINSSComponent> nssComponent(do_GetService(kNSSComponentCID, &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (aModuleName.IsEmpty()) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
*aReturn = JS_ERR_BAD_MODULE_NAME;
|
||||
nssComponent->GetPIPNSSBundleString("DelModuleBadName", errorMessage);
|
||||
alertUser(errorMessage.get());
|
||||
return NS_OK;
|
||||
}
|
||||
nsString final;
|
||||
nsAutoString temp;
|
||||
//Make sure the user knows we're trying to do this.
|
||||
nssComponent->GetPIPNSSBundleString("DelModuleWarning", final);
|
||||
final.Append(NS_LITERAL_STRING("\n").get());
|
||||
PRUnichar *tempUni = ToNewUnicode(aModuleName);
|
||||
const PRUnichar *formatStrings[1] = { tempUni };
|
||||
rv = nssComponent->PIPBundleFormatStringFromName("AddModuleName",
|
||||
formatStrings, 1, temp);
|
||||
nsMemory::Free(tempUni);
|
||||
final.Append(temp);
|
||||
if (!confirm_user(final.get())) {
|
||||
*aReturn = JS_ERR_USER_CANCEL_ACTION;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
char *modName = ToNewCString(aModuleName);
|
||||
|
@ -2967,25 +2983,69 @@ nsPkcs11::DeleteModule(const nsAString& aModuleName)
|
|||
nssComponent->ShutdownSmartCardThread(module);
|
||||
SECMOD_DestroyModule(module);
|
||||
}
|
||||
rv = NS_OK;
|
||||
if (modType == SECMOD_EXTERNAL) {
|
||||
nssComponent->GetPIPNSSBundleString("DelModuleExtSuccess", errorMessage);
|
||||
*aReturn = JS_OK_DEL_EXTERNAL_MOD;
|
||||
} else {
|
||||
nssComponent->GetPIPNSSBundleString("DelModuleIntSuccess", errorMessage);
|
||||
*aReturn = JS_OK_DEL_INTERNAL_MOD;
|
||||
}
|
||||
} else {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
*aReturn = JS_ERR_DEL_MOD;
|
||||
nssComponent->GetPIPNSSBundleString("DelModuleError", errorMessage);
|
||||
}
|
||||
NS_Free(modName);
|
||||
return rv;
|
||||
alertUser(errorMessage.get());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//Add a new PKCS11 module to the user's profile.
|
||||
NS_IMETHODIMP
|
||||
nsPkcs11::AddModule(const nsAString& aModuleName,
|
||||
nsPkcs11::Addmodule(const nsAString& aModuleName,
|
||||
const nsAString& aLibraryFullPath,
|
||||
PRInt32 aCryptoMechanismFlags,
|
||||
PRInt32 aCipherFlags)
|
||||
PRInt32 aCipherFlags, PRInt32* aReturn)
|
||||
{
|
||||
nsNSSShutDownPreventionLock locker;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsINSSComponent> nssComponent(do_GetService(kNSSComponentCID, &rv));
|
||||
nsString final;
|
||||
nsAutoString temp;
|
||||
|
||||
rv = nssComponent->GetPIPNSSBundleString("AddModulePrompt", final);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
final.Append(NS_LITERAL_STRING("\n").get());
|
||||
|
||||
PRUnichar *tempUni = ToNewUnicode(aModuleName);
|
||||
const PRUnichar *formatStrings[1] = { tempUni };
|
||||
rv = nssComponent->PIPBundleFormatStringFromName("AddModuleName",
|
||||
formatStrings, 1, temp);
|
||||
nsMemory::Free(tempUni);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
final.Append(temp);
|
||||
final.Append(NS_LITERAL_STRING("\n").get());
|
||||
|
||||
tempUni = ToNewUnicode(aLibraryFullPath);
|
||||
formatStrings[0] = tempUni;
|
||||
rv = nssComponent->PIPBundleFormatStringFromName("AddModulePath",
|
||||
formatStrings, 1, temp);
|
||||
nsMemory::Free(tempUni);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
final.Append(temp);
|
||||
final.Append(NS_LITERAL_STRING("\n").get());
|
||||
|
||||
if (!confirm_user(final.get())) {
|
||||
// The user has canceled. So let's return now.
|
||||
*aReturn = JS_ERR_USER_CANCEL_ACTION;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
char *moduleName = ToNewCString(aModuleName);
|
||||
char *fullPath = ToNewCString(aLibraryFullPath);
|
||||
PRUint32 mechFlags = SECMOD_PubMechFlagstoInternal(aCryptoMechanismFlags);
|
||||
|
@ -3007,12 +3067,22 @@ nsPkcs11::AddModule(const nsAString& aModuleName,
|
|||
// what the return value for SEDMOD_AddNewModule is
|
||||
switch (srv) {
|
||||
case SECSuccess:
|
||||
return NS_OK;
|
||||
nssComponent->GetPIPNSSBundleString("AddModuleSuccess", final);
|
||||
*aReturn = JS_OK_ADD_MOD;
|
||||
break;
|
||||
case SECFailure:
|
||||
nssComponent->GetPIPNSSBundleString("AddModuleFailure", final);
|
||||
*aReturn = JS_ERR_ADD_MOD;
|
||||
break;
|
||||
case -2:
|
||||
nssComponent->GetPIPNSSBundleString("AddModuleDup", final);
|
||||
*aReturn = JS_ERR_ADD_DUPLICATE_MOD;
|
||||
break;
|
||||
default:
|
||||
NS_ASSERTION(0,"Bogus return value, this should never happen");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_ASSERTION(0,"Bogus return value, this should never happen");
|
||||
return NS_ERROR_FAILURE;
|
||||
alertUser(final.get());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsIDOMCRMFObject.h"
|
||||
#include "nsIDOMCrypto.h"
|
||||
#include "nsIPKCS11.h"
|
||||
#include "nsIDOMPkcs11.h"
|
||||
#include "nsIRunnable.h"
|
||||
#include "nsString.h"
|
||||
#include "jsapi.h"
|
||||
|
@ -95,14 +95,14 @@ private:
|
|||
PRBool mEnableSmartCardEvents;
|
||||
};
|
||||
|
||||
class nsPkcs11 : public nsIPKCS11
|
||||
class nsPkcs11 : public nsIDOMPkcs11
|
||||
{
|
||||
public:
|
||||
nsPkcs11();
|
||||
virtual ~nsPkcs11();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPKCS11
|
||||
NS_DECL_NSIDOMPKCS11
|
||||
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче