Skip to content

Commit

Permalink
remove captcha key
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreampie committed Jan 6, 2016
1 parent 4ad71a9 commit e722e86
Showing 1 changed file with 28 additions and 30 deletions.
58 changes: 28 additions & 30 deletions resty-captcha/src/main/java/cn/dreampie/captcha/CaptchaFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,34 @@ public class CaptchaFactory {
private ConfigurableCaptchaService captchaService = null;

public CaptchaFactory() {
if (captchaService == null) {
captchaService = new ConfigurableCaptchaService();

// 颜色创建工厂
captchaService.setColorFactory(new SingleColorFactory(new Color(0, 0, 0)));

// 图片滤镜设置
captchaService.setFilterFactory(getFilterFactory(CaptchaFilter.Curves));

// 随机字体生成器
RandomFontFactory fontFactory = new RandomFontFactory();
fontFactory.setMaxSize(45);
fontFactory.setMinSize(45);
captchaService.setFontFactory(fontFactory);

// 随机字符生成器,去除掉容易混淆的字母和数字,如o和0等
RandomWordFactory wordFactory = new RandomWordFactory();
wordFactory.setCharacters("ABCDEFGHIJKLMNPQRSTUVWXYZ123456789");
wordFactory.setMaxLength(4);
wordFactory.setMinLength(4);
captchaService.setWordFactory(wordFactory);

// 文字渲染器设置
BestFitTextRenderer textRenderer = new BestFitTextRenderer();
textRenderer.setBottomMargin(1);
textRenderer.setTopMargin(1);
captchaService.setTextRenderer(textRenderer);

captchaService.setBackgroundFactory(new RandomColorBackgroundFactory());
}
captchaService = new ConfigurableCaptchaService();

// 颜色创建工厂
captchaService.setColorFactory(new SingleColorFactory(new Color(0, 0, 0)));

// 图片滤镜设置
captchaService.setFilterFactory(getFilterFactory(CaptchaFilter.Curves));

// 随机字体生成器
RandomFontFactory fontFactory = new RandomFontFactory();
fontFactory.setMaxSize(45);
fontFactory.setMinSize(45);
captchaService.setFontFactory(fontFactory);

// 随机字符生成器,去除掉容易混淆的字母和数字,如o和0等
RandomWordFactory wordFactory = new RandomWordFactory();
wordFactory.setCharacters("ABCDEFGHIJKLMNPQRSTUVWXYZ123456789");
wordFactory.setMaxLength(4);
wordFactory.setMinLength(4);
captchaService.setWordFactory(wordFactory);

// 文字渲染器设置
BestFitTextRenderer textRenderer = new BestFitTextRenderer();
textRenderer.setBottomMargin(1);
textRenderer.setTopMargin(1);
captchaService.setTextRenderer(textRenderer);

captchaService.setBackgroundFactory(new RandomColorBackgroundFactory());
}

public Captcha getCaptcha() {
Expand Down

0 comments on commit e722e86

Please sign in to comment.