com.google.code.kaptcha.impl.DefaultKaptcha Java Examples

The following examples show how to use com.google.code.kaptcha.impl.DefaultKaptcha. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KaptchaConfig.java    From spring-boot-projects with Apache License 2.0 6 votes vote down vote up
@Bean
public DefaultKaptcha getDefaultKaptcha(){
    com.google.code.kaptcha.impl.DefaultKaptcha defaultKaptcha = new com.google.code.kaptcha.impl.DefaultKaptcha();
    Properties properties = new Properties();
    properties.put("kaptcha.border", "no");
    properties.put("kaptcha.textproducer.font.color", "black");
    properties.put("kaptcha.image.width", "150");
    properties.put("kaptcha.image.height", "40");
    properties.put("kaptcha.textproducer.font.size", "30");
    properties.put("kaptcha.session.key", "verifyCode");
    properties.put("kaptcha.textproducer.char.space", "5");
    Config config = new Config(properties);
    defaultKaptcha.setConfig(config);

    return defaultKaptcha;
}
 
Example #2
Source File: KaptchaCodeUtils.java    From CAS with Apache License 2.0 6 votes vote down vote up
/**
 * Kaptcha 配置信息
 *
 * @return
 */
public static DefaultKaptcha getDefaultKaptcha() {
    com.google.code.kaptcha.impl.DefaultKaptcha defaultKaptcha = new com.google.code.kaptcha.impl.DefaultKaptcha();
    Properties properties = new Properties();
    properties.setProperty("kaptcha.border", "yes");
    properties.setProperty("kaptcha.border.color", "105,179,90");
    properties.setProperty("kaptcha.textproducer.font.color", "blue");
    properties.setProperty("kaptcha.image.width", "110");
    properties.setProperty("kaptcha.image.height", "40");
    properties.setProperty("kaptcha.textproducer.font.size", "30");
    properties.setProperty("kaptcha.session.key", "code");
    properties.setProperty("kaptcha.textproducer.char.length", "4");
    properties.setProperty("kaptcha.textproducer.font.names", "宋体,楷体,微软雅黑");
    Config config = new Config(properties);
    defaultKaptcha.setConfig(config);

    return defaultKaptcha;
}
 
Example #3
Source File: KaptchaCodeUtils.java    From CAS with Apache License 2.0 6 votes vote down vote up
/**
 * Kaptcha 配置信息
 *
 * @return
 */
public static DefaultKaptcha getDefaultKaptcha() {
    com.google.code.kaptcha.impl.DefaultKaptcha defaultKaptcha = new com.google.code.kaptcha.impl.DefaultKaptcha();
    Properties properties = new Properties();
    properties.setProperty("kaptcha.border", "yes");
    properties.setProperty("kaptcha.border.color", "105,179,90");
    properties.setProperty("kaptcha.textproducer.font.color", "blue");
    properties.setProperty("kaptcha.image.width", "110");
    properties.setProperty("kaptcha.image.height", "40");
    properties.setProperty("kaptcha.textproducer.font.size", "30");
    properties.setProperty("kaptcha.session.key", "code");
    properties.setProperty("kaptcha.textproducer.char.length", "4");
    properties.setProperty("kaptcha.textproducer.font.names", "宋体,楷体,微软雅黑");
    Config config = new Config(properties);
    defaultKaptcha.setConfig(config);

    return defaultKaptcha;
}
 
Example #4
Source File: PaasCloudOpcApplication.java    From paascloud-master with Apache License 2.0 6 votes vote down vote up
/**
 * Get kaptcha bean default kaptcha.
 *
 * @return the default kaptcha
 */
@Bean(name = "captchaProducer")
public DefaultKaptcha getKaptchaBean() {
	DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
	Properties properties = new Properties();
	properties.setProperty("kaptcha.border", "yes");
	properties.setProperty("kaptcha.border.color", "105,179,90");
	properties.setProperty("kaptcha.textproducer.font.color", "blue");
	properties.setProperty("kaptcha.image.width", "125");
	properties.setProperty("kaptcha.image.height", "45");
	properties.setProperty("kaptcha.session.key", "code");
	properties.setProperty("kaptcha.textproducer.char.length", "4");
	properties.setProperty("kaptcha.textproducer.font.names", "宋体,楷体,微软雅黑");
	Config config = new Config(properties);
	defaultKaptcha.setConfig(config);
	return defaultKaptcha;
}
 
Example #5
Source File: CaptchaConfig.java    From paascloud-master with Apache License 2.0 6 votes vote down vote up
/**
 * Get kaptcha bean default kaptcha.
 *
 * @return the default kaptcha
 */
