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


Java ImageCaptchaService类代码示例

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


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

示例1: init

import com.octo.captcha.service.image.ImageCaptchaService; //导入依赖的package包/类
/**
 * {@inheritDoc}
 *
 * @author  covito
 * @param config
 * @throws ServletException
 */
@Override
public void init(ServletConfig config) throws ServletException {
	super.init(config);
	WebApplicationContext appCtx = WebApplicationContextUtils
			.getWebApplicationContext(getServletContext());
	Map<String,ImageCaptchaService> m= BeanFactoryUtils.beansOfTypeIncludingAncestors(
			appCtx, ImageCaptchaService.class);
	if(ObjectUtil.empty(m)){
		logger.error("spring config not found com.octo.captcha.service.image.ImageCaptchaService impl");
		return;
	}
	String imageName=HttpCompUtil.getSvlConfig(config, "captchaService", null);
	if(imageName==null&&m.size()==1){
		captchaService=m.values().iterator().next();
	}else{
		captchaService=m.get(imageName);
	}
	
	if(captchaService==null){
		logger.error("spring config ImageCaptchaService impl not only or captchaService not found");
		return;
	}
}
 
开发者ID:kiwilew,项目名称:covito-kit,代码行数:31,代码来源:JcaptchaServlet.java

示例2: setUp

import com.octo.captcha.service.image.ImageCaptchaService; //导入依赖的package包/类
@Before
public void setUp() {
	request = new MockHttpServletRequest();
	request.setAttribute(HandlerMapping.INTROSPECT_TYPE_LEVEL_MAPPING, true);
	request.setRequestURI("/ajax/insert");
	request.setMethod("POST");
	response = new MockHttpServletResponse();
	adapter = new AnnotationMethodHandlerAdapter();
	ajaxController = new AjaxController();
	ajaxController.setAccountService(accountService);

	// mock captcha service
	captchaService = createMock(ImageCaptchaService.class);
	expect(
			captchaService.validateResponseForID(request.getSession()
					.getId(), CORRECT_CAPTCHA_KEY)).andReturn(true);
	expect(
			captchaService.validateResponseForID(request.getSession()
					.getId(), INCORRECT_CAPTCHA_KEY)).andReturn(false);
	ajaxController.setCaptchaService(captchaService);

}
 
开发者ID:omerg,项目名称:spring-mvc-base,代码行数:23,代码来源:InsertTest.java

示例3: init

import com.octo.captcha.service.image.ImageCaptchaService; //导入依赖的package包/类
@Override
public void init() throws ServletException {
	WebApplicationContext appCtx = WebApplicationContextUtils
			.getWebApplicationContext(getServletContext());
	captchaService = (ImageCaptchaService) BeanFactoryUtils
			.beanOfTypeIncludingAncestors(appCtx, ImageCaptchaService.class);
	session = (SessionProvider) BeanFactoryUtils
			.beanOfTypeIncludingAncestors(appCtx, SessionProvider.class);
}
 
开发者ID:huanzhou,项目名称:jeecms6,代码行数:10,代码来源:JcaptchaServlet.java

示例4: init

import com.octo.captcha.service.image.ImageCaptchaService; //导入依赖的package包/类
@Override
public void init() throws ServletException {
	WebApplicationContext appCtx = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
	if(appCtx != null){
		captchaService = BeanFactoryUtils.beanOfTypeIncludingAncestors(appCtx, ImageCaptchaService.class);
	}
	
}
 
开发者ID:8090boy,项目名称:gomall.la,代码行数:9,代码来源:JcaptchaServlet.java

示例5: flushNewCaptchaToResponse

import com.octo.captcha.service.image.ImageCaptchaService; //导入依赖的package包/类
/**
 * retrieve a new ImageCaptcha using ImageCaptchaService and flush it to the response.<br/> Captcha are localized
 * using request locale.<br/>
 * <p/>
 * This method returns a 404 to the client instead of the image if the request isn't correct (missing parameters,
 * etc...)..<br/> The log may be null.<br/>
 *
 * @param theRequest  the request
 * @param theResponse the response
 * @param log         a commons logger
 * @param service     an ImageCaptchaService instance
 *
 * @throws java.io.IOException if a problem occurs during the jpeg generation process
 */
public static void flushNewCaptchaToResponse(HttpServletRequest theRequest,
                                             HttpServletResponse theResponse,
                                             Log log,
                                             ImageCaptchaService service,
                                             String id,
                                             Locale locale)
        throws IOException {

    // call the ImageCaptchaService method to retrieve a captcha
    byte[] captchaChallengeAsJpeg = null;
    ByteArrayOutputStream jpegOutputStream = new ByteArrayOutputStream();
    try {
        BufferedImage challenge =
                service.getImageChallengeForID(id, locale);
        // the output stream to render the captcha image as jpeg into

        ImageIO.write(challenge, "jpg", jpegOutputStream);

    } catch (IllegalArgumentException e) {
        //    log a security warning and return a 404...
        if (log != null && log.isWarnEnabled()) {
            log.warn(
                    "There was a try from "
                            + theRequest.getRemoteAddr()
                            + " to render an captcha with invalid ID :'" + id
                            + "' or with a too long one");
            theResponse.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }
    } 

    captchaChallengeAsJpeg = jpegOutputStream.toByteArray();

    // render the captcha challenge as a JPEG image in the response
    theResponse.setHeader("Cache-Control", "no-store");
    theResponse.setHeader("Pragma", "no-cache");
    theResponse.setDateHeader("Expires", 0);

    theResponse.setContentType("image/jpeg");
    ServletOutputStream responseOutputStream =
            theResponse.getOutputStream();
    responseOutputStream.write(captchaChallengeAsJpeg);
    responseOutputStream.flush();
    responseOutputStream.close();
}
 
开发者ID:pengqiuyuan,项目名称:g2,代码行数:60,代码来源:ImageToJpegHelper.java

示例6: getInstance

import com.octo.captcha.service.image.ImageCaptchaService; //导入依赖的package包/类
public static ImageCaptchaService getInstance(){
    return instance;
}
 
开发者ID:webdsl,项目名称:webdsl,代码行数:4,代码来源:CaptchaServiceSingleton.java

示例7: setCaptchaService

import com.octo.captcha.service.image.ImageCaptchaService; //导入依赖的package包/类
public void setCaptchaService(ImageCaptchaService captchaService) {
	this.captchaService = captchaService;
}
 
开发者ID:omerg,项目名称:spring-mvc-base,代码行数:4,代码来源:AjaxController.java

示例8: captchaService

import com.octo.captcha.service.image.ImageCaptchaService; //导入依赖的package包/类
@Bean
public ImageCaptchaService captchaService() {
    return new GenericManageableCaptchaService(imageEngine(), MIN_STORAGE_DELAY, MAX_STORAGE_DELAY);
}
 
开发者ID:omerg,项目名称:spring-mvc-base,代码行数:5,代码来源:CaptchaConfiguration.java

示例9: getInstance

import com.octo.captcha.service.image.ImageCaptchaService; //导入依赖的package包/类
/**
 * Liefert die Instanz des Captcha-Services zurück.
 * @return Instanz des Captcha-Services
 */
public static ImageCaptchaService getInstance() {
    return instance;
}
 
开发者ID:MalteSchwering,项目名称:de.th.wildau.webapp.buchladen,代码行数:8,代码来源:CaptchaServiceSingleton.java


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