2002-02-20 08:51:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2001-09-25 05:03:58 +04:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
1999-08-20 13:51:02 +04:00
|
|
|
*
|
2001-09-25 05:03:58 +04:00
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.1 (the "License"); you may not use this file except in
|
|
|
|
* compliance with the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/NPL/
|
1999-08-20 13:51:02 +04:00
|
|
|
*
|
2001-09-25 05:03:58 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1999-08-20 13:51:02 +04:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2001-09-25 05:03:58 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:43:54 +03:00
|
|
|
*
|
2001-09-25 05:03:58 +04:00
|
|
|
* Contributor(s):
|
2002-02-13 07:20:46 +03:00
|
|
|
* Norris Boyd <nboyd@atg.com>
|
|
|
|
* Mitch Stoltz <mstoltz@netscape.com>
|
2003-07-24 09:15:20 +04:00
|
|
|
* Christopher A. Aillon <christopher@aillon.com>
|
2001-09-25 05:03:58 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2000-02-10 07:56:56 +03:00
|
|
|
|
2003-07-24 09:15:20 +04:00
|
|
|
#ifndef nsScriptSecurityManager_h__
|
|
|
|
#define nsScriptSecurityManager_h__
|
1999-08-20 13:51:02 +04:00
|
|
|
|
|
|
|
#include "nsIScriptSecurityManager.h"
|
|
|
|
#include "nsIPrincipal.h"
|
|
|
|
#include "jsapi.h"
|
2000-04-14 07:14:53 +04:00
|
|
|
#include "jsdbgapi.h"
|
1999-09-07 06:54:19 +04:00
|
|
|
#include "nsIXPCSecurityManager.h"
|
2003-07-24 09:15:20 +04:00
|
|
|
#include "nsInterfaceHashtable.h"
|
1999-11-12 01:10:36 +03:00
|
|
|
#include "nsHashtable.h"
|
2000-01-19 00:54:01 +03:00
|
|
|
#include "nsCOMPtr.h"
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
#include "nsIPrefService.h"
|
2000-07-26 08:53:01 +04:00
|
|
|
#include "nsISecurityPref.h"
|
2000-08-22 10:02:14 +04:00
|
|
|
#include "nsIJSContextStack.h"
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
#include "nsIObserver.h"
|
2002-02-13 07:20:46 +03:00
|
|
|
#include "pldhash.h"
|
2002-05-15 22:55:21 +04:00
|
|
|
#include "plstr.h"
|
2000-08-22 10:02:14 +04:00
|
|
|
|
2001-03-23 07:22:56 +03:00
|
|
|
class nsIDocShell;
|
2001-04-17 05:21:44 +04:00
|
|
|
class nsString;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
class nsIClassInfo;
|
2003-07-24 09:15:20 +04:00
|
|
|
class nsIIOService;
|
|
|
|
class nsIXPConnect;
|
2001-08-07 07:59:29 +04:00
|
|
|
class nsSystemPrincipal;
|
2002-02-13 07:20:46 +03:00
|
|
|
struct ClassPolicy;
|
2001-03-23 07:22:56 +03:00
|
|
|
|
2003-07-24 09:15:20 +04:00
|
|
|
#if defined(DEBUG_mstoltz) || defined(DEBUG_caillon)
|
|
|
|
#define DEBUG_CAPS_HACKER
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DEBUG_CAPS_HACKER
|
|
|
|
#define DEBUG_CAPS_CheckPropertyAccessImpl
|
|
|
|
#define DEBUG_CAPS_LookupPolicy
|
|
|
|
#define DEBUG_CAPS_CheckComponentPermissions
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
#define DEBUG_CAPS_CanCreateWrapper
|
|
|
|
#define DEBUG_CAPS_CanCreateInstance
|
|
|
|
#define DEBUG_CAPS_CanGetService
|
|
|
|
#endif
|
|
|
|
|
2000-03-21 07:05:35 +03:00
|
|
|
/////////////////////
|
2003-07-24 09:15:20 +04:00
|
|
|
// PrincipalKey //
|
2000-03-21 07:05:35 +03:00
|
|
|
/////////////////////
|
|
|
|
|
2003-07-24 09:15:20 +04:00
|
|
|
class NS_COM PrincipalKey : public PLDHashEntryHdr
|
|
|
|
{
|
2000-03-21 07:05:35 +03:00
|
|
|
public:
|
2003-07-24 09:15:20 +04:00
|
|
|
typedef const nsIPrincipal* KeyType;
|
|
|
|
typedef const nsIPrincipal* KeyTypePointer;
|
|
|
|
|
|
|
|
PrincipalKey(const nsIPrincipal* key)
|
|
|
|
: mKey(NS_CONST_CAST(nsIPrincipal*, key))
|
|
|
|
{
|
2000-03-21 07:05:35 +03:00
|
|
|
}
|
2003-07-24 09:15:20 +04:00
|
|
|
|
|
|
|
PrincipalKey(const PrincipalKey& toCopy)
|
|
|
|
: mKey(toCopy.mKey)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~PrincipalKey()
|
|
|
|
{
|
2000-03-21 07:05:35 +03:00
|
|
|
}
|
2003-07-24 09:15:20 +04:00
|
|
|
|
|
|
|
KeyType GetKey() const
|
|
|
|
{
|
|
|
|
return mKey;
|
2000-03-21 07:05:35 +03:00
|
|
|
}
|
2003-07-24 09:15:20 +04:00
|
|
|
|
|
|
|
KeyTypePointer GetKeyPointer() const
|
|
|
|
{
|
|
|
|
return mKey;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool KeyEquals(KeyTypePointer aKey) const
|
|
|
|
{
|
2000-03-21 07:05:35 +03:00
|
|
|
PRBool eq;
|
2003-07-24 09:15:20 +04:00
|
|
|
mKey->Equals(NS_CONST_CAST(nsIPrincipal*, aKey),
|
|
|
|
&eq);
|
2000-03-21 07:05:35 +03:00
|
|
|
return eq;
|
|
|
|
}
|
2003-07-24 09:15:20 +04:00
|
|
|
|
|
|
|
static KeyTypePointer KeyToPointer(KeyType aKey)
|
|
|
|
{
|
|
|
|
return aKey;
|
2000-03-21 07:05:35 +03:00
|
|
|
}
|
|
|
|
|
2003-07-24 09:15:20 +04:00
|
|
|
static PLDHashNumber HashKey(KeyTypePointer aKey)
|
|
|
|
{
|
|
|
|
PRUint32 hash;
|
|
|
|
NS_CONST_CAST(nsIPrincipal*, aKey)->GetHashValue(&hash);
|
|
|
|
return PLDHashNumber(hash);
|
|
|
|
}
|
|
|
|
|
|
|
|
enum { ALLOW_MEMMOVE = PR_TRUE };
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsCOMPtr<nsIPrincipal> mKey;
|
2000-03-21 07:05:35 +03:00
|
|
|
};
|
|
|
|
|
2002-02-13 07:20:46 +03:00
|
|
|
////////////////////
|
|
|
|
// Policy Storage //
|
|
|
|
////////////////////
|
|
|
|
|
|
|
|
// Property Policy
|
|
|
|
union SecurityLevel
|
|
|
|
{
|
|
|
|
long level;
|
|
|
|
char* capability;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Security levels
|
|
|
|
// These values all have the low bit set (except UNDEFINED_ACCESS)
|
|
|
|
// to distinguish them from pointer values, because no pointer
|
|
|
|
// to allocated memory ever has the low bit set. A SecurityLevel
|
|
|
|
// contains either one of these constants or a pointer to a string
|
|
|
|
// representing the name of a capability.
|
|
|
|
|
|
|
|
#define SCRIPT_SECURITY_UNDEFINED_ACCESS 0
|
|
|
|
#define SCRIPT_SECURITY_ACCESS_IS_SET_BIT 1
|
|
|
|
#define SCRIPT_SECURITY_NO_ACCESS \
|
|
|
|
((1 << 0) | SCRIPT_SECURITY_ACCESS_IS_SET_BIT)
|
|
|
|
#define SCRIPT_SECURITY_SAME_ORIGIN_ACCESS \
|
|
|
|
((1 << 1) | SCRIPT_SECURITY_ACCESS_IS_SET_BIT)
|
|
|
|
#define SCRIPT_SECURITY_ALL_ACCESS \
|
|
|
|
((1 << 2) | SCRIPT_SECURITY_ACCESS_IS_SET_BIT)
|
|
|
|
|
|
|
|
#define SECURITY_ACCESS_LEVEL_FLAG(_sl) \
|
|
|
|
((_sl.level == 0) || \
|
|
|
|
(_sl.level & SCRIPT_SECURITY_ACCESS_IS_SET_BIT))
|
|
|
|
|
|
|
|
|
|
|
|
struct PropertyPolicy : public PLDHashEntryHdr
|
|
|
|
{
|
|
|
|
jsval key; // property name as jsval
|
|
|
|
SecurityLevel mGet;
|
|
|
|
SecurityLevel mSet;
|
|
|
|
};
|
|
|
|
|
|
|
|
PR_STATIC_CALLBACK(void)
|
|
|
|
InitPropertyPolicyEntry(PLDHashTable *table,
|
|
|
|
PLDHashEntryHdr *entry,
|
|
|
|
const void *key)
|
|
|
|
{
|
|
|
|
PropertyPolicy* pp = (PropertyPolicy*)entry;
|
|
|
|
pp->key = (jsval)key;
|
|
|
|
pp->mGet.level = SCRIPT_SECURITY_UNDEFINED_ACCESS;
|
|
|
|
pp->mSet.level = SCRIPT_SECURITY_UNDEFINED_ACCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
PR_STATIC_CALLBACK(void)
|
|
|
|
ClearPropertyPolicyEntry(PLDHashTable *table, PLDHashEntryHdr *entry)
|
|
|
|
{
|
|
|
|
PropertyPolicy* pp = (PropertyPolicy*)entry;
|
|
|
|
pp->key = JSVAL_VOID;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Class Policy
|
|
|
|
#define NO_POLICY_FOR_CLASS (ClassPolicy*)1
|
|
|
|
|
|
|
|
struct ClassPolicy : public PLDHashEntryHdr
|
|
|
|
{
|
|
|
|
char* key;
|
2002-03-20 08:53:46 +03:00
|
|
|
PLDHashTable* mPolicy;
|
2002-02-13 07:20:46 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
PR_STATIC_CALLBACK(PRBool)
|
|
|
|
MatchClassPolicyKey(PLDHashTable *table,
|
|
|
|
const PLDHashEntryHdr *entry,
|
|
|
|
const void *key)
|
|
|
|
{
|
|
|
|
ClassPolicy* cp = (ClassPolicy *)entry;
|
|
|
|
return (cp->key == (char*)key) || (PL_strcmp(cp->key, (char*)key) == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
PR_STATIC_CALLBACK(void)
|
|
|
|
ClearClassPolicyEntry(PLDHashTable *table, PLDHashEntryHdr *entry)
|
|
|
|
{
|
|
|
|
ClassPolicy* cp = (ClassPolicy *)entry;
|
|
|
|
if (cp->key)
|
|
|
|
{
|
|
|
|
PL_strfree(cp->key);
|
|
|
|
cp->key = nsnull;
|
|
|
|
}
|
2002-03-20 08:53:46 +03:00
|
|
|
PL_DHashTableDestroy(cp->mPolicy);
|
2002-02-13 07:20:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
PR_STATIC_CALLBACK(void)
|
|
|
|
InitClassPolicyEntry(PLDHashTable *table,
|
|
|
|
PLDHashEntryHdr *entry,
|
|
|
|
const void *key)
|
|
|
|
{
|
|
|
|
static PLDHashTableOps classPolicyOps =
|
|
|
|
{
|
|
|
|
PL_DHashAllocTable,
|
|
|
|
PL_DHashFreeTable,
|
|
|
|
PL_DHashGetKeyStub,
|
|
|
|
PL_DHashVoidPtrKeyStub,
|
|
|
|
PL_DHashMatchEntryStub,
|
|
|
|
PL_DHashMoveEntryStub,
|
|
|
|
ClearPropertyPolicyEntry,
|
|
|
|
PL_DHashFinalizeStub,
|
|
|
|
InitPropertyPolicyEntry
|
|
|
|
};
|
|
|
|
|
|
|
|
ClassPolicy* cp = (ClassPolicy*)entry;
|
|
|
|
cp->key = PL_strdup((const char*)key);
|
2002-03-20 08:53:46 +03:00
|
|
|
cp->mPolicy = PL_NewDHashTable(&classPolicyOps, nsnull,
|
|
|
|
sizeof(PropertyPolicy), 16);
|
|
|
|
NS_ASSERTION(cp->mPolicy, "Failed to create hashtable - out of memory?");
|
2002-02-13 07:20:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Domain Policy
|
|
|
|
class DomainPolicy : public PLDHashTable
|
|
|
|
{
|
|
|
|
public:
|
2003-06-26 04:18:43 +04:00
|
|
|
DomainPolicy() : mWildcardPolicy(nsnull),
|
|
|
|
mRefCount(0)
|
2002-02-13 07:20:46 +03:00
|
|
|
{
|
2003-07-24 09:15:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
PRBool Init()
|
|
|
|
{
|
|
|
|
static const PLDHashTableOps domainPolicyOps =
|
2002-02-13 07:20:46 +03:00
|
|
|
{
|
|
|
|
PL_DHashAllocTable,
|
|
|
|
PL_DHashFreeTable,
|
|
|
|
PL_DHashGetKeyStub,
|
|
|
|
PL_DHashStringKey,
|
|
|
|
MatchClassPolicyKey,
|
|
|
|
PL_DHashMoveEntryStub,
|
|
|
|
ClearClassPolicyEntry,
|
|
|
|
PL_DHashFinalizeStub,
|
|
|
|
InitClassPolicyEntry
|
|
|
|
};
|
|
|
|
|
2003-07-24 09:15:20 +04:00
|
|
|
return PL_DHashTableInit(this, &domainPolicyOps, nsnull,
|
|
|
|
sizeof(ClassPolicy), 16);
|
2002-02-13 07:20:46 +03:00
|
|
|
}
|
|
|
|
|
2002-03-10 03:41:08 +03:00
|
|
|
~DomainPolicy()
|
|
|
|
{
|
|
|
|
PL_DHashTableFinish(this);
|
|
|
|
}
|
|
|
|
|
2002-02-13 07:20:46 +03:00
|
|
|
void Hold()
|
|
|
|
{
|
|
|
|
mRefCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Drop()
|
|
|
|
{
|
|
|
|
if (--mRefCount == 0)
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
2003-06-26 04:18:43 +04:00
|
|
|
ClassPolicy* mWildcardPolicy;
|
|
|
|
|
2002-02-13 07:20:46 +03:00
|
|
|
private:
|
|
|
|
PRUint32 mRefCount;
|
|
|
|
};
|
|
|
|
|
|
|
|
/////////////////////////////
|
|
|
|
// nsScriptSecurityManager //
|
|
|
|
/////////////////////////////
|
1999-08-20 13:51:02 +04:00
|
|
|
#define NS_SCRIPTSECURITYMANAGER_CID \
|
|
|
|
{ 0x7ee2a4c0, 0x4b93, 0x17d3, \
|
|
|
|
{ 0xba, 0x18, 0x00, 0x60, 0xb0, 0xf1, 0x99, 0xa2 }}
|
|
|
|
|
2002-02-13 07:20:46 +03:00
|
|
|
class nsScriptSecurityManager : public nsIScriptSecurityManager,
|
|
|
|
public nsIObserver
|
1999-09-07 06:54:19 +04:00
|
|
|
{
|
1999-08-20 13:51:02 +04:00
|
|
|
public:
|
2002-02-13 07:20:46 +03:00
|
|
|
static void Shutdown();
|
1999-08-30 01:58:42 +04:00
|
|
|
|
|
|
|
NS_DEFINE_STATIC_CID_ACCESSOR(NS_SCRIPTSECURITYMANAGER_CID)
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSISCRIPTSECURITYMANAGER
|
1999-09-07 06:54:19 +04:00
|
|
|
NS_DECL_NSIXPCSECURITYMANAGER
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
NS_DECL_NSIOBSERVER
|
2001-04-17 05:21:44 +04:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
static nsScriptSecurityManager*
|
1999-08-30 01:58:42 +04:00
|
|
|
GetScriptSecurityManager();
|
2000-08-22 10:02:14 +04:00
|
|
|
|
2001-08-07 07:59:29 +04:00
|
|
|
static nsSystemPrincipal*
|
|
|
|
SystemPrincipalSingletonConstructor();
|
|
|
|
|
2002-02-13 07:20:46 +03:00
|
|
|
JSContext* GetCurrentJSContext();
|
|
|
|
|
|
|
|
JSContext* GetSafeJSContext();
|
2001-04-17 05:21:44 +04:00
|
|
|
|
2002-06-15 03:54:18 +04:00
|
|
|
static nsresult
|
|
|
|
SecurityCompareURIs(nsIURI* aSourceURI,
|
|
|
|
nsIURI* aTargetURI,
|
|
|
|
PRBool* result);
|
|
|
|
|
1999-08-20 13:51:02 +04:00
|
|
|
private:
|
2000-01-19 00:54:01 +03:00
|
|
|
|
2003-01-17 05:00:01 +03:00
|
|
|
// GetScriptSecurityManager is the only call that can make one
|
|
|
|
nsScriptSecurityManager();
|
|
|
|
virtual ~nsScriptSecurityManager();
|
|
|
|
|
2002-02-13 16:30:06 +03:00
|
|
|
static JSBool JS_DLL_CALLBACK
|
2003-03-06 22:40:14 +03:00
|
|
|
CheckObjectAccess(JSContext *cx, JSObject *obj,
|
|
|
|
jsval id, JSAccessMode mode,
|
|
|
|
jsval *vp);
|
2002-02-13 07:20:46 +03:00
|
|
|
|
2002-02-20 08:51:05 +03:00
|
|
|
static nsresult
|
|
|
|
doGetObjectPrincipal(JSContext *cx, JSObject *obj, nsIPrincipal **result);
|
2001-03-23 07:22:56 +03:00
|
|
|
|
2001-08-03 00:32:48 +04:00
|
|
|
nsresult
|
|
|
|
GetBaseURIScheme(nsIURI* aURI, char** aScheme);
|
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
static nsresult
|
2002-06-15 03:54:18 +04:00
|
|
|
ReportError(JSContext* cx, const nsAString& messageTag,
|
|
|
|
nsIURI* aSource, nsIURI* aTarget);
|
2001-01-27 04:42:20 +03:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
nsresult
|
|
|
|
GetRootDocShell(JSContext* cx, nsIDocShell **result);
|
1999-08-30 01:58:42 +04:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
nsresult
|
2002-02-13 07:20:46 +03:00
|
|
|
CheckPropertyAccessImpl(PRUint32 aAction,
|
|
|
|
nsIXPCNativeCallContext* aCallContext,
|
|
|
|
JSContext* cx, JSObject* aJSObject,
|
2001-05-19 04:33:51 +04:00
|
|
|
nsISupports* aObj, nsIURI* aTargetURI,
|
|
|
|
nsIClassInfo* aClassInfo,
|
2002-02-13 07:20:46 +03:00
|
|
|
const char* aClassName, jsval aProperty,
|
|
|
|
void** aCachedClassPolicy);
|
1999-08-30 01:58:42 +04:00
|
|
|
|
2003-06-19 03:48:57 +04:00
|
|
|
nsresult
|
|
|
|
CheckSameOriginPrincipalInternal(nsIPrincipal* aSubject,
|
|
|
|
nsIPrincipal* aObject,
|
|
|
|
PRBool aIsCheckConnect);
|
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
nsresult
|
2002-06-15 03:54:18 +04:00
|
|
|
CheckSameOriginDOMProp(nsIPrincipal* aSubject,
|
|
|
|
nsIPrincipal* aObject,
|
2003-05-29 03:22:36 +04:00
|
|
|
PRUint32 aAction,
|
|
|
|
PRBool aIsCheckConnect);
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
|
|
|
|
nsresult
|
2003-06-26 04:18:43 +04:00
|
|
|
LookupPolicy(nsIPrincipal* principal,
|
2003-06-26 07:27:01 +04:00
|
|
|
const char* aClassName, jsval aProperty,
|
2003-06-26 04:18:43 +04:00
|
|
|
PRUint32 aAction,
|
|
|
|
ClassPolicy** aCachedClassPolicy,
|
|
|
|
SecurityLevel* result);
|
1999-08-30 01:58:42 +04:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
nsresult
|
|
|
|
CreateCodebasePrincipal(nsIURI* aURI, nsIPrincipal** result);
|
|
|
|
|
|
|
|
nsresult
|
2002-03-20 08:53:46 +03:00
|
|
|
GetSubjectPrincipal(JSContext* cx, nsIPrincipal** result);
|
1999-09-01 04:54:35 +04:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
nsresult
|
|
|
|
GetFramePrincipal(JSContext* cx, JSStackFrame* fp, nsIPrincipal** result);
|
2000-04-14 07:14:53 +04:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
nsresult
|
|
|
|
GetScriptPrincipal(JSContext* cx, JSScript* script, nsIPrincipal** result);
|
2000-04-14 07:14:53 +04:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
nsresult
|
|
|
|
GetFunctionObjectPrincipal(JSContext* cx, JSObject* obj,
|
|
|
|
nsIPrincipal** result);
|
2000-04-14 07:14:53 +04:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
nsresult
|
2001-05-11 04:43:27 +04:00
|
|
|
GetPrincipalAndFrame(JSContext *cx,
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
nsIPrincipal** result,
|
|
|
|
JSStackFrame** frameResult);
|
|
|
|
|
2002-03-20 08:53:46 +03:00
|
|
|
static PRBool
|
|
|
|
CheckConfirmDialog(JSContext* cx, nsIPrincipal* aPrincipal, PRBool *checkValue);
|
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
nsresult
|
2000-04-26 07:50:07 +04:00
|
|
|
SavePrincipal(nsIPrincipal* aToSave);
|
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
nsresult
|
2001-08-14 04:18:58 +04:00
|
|
|
CheckXPCPermissions(nsISupports* aObj,
|
|
|
|
const char* aObjectSecurityLevel);
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
|
2003-01-17 05:00:01 +03:00
|
|
|
nsresult
|
|
|
|
Init();
|
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
nsresult
|
|
|
|
InitPrefs();
|
2000-11-30 08:32:08 +03:00
|
|
|
|
2000-05-16 07:40:51 +04:00
|
|
|
static nsresult
|
|
|
|
PrincipalPrefNames(const char* pref, char** grantedPref, char** deniedPref);
|
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
nsresult
|
2002-02-13 07:20:46 +03:00
|
|
|
InitPolicies();
|
|
|
|
|
|
|
|
nsresult
|
2002-03-20 08:53:46 +03:00
|
|
|
InitDomainPolicy(JSContext* cx, const char* aPolicyName,
|
2002-02-13 07:20:46 +03:00
|
|
|
DomainPolicy* aDomainPolicy);
|
1999-11-25 08:28:18 +03:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
nsresult
|
2001-08-03 00:32:48 +04:00
|
|
|
InitPrincipals(PRUint32 prefCount, const char** prefNames,
|
|
|
|
nsISecurityPref* securityPref);
|
2000-01-19 00:54:01 +03:00
|
|
|
|
2003-03-12 05:17:37 +03:00
|
|
|
#ifdef XPC_IDISPATCH_SUPPORT
|
|
|
|
// While this header is included outside of caps, this class isn't
|
|
|
|
// referenced so this should be fine.
|
|
|
|
nsresult
|
|
|
|
CheckComponentPermissions(JSContext *cx, const nsCID &aCID);
|
|
|
|
#endif
|
2003-07-24 09:15:20 +04:00
|
|
|
#ifdef DEBUG_CAPS_HACKER
|
2002-02-13 07:20:46 +03:00
|
|
|
void
|
|
|
|
PrintPolicyDB();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// JS strings we need to clean up on shutdown
|
|
|
|
static jsval sEnabledID;
|
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
inline void
|
2001-08-03 00:32:48 +04:00
|
|
|
JSEnabledPrefChanged(nsISecurityPref* aSecurityPref);
|
2000-01-06 03:59:18 +03:00
|
|
|
|
2003-07-24 09:15:20 +04:00
|
|
|
static const char sJSEnabledPrefName[];
|
|
|
|
static const char sJSMailEnabledPrefName[];
|
2000-02-10 07:56:56 +03:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
nsObjectHashtable* mOriginToPolicyMap;
|
2002-02-13 07:20:46 +03:00
|
|
|
DomainPolicy* mDefaultPolicy;
|
|
|
|
nsObjectHashtable* mCapabilities;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPrefBranch> mPrefBranch;
|
|
|
|
nsCOMPtr<nsISecurityPref> mSecurityPref;
|
2003-07-24 09:15:20 +04:00
|
|
|
nsCOMPtr<nsIPrincipal> mSystemPrincipal;
|
2000-04-26 07:50:07 +04:00
|
|
|
nsCOMPtr<nsIPrincipal> mSystemCertificate;
|
2003-07-24 09:15:20 +04:00
|
|
|
nsInterfaceHashtable<PrincipalKey, nsIPrincipal> mPrincipals;
|
2002-02-13 07:20:46 +03:00
|
|
|
nsCOMPtr<nsIThreadJSContextStack> mJSContextStack;
|
2003-07-24 09:15:20 +04:00
|
|
|
PRPackedBool mIsJavaScriptEnabled;
|
|
|
|
PRPackedBool mIsMailJavaScriptEnabled;
|
|
|
|
PRPackedBool mIsWritingPrefs;
|
|
|
|
PRPackedBool mPolicyPrefsChanged;
|
2003-03-12 05:17:37 +03:00
|
|
|
#ifdef XPC_IDISPATCH_SUPPORT
|
2003-07-24 09:15:20 +04:00
|
|
|
PRPackedBool mXPCDefaultGrantAll;
|
|
|
|
static const char sXPCDefaultGrantAllName[];
|
2003-03-12 05:17:37 +03:00
|
|
|
#endif
|
1999-10-29 02:09:03 +04:00
|
|
|
|
2003-07-24 09:15:20 +04:00
|
|
|
static nsIIOService* sIOService;
|
|
|
|
static nsIXPConnect* sXPConnect;
|
|
|
|
};
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
|
2003-07-24 09:15:20 +04:00
|
|
|
#endif // nsScriptSecurityManager_h__
|