Interface CaptchaRenderer
- All Known Implementing Classes:
AudioCaptchaRenderer, Base64CaptchaRenderer, GifCaptchaRenderer, ImageCaptchaRenderer
public interface CaptchaRenderer
Captcha Renderer - Interface for CAPTCHA rendering
验证码渲染器 - 验证码渲染接口
This interface defines the contract for rendering CAPTCHAs to various outputs.
此接口定义了将验证码渲染到各种输出的契约。
Features | 主要功能:
- Multiple output format support - 多种输出格式支持
- Stream-based rendering - 基于流的渲染
Usage Examples | 使用示例:
CaptchaRenderer renderer = new ImageCaptchaRenderer();
renderer.render(captcha, outputStream);
Security | 安全性:
- Thread-safe: Implementation dependent - 线程安全: 取决于实现
- Null-safe: No (captcha and stream must not be null) - 空值安全: 否(验证码和流不能为null)
- Since:
- JDK 25, opencode-base-captcha V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic CaptchaRendereraudio()Creates an audio renderer.static CaptchaRendererbase64()Creates a Base64 renderer.Gets the content type of the rendered output.static CaptchaRenderergif()Creates a GIF renderer.static CaptchaRendererimage()Creates an image renderer.voidrender(Captcha captcha, OutputStream out) Renders the CAPTCHA to an output stream.renderToBase64(Captcha captcha) Renders the CAPTCHA to a Base64 string.byte[]renderToBytes(Captcha captcha) Renders the CAPTCHA to a byte array.
-
Method Details
-
render
Renders the CAPTCHA to an output stream. 将验证码渲染到输出流。- Parameters:
captcha- the CAPTCHA | 验证码out- the output stream | 输出流- Throws:
IOException- if rendering fails | 如果渲染失败
-
renderToBytes
Renders the CAPTCHA to a byte array. 将验证码渲染到字节数组。- Parameters:
captcha- the CAPTCHA | 验证码- Returns:
- the rendered bytes | 渲染的字节
-
renderToBase64
-
getContentType
String getContentType()Gets the content type of the rendered output. 获取渲染输出的内容类型。- Returns:
- the content type | 内容类型
-
image
-
gif
-
base64
Creates a Base64 renderer. 创建 Base64 渲染器。- Returns:
- the renderer | 渲染器
-
audio
-