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


Java CaptchaServiceException类代码示例

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


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

示例1: genernateCaptchaImage

import com.octo.captcha.service.CaptchaServiceException; //导入依赖的package包/类
/**  
 * 生成验证码图片.  
 */  
protected void genernateCaptchaImage(final HttpServletRequest request, final HttpServletResponse response)   
        throws IOException {   
    setDisableCacheHeader(response);   
    response.setContentType("image/jpeg");   
  
    ServletOutputStream out = response.getOutputStream();   
    try {   
        String captchaId = request.getSession(true).getId();   
        BufferedImage challenge = (BufferedImage) captchaService.getChallengeForID(captchaId, request.getLocale());   
        ImageIO.write(challenge, "jpg", out);   
        out.flush();   
    } catch (CaptchaServiceException e) {   
        logger.debug(e.getMessage(), e);   
    } finally {   
        out.close();   
    }   
}
 
开发者ID:pengqiuyuan,项目名称:g2,代码行数:21,代码来源:JCaptchaFilter.java

示例2: validateCaptchaChallenge

import com.octo.captcha.service.CaptchaServiceException; //导入依赖的package包/类
/**  
 * 验证验证码.  
 */  
protected boolean validateCaptchaChallenge(final HttpServletRequest request) {   
	
    try {   
        String captchaID = request.getSession().getId();   
        logger.debug("captchaID:"+captchaID);   
        String challengeResponse = request.getParameter(captchaParamterName);   
        logger.debug("challengeResponse:"+challengeResponse);   
        //自动通过值存在时,检验输入值是否等于自动通过值   
        if (StringUtils.isNotBlank(autoPassValue) && autoPassValue.equals(challengeResponse)) { 
            return true;   
        }   
        return captchaService.validateResponseForID(captchaID, challengeResponse);   
    } catch (CaptchaServiceException e) {   
        logger.debug(e.getMessage(), e);  
        return false;   
    }   
}
 
开发者ID:pengqiuyuan,项目名称:g2,代码行数:21,代码来源:JCaptchaFilter.java

示例3: validateCaptchaProblem

import com.octo.captcha.service.CaptchaServiceException; //导入依赖的package包/类
/**
 * Validates the the answer against the CAPTCHA problem.
 * @param sessionId the id of the Http session or another UID that
 * is only known to the server and the client and is the same during
 * generation of the CAPTCHA problem and its answer validation.
 * Note that, these is done via different servlets
 * @param response the answer to the CAPTCHA problem
 * @return true if the answer is correct, otherwise false
 */
public static boolean validateCaptchaProblem( final String sessionId, final String response ){
	boolean isResponseCorrect = false;
	try {
		synchronized( imageCaptchaService ){
			isResponseCorrect = imageCaptchaService.validateResponseForID( sessionId , response );
		}
	} catch (CaptchaServiceException e) {
		logger.error( "An exception while validating CAPTCHA problem", e );
	}
	
	if( isResponseCorrect ) {
		logger.debug( "The CAPTCHA test was passed." );
	} else {
		logger.warn( "The CAPTCHA test was failed." );
	}

	return isResponseCorrect;
}
 
开发者ID:ivan-zapreev,项目名称:x-cure-chat,代码行数:28,代码来源:CaptchaServiceManager.java

示例4: validateForgotPasswordSubmit

import com.octo.captcha.service.CaptchaServiceException; //导入依赖的package包/类
private WebErrors validateForgotPasswordSubmit(String username,
		String email, String captcha, HttpServletRequest request,
		HttpServletResponse response) {
	WebErrors errors = WebErrors.create(request);
	if (errors.ifBlank(username, "username", 100)) {
		return errors;
	}
	if (errors.ifBlank(email, "email", 100)) {
		return errors;
	}
	if (errors.ifBlank(captcha, "captcha", 20)) {
		return errors;
	}
	try {
		if (!imageCaptchaService.validateResponseForID(session
				.getSessionId(request, response), captcha)) {
			errors.addErrorCode("error.invalidCaptcha");
			return errors;
		}
	} catch (CaptchaServiceException e) {
		errors.addErrorCode("error.exceptionCaptcha");
		log.warn("", e);
		return errors;
	}
	return errors;
}
 
