本文整理汇总了Java中com.google.code.kaptcha.util.Config类的典型用法代码示例。如果您正苦于以下问题:Java Config类的具体用法?Java Config怎么用?Java Config使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Config类属于com.google.code.kaptcha.util包,在下文中一共展示了Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: producer
import com.google.code.kaptcha.util.Config; //导入依赖的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.util.Config; //导入依赖的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.util.Config; //导入依赖的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: init
import com.google.code.kaptcha.util.Config; //导入依赖的package包/类
@Override
public void init(ServletConfig conf) throws ServletException
{
super.init(conf);
// Switch off disk based caching.
ImageIO.setUseCache(false);
Enumeration<?> initParams = conf.getInitParameterNames();
while (initParams.hasMoreElements())
{
String key = (String) initParams.nextElement();
String value = conf.getInitParameter(key);
this.props.put(key, value);
}
Config config = new Config(this.props);
this.kaptchaProducer = config.getProducerImpl();
this.sessionKeyValue = config.getSessionKey();
this.sessionKeyDateValue = config.getSessionDate();
}
示例5: captchaProducer
import com.google.code.kaptcha.util.Config; //导入依赖的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;
}
示例6: afterPropertiesSet
import com.google.code.kaptcha.util.Config; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
config = new Config(CyclosConfiguration.getCyclosProperties());
wordRenderer = config.getWordRendererImpl();
gimpyEngine = config.getObscurificatorImpl();
customizedFileHandler.addImageChangeListener(new ImageChangeListener() {
@Override
public void onImageChanged(final Image image) {
if (image.getNature() == Nature.SYSTEM && image.getName().contains("captchaBackground")) {
// Whenever the captcha background has changed, set the cached image to null, so that it's reloaded again
background = null;
}
}
});
}
示例7: testGetDistortedImageAppliesShadowToFontAndAddsTwoNoises
import com.google.code.kaptcha.util.Config; //导入依赖的package包/类
public void testGetDistortedImageAppliesShadowToFontAndAddsTwoNoises()
throws Exception
{
properties.put(Constants.KAPTCHA_BACKGROUND_CLR_FROM, "CYAN");
properties.put(Constants.KAPTCHA_BACKGROUND_CLR_TO, "BLACK");
properties.put(Constants.KAPTCHA_TEXTPRODUCER_FONT_SIZE, "50");
properties.put(Constants.KAPTCHA_TEXTPRODUCER_FONT_NAMES, "Helvetica");
properties.put(Constants.KAPTCHA_TEXTPRODUCER_FONT_COLOR, "WHITE");
Config config = new Config(properties);
DefaultWordRenderer renderer = new DefaultWordRenderer();
DefaultBackground background = new DefaultBackground();
renderer.setConfig(config);
background.setConfig(config);
BufferedImage imageWithWord = renderer
.renderWord("Alan SHORE", 300, 80);
BufferedImage imageWithShadow = gimpy.getDistortedImage(imageWithWord);
BufferedImage imageWithBackground = background
.addBackground(imageWithShadow);
assertNotNull(imageWithBackground);
TestUtil.writePngImageFile("FishEyeGimpy_fishEyeAndLines",
imageWithBackground);
}
示例8: getKaptchaBean
import com.google.code.kaptcha.util.Config; //导入依赖的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;
}
示例9: configureCaptcha
import com.google.code.kaptcha.util.Config; //导入依赖的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());
}
示例10: getProducer
import com.google.code.kaptcha.util.Config; //导入依赖的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;
}
示例11: testGetDistortedImageAppliesShadowToFontAndAddsTwoNoises
import com.google.code.kaptcha.util.Config; //导入依赖的package包/类
public void testGetDistortedImageAppliesShadowToFontAndAddsTwoNoises()
throws Exception
{
properties.put(Constants.KAPTCHA_BACKGROUND_CLR_FROM, "BLUE");
properties.put(Constants.KAPTCHA_BACKGROUND_CLR_TO, "WHITE");
properties.put(Constants.KAPTCHA_TEXTPRODUCER_FONT_SIZE, "50");
properties.put(Constants.KAPTCHA_TEXTPRODUCER_FONT_NAMES, "Helvetica");
properties.put(Constants.KAPTCHA_TEXTPRODUCER_FONT_COLOR, "RED");
properties.put(Constants.KAPTCHA_NOISE_COLOR, "CYAN");
Config configManager = new Config(properties);
DefaultWordRenderer renderer = new DefaultWordRenderer();
DefaultBackground background = new DefaultBackground();
renderer.setConfig(configManager);
background.setConfig(configManager);
gimpy.setConfig(configManager);
BufferedImage imageWithWord = renderer.renderWord("Jerry ESPENSON",
300, 80);
BufferedImage imageWithShadow = gimpy.getDistortedImage(imageWithWord);
BufferedImage imageWithBackground = background
.addBackground(imageWithShadow);
assertNotNull(imageWithBackground);
TestUtil.writePngImageFile("WaterRipple_rippleAndTwoNoises",
imageWithBackground);
}
示例12: testGetDistortedImageAppliesShadowToFontAndAddsTwoNoises
import com.google.code.kaptcha.util.Config; //导入依赖的package包/类
public void testGetDistortedImageAppliesShadowToFontAndAddsTwoNoises()
throws Exception
{
properties.put(Constants.KAPTCHA_BACKGROUND_CLR_FROM, "GREEN");
properties.put(Constants.KAPTCHA_BACKGROUND_CLR_TO, "YELLOW");
properties.put(Constants.KAPTCHA_TEXTPRODUCER_FONT_SIZE, "50");
properties.put(Constants.KAPTCHA_TEXTPRODUCER_FONT_NAMES, "Arial");
properties.put(Constants.KAPTCHA_TEXTPRODUCER_FONT_COLOR, "BLUE");
Config config = new Config(properties);
DefaultWordRenderer renderer = new DefaultWordRenderer();
DefaultBackground background = new DefaultBackground();
renderer.setConfig(config);
background.setConfig(config);
gimpy.setConfig(config);
BufferedImage imageWithWord = renderer.renderWord("Clarence BELL", 300,
80);
BufferedImage imageWithShadow = gimpy.getDistortedImage(imageWithWord);
BufferedImage imageWithBackground = background
.addBackground(imageWithShadow);
assertNotNull(imageWithBackground);
TestUtil.writePngImageFile("ShadowGimpy_shadowFontAndTwoNoises",
imageWithBackground);
}
示例13: setUp
import com.google.code.kaptcha.util.Config; //导入依赖的package包/类
public void setUp()
{
properties = new Properties();
renderer = new DefaultWordRenderer();
renderer.setConfig(new Config(properties));
}
示例14: setUp
import com.google.code.kaptcha.util.Config; //导入依赖的package包/类
public void setUp()
{
properties = new Properties();
creator = new DefaultTextCreator();
creator.setConfig(new Config(properties));
}
示例15: setUp
import com.google.code.kaptcha.util.Config; //导入依赖的package包/类
public void setUp()
{
properties = new Properties();
noise = new DefaultNoise();
noise.setConfig(new Config(properties));
}