Changes in Security API: using CodeBlock interface instead of reusing Script to represent code that should be executed with different domain.

This commit is contained in:
igor%mir2.org 2003-11-07 22:29:59 +00:00
Родитель d3c70a3cd8
Коммит a96da1a17f
3 изменённых файлов: 11 добавлений и 10 удалений

Просмотреть файл

@ -3020,7 +3020,8 @@ public class Interpreter
activation.put(name, activation, value); activation.put(name, activation, value);
} }
private static Object execWithNewDomain(Context cx, Scriptable scope, private static Object execWithNewDomain(Context cx,
final Scriptable scope,
final Scriptable thisObj, final Scriptable thisObj,
final Object[] args, final Object[] args,
final double[] argsDbl, final double[] argsDbl,
@ -3033,8 +3034,8 @@ public class Interpreter
if (cx.interpreterSecurityDomain == idata.securityDomain) if (cx.interpreterSecurityDomain == idata.securityDomain)
Kit.codeBug(); Kit.codeBug();
Script code = new Script() { CodeBlock code = new CodeBlock() {
public Object exec(Context cx, Scriptable scope) public Object exec(Context cx, Object[] args)
throws JavaScriptException throws JavaScriptException
{ {
return interpret(cx, scope, thisObj, return interpret(cx, scope, thisObj,
@ -3047,7 +3048,7 @@ public class Interpreter
cx.interpreterSecurityDomain = idata.securityDomain; cx.interpreterSecurityDomain = idata.securityDomain;
try { try {
return cx.getSecurityController(). return cx.getSecurityController().
execWithDomain(cx, scope, code, idata.securityDomain); execWithDomain(cx, idata.securityDomain, code, args);
} finally { } finally {
cx.interpreterSecurityDomain = savedDomain; cx.interpreterSecurityDomain = savedDomain;
} }

Просмотреть файл

@ -84,7 +84,7 @@ public abstract class SecurityController {
public abstract Object getDynamicSecurityDomain(Object securityDomain); public abstract Object getDynamicSecurityDomain(Object securityDomain);
/** /**
* Call {@link Script#exec(Context cx, Scriptable scope)} of * Call {@link CodeBlock#run(Context cx, Object[] args)} of
* <i>script</i> under restricted security domain where an action is * <i>script</i> under restricted security domain where an action is
* allowed only if it is allowed according to the Java stack on the * allowed only if it is allowed according to the Java stack on the
* moment of the <i>execWithDomain</i> call and <i>securityDomain</i>. * moment of the <i>execWithDomain</i> call and <i>securityDomain</i>.
@ -93,7 +93,7 @@ public abstract class SecurityController {
* should return a domain incorporate restrictions imposed by * should return a domain incorporate restrictions imposed by
* <i>securityDomain</i>. * <i>securityDomain</i>.
*/ */
public abstract Object execWithDomain(Context cx, Scriptable scope, public abstract Object execWithDomain(Context cx, Object securityDomain,
Script script, Object securityDomain) CodeBlock code, Object[] args)
throws JavaScriptException; throws JavaScriptException;
} }

Просмотреть файл

@ -190,8 +190,8 @@ public class JavaPolicySecurity extends SecurityProxy
return contextDomain; return contextDomain;
} }
public Object execWithDomain(final Context cx, final Scriptable scope, public Object execWithDomain(final Context cx, Object securityDomain,
final Script script, Object securityDomain) final CodeBlock code, final Object[] args)
throws JavaScriptException throws JavaScriptException
{ {
ProtectionDomain staticDomain = (ProtectionDomain)securityDomain; ProtectionDomain staticDomain = (ProtectionDomain)securityDomain;
@ -216,7 +216,7 @@ public class JavaPolicySecurity extends SecurityProxy
PrivilegedExceptionAction action = new PrivilegedExceptionAction() { PrivilegedExceptionAction action = new PrivilegedExceptionAction() {
public Object run() throws JavaScriptException { public Object run() throws JavaScriptException {
return script.exec(cx, scope); return code.exec(cx, args);
} }
}; };