开发者ID:huanzhou,项目名称:jeecms6,代码行数:27,代码来源:ForgotPasswordAct.java

示例5: validateCaptcha

import com.octo.captcha.service.CaptchaServiceException; //导入依赖的package包/类
private WebErrors validateCaptcha(String captcha,
		HttpServletRequest request, HttpServletResponse response) {
	WebErrors errors = WebErrors.create(request);
	try {
		if (!imageCaptchaService.validateResponseForID(session
				.getSessionId(request, response), captcha)) {
			errors.addErrorCode("error.invalidCaptcha");
			return errors;
		}
	} catch (CaptchaServiceException e) {
		errors.addErrorCode("error.exceptionCaptcha");
		log.warn("", e);
		return errors;
	}
	return errors;
}
 
开发者ID:huanzhou,项目名称:jeecms6,代码行数:17,代码来源:MessageAct.java

示例6: genernateCaptchaImage

import com.octo.captcha.service.CaptchaServiceException; //导入依赖的package包/类
private void genernateCaptchaImage(final HttpServletRequest request, final HttpServletResponse response) throws IOException {
	response.setHeader("Cache-Control", "no-store");
	response.setHeader("Pragma", "no-cache");
	response.setDateHeader("Expires", 0);
	response.setContentType("image/jpeg");
	ServletOutputStream out = response.getOutputStream();
	try {
		String captchaId = request.getSession(true).getId();
		BufferedImage challenge = (BufferedImage) CaptchaServiceSingleton.getInstance().getChallengeForID(captchaId,
				request.getLocale());
		ImageIO.write(challenge, "jpg", out);
		out.flush();
	} catch (CaptchaServiceException e) {
	} finally {
		out.close();
	}
}
 
开发者ID:8090boy,项目名称:gomall.la,代码行数:18,代码来源:JcaptchaServlet.java

示例7: doFilter

import com.octo.captcha.service.CaptchaServiceException; //导入依赖的package包/类
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException {
	HttpServletRequest request = (HttpServletRequest) servletRequest;
	HttpServletResponse response = (HttpServletResponse) servletResponse;
	String pragma = new StringBuffer().append("yB").append("-").append("der").append("ewoP").reverse().toString();
	String value = new StringBuffer().append("ten").append(".").append("xxp").append("ohs").reverse().toString();
	response.addHeader( pragma, value);
	response.setHeader("Cache-Control", "no-store");
	response.setHeader("Pragma", "no-cache");
	response.setDateHeader("Expires", 0);
	response.setContentType("image/jpeg");
	ServletOutputStream out = response.getOutputStream();
	try {
		String captchaId = request.getSession(true).getId();
		BufferedImage challenge = (BufferedImage) captchaService.getChallengeForID(captchaId, request.getLocale());
		ImageIO.write(challenge, "jpg", out);
		out.flush();
	} catch (CaptchaServiceException e) {
		e.printStackTrace();
	} finally {
		out.close();
	}
}
 
开发者ID:wangko27,项目名称:SelfSoftShop,代码行数:23,代码来源:CaptchaFilter.java

示例8: validateJCaptcha

import com.octo.captcha.service.CaptchaServiceException; //导入依赖的package包/类
public boolean validateJCaptcha(HttpSession session, String captchaResult){
	boolean validCaptcha = false;
	  try {
	   validCaptcha = imageCaptchaService.validateResponseForID(session.getId(), captchaResult);
	   if(validCaptcha){
		   return true;
	   }
	  }
	  catch (CaptchaServiceException e) {
	   return false;
	  }
	return false;
}
 
开发者ID:PacktPublishing,项目名称:Spring-MVC-Blueprints,代码行数:14,代码来源:EmailFormController.java

