2001-09-25 05:03:58 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 15:12:37 +04: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 04:54:35 +04:00
|
|
|
|
|
|
|
/* Defines the abstract interface for a principal. */
|
|
|
|
|
2001-07-31 23:05:34 +04:00
|
|
|
#include "nsISerializable.idl"
|
1999-09-01 04:54:35 +04:00
|
|
|
|
1999-08-20 13:51:02 +04:00
|
|
|
%{C++
|
2003-11-03 07:26:55 +03:00
|
|
|
struct JSContext;
|
1999-08-20 13:51:02 +04:00
|
|
|
struct JSPrincipals;
|
|
|
|
%}
|
|
|
|
|
2003-10-22 02:11:49 +04:00
|
|
|
interface nsIURI;
|
2010-01-23 00:38:21 +03:00
|
|
|
interface nsIContentSecurityPolicy;
|
2003-10-22 02:11:49 +04:00
|
|
|
|
2003-11-03 07:26:55 +03:00
|
|
|
[ptr] native JSContext(JSContext);
|
1999-08-20 13:51:02 +04:00
|
|
|
[ptr] native JSPrincipals(JSPrincipals);
|
1999-07-24 07:58:23 +04:00
|
|
|
|
2012-05-03 01:57:43 +04:00
|
|
|
[scriptable, uuid(42ba6a38-d619-49ab-8248-3d247e959d5e)]
|
2003-07-24 09:15:20 +04:00
|
|
|
interface nsIPrincipal : nsISerializable
|
|
|
|
{
|
2003-10-22 02:11:49 +04:00
|
|
|
/**
|
|
|
|
* Values of capabilities for each principal. Order is
|
|
|
|
* significant: if an operation is performed on a set
|
|
|
|
* of capabilities, the minimum is computed.
|
|
|
|
*/
|
2001-07-31 23:05:34 +04:00
|
|
|
const short ENABLE_DENIED = 1;
|
|
|
|
const short ENABLE_UNKNOWN = 2;
|
|
|
|
const short ENABLE_WITH_USER_PERMISSION = 3;
|
|
|
|
const short ENABLE_GRANTED = 4;
|
1999-11-12 01:10:36 +03:00
|
|
|
|
2003-10-22 02:11:49 +04:00
|
|
|
/**
|
|
|
|
* Returns the security preferences associated with this principal.
|
|
|
|
* prefBranch will be set to the pref branch to which these preferences
|
|
|
|
* pertain. id is a pseudo-unique identifier, pertaining to either the
|
2005-07-22 23:05:42 +04:00
|
|
|
* fingerprint or the origin. subjectName is a name that identifies the
|
|
|
|
* entity this principal represents (may be empty). grantedList and
|
|
|
|
* deniedList are space-separated lists of capabilities which were
|
2007-02-09 07:52:44 +03:00
|
|
|
* explicitly granted or denied by a pref. isTrusted is a boolean that
|
|
|
|
* indicates whether this is a codebaseTrusted certificate.
|
2003-10-22 02:11:49 +04:00
|
|
|
*/
|
2010-12-22 16:58:22 +03:00
|
|
|
void getPreferences(out string prefBranch, out string id,
|
|
|
|
out string subjectName, out string grantedList,
|
|
|
|
out string deniedList, out boolean isTrusted);
|
2000-04-26 07:50:07 +04:00
|
|
|
|
2003-10-22 02:11:49 +04:00
|
|
|
/**
|
|
|
|
* Returns whether the other principal is equivalent to this principal.
|
|
|
|
* Principals are considered equal if they are the same principal,
|
2005-07-22 23:05:42 +04:00
|
|
|
* they have the same origin, or have the same certificate fingerprint ID
|
2003-10-22 02:11:49 +04:00
|
|
|
*/
|
|
|
|
boolean equals(in nsIPrincipal other);
|
|
|
|
|
2011-05-19 15:31:54 +04:00
|
|
|
/**
|
|
|
|
* Like equals, but doesn't take document.domain changes into account.
|
|
|
|
*/
|
|
|
|
boolean equalsIgnoringDomain(in nsIPrincipal other);
|
|
|
|
|
2003-10-22 02:11:49 +04:00
|
|
|
/**
|
|
|
|
* Returns a hash value for the principal.
|
|
|
|
*/
|
2006-02-17 19:12:17 +03:00
|
|
|
[noscript] readonly attribute unsigned long hashValue;
|
2003-10-22 02:11:49 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The domain security policy of the principal.
|
|
|
|
*/
|
|
|
|
// XXXcaa should this be here? The script security manager is the only
|
|
|
|
// thing that should care about this. Wouldn't storing this data in one
|
|
|
|
// of the hashtables in nsScriptSecurityManager be better?
|
2005-07-22 23:05:42 +04:00
|
|
|
// XXXbz why is this writable? Who should have write access to this? What
|
|
|
|
// happens if this principal is in our hashtable and we pass it out of the
|
|
|
|
// security manager and someone writes to this field? Especially if they
|
|
|
|
// write garbage? If we need to give someone other than the security
|
|
|
|
// manager a way to set this (which I question, since it can increase the
|
|
|
|
// permissions of a page) it should be a |void clearSecurityPolicy()|
|
|
|
|
// method.
|
2006-02-17 19:12:17 +03:00
|
|
|
[noscript] attribute voidPtr securityPolicy;
|
2003-10-22 02:11:49 +04:00
|
|
|
|
|
|
|
// XXXcaa probably should be turned into {get|set}CapabilityFlags
|
2005-07-22 23:05:42 +04:00
|
|
|
// XXXbz again, what if this lives in our hashtable and someone
|
|
|
|
// messes with it? Is that OK?
|
2006-02-17 19:12:17 +03:00
|
|
|
[noscript] short canEnableCapability(in string capability);
|
|
|
|
[noscript] boolean isCapabilityEnabled(in string capability,
|
|
|
|
in voidPtr annotation);
|
|
|
|
[noscript] void enableCapability(in string capability,
|
|
|
|
inout voidPtr annotation);
|
2003-10-22 02:11:49 +04:00
|
|
|
/**
|
|
|
|
* The codebase URI to which this principal pertains. This is
|
|
|
|
* generally the document URI.
|
|
|
|
*/
|
2010-12-22 16:58:22 +03:00
|
|
|
readonly attribute nsIURI URI;
|
2003-10-22 02:11:49 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The domain URI to which this principal pertains.
|
|
|
|
* This is congruent with HTMLDocument.domain, and may be null.
|
|
|
|
* Setting this has no effect on the URI.
|
|
|
|
*/
|
2006-02-17 19:12:17 +03:00
|
|
|
[noscript] attribute nsIURI domain;
|
2003-10-22 02:11:49 +04:00
|
|
|
|
|
|
|
/**
|
2008-03-19 03:27:56 +03:00
|
|
|
* The origin of this principal's codebase URI.
|
|
|
|
* An origin is defined as: scheme + host + port.
|
2003-10-22 02:11:49 +04:00
|
|
|
*/
|
|
|
|
// XXXcaa this should probably be turned into an nsIURI.
|
|
|
|
// The system principal's origin should be some caps namespace
|
|
|
|
// with a chrome URI. All of chrome should probably be the same.
|
2010-12-22 16:58:22 +03:00
|
|
|
readonly attribute string origin;
|
2003-10-22 02:11:49 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether this principal is associated with a certificate.
|
|
|
|
*/
|
|
|
|
readonly attribute boolean hasCertificate;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The fingerprint ID of this principal's certificate.
|
|
|
|
* Throws if there is no certificate associated with this principal.
|
|
|
|
*/
|
|
|
|
// XXXcaa kaie says this may not be unique. We should probably
|
|
|
|
// consider using something else for this....
|
2005-07-22 23:05:42 +04:00
|
|
|
readonly attribute AUTF8String fingerprint;
|
2003-10-22 02:11:49 +04:00
|
|
|
|
|
|
|
/**
|
2005-07-22 23:05:42 +04:00
|
|
|
* The pretty name for the certificate. This sort of (but not really)
|
|
|
|
* identifies the subject of the certificate (the entity that stands behind
|
|
|
|
* the certificate). Note that this may be empty; prefer to get the
|
|
|
|
* certificate itself and get this information from it, since that may
|
|
|
|
* provide more information.
|
|
|
|
*
|
2003-10-22 02:11:49 +04:00
|
|
|
* Throws if there is no certificate associated with this principal.
|
|
|
|
*/
|
2005-07-22 23:05:42 +04:00
|
|
|
readonly attribute AUTF8String prettyName;
|
2005-07-09 03:26:36 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether the other principal is equal to or weaker than this
|
|
|
|
* principal. Principals are equal if they are the same object, they
|
|
|
|
* have the same origin, or they have the same certificate ID.
|
|
|
|
*
|
2006-04-03 02:00:08 +04:00
|
|
|
* Thus a principal always subsumes itself.
|
2005-07-09 03:26:36 +04:00
|
|
|
*
|
2006-04-03 02:00:08 +04:00
|
|
|
* The system principal subsumes itself and all other principals.
|
2005-07-09 03:26:36 +04:00
|
|
|
*
|
2006-04-03 02:00:08 +04:00
|
|
|
* A null principal (corresponding to an unknown, hence assumed minimally
|
|
|
|
* privileged, security context) is not equal to any other principal
|
|
|
|
* (including other null principals), and therefore does not subsume
|
|
|
|
* anything but itself.
|
2005-07-09 03:26:36 +04:00
|
|
|
*
|
|
|
|
* Both codebase and certificate principals are subsumed by the system
|
|
|
|
* principal, but no codebase or certificate principal yet subsumes any
|
|
|
|
* other codebase or certificate principal. This may change in a future
|
|
|
|
* release; note that nsIPrincipal is unfrozen, not slated to be frozen.
|
2006-04-03 02:00:08 +04:00
|
|
|
*
|
|
|
|
* XXXbz except see bug 147145!
|
|
|
|
*
|
|
|
|
* Note for the future: Perhaps we should consider a certificate principal
|
|
|
|
* for a given URI subsuming a codebase principal for the same URI? Not
|
|
|
|
* sure what the immediate benefit would be, but I think the setup could
|
|
|
|
* make some code (e.g. MaybeDowngradeToCodebase) clearer.
|
2005-07-09 03:26:36 +04:00
|
|
|
*/
|
2010-12-22 16:58:22 +03:00
|
|
|
boolean subsumes(in nsIPrincipal other);
|
2005-07-22 23:05:42 +04:00
|
|
|
|
2012-02-23 21:41:25 +04:00
|
|
|
/**
|
|
|
|
* Same as the previous method, subsumes(), but for codebase principals
|
|
|
|
* ignores changes to document.domain.
|
|
|
|
*/
|
|
|
|
boolean subsumesIgnoringDomain(in nsIPrincipal other);
|
|
|
|
|
2008-02-27 06:45:29 +03:00
|
|
|
/**
|
|
|
|
* Checks whether this principal is allowed to load the network resource
|
|
|
|
* located at the given URI under the same-origin policy. This means that
|
|
|
|
* codebase principals are only allowed to load resources from the same
|
|
|
|
* domain, the system principal is allowed to load anything, and null
|
|
|
|
* principals are not allowed to load anything.
|
|
|
|
*
|
|
|
|
* If the load is allowed this function does nothing. If the load is not
|
|
|
|
* allowed the function throws NS_ERROR_DOM_BAD_URI.
|
|
|
|
*
|
|
|
|
* NOTE: Other policies might override this, such as the Access-Control
|
|
|
|
* specification.
|
|
|
|
* NOTE: The 'domain' attribute has no effect on the behaviour of this
|
|
|
|
* function.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param uri The URI about to be loaded.
|
|
|
|
* @param report If true, will report a warning to the console service
|
|
|
|
* if the load is not allowed.
|
|
|
|
* @throws NS_ERROR_DOM_BAD_URI if the load is not allowed.
|
|
|
|
*/
|
2010-12-22 16:58:22 +03:00
|
|
|
void checkMayLoad(in nsIURI uri, in boolean report);
|
2008-02-27 06:45:29 +03:00
|
|
|
|
2005-07-22 23:05:42 +04:00
|
|
|
/**
|
|
|
|
* The subject name for the certificate. This actually identifies the
|
|
|
|
* subject of the certificate. This may well not be a string that would
|
|
|
|
* mean much to a typical user on its own (e.g. it may have a number of
|
|
|
|
* different names all concatenated together with some information on what
|
|
|
|
* they mean in between).
|
|
|
|
*
|
|
|
|
* Throws if there is no certificate associated with this principal.
|
|
|
|
*/
|
|
|
|
readonly attribute AUTF8String subjectName;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The certificate associated with this principal, if any. If there isn't
|
|
|
|
* one, this will return null. Getting this attribute never throws.
|
|
|
|
*/
|
|
|
|
readonly attribute nsISupports certificate;
|
2010-01-23 00:38:21 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A Content Security Policy associated with this principal.
|
|
|
|
*/
|
|
|
|
[noscript] attribute nsIContentSecurityPolicy csp;
|
1999-07-24 07:58:23 +04:00
|
|
|
};
|