diff --git a/caps/idl/nsIPrincipal.idl b/caps/idl/nsIPrincipal.idl index cfc2bac4dfaa..646a7139f128 100644 --- a/caps/idl/nsIPrincipal.idl +++ b/caps/idl/nsIPrincipal.idl @@ -52,7 +52,7 @@ interface nsIContentSecurityPolicy; [ptr] native JSContext(JSContext); [ptr] native JSPrincipals(JSPrincipals); -[scriptable, uuid(f8c4c89a-d726-421b-8415-3e34b241175b)] +[scriptable, uuid(fb783979-b3f8-4e0d-980f-f0f83b0f505d)] interface nsIPrincipal : nsISerializable { /** @@ -115,8 +115,6 @@ interface nsIPrincipal : nsISerializable // XXXbz again, what if this lives in our hashtable and someone // messes with it? Is that OK? [noscript] short canEnableCapability(in string capability); - [noscript] void setCanEnableCapability(in string capability, - in short canEnable); [noscript] boolean isCapabilityEnabled(in string capability, in voidPtr annotation); [noscript] void enableCapability(in string capability, diff --git a/caps/idl/nsIScriptSecurityManager.idl b/caps/idl/nsIScriptSecurityManager.idl index b35e797ce7ee..4af2d6f39242 100644 --- a/caps/idl/nsIScriptSecurityManager.idl +++ b/caps/idl/nsIScriptSecurityManager.idl @@ -41,7 +41,7 @@ interface nsIURI; interface nsIChannel; -[scriptable, uuid(50eda256-4dd2-4c7c-baed-96983910af9f)] +[scriptable, uuid(d6cf287a-476a-43ba-aa03-70af4a01044e)] interface nsIScriptSecurityManager : nsIXPCSecurityManager { ///////////////// Security Checks ////////////////// @@ -245,12 +245,6 @@ interface nsIScriptSecurityManager : nsIXPCSecurityManager * Allow 'certificateID' to enable 'capability.' Can only be performed * by code signed by the system certificate. */ - // XXXbz Capabilities can't have non-ascii chars? - // XXXbz ideally we'd pass a subjectName here too, and the nsISupports - // cert we're enabling for... - void setCanEnableCapability(in AUTF8String certificateFingerprint, - in string capability, - in short canEnable); /////////////////////// /** diff --git a/caps/include/nsPrincipal.h b/caps/include/nsPrincipal.h index 1542dc6ba7de..6742a22ff082 100644 --- a/caps/include/nsPrincipal.h +++ b/caps/include/nsPrincipal.h @@ -107,6 +107,9 @@ public: #endif protected: + // Formerly an IDL method. Now just a protected helper. + nsresult SetCanEnableCapability(const char *capability, PRInt16 canEnable); + nsTArray< nsAutoPtr > mAnnotations; nsHashtable* mCapabilities; nsCString mPrefName; diff --git a/caps/include/nsScriptSecurityManager.h b/caps/include/nsScriptSecurityManager.h index acbeceb16f13..05603beae5eb 100644 --- a/caps/include/nsScriptSecurityManager.h +++ b/caps/include/nsScriptSecurityManager.h @@ -526,9 +526,6 @@ private: static void FormatCapabilityString(nsAString& aCapability); - nsresult - SavePrincipal(nsIPrincipal* aToSave); - /** * Check capability levels for an |aObj| that implements * nsISecurityCheckedComponent. diff --git a/caps/src/nsNullPrincipal.cpp b/caps/src/nsNullPrincipal.cpp index 8f69ade01b5f..77d5f204b409 100644 --- a/caps/src/nsNullPrincipal.cpp +++ b/caps/src/nsNullPrincipal.cpp @@ -220,14 +220,6 @@ nsNullPrincipal::CanEnableCapability(const char *aCapability, return NS_OK; } -NS_IMETHODIMP -nsNullPrincipal::SetCanEnableCapability(const char *aCapability, - PRInt16 aCanEnable) -{ - return NS_ERROR_NOT_AVAILABLE; -} - - NS_IMETHODIMP nsNullPrincipal::IsCapabilityEnabled(const char *aCapability, void *aAnnotation, diff --git a/caps/src/nsPrincipal.cpp b/caps/src/nsPrincipal.cpp index 0d84720d1127..f387c8122ffe 100644 --- a/caps/src/nsPrincipal.cpp +++ b/caps/src/nsPrincipal.cpp @@ -542,7 +542,7 @@ nsPrincipal::CanEnableCapability(const char *capability, PRInt16 *result) return NS_OK; } -NS_IMETHODIMP +nsresult nsPrincipal::SetCanEnableCapability(const char *capability, PRInt16 canEnable) { diff --git a/caps/src/nsScriptSecurityManager.cpp b/caps/src/nsScriptSecurityManager.cpp index f83cc3b0b13f..1381fac84c6e 100644 --- a/caps/src/nsScriptSecurityManager.cpp +++ b/caps/src/nsScriptSecurityManager.cpp @@ -2536,64 +2536,6 @@ nsScriptSecurityManager::doGetObjectPrincipal(JSObject *aObj return result; } -nsresult -nsScriptSecurityManager::SavePrincipal(nsIPrincipal* aToSave) -{ - //-- Save to mPrincipals - mPrincipals.Put(aToSave, aToSave); - - //-- Save to prefs - nsXPIDLCString idPrefName; - nsXPIDLCString id; - nsXPIDLCString subjectName; - nsXPIDLCString grantedList; - nsXPIDLCString deniedList; - bool isTrusted; - nsresult rv = aToSave->GetPreferences(getter_Copies(idPrefName), - getter_Copies(id), - getter_Copies(subjectName), - getter_Copies(grantedList), - getter_Copies(deniedList), - &isTrusted); - if (NS_FAILED(rv)) return NS_ERROR_FAILURE; - - nsCAutoString grantedPrefName; - nsCAutoString deniedPrefName; - nsCAutoString subjectNamePrefName; - rv = GetPrincipalPrefNames( idPrefName, - grantedPrefName, - deniedPrefName, - subjectNamePrefName ); - if (NS_FAILED(rv)) return NS_ERROR_FAILURE; - - mIsWritingPrefs = true; - if (grantedList) { - Preferences::SetCString(grantedPrefName.get(), grantedList); - } else { - Preferences::ClearUser(grantedPrefName.get()); - } - - if (deniedList) { - Preferences::SetCString(deniedPrefName.get(), deniedList); - } else { - Preferences::ClearUser(deniedPrefName.get()); - } - - if (grantedList || deniedList) { - Preferences::SetCString(idPrefName, id); - Preferences::SetCString(subjectNamePrefName.get(), subjectName); - } else { - Preferences::ClearUser(idPrefName); - Preferences::ClearUser(subjectNamePrefName.get()); - } - - mIsWritingPrefs = false; - - nsIPrefService* prefService = Preferences::GetService(); - NS_ENSURE_TRUE(prefService, NS_ERROR_FAILURE); - return prefService->SavePrefFile(nsnull); -} - ///////////////// Capabilities API ///////////////////// NS_IMETHODIMP nsScriptSecurityManager::IsCapabilityEnabled(const char *capability, @@ -2864,71 +2806,6 @@ nsScriptSecurityManager::DisableCapability(const char *capability) return NS_OK; } -//////////////// Master Certificate Functions /////////////////////////////////////// -NS_IMETHODIMP -nsScriptSecurityManager::SetCanEnableCapability(const nsACString& certFingerprint, - const char* capability, - PRInt16 canEnable) -{ - NS_ENSURE_ARG(!certFingerprint.IsEmpty()); - - nsresult rv; - nsIPrincipal* subjectPrincipal = doGetSubjectPrincipal(&rv); - if (NS_FAILED(rv)) - return rv; - - //-- Get the system certificate - if (!mSystemCertificate) - { - nsCOMPtr systemCertFile; - nsCOMPtr directoryService = - do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv); - if (!directoryService) return NS_ERROR_FAILURE; - rv = directoryService->Get(NS_XPCOM_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile), - getter_AddRefs(systemCertFile)); - if (NS_FAILED(rv)) return NS_ERROR_FAILURE; - systemCertFile->AppendNative(NS_LITERAL_CSTRING("systemSignature.jar")); - if (NS_FAILED(rv)) return NS_ERROR_FAILURE; - nsCOMPtr systemCertZip = do_CreateInstance(kZipReaderCID, &rv); - if (NS_FAILED(rv)) return NS_ERROR_FAILURE; - rv = systemCertZip->Open(systemCertFile); - if (NS_SUCCEEDED(rv)) - { - rv = systemCertZip->GetCertificatePrincipal(EmptyCString(), - getter_AddRefs(mSystemCertificate)); - if (NS_FAILED(rv)) return NS_ERROR_FAILURE; - } - } - - //-- Make sure the caller's principal is the system certificate - bool isEqual = false; - if (mSystemCertificate) - { - rv = mSystemCertificate->Equals(subjectPrincipal, &isEqual); - if (NS_FAILED(rv)) return NS_ERROR_FAILURE; - } - if (!isEqual) - { - JSContext* cx = GetCurrentJSContext(); - if (!cx) return NS_ERROR_FAILURE; - static const char msg1[] = "Only code signed by the system certificate may call SetCanEnableCapability or Invalidate"; - static const char msg2[] = "Attempt to call SetCanEnableCapability or Invalidate when no system certificate has been established"; - SetPendingException(cx, mSystemCertificate ? msg1 : msg2); - return NS_ERROR_FAILURE; - } - - //-- Get the target principal - nsCOMPtr objectPrincipal; - rv = DoGetCertificatePrincipal(certFingerprint, EmptyCString(), - EmptyCString(), nsnull, - nsnull, false, - getter_AddRefs(objectPrincipal)); - if (NS_FAILED(rv)) return NS_ERROR_FAILURE; - rv = objectPrincipal->SetCanEnableCapability(capability, canEnable); - if (NS_FAILED(rv)) return NS_ERROR_FAILURE; - return SavePrincipal(objectPrincipal); -} - //////////////////////////////////////////////// // Methods implementing nsIXPCSecurityManager // //////////////////////////////////////////////// diff --git a/caps/src/nsSystemPrincipal.cpp b/caps/src/nsSystemPrincipal.cpp index 2b3f5b499bca..6840a5f18ccd 100644 --- a/caps/src/nsSystemPrincipal.cpp +++ b/caps/src/nsSystemPrincipal.cpp @@ -167,14 +167,6 @@ nsSystemPrincipal::CanEnableCapability(const char *capability, return NS_OK; } -NS_IMETHODIMP -nsSystemPrincipal::SetCanEnableCapability(const char *capability, - PRInt16 canEnable) -{ - return NS_ERROR_FAILURE; -} - - NS_IMETHODIMP nsSystemPrincipal::IsCapabilityEnabled(const char *capability, void *annotation, diff --git a/ipc/testshell/XPCShellEnvironment.cpp b/ipc/testshell/XPCShellEnvironment.cpp index a7062f717c87..ae9c1e0b84c7 100644 --- a/ipc/testshell/XPCShellEnvironment.cpp +++ b/ipc/testshell/XPCShellEnvironment.cpp @@ -872,14 +872,6 @@ FullTrustSecMan::DisableCapability(const char *capability) return NS_OK; } -NS_IMETHODIMP -FullTrustSecMan::SetCanEnableCapability(const nsACString & certificateFingerprint, - const char *capability, - PRInt16 canEnable) -{ - return NS_OK; -} - NS_IMETHODIMP FullTrustSecMan::GetObjectPrincipal(JSContext * cx, JSObject * obj, diff --git a/js/xpconnect/shell/xpcshell.cpp b/js/xpconnect/shell/xpcshell.cpp index 2b97f5fcb4de..2045c68443e0 100644 --- a/js/xpconnect/shell/xpcshell.cpp +++ b/js/xpconnect/shell/xpcshell.cpp @@ -1521,15 +1521,6 @@ FullTrustSecMan::DisableCapability(const char *capability) return NS_OK; } -/* void setCanEnableCapability (in AUTF8String certificateFingerprint, in string capability, in short canEnable); */ -NS_IMETHODIMP -FullTrustSecMan::SetCanEnableCapability(const nsACString & certificateFingerprint, - const char *capability, - PRInt16 canEnable) -{ - return NS_OK; -} - /* [noscript] nsIPrincipal getObjectPrincipal (in JSContextPtr cx, in JSObjectPtr obj); */ NS_IMETHODIMP FullTrustSecMan::GetObjectPrincipal(JSContext * cx, JSObject * obj,