2001-09-25 01:03:58 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-09-01 00:54:35 +00:00
|
|
|
|
|
|
|
/* The privileged system principal. */
|
|
|
|
|
2001-08-14 07:59:59 +00:00
|
|
|
#include "nscore.h"
|
1999-09-01 00:54:35 +00:00
|
|
|
#include "nsSystemPrincipal.h"
|
|
|
|
#include "nsIComponentManager.h"
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIURL.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsXPIDLString.h"
|
2001-09-29 08:28:41 +00:00
|
|
|
#include "nsReadableUtils.h"
|
2002-05-15 18:55:21 +00:00
|
|
|
#include "nsCRT.h"
|
2003-10-21 22:11:49 +00:00
|
|
|
#include "nsString.h"
|
2006-03-15 04:59:42 +00:00
|
|
|
#include "nsIClassInfoImpl.h"
|
2012-07-20 05:44:03 +00:00
|
|
|
#include "nsIScriptSecurityManager.h"
|
2013-07-11 20:21:45 +00:00
|
|
|
#include "pratom.h"
|
1999-09-01 00:54:35 +00:00
|
|
|
|
2013-04-03 00:16:25 +00:00
|
|
|
NS_IMPL_CLASSINFO(nsSystemPrincipal, nullptr,
|
2010-06-22 16:59:57 +00:00
|
|
|
nsIClassInfo::SINGLETON | nsIClassInfo::MAIN_THREAD_ONLY,
|
|
|
|
NS_SYSTEMPRINCIPAL_CID)
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_QUERY_INTERFACE_CI(nsSystemPrincipal,
|
|
|
|
nsIPrincipal,
|
|
|
|
nsISerializable)
|
|
|
|
NS_IMPL_CI_INTERFACE_GETTER(nsSystemPrincipal,
|
2003-10-21 22:11:49 +00:00
|
|
|
nsIPrincipal,
|
|
|
|
nsISerializable)
|
1999-11-12 18:59:03 +00:00
|
|
|
|
2015-05-16 08:07:10 +00:00
|
|
|
#define SYSTEM_PRINCIPAL_SPEC "[System Principal]"
|
2012-03-09 09:48:50 +00:00
|
|
|
|
2016-08-30 04:22:04 +00:00
|
|
|
nsresult
|
2012-03-09 09:48:50 +00:00
|
|
|
nsSystemPrincipal::GetScriptLocation(nsACString &aStr)
|
|
|
|
{
|
2015-05-16 08:07:10 +00:00
|
|
|
aStr.AssignLiteral(SYSTEM_PRINCIPAL_SPEC);
|
2016-08-30 04:22:04 +00:00
|
|
|
return NS_OK;
|
2012-03-09 09:48:50 +00:00
|
|
|
}
|
|
|
|
|
2003-10-21 22:11:49 +00:00
|
|
|
///////////////////////////////////////
|
|
|
|
// Methods implementing nsIPrincipal //
|
|
|
|
///////////////////////////////////////
|
|
|
|
|
1999-09-01 00:54:35 +00:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSystemPrincipal::GetHashValue(uint32_t *result)
|
1999-09-01 00:54:35 +00:00
|
|
|
{
|
2001-08-14 07:59:59 +00:00
|
|
|
*result = NS_PTR_TO_INT32(this);
|
1999-09-01 00:54:35 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-10-21 22:11:49 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSystemPrincipal::GetURI(nsIURI** aURI)
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
*aURI = nullptr;
|
2003-10-21 22:11:49 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-05-14 23:50:44 +00:00
|
|
|
nsresult
|
|
|
|
nsSystemPrincipal::GetOriginInternal(nsACString& aOrigin)
|
2003-10-21 22:11:49 +00:00
|
|
|
{
|
2015-05-12 22:08:20 +00:00
|
|
|
aOrigin.AssignLiteral(SYSTEM_PRINCIPAL_SPEC);
|
|
|
|
return NS_OK;
|
2003-10-21 22:11:49 +00:00
|
|
|
}
|
|
|
|
|
2010-01-22 21:38:21 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSystemPrincipal::GetCsp(nsIContentSecurityPolicy** aCsp)
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
*aCsp = nullptr;
|
2010-01-22 21:38:21 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2016-01-14 21:21:31 +00:00
|
|
|
nsSystemPrincipal::EnsureCSP(nsIDOMDocument* aDocument,
|
|
|
|
nsIContentSecurityPolicy** aCSP)
|
2010-01-22 21:38:21 +00:00
|
|
|
{
|
2015-11-15 03:28:23 +00:00
|
|
|
// CSP on a system principal makes no sense
|
2016-05-21 17:36:24 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2015-11-15 03:28:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSystemPrincipal::GetPreloadCsp(nsIContentSecurityPolicy** aPreloadCSP)
|
|
|
|
{
|
|
|
|
*aPreloadCSP = nullptr;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2016-01-14 21:21:31 +00:00
|
|
|
nsSystemPrincipal::EnsurePreloadCSP(nsIDOMDocument* aDocument,
|
|
|
|
nsIContentSecurityPolicy** aPreloadCSP)
|
2015-11-15 03:28:23 +00:00
|
|
|
{
|
|
|
|
// CSP on a system principal makes no sense
|
2010-01-22 21:38:21 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-10-21 22:11:49 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSystemPrincipal::GetDomain(nsIURI** aDomain)
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
*aDomain = nullptr;
|
2003-10-21 22:11:49 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSystemPrincipal::SetDomain(nsIURI* aDomain)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-01-08 21:53:32 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSystemPrincipal::GetBaseDomain(nsACString& aBaseDomain)
|
|
|
|
{
|
|
|
|
// No base domain for chrome.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-07-31 19:05:34 +00:00
|
|
|
//////////////////////////////////////////
|
|
|
|
// Methods implementing nsISerializable //
|
|
|
|
//////////////////////////////////////////
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSystemPrincipal::Read(nsIObjectInputStream* aStream)
|
|
|
|
{
|
|
|
|
// no-op: CID is sufficient to identify the mSystemPrincipal singleton
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSystemPrincipal::Write(nsIObjectOutputStream* aStream)
|
|
|
|
{
|
|
|
|
// no-op: CID is sufficient to identify the mSystemPrincipal singleton
|
|
|
|
return NS_OK;
|
|
|
|
}
|