org.mozilla.javascript
public abstract class SecurityController extends Object
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.
These three pieces of functionality are encapsulated in the SecurityController class.
Since: 1.5 Release 4
See Also: setSecurityController java.lang.ClassLoader
Method Summary | |
---|---|
Object | callWithDomain(Object securityDomain, Context cx, Callable callable, Scriptable scope, Scriptable thisObj, Object[] args)
Call {@link
Callable#call(Context cx, Scriptable scope, Scriptable thisObj,
Object[] args)}
of callable under restricted security domain where an action is
allowed only if it is allowed according to the Java stack on the
moment of the execWithDomain call and securityDomain.
|
abstract GeneratedClassLoader | createClassLoader(ClassLoader parentLoader, Object securityDomain)
Get class loader-like object that can be used
to define classes with the given security context. |
static GeneratedClassLoader | createLoader(ClassLoader parent, Object staticDomain)
Create {@link GeneratedClassLoader} with restrictions imposed by
staticDomain and all current stack frames.
|
Object | execWithDomain(Context cx, Scriptable scope, Script script, Object securityDomain) |
abstract Object | getDynamicSecurityDomain(Object securityDomain)
Get dynamic security domain that allows an action only if it is allowed
by the current Java stack and securityDomain. |
static boolean | hasGlobal()
Check if global {@link SecurityController} was already installed. |
static void | initGlobal(SecurityController controller)
Initialize global controller that will be used for all
security-related operations. |
The method should always be overridden, it is not declared abstract for compatibility reasons.
Parameters: parentLoader parent class loader to delegate search for classes not defined by the class loader itself securityDomain some object specifying the security context of the code that is defined by the returned class loader.
Parameters: parent parent class loader. If null, {@link Context#getApplicationClassLoader()} will be used. staticDomain static security domain.
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)}.
See Also: SecurityController
The method can only be called once.
See Also: hasGlobal