Interface CaptchaValidator
- All Known Implementing Classes:
BehaviorCaptchaValidator, CompositeValidator, HashedCaptchaValidator, PowCaptchaValidator, SimpleCaptchaValidator, TimeBasedCaptchaValidator
public interface CaptchaValidator
Captcha Validator - Interface for CAPTCHA validation
验证码验证器 - 验证码验证接口
This interface defines the contract for validating CAPTCHA answers.
此接口定义了验证验证码答案的契约。
Features | 主要功能:
- Answer validation contract - 答案验证契约
- Multiple implementation support - 多种实现支持
Usage Examples | 使用示例:
CaptchaValidator validator = new SimpleCaptchaValidator(store);
ValidationResult result = validator.validate(id, answer);
Security | 安全性:
- Thread-safe: Implementation dependent - 线程安全: 取决于实现
- Null-safe: No (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:
-
Method Summary
Modifier and TypeMethodDescriptionstatic CaptchaValidatorcomposite(CaptchaValidator first, CaptchaValidator... rest) Creates a composite validator that chains multiple validators.static CaptchaValidatorhashed(HashedCaptchaStore store) Creates a validator for hashed stores.static CaptchaValidatorpow(CaptchaStore store) Creates a Proof-of-Work validator.static CaptchaValidatorsimple(CaptchaStore store) Creates a simple validator.static CaptchaValidatortimeBased(CaptchaStore store) Creates a time-based validator with behavior checking.Validates a CAPTCHA answer.Validates a CAPTCHA answer with case sensitivity option.
-
Method Details
-
validate
Validates a CAPTCHA answer. 验证验证码答案。- Parameters:
id- the CAPTCHA ID | 验证码 IDanswer- the provided answer | 提供的答案- Returns:
- the validation result | 验证结果
-
validate
Validates a CAPTCHA answer with case sensitivity option. 验证验证码答案(带大小写敏感选项)。- Parameters:
id- the CAPTCHA ID | 验证码 IDanswer- the provided answer | 提供的答案caseSensitive- whether case sensitive | 是否区分大小写- Returns:
- the validation result | 验证结果
-
simple
Creates a simple validator. 创建简单验证器。- Parameters:
store- the CAPTCHA store | 验证码存储- Returns:
- the validator | 验证器
-
timeBased
Creates a time-based validator with behavior checking. 创建带行为检查的基于时间的验证器。- Parameters:
store- the CAPTCHA store | 验证码存储- Returns:
- the validator | 验证器
-
pow
Creates a Proof-of-Work validator. 创建工作量证明验证器。- Parameters:
store- the CAPTCHA store | 验证码存储- Returns:
- the validator | 验证器
-
composite
Creates a composite validator that chains multiple validators. 创建串联多个验证器的组合验证器。- Parameters:
first- the first (primary) validator | 第一个(主要)验证器rest- additional validators | 附加验证器- Returns:
- the composite validator | 组合验证器
-
hashed
Creates a validator for hashed stores. 创建用于哈希存储的验证器。- Parameters:
store- the hashed CAPTCHA store | 哈希验证码存储- Returns:
- the validator | 验证器
-