@Bean(name = "captchaProducer")
public DefaultKaptcha getKaptchaBean() {
	DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
	Properties properties = new Properties();
	properties.setProperty("kaptcha.border", "no");
	properties.setProperty("kaptcha.border.color", "no");
	properties.setProperty("kaptcha.border.color", "220,227,232");
	properties.setProperty("kaptcha.textproducer.char.string", "2345689");
	properties.setProperty("kaptcha.textproducer.font.color", "black");
	properties.setProperty("kaptcha.textproducer.font.size", "16");
	properties.setProperty("kaptcha.image.width", "106");
	properties.setProperty("kaptcha.image.height", "30");
	properties.setProperty("kaptcha.session.key", "kaptchaCode");
	properties.setProperty("kaptcha.textproducer.char.length", "4");
	properties.setProperty("kaptcha.background.clear.from", "white");
	properties.setProperty("kaptcha.background.clear.to", "white");
	properties.setProperty("kaptcha.textproducer.char.space", "5");
	properties.setProperty("kaptcha.obscurificator.impl", "com.google.code.kaptcha.impl.ShadowGimpy");
	properties.setProperty("kaptcha.noise.impl", "com.google.code.kaptcha.impl.NoNoise");
	properties.setProperty("kaptcha.textproducer.font.names", "Verdana");
	Config config = new Config(properties);
	defaultKaptcha.setConfig(config);
	return defaultKaptcha;
}
 
Example #6
Source File: KaptchaHelper.java    From seezoon-framework-all with Apache License 2.0 6 votes vote down vote up
public KaptchaHelper() {
		Properties properties = new Properties();
		properties.setProperty("kaptcha.border", border);
		properties.setProperty("kaptcha.border.color", borderColor);
		properties.setProperty("kaptcha.textproducer.font.color", fontColor);
		properties.setProperty("kaptcha.textproducer.font.size", fontSize);
		properties.setProperty("kaptcha.image.width", imageWidth);
		properties.setProperty("kaptcha.image.height", imageHeight);
		properties.setProperty("kaptcha.textproducer.char.length", charLength);
		properties.setProperty("kaptcha.textproducer.font.names", fontNames);
		//间隔
		properties.setProperty("kaptcha.textproducer.char.space", "3");
		
//		图片样式:
//		水纹com.google.code.kaptcha.impl.WaterRipple
//		鱼眼com.google.code.kaptcha.impl.FishEyeGimpy
//		阴影com.google.code.kaptcha.impl.ShadowGimpy
		properties.setProperty("kaptcha.obscurificator.impl", "com.google.code.kaptcha.impl.FishEyeGimpy");
		
		Config config = new Config(properties);
		defaultKaptcha = new DefaultKaptcha();
		defaultKaptcha.setConfig(config);
	}
 
Example #7
Source File: KaptchaCodeUtils.java    From CAS with Apache License 2.0 6 votes vote down vote up
/**
 * Kaptcha 配置信息
 *
 * @return
 */
public static DefaultKaptcha getDefaultKaptcha() {
    com.google.code.kaptcha.impl.DefaultKaptcha defaultKaptcha = new com.google.code.kaptcha.impl.DefaultKaptcha();
    Properties properties = new Properties();
    properties.setProperty("kaptcha.border", "yes");
    properties.setProperty("kaptcha.border.color", "105,179,90");
    properties.setProperty("kaptcha.textproducer.font.color", "blue");
    properties.setProperty("kaptcha.image.width", "110");
    properties.setProperty("kaptcha.image.height", "40");
    properties.setProperty("kaptcha.textproducer.font.size", "30");
    properties.setProperty("kaptcha.session.key", "code");
    properties.setProperty("kaptcha.textproducer.char.length", "4");
    properties.setProperty("kaptcha.textproducer.font.names", "宋体,楷体,微软雅黑");
    Config config = new Config(properties);
    defaultKaptcha.setConfig(config);

    return defaultKaptcha;
}
 
Example #8
Source File: KaptchaConfig.java    From newbee-mall with GNU General Public License v3.0 6 votes vote down vote up
@Bean
public DefaultKaptcha getDefaultKaptcha(){
    com.google.code.kaptcha.impl.DefaultKaptcha defaultKaptcha = new com.google.code.kaptcha.impl.DefaultKaptcha();
    Properties properties = new Properties();
    properties.put("kaptcha.border", "no");
    properties.put("kaptcha.textproducer.font.color", "black");
    properties.put("kaptcha.image.width", "150");
    properties.put("kaptcha.image.height", "40");
    properties.put("kaptcha.textproducer.font.size", "30");
    properties.put("kaptcha.session.key", "verifyCode");
    properties.put("kaptcha.textproducer.char.space", "5");
    Config config = new Config(properties);
    defaultKaptcha.setConfig(config);

    return defaultKaptcha;
}
 
Example #9
Source File: WebConfig.java    From WebStack-Guns with MIT License 6 votes vote down vote up
/**
 * 验证码生成相关
 */
