Class ScriptSandboxContext

java.lang.Object
com.xebialabs.xlrelease.script.security.ScriptSandboxContext

public final class ScriptSandboxContext extends Object
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.

  • Method Details

    • enter

      public static void enter(PermissionCollection permissions, String executionId)
      Marks the current thread as executing a restricted script with the given effective class-access permissions. Must be paired with clear() in a finally block.
    • clear

      public static void clear()
    • isRestricted

      public static boolean isRestricted()
      Whether the current thread is inside a restricted script execution.
    • permissions

      public static PermissionCollection permissions()
      Effective class-access permissions for the current restricted script; an empty (deny-all) collection if no restricted execution is in progress.
    • executionId

      public static String executionId()
      Execution id of the current restricted script, or null if none.
    • suspend

      public static ScriptSandboxContext.Suspension 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 with restore(Suspension) in a finally block.
    • restore

      public static void restore(ScriptSandboxContext.Suspension suspension)
      Restores a context previously left via suspend(). No-op if nothing was suspended.