package com.hanhanfilm.common.captcha.bean;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.Random;
/**
* https://www.hanhanfilm.com
* Created by badouyuren.
*/
public class IllegalCaptcha extends BaseCaptcha {
public IllegalCaptcha(int randomCodeNum) {
super(randomCodeNum);
}
@Override
public String generateRandomCode() {
return "非法的请求";
}
@Override
public BufferedImage drawGraphic() {
BufferedImage image = new BufferedImage(imgWidth, imgHeight, BufferedImage.TYPE_INT_RGB);
Graphics g = image.createGraphics();
g.setColor(getRandColor(200, 250));
g.fillRect(0, 0, imgWidth, imgHeight);
g.setFont(new Font("TimesRoman", Font.PLAIN, 20));
Random random = new Random();
g.setColor(new Color(20 + random.nextInt(110), 20 + random.nextInt(110), 20 + random.nextInt(110)));
g.drawString(this.randomCode,4,21);
g.dispose();
return image;
}
}对非法请求获取验证码图片做出回应