2001-09-25 01:03:58 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
1999-07-15 23:23:16 +00:00
|
|
|
*
|
2001-09-25 01:03:58 +00: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-07-15 23:23:16 +00:00
|
|
|
*
|
2001-09-25 01:03:58 +00: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-07-15 23:23:16 +00:00
|
|
|
*
|
1999-11-06 03:43:54 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2001-09-25 01:03:58 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1999
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:43:54 +00: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 16:46:42 +00:00
|
|
|
* Contributor(s):
|
2001-09-25 01:03:58 +00: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 ***** */
|
1999-07-15 23:23:16 +00:00
|
|
|
|
1999-09-07 20:40:20 +00:00
|
|
|
#include "nsISupports.idl"
|
1999-09-07 21:26:56 +00:00
|
|
|
#include "nsIPrincipal.idl"
|
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 16:46:42 +00:00
|
|
|
#include "nsIXPCSecurityManager.idl"
|
1999-07-15 23:23:16 +00:00
|
|
|
interface nsIURI;
|
|
|
|
|
2000-11-07 01:14:08 +00:00
|
|
|
[scriptable, uuid(58df5780-8006-11d2-bd91-00805f8ae3f4)]
|
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 16:46:42 +00:00
|
|
|
interface nsIScriptSecurityManager : nsIXPCSecurityManager
|
1999-07-15 23:23:16 +00: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 16:46:42 +00:00
|
|
|
///////////////// Security Checks //////////////////
|
|
|
|
/**
|
|
|
|
* Checks whether the running script is allowed to access aProperty.
|
|
|
|
*/
|
2001-05-19 00:33:51 +00:00
|
|
|
[noscript] void checkPropertyAccess(in JSContextPtr aJSContext,
|
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 16:46:42 +00:00
|
|
|
in JSObjectPtr aJSObject,
|
|
|
|
in string aClassName,
|
2002-02-13 04:20:46 +00:00
|
|
|
in JSVal aProperty,
|
2001-05-19 00:33:51 +00:00
|
|
|
in PRUint32 aAction);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks whether the running script is allowed to connect to aTargetURI
|
|
|
|
*/
|
|
|
|
[noscript] void checkConnect(in JSContextPtr aJSContext,
|
|
|
|
in nsIURI aTargetURI,
|
|
|
|
in string aClassName,
|
2002-02-13 04:20:46 +00:00
|
|
|
in string aProperty);
|
2000-02-23 22:34:40 +00:00
|
|
|
|
1999-09-15 04:05:43 +00: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 16:46:42 +00:00
|
|
|
* Check that the script currently running in context "cx" can load "uri".
|
1999-09-15 04:05:43 +00: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 16:46:42 +00:00
|
|
|
* Will return error code NS_ERROR_DOM_BAD_URI if the load request
|
|
|
|
* should be denied.
|
|
|
|
*
|
|
|
|
* @param cx the JSContext of the script causing the load
|
|
|
|
* @param uri the URI that is being loaded
|
|
|
|
*/
|
2001-03-02 00:09:20 +00:00
|
|
|
[noscript] void checkLoadURIFromScript(in JSContextPtr cx, in nsIURI uri);
|
1999-11-16 05:07:31 +00: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 16:46:42 +00:00
|
|
|
/**
|
2000-10-13 22:59:47 +00:00
|
|
|
* Default CheckLoadURI permissions
|
|
|
|
*/
|
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 16:46:42 +00:00
|
|
|
// Default permissions
|
2000-10-13 22:59:47 +00:00
|
|
|
const unsigned long STANDARD = 0;
|
|
|
|
|
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 16:46:42 +00:00
|
|
|
// If the source is mail, disallow the load
|
2000-10-13 22:59:47 +00:00
|
|
|
const unsigned long DISALLOW_FROM_MAIL = 1 << 0;
|
|
|
|
|
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 16:46:42 +00:00
|
|
|
// Allow the loading of chrome URLs by non-chrome URLs
|
2000-10-13 22:59:47 +00:00
|
|
|
const unsigned long ALLOW_CHROME = 1 << 1;
|
|
|
|
|
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 16:46:42 +00:00
|
|
|
/**
|
|
|
|
* Check that content from "from" can load "uri".
|
|
|
|
*
|
|
|
|
* Will return error code NS_ERROR_DOM_BAD_URI if the load request
|
|
|
|
* should be denied.
|
|
|
|
*
|
|
|
|
* @param from the URI causing the load
|
|
|
|
* @param uri the URI that is being loaded
|
|
|
|
* @param flags the permission set, see above
|
|
|
|
*/
|
2001-03-02 00:09:20 +00:00
|
|
|
void checkLoadURI(in nsIURI from, in nsIURI uri,
|
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 16:46:42 +00:00
|
|
|
in unsigned long flags);
|
1999-09-01 00:54:35 +00: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 16:46:42 +00:00
|
|
|
/**
|
|
|
|
* Same as CheckLoadURI but takes string arguments for ease of use
|
|
|
|
* by scripts
|
|
|
|
*/
|
2001-04-17 01:21:44 +00:00
|
|
|
void checkLoadURIStr(in string from, in string uri,
|
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 16:46:42 +00:00
|
|
|
in unsigned long flags);
|
2001-04-17 01:21:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check that the function 'funObj' is allowed to run on 'targetObj'
|
|
|
|
*
|
|
|
|
* Will return error code NS_ERROR_DOM_SECURITY_ERR if the function
|
|
|
|
* should not run
|
|
|
|
*
|
|
|
|
* @param cx The current active JavaScript context.
|
|
|
|
* @param funObj The function trying to run..
|
|
|
|
* @param targetObj The object the function will run on.
|
|
|
|
*/
|
2001-03-02 00:09:20 +00:00
|
|
|
[noscript] void checkFunctionAccess(in JSContextPtr cx, in voidPtr funObj,
|
2000-11-07 01:14:08 +00:00
|
|
|
in voidPtr targetObj);
|
2000-06-21 00:21:50 +00: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 16:46:42 +00:00
|
|
|
/**
|
|
|
|
* Return true if content from the given principal is allowed to
|
|
|
|
* execute scripts.
|
|
|
|
*/
|
|
|
|
[noscript] boolean canExecuteScripts(in JSContextPtr cx,
|
|
|
|
in nsIPrincipal principal);
|
1999-09-17 20:13:52 +00: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 16:46:42 +00:00
|
|
|
///////////////// Principals ///////////////////////
|
|
|
|
/**
|
|
|
|
* Return the principal of the innermost frame of the currently
|
|
|
|
* executing script. Will return null if there is no script
|
|
|
|
* currently executing.
|
|
|
|
*/
|
|
|
|
nsIPrincipal getSubjectPrincipal();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the all-powerful system principal.
|
|
|
|
*/
|
|
|
|
nsIPrincipal getSystemPrincipal();
|
2000-02-23 22:34:40 +00: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 16:46:42 +00:00
|
|
|
/**
|
|
|
|
* Return a principal that can be QI'd to nsICertificatePrincipal.
|
|
|
|
*/
|
|
|
|
nsIPrincipal getCertificatePrincipal(in string CertID);
|
2000-05-16 03:40:51 +00: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 16:46:42 +00:00
|
|
|
* Return a principal that can be QI'd to nsICodebasePrincipal and
|
|
|
|
* has the same origin as aURI.
|
|
|
|
*/
|
|
|
|
nsIPrincipal getCodebasePrincipal(in nsIURI aURI);
|
|
|
|
|
|
|
|
///////////////// Capabilities API /////////////////////
|
|
|
|
/**
|
|
|
|
* Request that 'capability' can be enabled by scripts or applets
|
|
|
|
* running with 'principal'. Will prompt user if
|
|
|
|
* necessary. Returns nsIPrincipal::ENABLE_GRANTED or
|
|
|
|
* nsIPrincipal::ENABLE_DENIED based on user's choice.
|
|
|
|
*/
|
|
|
|
void requestCapability(in nsIPrincipal principal, in string capability,
|
|
|
|
out short result);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if the currently executing script has 'capability' enabled.
|
2000-05-16 03:40:51 +00:00
|
|
|
*/
|
1999-10-28 22:09:03 +00:00
|
|
|
boolean IsCapabilityEnabled(in string capability);
|
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 16:46:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Enable 'capability' in the innermost frame of the currently executing
|
|
|
|
* script.
|
|
|
|
*/
|
|
|
|
void enableCapability(in string capability);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove 'capability' from the innermost frame of the currently
|
|
|
|
* executing script. Any setting of 'capability' from enclosing
|
|
|
|
* frames thus comes into effect.
|
|
|
|
*/
|
2001-03-02 00:09:20 +00:00
|
|
|
void revertCapability(in string capability);
|
1999-09-15 04:05:43 +00: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 16:46:42 +00:00
|
|
|
/**
|
|
|
|
* Disable 'capability' in the innermost frame of the currently executing
|
|
|
|
* script.
|
|
|
|
*/
|
2001-03-02 00:09:20 +00:00
|
|
|
void disableCapability(in string capability);
|
2000-04-26 03:50:07 +00:00
|
|
|
|
|
|
|
//////////////// Master Certificate Functions ////////////////////
|
2001-03-02 00:09:20 +00: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 16:46:42 +00:00
|
|
|
* Allow 'certificateID' to enable 'capability.' Can only be performed
|
|
|
|
* by code signed by the system certificate.
|
2001-03-02 00:09:20 +00: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 16:46:42 +00:00
|
|
|
void setCanEnableCapability(in string certificateID, in string capability,
|
|
|
|
in short canEnable);
|
2001-07-13 07:08:26 +00:00
|
|
|
|
|
|
|
///////////////////////
|
|
|
|
/**
|
|
|
|
* Return the principal of the specified object in the specified context.
|
|
|
|
*/
|
|
|
|
[noscript] nsIPrincipal getObjectPrincipal(in JSContextPtr cx,
|
|
|
|
in JSObjectPtr obj);
|
2002-02-13 04:20:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Forget all currently stored security policies and reread from prefs.
|
|
|
|
* This must be called after any capability.policy prefs have changed.
|
|
|
|
*/
|
|
|
|
void reloadSecurityPolicies();
|
1999-07-15 23:23:16 +00:00
|
|
|
};
|
1999-08-20 09:51:02 +00:00
|
|
|
|
1999-07-15 23:23:16 +00:00
|
|
|
%{C++
|
2000-09-13 23:57:52 +00:00
|
|
|
#define NS_SCRIPTSECURITYMANAGER_CONTRACTID "@mozilla.org/scriptsecuritymanager;1"
|
1999-08-20 09:51:02 +00:00
|
|
|
#define NS_SCRIPTSECURITYMANAGER_CLASSNAME "scriptsecuritymanager"
|
1999-09-01 00:54:35 +00:00
|
|
|
%}
|