本文整理汇总了Java中com.google.code.kaptcha.impl.DefaultKaptcha.setConfig方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultKaptcha.setConfig方法的具体用法?Java DefaultKaptcha.setConfig怎么用?Java DefaultKaptcha.setConfig使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.code.kaptcha.impl.DefaultKaptcha
的用法示例。
在下文中一共展示了DefaultKaptcha.setConfig方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: producer
import com.google.code.kaptcha.impl.DefaultKaptcha; //导入方法依赖的package包/类
@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;
}
示例2: getKaptchaBean
import com.google.code.kaptcha.impl.DefaultKaptcha; //导入方法依赖的package包/类
@Bean(name="captchaProducer")
public DefaultKaptcha getKaptchaBean(){
DefaultKaptcha defaultKaptcha=new DefaultKaptcha();
Properties properties=new Properties();
properties.setProperty("kaptcha.border", env.getProperty("kaptcha.border").equals("true")? "yes":"no");
properties.setProperty("kaptcha.border.color", env.getProperty("kaptcha.borderColor"));
properties.setProperty("kaptcha.textproducer.font.color", env.getProperty("kaptcha.textproducerFontColor"));
properties.setProperty("kaptcha.image.width", env.getProperty("kaptcha.imageWidth"));
properties.setProperty("kaptcha.image.height", env.getProperty("kaptcha.imageHeight"));
properties.setProperty("kaptcha.session.key", env.getProperty("kaptcha.sessionKey"));
properties.setProperty("kaptcha.textproducer.char.length", env.getProperty("kaptcha.textproducerCharLength"));
properties.setProperty("kaptcha.textproducer.font.names", env.getProperty("kaptcha.textproducerFontNames"));
Config config=new Config(properties);
defaultKaptcha.setConfig(config);
return defaultKaptcha;
}
示例3: init
import com.google.code.kaptcha.impl.DefaultKaptcha; //导入方法依赖的package包/类
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);
}
示例4: captchaProducer
import com.google.code.kaptcha.impl.DefaultKaptcha; //导入方法依赖的package包/类
@Bean
public DefaultKaptcha captchaProducer() {
Properties properties = new Properties();
properties.put("kaptcha.border", "yes");
properties.put("kaptcha.border.color", "lightGray");
properties.put("kaptcha.textproducer.font.color", "darkGray");
properties.put("kaptcha.image.width", "160");
properties.put("kaptcha.image.height", "50");
properties.put("kaptcha.textproducer.font.size", "40");
properties.put("kaptcha.session.key", "kaptcha");
properties.put("kaptcha.textproducer.char.length", "4");
properties.put("kaptcha.background.clear.to", "gray");
properties.put("kaptcha.textproducer.font.names", "宋体,楷体,微软雅黑");
Config config = new Config(properties);
DefaultKaptcha kaptcha = new DefaultKaptcha();
kaptcha.setConfig(config);
return kaptcha;
}
示例5: getKaptchaBean
import com.google.code.kaptcha.impl.DefaultKaptcha; //导入方法依赖的package包/类
@Bean(name="captchaProducer")
@Scope(value = "prototype")
public DefaultKaptcha getKaptchaBean(){
// 生成一个 DefaultKaptcha 的实例
DefaultKaptcha defaultKaptcha=new DefaultKaptcha();
Properties properties=new Properties();
// 大小设置
properties.setProperty("kaptcha.image.width", "100");
properties.setProperty("kaptcha.image.height", "38");
// 样式设置
properties.setProperty("kaptcha.border", "no");
properties.setProperty("kaptcha.background.clear.from","white");
properties.setProperty("kaptcha.background.clear.to","white");
// 字体设置
properties.setProperty("kaptcha.textproducer.char.space","3");
properties.setProperty("kaptcha.textproducer.char.length", "4");
properties.setProperty("kaptcha.textproducer.font.color", "black");
properties.setProperty("kaptcha.textproducer.font.size","26");
// 验证码生成的文字设置
properties.setProperty("kaptcha.textproducer.char.string","0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
// 实现
properties.setProperty("kaptcha.obscurificator.impl","com.nbsaw.miaohu.common.CustomCaptcha");
// 将配置导入到 DefaultKaptcha 实例中
Config config=new Config(properties);
defaultKaptcha.setConfig(config);
return defaultKaptcha;
}
示例6: configureCaptcha
import com.google.code.kaptcha.impl.DefaultKaptcha; //导入方法依赖的package包/类
void configureCaptcha(Binder binder) {
DefaultKaptcha producer = new DefaultKaptcha();
Properties properties;
try {
properties = ActionConfig.loadPropertyFile("captcha.properties");
Config config = new Config(properties);
producer.setConfig(config);
} catch (RuntimeException e) {
log.warn(e.getMessage());
}
binder.bind(Producer.class).toInstance(producer);
binder.bind(KaptchaExtend.class).toInstance(new KaptchaExtend());
}
示例7: getProducer
import com.google.code.kaptcha.impl.DefaultKaptcha; //导入方法依赖的package包/类
private Producer getProducer(int width, int height) {
DefaultKaptcha kaptcha = new DefaultKaptcha();
Properties prop = new Properties();
prop.put(Constants.KAPTCHA_IMAGE_WIDTH,String.valueOf(width));
prop.put(Constants.KAPTCHA_IMAGE_HEIGHT,String.valueOf(height));
prop.put(Constants.KAPTCHA_TEXTPRODUCER_CHAR_LENGTH, 5);
prop.put(Constants.KAPTCHA_TEXTPRODUCER_CHAR_SPACE,"6");
prop.put(
Constants.KAPTCHA_BACKGROUND_CLR_FROM,
String.valueOf(RandomUtils.nextInt(255)) + ","
+ RandomUtils.nextInt(255) + ","
+ RandomUtils.nextInt(255));
prop.put(
Constants.KAPTCHA_BACKGROUND_CLR_TO,
String.valueOf(RandomUtils.nextInt(255)) + ","
+ RandomUtils.nextInt(255) + ","
+ RandomUtils.nextInt(255));
prop.put(
Constants.KAPTCHA_NOISE_COLOR,
String.valueOf(RandomUtils.nextInt(255)) + ","
+ RandomUtils.nextInt(255) + ","
+ RandomUtils.nextInt(255));
prop.put(
Constants.KAPTCHA_TEXTPRODUCER_FONT_COLOR,
String.valueOf(RandomUtils.nextInt(255)) + ","
+ RandomUtils.nextInt(255) + ","
+ RandomUtils.nextInt(255));
prop.put(Constants.KAPTCHA_TEXTPRODUCER_FONT_SIZE, String.valueOf(height-14));
prop.put(Constants.KAPTCHA_TEXTPRODUCER_CHAR_STRING,
"123456789abcdefghijkmnlpqrstuvwxyz");
Config config = new Config(prop);
kaptcha.setConfig(config);
return kaptcha;
}
示例8: afterPropertiesSet
import com.google.code.kaptcha.impl.DefaultKaptcha; //导入方法依赖的package包/类
public void afterPropertiesSet()
throws Exception {
producer = new DefaultKaptcha();
producer.setConfig(new Config(new Properties()));
}