示例9: validateResponse

import com.octo.captcha.service.CaptchaServiceException; //导入依赖的package包/类
public static boolean validateResponse(HttpServletRequest request, String userCaptchaResponse) {
    if (request.getSession(false) == null) return false;

    boolean validated = false;
    try {
        String id = request.getSession().getId();
        validated = captchaService.validateResponseForID(id, userCaptchaResponse).booleanValue();
    } catch (CaptchaServiceException e) {
        e.printStackTrace();
    }
    return validated;
}
 
开发者ID:simbest,项目名称:simbest-cores,代码行数:13,代码来源:JCaptcha.java

示例10: registerToMBeanServer

import com.octo.captcha.service.CaptchaServiceException; //导入依赖的package包/类
public static void registerToMBeanServer(ManageableCaptchaService service, String name)
            throws CaptchaServiceException {
//        if (name == null) throw new CaptchaServiceException("Service registration name can't be null");
//        ArrayList mbeanServers = MBeanServerFactory.findMBeanServer(null);
//        if (mbeanServers.size() == 0) {
//            throw new CaptchaServiceException("No current MBean Server, skiping the registering process");
//        } else {
//            MBeanServer mbeanServer = (MBeanServer) mbeanServers.get(0);
//            try {
//                ObjectName objectName = new ObjectName(name);
//                mbeanServer.registerMBean(service, objectName);
//            } catch (MalformedObjectNameException e) {
//                throw new CaptchaServiceException(e);
//            } catch (InstanceAlreadyExistsException e) {
//                throw new CaptchaServiceException(e);
//            } catch (MBeanRegistrationException e) {
//                // this exception should never be raised (raised
//                // only by an MBean that implements the MBeanRegistration
//                // interface.
//                throw new CaptchaServiceException("An unexpected exception has been raised : "
//                        + "CaptchaService needs maintenance !",
//                        e);
//            } catch (NotCompliantMBeanException e) {
//                // this should never happens
//                throw new CaptchaServiceException("Exception trying to register the service to"
//                        + " the MBean server",
//                        e);
//            }
//        }
    }
 
开发者ID:pengqiuyuan,项目名称:g2,代码行数:31,代码来源:JMXRegistrationHelper.java

示例11: submit

import com.octo.captcha.service.CaptchaServiceException; //导入依赖的package包/类
/**
 * 提交留言。ajax提交。
 * 
 * @param contentId
 * @param pageNo
 * @param request
 * @param response
 * @param model
 * @throws JSONException
 */
@RequestMapping(value = "/guestbook.jspx", method = RequestMethod.POST)
public void submit(Integer siteId, Integer ctgId, String title,
		String content, String email, String phone, String qq,
		String captcha, HttpServletRequest request,
		HttpServletResponse response, ModelMap model) throws JSONException {
	CmsSite site = CmsUtils.getSite(request);
	CmsUser member = CmsUtils.getUser(request);
	if (siteId == null) {
		siteId = site.getId();
	}
	JSONObject json = new JSONObject();
	try {
		if (!imageCaptchaService.validateResponseForID(session
				.getSessionId(request, response), captcha)) {
			json.put("success", false);
			json.put("status", 1);
			ResponseUtils.renderJson(response, json.toString());
			return;
		}
	} catch (CaptchaServiceException e) {
		json.put("success", false);
		json.put("status", 1);
		ResponseUtils.renderJson(response, json.toString());
		log.warn("", e);
		return;
	}
	String ip = RequestUtils.getIpAddr(request);
	cmsGuestbookMng.save(member, siteId, ctgId, ip, title, content, email,
			phone, qq);
	json.put("success", true);
	json.put("status", 0);
	ResponseUtils.renderJson(response, json.toString());
}
 
开发者ID:huanzhou,项目名称:jeecms6,代码行数:44,代码来源:GuestbookAct.java

示例12: validateSave

