mirror of
https://gitee.com/dromara/sa-token.git
synced 2025-10-21 02:57:23 +08:00
feat: 新增 SaFirewallStrategy#removeHook 函数,用于移除指定类型的防火墙校验 hook
This commit is contained in:
@@ -36,12 +36,13 @@ public final class SaFirewallStrategy {
|
||||
*/
|
||||
public static final SaFirewallStrategy instance = new SaFirewallStrategy();
|
||||
|
||||
|
||||
// ----------------------- 所有策略
|
||||
|
||||
/**
|
||||
* 防火墙校验钩子函数集合
|
||||
*/
|
||||
public List<SaFirewallCheckHook> checkHooks = new ArrayList<>();
|
||||
|
||||
private SaFirewallStrategy() {
|
||||
// 初始化默认的防火墙校验钩子函数集合
|
||||
checkHooks.add(SaFirewallCheckHookForWhitePath.instance);
|
||||
checkHooks.add(SaFirewallCheckHookForBlackPath.instance);
|
||||
checkHooks.add(SaFirewallCheckHookForPathDangerCharacter.instance);
|
||||
@@ -57,11 +58,25 @@ public final class SaFirewallStrategy {
|
||||
* 注册一个防火墙校验 hook
|
||||
* @param checkHook /
|
||||
*/
|
||||
public void registerCheckHook(SaFirewallCheckHook checkHook) {
|
||||
public void registerHook(SaFirewallCheckHook checkHook) {
|
||||
SaManager.getLog().info("防火墙校验 hook 注册成功: " + checkHook.getClass());
|
||||
checkHooks.add(checkHook);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除指定类型的防火墙校验 hook
|
||||
* @param hookClass /
|
||||
*/
|
||||
public void removeHook(Class<? extends SaFirewallCheckHook> hookClass) {
|
||||
for (SaFirewallCheckHook hook : checkHooks) {
|
||||
if (hook.getClass().equals(hookClass)) {
|
||||
checkHooks.remove(hook);
|
||||
SaManager.getLog().info("防火墙校验 hook 移除成功: " + hookClass);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 防火墙校验函数
|
||||
*/
|
||||
|
@@ -38,7 +38,6 @@ public class SaFirewallCheckHookForPathBannedCharacter implements SaFirewallChec
|
||||
*/
|
||||
public boolean bannedPercentage = false;
|
||||
|
||||
|
||||
/**
|
||||
* 重载配置
|
||||
* @param bannedPercentage 是否严格禁止出现百分号字符 % (默认:否)
|
||||
@@ -47,7 +46,6 @@ public class SaFirewallCheckHookForPathBannedCharacter implements SaFirewallChec
|
||||
this.bannedPercentage = bannedPercentage;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 执行的方法
|
||||
*
|
||||
|
Reference in New Issue
Block a user