当前位置: 首页>>代码示例>>Java>>正文


Java Producer类代码示例

本文整理汇总了Java中com.google.code.kaptcha.Producer的典型用法代码示例。如果您正苦于以下问题:Java Producer类的具体用法?Java Producer怎么用?Java Producer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Producer类属于com.google.code.kaptcha包,在下文中一共展示了Producer类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureCaptcha

import com.google.code.kaptcha.Producer; //导入依赖的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());
}
 
开发者ID:Xlongshu,项目名称:EasyController,代码行数:16,代码来源:ActionModule.java

示例2: execute

import com.google.code.kaptcha.Producer; //导入依赖的package包/类
public void execute(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
	response.setDateHeader("Expires", 0);
	// Set standard HTTP/1.1 no-cache headers.
	response.setHeader("Cache-Control","no-store, no-cache, must-revalidate");
	// Set IE extended HTTP/1.1 no-cache headers (use addHeader).
	response.addHeader("Cache-Control", "post-check=0, pre-check=0");
	// Set standard HTTP/1.0 no-cache header.
	response.setHeader("Pragma", "no-cache");
	// return a jpeg
	response.setContentType("image/jpeg");
	
	int width=defaultWidth;
	int height=defaultHeight;
	String key=defaultSessionKey;
	if(StringUtils.isNotEmpty(request.getParameter("width"))){
		width=Integer.valueOf(request.getParameter("width"));
	}
	if(StringUtils.isNotEmpty(request.getParameter("height"))){
		height=Integer.valueOf(request.getParameter("height"));
	}
	if(StringUtils.isNotEmpty(request.getParameter("key"))){
		key=request.getParameter("key");
	}
	Producer captchaProducer = this.getProducer(width, height);
	String capText = captchaProducer.createText();
	request.getSession().setAttribute(key,capText);
	// create the image with the text
	BufferedImage bi = captchaProducer.createImage(capText);
	ServletOutputStream out = response.getOutputStream();
	try {
		// write the data out
		ImageIO.write(bi,"jpg", out);
		out.flush();
	} finally {
		out.close();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:38,代码来源:CaptchaController.java

示例3: getProducer

import com.google.code.kaptcha.Producer; //导入依赖的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;
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:35,代码来源:CaptchaController.java

示例4: captcha

import com.google.code.kaptcha.Producer; //导入依赖的package包/类
/**
 * 获取登录的图片验证码
 */
@RequestMapping(value = "/imgcode", method = RequestMethod.GET)
public void captcha(HttpServletRequest request, HttpServletResponse response )
		throws ServletException, IOException {
	Subject currentUser = SecurityUtils.getSubject();
	Session session = currentUser.getSession();
	Producer captchaProducer = KaptchaProducerAgency.getKaptchaProducerExample();
	response.setDateHeader("Expires", 0);
	// Set standard HTTP/1.1 no-cache headers.
	response.setHeader("Cache-Control",
			"no-store, no-cache, must-revalidate");
	// Set IE extended HTTP/1.1 no-cache headers (use addHeader).
	response.addHeader("Cache-Control", "post-check=0, pre-check=0");
	// Set standard HTTP/1.0 no-cache header.
	response.setHeader("Pragma", "no-cache");
	// return a jpeg
	response.setContentType("image/jpeg");
	// create the text for the image
	String capText = captchaProducer.createText();
	log.debug("******************验证码是: " + capText + "******************");
	// store the text in the session
	session.setAttribute(Constants.KAPTCHA_SESSION_KEY, capText	);
	// create the image with the text
	BufferedImage bi = captchaProducer.createImage(capText);
	ServletOutputStream out = response.getOutputStream();
	// write the data out
	ImageIO.write(bi, "jpg", out);
	try {
		out.flush();
	} finally {
		out.close();
	}
}
 
开发者ID:summerDp,项目名称:dpCms,代码行数:36,代码来源:LoginController.java

示例5: getProducerImpl

import com.google.code.kaptcha.Producer; //导入依赖的package包/类
/** */
public Producer getProducerImpl()
{
	String paramName = Constants.KAPTCHA_PRODUCER_IMPL;
	String paramValue = this.properties.getProperty(paramName);
	Producer producer = (Producer) this.helper.getClassInstance(paramName, paramValue, new DefaultKaptcha(), this);
	return producer;
}
 
开发者ID:ycaihua,项目名称:kaptcha,代码行数:9,代码来源:Config.java

示例6: setCaptchaProducer

import com.google.code.kaptcha.Producer; //导入依赖的package包/类
@Autowired  
public void setCaptchaProducer(Producer captchaProducer) {  
    this.captchaProducer = captchaProducer;  
}
 
开发者ID:zjlywjh001,项目名称:PhrackCTF-Platform-Team,代码行数:5,代码来源:CaptchaImageCreateController.java

示例7: setCaptchaProducer

import com.google.code.kaptcha.Producer; //导入依赖的package包/类
@Inject
public void setCaptchaProducer(final Producer captchaProducer) {
    this.captchaProducer = captchaProducer;
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:5,代码来源:CaptchaServlet.java

示例8: setCaptchaProducer

import com.google.code.kaptcha.Producer; //导入依赖的package包/类
public void setCaptchaProducer(Producer captchaProducer) {
	this.captchaProducer = captchaProducer;
}
 
开发者ID:wu560130911,项目名称:MultimediaDesktop,代码行数:4,代码来源:CaptchaImageCreateController.java

示例9: getCaptchaProducer

import com.google.code.kaptcha.Producer; //导入依赖的package包/类
public Producer getCaptchaProducer() {
	return captchaProducer;
}
 
开发者ID:mingxin6,项目名称:incu,代码行数:4,代码来源:CaptchaImageCreateController.java


注:本文中的com.google.code.kaptcha.Producer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。