Class ScriptSandboxContext
java.lang.Object
com.xebialabs.xlrelease.script.security.ScriptSandboxContext
Thread-local marker for "the current thread is executing a restricted user script", carrying the
effective class-access
PermissionCollection for that script.
This replaces the AccessControlContext/Security-Manager based restricted-context
detection that no longer works on JDK 24+ (JEP 486 permanently disables the Security Manager). The
context is entered around the evaluation of a restricted script and cleared in a finally, so
class loads that happen during engine construction, module reload, or trusted (non-permission-checked)
scripts are not affected.
Fail-closed: while a restricted script is executing, the effective permissions are those supplied on
enter(java.security.PermissionCollection, java.lang.String); if none were supplied the collection is empty, i.e. every class is denied.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classOpaque handle returned bysuspend()and consumed byrestore(Suspension). -
Method Summary
Modifier and TypeMethodDescriptionstatic voidclear()static voidenter(PermissionCollection permissions, String executionId) Marks the current thread as executing a restricted script with the given effective class-access permissions.static StringExecution id of the current restricted script, ornullif none.static booleanWhether the current thread is inside a restricted script execution.static PermissionCollectionEffective class-access permissions for the current restricted script; an empty (deny-all) collection if no restricted execution is in progress.static voidrestore(ScriptSandboxContext.Suspension suspension) Restores a context previously left viasuspend().suspend()Temporarily leaves the restricted context so a trusted, framework-internal evaluation (e.g.
-
Method Details
-
enter
Marks the current thread as executing a restricted script with the given effective class-access permissions. Must be paired withclear()in afinallyblock. -
clear
public static void clear() -
isRestricted
public static boolean isRestricted()Whether the current thread is inside a restricted script execution. -
permissions
Effective class-access permissions for the current restricted script; an empty (deny-all) collection if no restricted execution is in progress. -
executionId
Execution id of the current restricted script, ornullif none. -
suspend
Temporarily leaves the restricted context so a trusted, framework-internal evaluation (e.g. binding wrap/unwrap helper scripts) can run without class-access enforcement. Mirrors JDK <= 23, where such helper evaluations ran outside the script's privileged frame and were therefore never checked. Must be paired withrestore(Suspension)in afinallyblock. -
restore
Restores a context previously left viasuspend(). No-op if nothing was suspended.
-