@Bean
public DefaultKaptcha kaptcha() {
    Properties properties = new Properties();
    properties.put("kaptcha.border", "no");
    properties.put("kaptcha.border.color", "105,179,90");
    properties.put("kaptcha.textproducer.font.color", "blue");
    properties.put("kaptcha.image.width", "125");
    properties.put("kaptcha.image.height", "45");
    properties.put("kaptcha.textproducer.font.size", "45");
    properties.put("kaptcha.session.key", "code");
    properties.put("kaptcha.textproducer.char.length", "4");
    properties.put("kaptcha.textproducer.font.names", "宋体,楷体,微软雅黑");
    Config config = new Config(properties);
    DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
    defaultKaptcha.setConfig(config);
    return defaultKaptcha;
}
 
Example #10
Source File: WebConfig.java    From Guns with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 验证码生成相关
 */
@Bean
public DefaultKaptcha kaptcha() {
    Properties properties = new Properties();
    properties.put("kaptcha.border", "no");
    properties.put("kaptcha.border.color", "105,179,90");
    properties.put("kaptcha.textproducer.font.color", "blue");
    properties.put("kaptcha.image.width", "125");
    properties.put("kaptcha.image.height", "45");
    properties.put("kaptcha.textproducer.font.size", "45");
    properties.put("kaptcha.session.key", "code");
    properties.put("kaptcha.textproducer.char.length", "4");
    properties.put("kaptcha.textproducer.font.names", "宋体,楷体,微软雅黑");
    Config config = new Config(properties);
    DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
    defaultKaptcha.setConfig(config);
    return defaultKaptcha;
}
 
Example #11
Source File: KaptchaCodeUtils.java    From CAS with Apache License 2.0 6 votes vote down vote up
/**
 * Kaptcha 配置信息
 *
 * @return
 */
public static DefaultKaptcha getDefaultKaptcha() {
    com.google.code.kaptcha.impl.DefaultKaptcha defaultKaptcha = new com.google.code.kaptcha.impl.DefaultKaptcha();
    Properties properties = new Properties();
    properties.setProperty("kaptcha.border", "yes");
    properties.setProperty("kaptcha.border.color", "105,179,90");
    properties.setProperty("kaptcha.textproducer.font.color", "blue");
    properties.setProperty("kaptcha.image.width", "110");
    properties.setProperty("kaptcha.image.height", "40");
    properties.setProperty("kaptcha.textproducer.font.size", "30");
    properties.setProperty("kaptcha.session.key", "code");
    properties.setProperty("kaptcha.textproducer.char.length", "4");
    properties.setProperty("kaptcha.textproducer.font.names", "宋体,楷体,微软雅黑");
    Config config = new Config(properties);
    defaultKaptcha.setConfig(config);

    return defaultKaptcha;
}
 
Example #12
Source File: WebConfig.java    From MeetingFilm with Apache License 2.0 6 votes vote down vote up
/**
 * 验证码生成相关
 */
@Bean
public DefaultKaptcha kaptcha() {
    Properties properties = new Properties();
    properties.put("kaptcha.border", "no");
    properties.put("kaptcha.border.color", "105,179,90");
    properties.put("kaptcha.textproducer.font.color", "blue");
    properties.put("kaptcha.image.width", "125");
    properties.put("kaptcha.image.height", "45");
    properties.put("kaptcha.textproducer.font.size", "45");
    properties.put("kaptcha.session.key", "code");
    properties.put("kaptcha.textproducer.char.length", "4");
    properties.put("kaptcha.textproducer.font.names", "宋体,楷体,微软雅黑");
    Config config = new Config(properties);
    DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
    defaultKaptcha.setConfig(config);
    return defaultKaptcha;
}
 
Example #13
Source File: ValidateCodeConfig.java    From spring-microservice-exam with MIT License 6 votes vote down vote up
@Bean
public DefaultKaptcha producer() {
    Properties properties = new Properties();
    properties.put("kaptcha.border", "no");
    // 验证码字体颜色
    properties.put("kaptcha.textproducer.font.color", "black");
    // 验证码字体大小
    properties.put("kaptcha.textproducer.font.size", "40");
    // 验证码文本字符间距
    properties.put("kaptcha.textproducer.char.space", "6");
    // 验证码宽度
    properties.put("kaptcha.image.width", "120");
    // 验证码高度
    properties.put("kaptcha.image.height", "50");
    properties.put("kaptcha.textproducer.char.length", "4");
    Config config = new Config(properties);
    DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
    defaultKaptcha.setConfig(config);
    return defaultKaptcha;
}
 
