Interface CaptchaEventListener

All Known Implementing Classes:
CaptchaEventDispatcher

public interface CaptchaEventListener
Captcha Event Listener - Interface for CAPTCHA lifecycle event callbacks 验证码事件监听器 - 验证码生命周期事件回调接口

Defines callback methods for CAPTCHA lifecycle events including generation, successful validation, and failed validation. All methods have default empty implementations so listeners can override only the events they are interested in.

定义验证码生命周期事件的回调方法,包括生成、验证成功和验证失败。 所有方法都有默认的空实现,监听器可以只覆盖感兴趣的事件。

Features | 主要功能:

  • Generation event callback - 生成事件回调
  • Validation success callback - 验证成功回调
  • Validation failure callback with reason code - 带原因代码的验证失败回调
  • Default empty implementations for selective override - 默认空实现支持选择性覆盖

Usage Examples | 使用示例:

CaptchaEventListener listener = new CaptchaEventListener() {
    @Override
    public void onValidationFailure(String captchaId, ValidationResult.ResultCode reason) {
        logger.warn("Captcha validation failed: {} reason={}", captchaId, reason);
    }
};

Security | 安全性:

  • Thread-safe: Implementation-dependent - 线程安全: 取决于实现
  • Null-safe: No (parameters should not be null) - 空值安全: 否(参数不应为空)
Since:
JDK 25, opencode-base-captcha V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Details

    • onGenerated

      default void onGenerated(Captcha captcha)
      Called when a CAPTCHA is generated. 当验证码生成时调用。
      Parameters:
      captcha - the generated CAPTCHA | 生成的验证码
    • onValidationSuccess

      default void onValidationSuccess(String captchaId)
      Called when a CAPTCHA validation succeeds. 当验证码验证成功时调用。
      Parameters:
      captchaId - the CAPTCHA ID that was validated | 被验证的验证码 ID
    • onValidationFailure

      default void onValidationFailure(String captchaId, ValidationResult.ResultCode reason)
      Called when a CAPTCHA validation fails. 当验证码验证失败时调用。
      Parameters:
      captchaId - the CAPTCHA ID that failed validation | 验证失败的验证码 ID
      reason - the failure reason code | 失败原因代码