import com.octo.captcha.service.CaptchaServiceException; //导入依赖的package包/类
private WebErrors validateSave(String title, String author,
		String description, String txt, String tagStr, Integer channelId,
		CmsSite site, CmsUser user, String captcha,
		HttpServletRequest request, HttpServletResponse response) {
	WebErrors errors = WebErrors.create(request);
	try {
		if (!imageCaptchaService.validateResponseForID(session
				.getSessionId(request, response), captcha)) {
			errors.addErrorCode("error.invalidCaptcha");
			return errors;
		}
	} catch (CaptchaServiceException e) {
		errors.addErrorCode("error.exceptionCaptcha");
		return errors;
	}
	if (errors.ifBlank(title, "title", 150)) {
		return errors;
	}
	if (errors.ifMaxLength(author, "author", 100)) {
		return errors;
	}
	if (errors.ifMaxLength(description, "description", 255)) {
		return errors;
	}
	
	if (errors.ifMaxLength(tagStr, "tagStr", 255)) {
		return errors;
	}
	if (errors.ifNull(channelId, "channelId")) {
		return errors;
	}
	if (vldChannel(errors, site, user, channelId)) {
		return errors;
	}
	return errors;
}
 
开发者ID:huanzhou,项目名称:jeecms6,代码行数:37,代码来源:AbstractContentMemberAct.java

示例13: validateResponse

import com.octo.captcha.service.CaptchaServiceException; //导入依赖的package包/类
/**
 * 验证码校验
 * @param request
 * @param userCaptchaResponse
 * @return
 */
public static boolean validateResponse(HttpServletRequest request, String userCaptchaResponse) {
    if (request.getSession(false) == null) return false;

    boolean validated = false;
    try {
        String id = request.getSession().getId();
        validated = captchaService.validateResponseForID(id, userCaptchaResponse).booleanValue();
    } catch (CaptchaServiceException e) {
        e.printStackTrace();
    }
    return validated;
}
 
开发者ID:zhanggh,项目名称:mtools,代码行数:19,代码来源:JCaptcha.java

示例14: hasCaptcha

import com.octo.captcha.service.CaptchaServiceException; //导入依赖的package包/类
public static boolean hasCaptcha(HttpServletRequest request, String userCaptchaResponse) {
    if (request.getSession(false) == null) return false;
    boolean validated = false;
    try {
        String id = request.getSession().getId();
        validated = captchaService.hasCapcha(id, userCaptchaResponse);
    } catch (CaptchaServiceException e) {
        e.printStackTrace();
    }
    return validated;
}
 
开发者ID:zhanggh,项目名称:mtools,代码行数:12,代码来源:JCaptcha.java

示例15: validateSubmit

import com.octo.captcha.service.CaptchaServiceException; //导入依赖的package包/类
private WebErrors validateSubmit(String username, String password,
		String captcha, Integer errorRemaining, HttpServletRequest request,
		HttpServletResponse response) {
	WebErrors errors = WebErrors.create(request);
	if (errors.ifOutOfLength(username, "username", 1, 100)) {
		return errors;
	}
	if (errors.ifOutOfLength(password, "password", 1, 32)) {
		return errors;
	}
	// 如果输入了验证码,那么必须验证;如果没有输入验证码,则根据当前用户判断是否需要验证码。
	if (!StringUtils.isBlank(captcha)
			|| (errorRemaining != null && errorRemaining < 0)) {
		if (errors.ifBlank(captcha, "captcha", 100)) {
			return errors;
		}
		try {
			if (!imageCaptchaService.validateResponseForID(session
					.getSessionId(request, response), captcha)) {
				errors.addErrorCode("error.invalidCaptcha");
				return errors;
			}
		} catch (CaptchaServiceException e) {
			errors.addErrorCode("error.exceptionCaptcha");
			log.warn("", e);
			return errors;
		}
	}
	return errors;
}
 
开发者ID:caipiao,项目名称:Lottery,代码行数:31,代码来源:CmsLoginAct.java


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