Class BehaviorAnalyzer

java.lang.Object
cloud.opencode.base.captcha.security.BehaviorAnalyzer

public final class BehaviorAnalyzer extends Object
Behavior Analyzer - Analyzes user behavior for bot detection 行为分析器 - 分析用户行为以检测机器人

This class analyzes patterns in CAPTCHA interactions to detect potential bots.

此类分析验证码交互中的模式以检测潜在的机器人。

Features | 主要功能:

  • Response time analysis - 响应时间分析
  • Failure pattern detection - 失败模式检测
  • Client risk scoring - 客户端风险评分

Usage Examples | 使用示例:

BehaviorAnalyzer analyzer = new BehaviorAnalyzer();
analyzer.recordAttempt(clientId, success, responseTime);
double riskScore = analyzer.getRiskScore(clientId);

Security | 安全性:

  • Thread-safe: Yes (uses ConcurrentHashMap) - 线程安全: 是(使用ConcurrentHashMap)
  • Null-safe: No (clientId must not be null) - 空值安全: 否(客户端ID不能为null)
Since:
JDK 25, opencode-base-captcha V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • BehaviorAnalyzer

      public BehaviorAnalyzer()
  • Method Details

    • analyze

      public BehaviorAnalyzer.AnalysisResult analyze(String clientId, Duration responseTime, boolean success)
      Analyzes behavior for a client. 分析客户端的行为。
      Parameters:
      clientId - the client identifier | 客户端标识符
      responseTime - the response time | 响应时间
      success - whether the attempt was successful | 尝试是否成功
      Returns:
      the analysis result | 分析结果
    • getBehavior

      public BehaviorAnalyzer.ClientBehavior getBehavior(String clientId)
      Gets the behavior for a client. 获取客户端的行为。
      Parameters:
      clientId - the client identifier | 客户端标识符
      Returns:
      the behavior or null | 行为或 null
    • clear

      public void clear(String clientId)
      Clears behavior data for a client. 清除客户端的行为数据。
      Parameters:
      clientId - the client identifier | 客户端标识符
    • clearOld

      public void clearOld()
      Clears all old behavior data. 清除所有旧的行为数据。