Class AntiBotStrategy
java.lang.Object
cloud.opencode.base.captcha.security.AntiBotStrategy
Anti-Bot Strategy - Adaptive CAPTCHA difficulty strategy
反机器人策略 - 自适应验证码难度策略
This class provides strategies for adjusting CAPTCHA difficulty based on detected behavior patterns.
此类提供根据检测到的行为模式调整验证码难度的策略。
Features | 主要功能:
- Adaptive difficulty adjustment - 自适应难度调整
- Behavior-based strategy selection - 基于行为的策略选择
Usage Examples | 使用示例:
AntiBotStrategy strategy = new AntiBotStrategy(analyzer);
CaptchaStrength strength = strategy.recommendStrength(clientId);
Security | 安全性:
- Thread-safe: Yes (volatile fields + thread-safe analyzer) - 线程安全: 是(volatile 字段 + 线程安全分析器)
- Null-safe: No (analyzer must not be null) - 空值安全: 否(分析器不能为null)
- Since:
- JDK 25, opencode-base-captcha V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionAntiBotStrategy(BehaviorAnalyzer analyzer) Creates a new strategy with the given analyzer. -
Method Summary
Modifier and TypeMethodDescriptionstatic AntiBotStrategycreate()Creates a new strategy with a new analyzer.Gets the behavior analyzer.recommendStrength(String clientId) Determines the recommended CAPTCHA strength for a client.recommendType(String clientId) Determines the recommended CAPTCHA type for a client.booleanshouldBlock(String clientId) Checks if a client should be blocked.withBaseStrength(CaptchaStrength strength) Sets the base strength.withBaseType(CaptchaType type) Sets the base type.
-
Constructor Details
-
AntiBotStrategy
Creates a new strategy with the given analyzer. 使用给定的分析器创建新策略。- Parameters:
analyzer- the behavior analyzer | 行为分析器
-
-
Method Details
-
create
Creates a new strategy with a new analyzer. 使用新的分析器创建新策略。- Returns:
- the strategy | 策略
-
withBaseStrength
Sets the base strength. 设置基础强度。- Parameters:
strength- the base strength | 基础强度- Returns:
- this strategy | 此策略
-
withBaseType
Sets the base type. 设置基础类型。- Parameters:
type- the base type | 基础类型- Returns:
- this strategy | 此策略
-
recommendStrength
Determines the recommended CAPTCHA strength for a client. 确定客户端的推荐验证码强度。- Parameters:
clientId- the client identifier | 客户端标识符- Returns:
- the recommended strength | 推荐的强度
-
recommendType
Determines the recommended CAPTCHA type for a client. 确定客户端的推荐验证码类型。- Parameters:
clientId- the client identifier | 客户端标识符- Returns:
- the recommended type | 推荐的类型
-
shouldBlock
Checks if a client should be blocked. 检查客户端是否应被阻止。- Parameters:
clientId- the client identifier | 客户端标识符- Returns:
- true if should be blocked | 如果应该阻止返回 true
-
getAnalyzer
Gets the behavior analyzer. 获取行为分析器。- Returns:
- the analyzer | 分析器
-