pub enum QLSecurityStrategy {
Open,
Isolation,
BlackList(HashSet<NativeMember>),
WhiteList(HashSet<NativeMember>),
SharedBlackList(SharedNativeMembers),
SharedWhiteList(SharedNativeMembers),
Custom(Rc<dyn Fn(&NativeMember) -> bool>),
}Expand description
QLSecurityStrategy 枚举的 Rust 实现,保留对应对象的领域职责与公开契约。
对应或承接 Java 源文件:com/alibaba/qlexpress4/security/QLSecurityStrategy.java;具体对象路径见 docs/对象级对照表.md。
Mirroring Java QLSecurityStrategy: decides whether a native member may
be accessed from a script.
对应 Java: com.alibaba.qlexpress4.security.QLSecurityStrategy。
Variants§
Open
Java QLSecurityStrategy.open(): allow everything.
Isolation
Java QLSecurityStrategy.isolation(): allow nothing. (Java default.)
BlackList(HashSet<NativeMember>)
Java QLSecurityStrategy.blackList(Set<Member>).
WhiteList(HashSet<NativeMember>)
Java QLSecurityStrategy.whiteList(Set<Member>).
保存调用方集合引用的 Java 黑名单语义。
保存调用方集合引用的 Java 白名单语义。
Custom(Rc<dyn Fn(&NativeMember) -> bool>)
业务宿主实现 Java QLSecurityStrategy#check(Member) 的 Rust 闭包适配。
Implementations§
Source§impl QLSecurityStrategy
impl QLSecurityStrategy
Sourcepub fn open() -> Self
pub fn open() -> Self
创建允许访问全部已注册原生成员的开放策略。
无显式参数;返回:Self。
对应或承接 Java 源文件:com/alibaba/qlexpress4/security/QLSecurityStrategy.java,方法 open;Rust 侧按所有权与 Result 语义适配。
Java QLSecurityStrategy.open().
对应 Java: com.alibaba.qlexpress4.security.QLSecurityStrategy#open。
Sourcepub fn isolation() -> Self
pub fn isolation() -> Self
创建拒绝全部原生成员访问的隔离策略。
无显式参数;返回:Self。
对应或承接 Java 源文件:com/alibaba/qlexpress4/security/QLSecurityStrategy.java,方法 isolation;Rust 侧按所有权与 Result 语义适配。
Java QLSecurityStrategy.isolation().
对应 Java: com.alibaba.qlexpress4.security.QLSecurityStrategy#isolation。
Sourcepub fn black_list(black_list: HashSet<NativeMember>) -> Self
pub fn black_list(black_list: HashSet<NativeMember>) -> Self
创建拒绝指定原生成员的黑名单策略。
参数:black_list;返回:Self。
对应或承接 Java 源文件:com/alibaba/qlexpress4/security/QLSecurityStrategy.java,方法 blackList;Rust 侧按所有权与 Result 语义适配。
Java QLSecurityStrategy.blackList(...).
对应 Java: com.alibaba.qlexpress4.security.QLSecurityStrategy#blackList。
Sourcepub fn white_list(white_list: HashSet<NativeMember>) -> Self
pub fn white_list(white_list: HashSet<NativeMember>) -> Self
创建仅允许指定原生成员的白名单策略。
参数:white_list;返回:Self。
对应或承接 Java 源文件:com/alibaba/qlexpress4/security/QLSecurityStrategy.java,方法 whiteList;Rust 侧按所有权与 Result 语义适配。
Java QLSecurityStrategy.whiteList(...).
对应 Java: com.alibaba.qlexpress4.security.QLSecurityStrategy#whiteList。
Sourcepub fn check(&self, member: Option<&NativeMember>) -> Result<bool, QLException>
pub fn check(&self, member: Option<&NativeMember>) -> Result<bool, QLException>
依据 Java 接口契约执行校验。
参数:member;返回:成员是否允许访问,或 Java 对应异常。
对应或承接 Java 源文件:com/alibaba/qlexpress4/security/QLSecurityStrategy.java,方法 check;Rust 侧按所有权与 Result 语义适配。
Java check(Member): true when the member is secure to access.
Isolation 必须抛出 IllegalStateException,不能与运行时的“拒绝访问”
布尔适配混为一谈;Java 的黑白名单允许传入 null 成员。
§错误
隔离策略始终返回 java.lang.IllegalStateException 对应的 QLException。
对应 Java: com.alibaba.qlexpress4.security.QLSecurityStrategy#check。
Sourcepub fn is_allowed(&self, member: &NativeMember) -> bool
pub fn is_allowed(&self, member: &NativeMember) -> bool
将 Java 策略契约适配为引擎成员解析所需的安全布尔值。
隔离策略的 Java check 会抛异常,但 ReflectLoader 会在普通字段和
方法解析前识别隔离策略并直接拒绝。Rust 注册表使用本入口表达同一
“不允许解析”结果,同时保留 Self::check 的原始异常契约。
§参数
member:已由 NativeRegistry 解析出的非空宿主成员。
§返回值
允许访问返回 true;策略拒绝或策略检查失败返回 false。
对应 Java:ReflectLoader 调用 QLSecurityStrategy#check 的准入分支。
Trait Implementations§
Source§impl Clone for QLSecurityStrategy
impl Clone for QLSecurityStrategy
Source§fn clone(&self) -> QLSecurityStrategy
fn clone(&self) -> QLSecurityStrategy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for QLSecurityStrategy
impl Debug for QLSecurityStrategy
Source§impl Default for QLSecurityStrategy
impl Default for QLSecurityStrategy
Source§fn default() -> QLSecurityStrategy
fn default() -> QLSecurityStrategy
impl Eq for QLSecurityStrategy
Source§impl From<StrategyBlackList> for QLSecurityStrategy
转为等价的外观枚举 QLSecurityStrategy::BlackList。
impl From<StrategyBlackList> for QLSecurityStrategy
转为等价的外观枚举 QLSecurityStrategy::BlackList。
Source§fn from(strategy: StrategyBlackList) -> Self
fn from(strategy: StrategyBlackList) -> Self
Source§impl From<StrategyIsolation> for QLSecurityStrategy
转为等价的外观枚举 QLSecurityStrategy::Isolation。
impl From<StrategyIsolation> for QLSecurityStrategy
转为等价的外观枚举 QLSecurityStrategy::Isolation。
Source§fn from(_strategy: StrategyIsolation) -> Self
fn from(_strategy: StrategyIsolation) -> Self
Source§impl From<StrategyOpen> for QLSecurityStrategy
转为等价的外观枚举 QLSecurityStrategy::Open。
(Java 中 StrategyOpen 直接实现 QLSecurityStrategy 接口。)
impl From<StrategyOpen> for QLSecurityStrategy
转为等价的外观枚举 QLSecurityStrategy::Open。
(Java 中 StrategyOpen 直接实现 QLSecurityStrategy 接口。)
Source§fn from(_strategy: StrategyOpen) -> Self
fn from(_strategy: StrategyOpen) -> Self
Source§impl From<StrategyWhiteList> for QLSecurityStrategy
转为等价的外观枚举 QLSecurityStrategy::WhiteList。
impl From<StrategyWhiteList> for QLSecurityStrategy
转为等价的外观枚举 QLSecurityStrategy::WhiteList。