Class SimpleCaptchaValidator

java.lang.Object
cloud.opencode.base.captcha.validator.SimpleCaptchaValidator
All Implemented Interfaces:
CaptchaValidator

public final class SimpleCaptchaValidator extends Object implements CaptchaValidator
Simple Captcha Validator - Basic CAPTCHA validation 简单验证码验证器 - 基础验证码验证

Features | 主要功能:

  • Case-insensitive answer comparison - 大小写不敏感的答案比较
  • Single-use validation (answer removed after check) - 一次性验证(检查后删除答案)

Usage Examples | 使用示例:

CaptchaValidator validator = new SimpleCaptchaValidator(store);
ValidationResult result = validator.validate(captchaId, userAnswer);

Security | 安全性:

  • Thread-safe: Yes (delegates to thread-safe store) - 线程安全: 是(委托给线程安全的存储)
  • Null-safe: No (store, id, and answer 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

    • SimpleCaptchaValidator

      public SimpleCaptchaValidator(CaptchaStore store)
      Creates a new validator with the specified store. 使用指定存储创建新验证器。
      Parameters:
      store - the CAPTCHA store | 验证码存储
  • Method Details

    • validate

      public ValidationResult validate(String id, String answer)
      Description copied from interface: CaptchaValidator
      Validates a CAPTCHA answer. 验证验证码答案。
      Specified by:
      validate in interface CaptchaValidator
      Parameters:
      id - the CAPTCHA ID | 验证码 ID
      answer - the provided answer | 提供的答案
      Returns:
      the validation result | 验证结果
    • validate

      public ValidationResult validate(String id, String answer, boolean caseSensitive)
      Description copied from interface: CaptchaValidator
      Validates a CAPTCHA answer with case sensitivity option. 验证验证码答案(带大小写敏感选项)。
      Specified by:
      validate in interface CaptchaValidator
      Parameters:
      id - the CAPTCHA ID | 验证码 ID
      answer - the provided answer | 提供的答案
      caseSensitive - whether case sensitive | 是否区分大小写
      Returns:
      the validation result | 验证结果