Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
Rhino JavaScript Java Library Source Code
Rhino JavaScript Java Library is an open-source implementation of JavaScript written entirely in Java.
Rhino JavaScript Java Library Source Code files are provided in binary package (rhino-1.7.14.zip).
You can also browse the source code below:
✍: FYIcenter.com
⏎ org/mozilla/javascript/SecurityController.java
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * 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/. */ // API class package org.mozilla.javascript; /** * This class describes the support needed to implement security. * <p> * Three main pieces of functionality are required to implement * security for JavaScript. First, it must be possible to define * classes with an associated security domain. (This security * domain may be any object incorporating notion of access * restrictions that has meaning to an embedding; for a client-side * JavaScript embedding this would typically be * java.security.ProtectionDomain or similar object depending on an * origin URL and/or a digital certificate.) * Next it must be possible to get a security domain object that * allows a particular action only if all security domains * associated with code on the current Java stack allows it. And * finally, it must be possible to execute script code with * associated security domain injected into Java stack. * <p> * These three pieces of functionality are encapsulated in the * SecurityController class. * * @see org.mozilla.javascript.Context#setSecurityController(SecurityController) * @see java.lang.ClassLoader * @since 1.5 Release 4 */ public abstract class SecurityController { private static SecurityController global; // The method must NOT be public or protected static SecurityController global() { return global; } /** * Check if global {@link SecurityController} was already installed. * @see #initGlobal(SecurityController controller) */ public static boolean hasGlobal() { return global != null; } /** * Initialize global controller that will be used for all * security-related operations. The global controller takes precedence * over already installed {@link Context}-specific controllers and cause * any subsequent call to * {@link Context#setSecurityController(SecurityController)} * to throw an exception. * <p> * The method can only be called once. * * @see #hasGlobal() */ public static void initGlobal(SecurityController controller) { if (controller == null) throw new IllegalArgumentException(); if (global != null) { throw new SecurityException("Cannot overwrite already installed global SecurityController"); } global = controller; } /** * Get class loader-like object that can be used * to define classes with the given security context. * @param parentLoader parent class loader to delegate search for classes * not defined by the class loader itself * @param securityDomain some object specifying the security * context of the code that is defined by the returned class loader. */ public abstract GeneratedClassLoader createClassLoader( ClassLoader parentLoader, Object securityDomain); /** * Create {@link GeneratedClassLoader} with restrictions imposed by * staticDomain and all current stack frames. * The method uses the SecurityController instance associated with the * current {@link Context} to construct proper dynamic domain and create * corresponding class loader. * <p> * If no SecurityController is associated with the current {@link Context} , * the method calls {@link Context#createClassLoader(ClassLoader parent)}. * </p> * @param parent parent class loader. If null, * {@link Context#getApplicationClassLoader()} will be used. * @param staticDomain static security domain. */ public static GeneratedClassLoader createLoader( ClassLoader parent, Object staticDomain) { Context cx = Context.getContext(); if (parent == null) { parent = cx.getApplicationClassLoader(); } SecurityController sc = cx.getSecurityController(); GeneratedClassLoader loader; if (sc == null) { loader = cx.createClassLoader(parent); } else { Object dynamicDomain = sc.getDynamicSecurityDomain(staticDomain); loader = sc.createClassLoader(parent, dynamicDomain); } return loader; } public static Class<?> getStaticSecurityDomainClass() { SecurityController sc = Context.getContext().getSecurityController(); return sc == null ? null : sc.getStaticSecurityDomainClassInternal(); } public Class<?> getStaticSecurityDomainClassInternal() { return null; } /** * Get dynamic security domain that allows an action only if it is allowed * by the current Java stack and <i>securityDomain</i>. If * <i>securityDomain</i> is null, return domain representing permissions * allowed by the current stack. */ public abstract Object getDynamicSecurityDomain(Object securityDomain); /** * Call {@link * Callable#call(Context cx, Scriptable scope, Scriptable thisObj, * Object[] args)} * of <i>callable</i> under restricted security domain where an action is * allowed only if it is allowed according to the Java stack on the * moment of the <i>execWithDomain</i> call and <i>securityDomain</i>. * Any call to {@link #getDynamicSecurityDomain(Object)} during * execution of <code>callable.call(cx, scope, thisObj, args)</code> * should return a domain incorporate restrictions imposed by * <i>securityDomain</i> and Java stack on the moment of callWithDomain * invocation. * <p> * The method should always be overridden, it is not declared abstract * for compatibility reasons. */ public Object callWithDomain(Object securityDomain, Context cx, final Callable callable, Scriptable scope, final Scriptable thisObj, final Object[] args) { return execWithDomain(cx, scope, new Script() { @Override public Object exec(Context cx, Scriptable scope) { return callable.call(cx, scope, thisObj, args); } }, securityDomain); } /** * @deprecated The application should not override this method and instead * override * {@link #callWithDomain(Object securityDomain, Context cx, Callable callable, Scriptable scope, Scriptable thisObj, Object[] args)}. */ @Deprecated public Object execWithDomain(Context cx, Scriptable scope, Script script, Object securityDomain) { throw new IllegalStateException("callWithDomain should be overridden"); } }
⏎ org/mozilla/javascript/SecurityController.java
Or download all of them as a single archive file:
File name: rhino-1.7.14-sources.jar File size: 1029165 bytes Release date: 2022-01-06 Download
⇒ Example code to Test rhino-runtime-1.7.14.jar
⇐ Download Rhino JavaScript Binary Package
2022-05-03, 35435👍, 1💬
Popular Posts:
How to download and install ojdbc5.jar for Oracle 11g R1? ojdbc5.jar for Oracle 11g R1 is a Java 5 J...
JDK 11 jdk.internal.vm.compiler .jmodis the JMOD file for JDK 11 Internal VM Compiler module. JDK 11...
What Is fop.jar? I got it from the fop-2.7-bin.zip. fop.jar in fop-2.7-bin.zip is the JAR file for F...
The Digester package lets you configure an XML -> Java object mapping module, which triggers certain...
SLF4J API is a simple API that allows to plug in any desired logging library at deployment time. Her...