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
Родитель 49ffeac3df
Коммит dc34ed3dc1
3 изменённых файлов: 11 добавлений и 10 удалений

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

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

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

@ -84,7 +84,7 @@ public abstract class SecurityController {
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
* allowed only if it is allowed according to the Java stack on the
* 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
* <i>securityDomain</i>.
*/
public abstract Object execWithDomain(Context cx, Scriptable scope,
Script script, Object securityDomain)
public abstract Object execWithDomain(Context cx, Object securityDomain,
CodeBlock code, Object[] args)
throws JavaScriptException;
}

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

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