public class BlockPuzzleCaptchaServiceImpl extends AbstractCaptchaService
Created by raodeming on 2019/12/25.
cacheType, captchaAesStatus, captchaInterferenceOptions, clickWordFont, clickWordFontStr, EXPIRESIN_SECONDS, EXPIRESIN_THREE, HAN_ZI_SIZE, HAN_ZI_SIZE_HALF, IMAGE_TYPE_PNG, logger, REDIS_CAPTCHA_KEY, REDIS_SECOND_CAPTCHA_KEY, slipOffset, waterMark, waterMarkFont, waterMarkFontStr| 构造器和说明 |
|---|
BlockPuzzleCaptchaServiceImpl() |
| 限定符和类型 | 方法和说明 |
|---|---|
private static int |
avgMatrix(int[][] matrix) |
String |
captchaType()
验证码类型
通过java SPI机制,接入方可自定义实现类,实现新的验证类型
|
ResponseModel |
check(CaptchaVO captchaVO)
核对验证码(前端)
|
private static void |
cutByTemplate(BufferedImage oriImage,
BufferedImage templateImage,
BufferedImage newImage,
int x,
int y) |
void |
destroy(Properties config)
历史资源清除(过期的图片文件,生成的临时图片...)
|
private static void |
fillMatrix(int[][] matrix,
int[] values) |
private static PointVO |
generateJigsawPoint(int originalWidth,
int originalHeight,
int jigsawWidth,
int jigsawHeight)
随机生成拼图坐标
|
ResponseModel |
get(CaptchaVO captchaVO)
获取验证码
|
void |
init(Properties config)
判断应用是否实现了自定义缓存,没有就使用内存
|
private static void |
interferenceByTemplate(BufferedImage oriImage,
BufferedImage templateImage,
int x,
int y)
干扰抠图处理
|
CaptchaVO |
pictureTemplatesCut(BufferedImage originalImage,
BufferedImage jigsawImage,
String jigsawImageBase64)
根据模板切图
|
private static void |
readPixel(BufferedImage img,
int x,
int y,
int[] pixels) |
ResponseModel |
verification(CaptchaVO captchaVO)
二次校验验证码(后端)
|
afterValidateFail, base64StrToImage, decrypt, getCacheService, getEnOrChLength, getValidateClientId, validatedReqpublic void init(Properties config)
AbstractCaptchaServiceinit 在接口中 CaptchaServiceinit 在类中 AbstractCaptchaServiceconfig - configpublic void destroy(Properties config)
CaptchaServicedestroy 在接口中 CaptchaServicedestroy 在类中 AbstractCaptchaServiceconfig - 配置项 控制资源清理的粒度public String captchaType()
CaptchaServicepublic ResponseModel get(CaptchaVO captchaVO)
CaptchaServiceget 在接口中 CaptchaServiceget 在类中 AbstractCaptchaServicepublic ResponseModel check(CaptchaVO captchaVO)
CaptchaServicecheck 在接口中 CaptchaServicecheck 在类中 AbstractCaptchaServicepublic ResponseModel verification(CaptchaVO captchaVO)
CaptchaServiceverification 在接口中 CaptchaServiceverification 在类中 AbstractCaptchaServicepublic CaptchaVO pictureTemplatesCut(BufferedImage originalImage, BufferedImage jigsawImage, String jigsawImageBase64)
originalImage - originalImagejigsawImage - jigsawImagejigsawImageBase64 - jigsawImageBase64private static PointVO generateJigsawPoint(int originalWidth, int originalHeight, int jigsawWidth, int jigsawHeight)
originalWidth - originalWidthoriginalHeight - originalHeightjigsawWidth - jigsawWidthjigsawHeight - jigsawHeightprivate static void cutByTemplate(BufferedImage oriImage, BufferedImage templateImage, BufferedImage newImage, int x, int y)
oriImage - 原图templateImage - 模板图newImage - 新抠出的小图x - 随机扣取坐标Xy - 随机扣取坐标yprivate static void interferenceByTemplate(BufferedImage oriImage, BufferedImage templateImage, int x, int y)
oriImage - 原图templateImage - 模板图x - 随机扣取坐标Xy - 随机扣取坐标yprivate static void readPixel(BufferedImage img, int x, int y, int[] pixels)
private static void fillMatrix(int[][] matrix,
int[] values)
private static int avgMatrix(int[][] matrix)
Copyright © 2023. All rights reserved.