Example #14
Source File: KaptchaProducerAgency.java    From dpCms with Apache License 2.0 6 votes vote down vote up
private static void init(){
  	kaptchaProducer = new DefaultKaptcha();
  	Properties properties = new Properties();
properties.setProperty("kaptcha.border", "no");
properties.setProperty("kaptcha.textproducer.font.color", "black");
properties.setProperty("kaptcha.noise.color", "black");
properties.setProperty("kaptcha.textproducer.impl", "com.google.code.kaptcha.text.impl.DefaultTextCreator");
properties.setProperty("kaptcha.textproducer.char.string", "1234567890");
properties.setProperty("kaptcha.obscurificator.impl", "com.google.code.kaptcha.impl.ShadowGimpy");
properties.setProperty("kaptcha.image.width", "100");
properties.setProperty("kaptcha.textproducer.font.size", "21");
properties.setProperty("kaptcha.image.height", "40");
properties.setProperty("kaptcha.session.key", "loginCode");
properties.setProperty("kaptcha.textproducer.char.length", "5");
properties.setProperty("kaptcha.textproducer.font.names", "宋体,楷体,微软雅黑");
Config config = new Config(properties);
kaptchaProducer.setConfig(config);
  }
 
Example #15
Source File: SmartKaptchaConfig.java    From smart-admin with MIT License 6 votes vote down vote up
@Bean
public DefaultKaptcha getDefaultKaptcha(){
    DefaultKaptcha defaultKaptcha=new DefaultKaptcha();
    Properties properties=new Properties();
    properties.setProperty("kaptcha.border", "no");
    properties.setProperty("kaptcha.border.color", "34,114,200");
    properties.setProperty("kaptcha.image.width", "125");
    properties.setProperty("kaptcha.image.height", "45");
    properties.setProperty("kaptcha.textproducer.char.string", "ABCDEFG23456789");
    properties.setProperty("kaptcha.textproducer.char.length", "5");
    properties.setProperty("kaptcha.textproducer.font.names", "Arial,Arial Narrow,Serif,Helvetica,Tahoma,Times New Roman,Verdana");
    properties.setProperty("kaptcha.textproducer.font.size", "38");

    properties.setProperty("kaptcha.background.clear.from", "white");
    properties.setProperty("kaptcha.background.clear.to", "white");

    properties.setProperty("kaptcha.word.impl", KaptchaWordRenderer.class.getName());
    properties.setProperty("kaptcha.noise.impl", KaptchaNoise.class.getName());

    Config config=new Config(properties);
    defaultKaptcha.setConfig(config);
    return defaultKaptcha;
}
 
