Skip to main content

QLSecurityStrategy

Enum QLSecurityStrategy 

Source
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>).

§

SharedBlackList(SharedNativeMembers)

保存调用方集合引用的 Java 黑名单语义。

§

SharedWhiteList(SharedNativeMembers)

保存调用方集合引用的 Java 白名单语义。

§

Custom(Rc<dyn Fn(&NativeMember) -> bool>)

业务宿主实现 Java QLSecurityStrategy#check(Member) 的 Rust 闭包适配。

Implementations§

Source§

impl QLSecurityStrategy

Source

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。

Source

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。

Source

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。

Source

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。

Source

pub fn shared_black_list(black_list: SharedNativeMembers) -> Self

使用调用方保留的共享集合创建黑名单策略。

Java StrategyBlackList 直接保存构造参数 Set<Member>;调用方在 runner 创建后修改集合时,后续成员检查会立即观察到变化。

§参数
  • black_list:宿主与策略共享的成员集合。
§返回值

返回具有 Java 引用语义的黑名单策略。 对应 Java:QLSecurityStrategy#blackList(Set<Member>) 的集合引用语义。

Source

pub fn shared_white_list(white_list: SharedNativeMembers) -> Self

使用调用方保留的共享集合创建白名单策略。

§参数
  • white_list:宿主与策略共享的成员集合。
§返回值

返回具有 Java 引用语义的白名单策略。 对应 Java:QLSecurityStrategy#whiteList(Set<Member>) 的集合引用语义。

Source

pub fn custom<F>(check: F) -> Self
where F: Fn(&NativeMember) -> bool + 'static,

使用宿主闭包创建自定义成员安全策略。

Java 的 QLSecurityStrategy 是公开接口,业务宿主可按成员、租户或 动态配置实现 check(Member);本方法以共享闭包保留同一扩展能力。

§参数
  • check:接收成员描述符并返回是否放行的策略函数。
§返回值

返回可克隆且共享闭包状态的安全策略。 对应 Java:业务实现 QLSecurityStrategy#check(Member)

Source

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。

Source

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

Source§

fn clone(&self) -> QLSecurityStrategy

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for QLSecurityStrategy

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for QLSecurityStrategy

Source§

fn default() -> QLSecurityStrategy

Returns the “default value” for a type. Read more
Source§

impl Eq for QLSecurityStrategy

Source§

impl From<StrategyBlackList> for QLSecurityStrategy

转为等价的外观枚举 QLSecurityStrategy::BlackList

Source§

fn from(strategy: StrategyBlackList) -> Self

Converts to this type from the input type.
Source§

impl From<StrategyIsolation> for QLSecurityStrategy

转为等价的外观枚举 QLSecurityStrategy::Isolation

Source§

fn from(_strategy: StrategyIsolation) -> Self

Converts to this type from the input type.
Source§

impl From<StrategyOpen> for QLSecurityStrategy

转为等价的外观枚举 QLSecurityStrategy::Open。 (Java 中 StrategyOpen 直接实现 QLSecurityStrategy 接口。)

Source§

fn from(_strategy: StrategyOpen) -> Self

Converts to this type from the input type.
Source§

impl From<StrategyWhiteList> for QLSecurityStrategy

转为等价的外观枚举 QLSecurityStrategy::WhiteList

Source§

fn from(strategy: StrategyWhiteList) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for QLSecurityStrategy

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.