Debian Codegraph @

rhino/src/org/mozilla/javascript/RhinoSecurityManager.java

raw symbols SCIP
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 package org.mozilla.javascript;
6
7 /**
8 * A <code>java.lang.SecurityManager</code> subclass that provides access to
9 * the current top-most script class on the execution stack. This can be used
10 * to get the class loader or protection domain of the script that triggered
11 * the current action. It is required for JavaAdapters to have the same
12 * <code>ProtectionDomain</code> as the script code that created them.
13 * Embeddings that implement their own SecurityManager can use this as base class.
14 */
15 public class RhinoSecurityManager extends SecurityManager {
16
17 /**
18 * Get the class of the top-most stack element representing a script.
19 * @return The class of the top-most script in the current stack,
20 * or null if no script is currently running
21 */
22 protected Class<?> getCurrentScriptClass() {
23 Class<?>[] context = getClassContext();
24 for (Class<?> c : context) {
25 if (c != InterpretedFunction.class && NativeFunction.class.isAssignableFrom(c) ||
26 PolicySecurityController.SecureCaller.class.isAssignableFrom(c)) {
27 return c;
28 }
29 }
30 return null;
31 }
32
33 }