Example #16
Source File: KaptchaConfig.java    From MyCommunity with Apache License 2.0 6 votes vote down vote up
@Bean
public Producer kaptchaProducer()  {
    Properties properties = new Properties();
    properties.setProperty("kaptcha.image.width", "100");
    properties.setProperty("kaptcha.image.height", "40");
    properties.setProperty("kaptcha.textproducer.font.size", "32");  // 字号
    properties.setProperty("kaptcha.textproducer.font.color", "0,0,0");  // 字体颜色
    properties.setProperty("kaptcha.textproducer.char.string", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYAZ");
    properties.setProperty("kaptcha.textproducer.char.length", "4");  // 验证码数量
    properties.setProperty("kaptcha.noise.impl", "com.google.code.kaptcha.impl.NoNoise");  // 设置干扰

    DefaultKaptcha kaptcha = new DefaultKaptcha();
    Config config = new Config(properties);
    kaptcha.setConfig(config);
    return kaptcha;
}
 
Example #17
Source File: KaptchaCodeUtils.java    From CAS with Apache License 2.0 6 votes vote down vote up
/**
 * Kaptcha 配置信息
 *
 * @return
 */
public static DefaultKaptcha getDefaultKaptcha() {
    com.google.code.kaptcha.impl.DefaultKaptcha defaultKaptcha = new com.google.code.kaptcha.impl.DefaultKaptcha();
    Properties properties = new Properties();
    properties.setProperty("kaptcha.border", "yes");
    properties.setProperty("kaptcha.border.color", "105,179,90");
    properties.setProperty("kaptcha.textproducer.font.color", "blue");
    properties.setProperty("kaptcha.image.width", "110");
    properties.setProperty("kaptcha.image.height", "40");
    properties.setProperty("kaptcha.textproducer.font.size", "30");
    properties.setProperty("kaptcha.session.key", "code");
    properties.setProperty("kaptcha.textproducer.char.length", "4");
    properties.setProperty("kaptcha.textproducer.font.names", "宋体,楷体,微软雅黑");
    Config config = new Config(properties);
    defaultKaptcha.setConfig(config);

    return defaultKaptcha;
}
 
Example #18
Source File: KaptchaConfig.java    From My-Blog with Apache License 2.0 6 votes vote down vote up
@Bean
public DefaultKaptcha getDefaultKaptcha(){
    com.google.code.kaptcha.impl.DefaultKaptcha defaultKaptcha = new com.google.code.kaptcha.impl.DefaultKaptcha();
    Properties properties = new Properties();
    properties.put("kaptcha.border", "no");
    properties.put("kaptcha.textproducer.font.color", "black");
    properties.put("kaptcha.image.width", "150");
    properties.put("kaptcha.image.height", "40");
    properties.put("kaptcha.textproducer.font.size", "30");
    properties.put("kaptcha.session.key", "verifyCode");
    properties.put("kaptcha.textproducer.char.space", "5");
    Config config = new Config(properties);
    defaultKaptcha.setConfig(config);

    return defaultKaptcha;
}
 
Example #19
Source File: KaptchaCodeUtils.java    From CAS with Apache License 2.0 6 votes vote down vote up
/**
 * Kaptcha 配置信息
 *
 * @return
 */
public static DefaultKaptcha getDefaultKaptcha() {
    com.google.code.kaptcha.impl.DefaultKaptcha defaultKaptcha = new com.google.code.kaptcha.impl.DefaultKaptcha();
    Properties properties = new Properties();
    properties.setProperty("kaptcha.border", "yes");
    properties.setProperty("kaptcha.border.color", "105,179,90");
    properties.setProperty("kaptcha.textproducer.font.color", "blue");
    properties.setProperty("kaptcha.image.width", "110");
    properties.setProperty("kaptcha.image.height", "40");
    properties.setProperty("kaptcha.textproducer.font.size", "30");
    properties.setProperty("kaptcha.session.key", "code");
    properties.setProperty("kaptcha.textproducer.char.length", "4");
    properties.setProperty("kaptcha.textproducer.font.names", "宋体,楷体,微软雅黑");
    Config config = new Config(properties);
    defaultKaptcha.setConfig(config);

    return defaultKaptcha;
}
 
Example #20
Source File: KaptchaConfig.java    From sdb-mall with Apache License 2.0 5 votes vote down vote up
@Bean
public DefaultKaptcha producer() {
    Properties properties = new Properties();
    properties.put("kaptcha.border", "no");
    properties.put("kaptcha.textproducer.font.color", "black");
    properties.put("kaptcha.textproducer.char.space", "5");
    Config config = new Config(properties);
    DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
    defaultKaptcha.setConfig(config);
    return defaultKaptcha;
}
 
Example #21
Source File: KaptchaConfig.java    From pig with MIT License 5 votes vote down vote up
@Bean
public DefaultKaptcha producer() {
    Properties properties = new Properties();
    properties.put(KAPTCHA_BORDER, SecurityConstants.DEFAULT_IMAGE_BORDER);
    properties.put(KAPTCHA_TEXTPRODUCER_FONT_COLOR, SecurityConstants.DEFAULT_COLOR_FONT);
    properties.put(KAPTCHA_TEXTPRODUCER_CHAR_SPACE, SecurityConstants.DEFAULT_CHAR_SPACE);
    properties.put(KAPTCHA_IMAGE_WIDTH, SecurityConstants.DEFAULT_IMAGE_WIDTH);
    properties.put(KAPTCHA_IMAGE_HEIGHT, SecurityConstants.DEFAULT_IMAGE_HEIGHT);
    properties.put(KAPTCHA_IMAGE_FONT_SIZE, SecurityConstants.DEFAULT_IMAGE_FONT_SIZE);
    properties.put(KAPTCHA_TEXTPRODUCER_CHAR_LENGTH, SecurityConstants.DEFAULT_IMAGE_LENGTH);
    Config config = new Config(properties);
    DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
    defaultKaptcha.setConfig(config);
    return defaultKaptcha;
}
 
Example #22
Source File: CaptchaController.java    From CAS with Apache License 2.0 5 votes vote down vote up
/**
 * 谷歌kaptcha验证码路径
 *
 * @param request
 * @param response
 * @throws Exception
 */
@GetMapping(value = "/kaptcha", produces = "image/png")
public void kaptcha(HttpServletRequest request, HttpServletResponse response) throws Exception {
    byte[] captchaChallengeAsJpeg = null;
    DefaultKaptcha captchaProducer = KaptchaCodeUtils.getDefaultKaptcha();
    OutputStream out = null;
    ByteArrayOutputStream jpegOutputStream = new ByteArrayOutputStream();
    try {

        response.setHeader("Cache-Control", "no-store");
        response.setContentType("image/png");

        //生产验证码字符串并保存到session中
        String createText = captchaProducer.createText();
        request.getSession().setAttribute("captcha_code", createText);

        //使用生产的验证码字符串返回一个BufferedImage对象并转为byte写入到byte数组中
        BufferedImage challenge = captchaProducer.createImage(createText);
        ImageIO.write(challenge, "png", jpegOutputStream);

        //使用response输出流输出图片的byte数组
        captchaChallengeAsJpeg = jpegOutputStream.toByteArray();

        out = response.getOutputStream();

        out.write(captchaChallengeAsJpeg);
        out.flush();


    } catch (IllegalArgumentException e) {
        response.sendError(HttpServletResponse.SC_NOT_FOUND);
        return;
    } finally {
        if (out != null) {
            out.close();
        }
    }
}
 
Example #23
Source File: KaptchaConfig.java    From fw-cloud-framework with MIT License 5 votes vote down vote up
@Bean
public DefaultKaptcha producer() {
	Properties properties = new Properties();
	properties.put(KAPTCHA_BORDER, SecurityConstant.DEFAULT_IMAGE_BORDER);
	properties.put(KAPTCHA_TEXTPRODUCER_FONT_COLOR, SecurityConstant.DEFAULT_COLOR_FONT);
	properties.put(KAPTCHA_TEXTPRODUCER_CHAR_SPACE, SecurityConstant.DEFAULT_CHAR_SPACE);
	properties.put(KAPTCHA_IMAGE_WIDTH, SecurityConstant.DEFAULT_IMAGE_WIDTH);
	properties.put(KAPTCHA_IMAGE_HEIGHT, SecurityConstant.DEFAULT_IMAGE_HEIGHT);
	properties.put(KAPTCHA_IMAGE_FONT_SIZE, SecurityConstant.DEFAULT_IMAGE_FONT_SIZE);
	properties.put(KAPTCHA_TEXTPRODUCER_CHAR_LENGTH, SecurityConstant.DEFAULT_IMAGE_LENGTH);
	Config config = new Config(properties);
	DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
	defaultKaptcha.setConfig(config);
	return defaultKaptcha;
}
 
Example #24
Source File: KaptchaConfiguration.java    From ml-blog with MIT License 5 votes vote down vote up
@Bean
public DefaultKaptcha producer() {
    Properties properties = new Properties();
    properties.put("kaptcha.border", "no");
    properties.put("kaptcha.image.width","110");
    properties.put("kaptcha.image.height","45");
    properties.put("kaptcha.textproducer.font.size","35");
    properties.put("kaptcha.textproducer.font.color", "black");
    properties.put("kaptcha.textproducer.char.length", "4");
    Config config = new Config(properties);
    DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
    defaultKaptcha.setConfig(config);
    return defaultKaptcha;
}
 
Example #25
Source File: CaptchaConfig.java    From RuoYi with Apache License 2.0 5 votes vote down vote up
@Bean(name = "captchaProducer")
public DefaultKaptcha getKaptchaBean() {
    DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
    Properties properties = new Properties();
    // 是否有边框 默认为true 我们可以自己设置yes,no
    properties.setProperty("kaptcha.border", "yes");
    // 边框颜色 默认为Color.BLACK
    properties.setProperty("kaptcha.border.color", "105,179,90");
    // 验证码文本字符颜色 默认为Color.BLACK
    properties.setProperty("kaptcha.textproducer.font.color", "blue");
    // 验证码图片宽度 默认为200
    properties.setProperty("kaptcha.image.width", "180");
    // 验证码图片高度 默认为50
    properties.setProperty("kaptcha.image.height", "60");
    // 验证码文本字符大小 默认为40
    properties.setProperty("kaptcha.textproducer.font.size", "30");
    // KAPTCHA_SESSION_KEY
    properties.setProperty("kaptcha.session.key", "kaptchaCode");
    // 验证码文本字符间距 默认为2
    properties.setProperty("kaptcha.textproducer.char.space", "3");
    // 验证码文本字符长度 默认为5
    properties.setProperty("kaptcha.textproducer.char.length", "6");
    // 验证码文本字体样式 默认为new Font("Arial", 1, fontSize), new Font("Courier", 1, fontSize)
    properties.setProperty("kaptcha.textproducer.font.names", "Arial,Courier");
    // 验证码噪点颜色 默认为Color.BLACK
    properties.setProperty("kaptcha.noise.color", "white");
    Config config = new Config(properties);
    defaultKaptcha.setConfig(config);
    return defaultKaptcha;
}
 
Example #26
Source File: CaptchaConfig.java    From RuoYi with Apache License 2.0 5 votes vote down vote up
@Bean(name = "captchaProducerMath")
public DefaultKaptcha getKaptchaBeanMath() {
    DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
    Properties properties = new Properties();
    // 是否有边框 默认为true 我们可以自己设置yes,no
    properties.setProperty("kaptcha.border", "yes");
    // 边框颜色 默认为Color.BLACK
    properties.setProperty("kaptcha.border.color", "105,179,90");
    // 验证码文本字符颜色 默认为Color.BLACK
    properties.setProperty("kaptcha.textproducer.font.color", "blue");
    // 验证码图片宽度 默认为200
    properties.setProperty("kaptcha.image.width", "160");
    // 验证码图片高度 默认为50
    properties.setProperty("kaptcha.image.height", "60");
    // 验证码文本字符大小 默认为40
    properties.setProperty("kaptcha.textproducer.font.size", "35");
    // KAPTCHA_SESSION_KEY
    properties.setProperty("kaptcha.session.key", "kaptchaCodeMath");
    // 验证码文本生成器
    properties.setProperty("kaptcha.textproducer.impl", "com.ruoyi.framework.config.KaptchaTextCreator");
    // 验证码文本字符间距 默认为2
    properties.setProperty("kaptcha.textproducer.char.space", "4");
    // 验证码文本字符长度 默认为5
    properties.setProperty("kaptcha.textproducer.char.length", "6");
    // 验证码文本字体样式 默认为new Font("Arial", 1, fontSize), new Font("Courier", 1, fontSize)
    properties.setProperty("kaptcha.textproducer.font.names", "Arial,Courier");
    // 验证码噪点颜色 默认为Color.BLACK
    properties.setProperty("kaptcha.noise.color", "white");
    // 干扰实现类
    properties.setProperty("kaptcha.noise.impl", "com.google.code.kaptcha.impl.NoNoise");
    // 图片样式 水纹com.google.code.kaptcha.impl.WaterRipple 鱼眼com.google.code.kaptcha.impl.FishEyeGimpy 阴影com.google.code.kaptcha.impl.ShadowGimpy
    properties.setProperty("kaptcha.obscurificator.impl", "com.google.code.kaptcha.impl.ShadowGimpy");
    Config config = new Config(properties);
    defaultKaptcha.setConfig(config);
    return defaultKaptcha;
}
 
Example #27
Source File: CaptchaConfig.java    From LuckyFrameWeb with GNU Affero General Public License v3.0 5 votes vote down vote up
@Bean(name = "captchaProducer")
public DefaultKaptcha getKaptchaBean()
{
    DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
    Properties properties = new Properties();
    // 是否有边框  默认为true  我们可以自己设置yes,no
    properties.setProperty("kaptcha.border", "yes");
    // 边框颜色   默认为Color.BLACK  
    properties.setProperty("kaptcha.border.color", "105,179,90");
    // 验证码文本字符颜色  默认为Color.BLACK 
    properties.setProperty("kaptcha.textproducer.font.color", "blue");
    // 验证码图片宽度  默认为200 
    properties.setProperty("kaptcha.image.width", "160");
    // 验证码图片高度  默认为50
    properties.setProperty("kaptcha.image.height", "60");
    // 验证码文本字符大小  默认为40
    properties.setProperty("kaptcha.textproducer.font.size", "30");
    // KAPTCHA_SESSION_KEY
    properties.setProperty("kaptcha.session.key", "kaptchaCode");
    // 验证码文本字符间距  默认为2
    properties.setProperty("kaptcha.textproducer.char.space", "3");
    // 验证码文本字符长度  默认为5
    properties.setProperty("kaptcha.textproducer.char.length", "5");
    // 验证码文本字体样式  默认为new Font("Arial", 1, fontSize), new Font("Courier", 1, fontSize) 
    properties.setProperty("kaptcha.textproducer.font.names", "Arial,Courier");
    // 验证码噪点颜色   默认为Color.BLACK
    properties.setProperty("kaptcha.noise.color", "white");
    Config config = new Config(properties);
    defaultKaptcha.setConfig(config);
    return defaultKaptcha;
}
 
Example #28
Source File: CaptchaConfig.java    From LuckyFrameWeb with GNU Affero General Public License v3.0 5 votes vote down vote up
@Bean(name = "captchaProducerMath")
public DefaultKaptcha getKaptchaBeanMath()
{
    DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
    Properties properties = new Properties();
    // 是否有边框 默认为true 我们可以自己设置yes,no
    properties.setProperty("kaptcha.border", "yes");
    // 边框颜色 默认为Color.BLACK
    properties.setProperty("kaptcha.border.color", "105,179,90");
    // 验证码文本字符颜色 默认为Color.BLACK
    properties.setProperty("kaptcha.textproducer.font.color", "blue");
    // 验证码图片宽度 默认为200
    properties.setProperty("kaptcha.image.width", "160");
    // 验证码图片高度 默认为50
    properties.setProperty("kaptcha.image.height", "60");
    // 验证码文本字符大小 默认为40
    properties.setProperty("kaptcha.textproducer.font.size", "35");
    // KAPTCHA_SESSION_KEY
    properties.setProperty("kaptcha.session.key", "kaptchaCodeMath");
    // 验证码文本生成器
    properties.setProperty("kaptcha.textproducer.impl", "com.luckyframe.framework.config.KaptchaTextCreator");
    // 验证码文本字符间距 默认为2
    properties.setProperty("kaptcha.textproducer.char.space", "3");
    // 验证码文本字符长度 默认为5
    properties.setProperty("kaptcha.textproducer.char.length", "6");
    // 验证码文本字体样式 默认为new Font("Arial", 1, fontSize), new Font("Courier", 1, fontSize)
    properties.setProperty("kaptcha.textproducer.font.names", "Arial,Courier");
    // 验证码噪点颜色 默认为Color.BLACK
    properties.setProperty("kaptcha.noise.color", "white");
    // 干扰实现类
    properties.setProperty("kaptcha.noise.impl", "com.google.code.kaptcha.impl.NoNoise");
    // 图片样式 水纹com.google.code.kaptcha.impl.WaterRipple 鱼眼com.google.code.kaptcha.impl.FishEyeGimpy 阴影com.google.code.kaptcha.impl.ShadowGimpy
    properties.setProperty("kaptcha.obscurificator.impl", "com.google.code.kaptcha.impl.ShadowGimpy");
    Config config = new Config(properties);
    defaultKaptcha.setConfig(config);
    return defaultKaptcha;
}
 
Example #29
Source File: CaptchaConfig.java    From supplierShop with MIT License 5 votes vote down vote up
@Bean(name = "captchaProducerMath")
public DefaultKaptcha getKaptchaBeanMath()
{
    DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
    Properties properties = new Properties();
    // 是否有边框 默认为true 我们可以自己设置yes,no
    properties.setProperty(KAPTCHA_BORDER, "yes");
    // 边框颜色 默认为Color.BLACK
    properties.setProperty(KAPTCHA_BORDER_COLOR, "105,179,90");
    // 验证码文本字符颜色 默认为Color.BLACK
    properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_COLOR, "blue");
    // 验证码图片宽度 默认为200
    properties.setProperty(KAPTCHA_IMAGE_WIDTH, "160");
    // 验证码图片高度 默认为50
    properties.setProperty(KAPTCHA_IMAGE_HEIGHT, "60");
    // 验证码文本字符大小 默认为40
    properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_SIZE, "35");
    // KAPTCHA_SESSION_KEY
    properties.setProperty(KAPTCHA_SESSION_CONFIG_KEY, "kaptchaCodeMath");
    // 验证码文本生成器
    properties.setProperty(KAPTCHA_TEXTPRODUCER_IMPL, "com.ruoyi.framework.config.KaptchaTextCreator");
    // 验证码文本字符间距 默认为2
    properties.setProperty(KAPTCHA_TEXTPRODUCER_CHAR_SPACE, "3");
    // 验证码文本字符长度 默认为5
    properties.setProperty(KAPTCHA_TEXTPRODUCER_CHAR_LENGTH, "6");
    // 验证码文本字体样式 默认为new Font("Arial", 1, fontSize), new Font("Courier", 1, fontSize)
    properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_NAMES, "Arial,Courier");
    // 验证码噪点颜色 默认为Color.BLACK
    properties.setProperty(KAPTCHA_NOISE_COLOR, "white");
    // 干扰实现类
    properties.setProperty(KAPTCHA_NOISE_IMPL, "com.google.code.kaptcha.impl.NoNoise");
    // 图片样式 水纹com.google.code.kaptcha.impl.WaterRipple 鱼眼com.google.code.kaptcha.impl.FishEyeGimpy 阴影com.google.code.kaptcha.impl.ShadowGimpy
    properties.setProperty(KAPTCHA_OBSCURIFICATOR_IMPL, "com.google.code.kaptcha.impl.ShadowGimpy");
    Config config = new Config(properties);
    defaultKaptcha.setConfig(config);
    return defaultKaptcha;
}
 
Example #30
Source File: KaptchaConfiguration.java    From albedo with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public DefaultKaptcha producer() {
	Properties properties = new Properties();
	properties.put(KAPTCHA_BORDER, CommonConstants.DEFAULT_IMAGE_BORDER);
	properties.put(KAPTCHA_TEXTPRODUCER_FONT_COLOR, CommonConstants.DEFAULT_COLOR_FONT);
	properties.put(KAPTCHA_TEXTPRODUCER_CHAR_SPACE, CommonConstants.DEFAULT_CHAR_SPACE);
	properties.put(KAPTCHA_IMAGE_WIDTH, CommonConstants.DEFAULT_IMAGE_WIDTH);
	properties.put(KAPTCHA_IMAGE_HEIGHT, CommonConstants.DEFAULT_IMAGE_HEIGHT);
	properties.put(KAPTCHA_IMAGE_FONT_SIZE, CommonConstants.DEFAULT_IMAGE_FONT_SIZE);
	properties.put(KAPTCHA_TEXTPRODUCER_CHAR_LENGTH, CommonConstants.DEFAULT_IMAGE_LENGTH);
	Config config = new Config(properties);
	DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
	defaultKaptcha.setConfig(config);
	return defaultKaptcha;
}