Interface Sandbox
- All Known Implementing Classes:
DefaultSandbox
public interface Sandbox
Security Sandbox Interface
安全沙箱接口
Provides security constraints for expression evaluation.
为表达式求值提供安全约束。
Features | 主要功能:
- Class access control - 类访问控制
- Method call control - 方法调用控制
- Property access control - 属性访问控制
- Construction control - 构造控制
- Expression length, depth, and time limits - 表达式长度、深度和时间限制
Usage Examples | 使用示例:
Sandbox sandbox = DefaultSandbox.standard();
StandardContext ctx = StandardContext.builder()
.sandbox(sandbox)
.build();
// Expressions evaluated with ctx will be constrained by the sandbox
Object result = OpenExpression.eval("user.name", ctx);
Security | 安全性:
- Thread-safe: Depends on implementation - 线程安全: 取决于实现
- Null-safe: Depends on implementation - 空值安全: 取决于实现
- Since:
- JDK 25, opencode-base-expression V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault intGet the maximum evaluation depth 获取最大求值深度default longGet the maximum evaluation time in milliseconds 获取最大求值时间(毫秒)default intGet the maximum expression length 获取最大表达式长度booleanisClassAllowed(Class<?> clazz) Check if a class is allowed 检查是否允许访问类default booleanisConstructionAllowed(Class<?> clazz) Check if a type construction is allowed 检查是否允许类型构造booleanisMethodAllowed(Object target, Method method) Check if a method call is allowed 检查是否允许调用方法booleanisPropertyAllowed(Object target, String property) Check if a property access is allowed 检查是否允许访问属性
-
Method Details
-
isClassAllowed
Check if a class is allowed 检查是否允许访问类- Parameters:
clazz- the class | 类- Returns:
- true if allowed | 如果允许返回true
-
isMethodAllowed
-
isPropertyAllowed
-
isConstructionAllowed
Check if a type construction is allowed 检查是否允许类型构造- Parameters:
clazz- the class to construct | 要构造的类- Returns:
- true if allowed | 如果允许返回true
-
getMaxExpressionLength
default int getMaxExpressionLength()Get the maximum expression length 获取最大表达式长度- Returns:
- the max length, -1 for unlimited | 最大长度,-1表示无限
-
getMaxEvaluationDepth
default int getMaxEvaluationDepth()Get the maximum evaluation depth 获取最大求值深度- Returns:
- the max depth, -1 for unlimited | 最大深度,-1表示无限
-
getMaxEvaluationTime
default long getMaxEvaluationTime()Get the maximum evaluation time in milliseconds 获取最大求值时间(毫秒)- Returns:
- the max time, -1 for unlimited | 最大时间,-1表示无限
-