Examples of Captcha


Examples of cn.dreampie.captcha.service.Captcha

import java.io.OutputStream;

public class EncoderHelper {

  public static String getChallangeAndWriteImage(CaptchaService service, String format, OutputStream os) throws IOException {
    Captcha captcha = service.getCaptcha();
    ImageIO.write(captcha.getImage(), format, os);
    return captcha.getChallenge();
  }
View Full Code Here

Examples of cn.dreampie.captcha.service.Captcha

    //初始化
    initCaptchService();
    ServletOutputStream outputStream = null;

    // 得到验证码对象,有验证码图片和验证码字符串
    Captcha captcha = configurableCaptchaService.getCaptcha();
    // 取得验证码字符串放入Session
    String captchaCode = captcha.getChallenge();
    if (logger.isDebugEnabled()) {
      logger.debug("captcha:" + captchaCode);
    }
    //System.out.println(validationCode);
    HttpSession session = request.getSession();
    session.setAttribute(captchaName, EncriptionKit.encrypt(captchaCode.toLowerCase()));
    session.setAttribute(captchaName + "_time", new Date().getTime());
//    CookieUtils.addCookie(request, response, AppConstants.CAPTCHA_NAME, EncriptionKit.encrypt(captchaCode), -1);
    // 取得验证码图片并输出
    BufferedImage bufferedImage = captcha.getImage();

    try {
      outputStream = response.getOutputStream();
      ImageIO.write(bufferedImage, "png", outputStream);
    } catch (Exception e) {
View Full Code Here

Examples of cn.dreampie.common.plugin.patchca.service.Captcha

import java.io.OutputStream;

public class EncoderHelper {

  public static String getChallangeAndWriteImage(CaptchaService service, String format, OutputStream os) throws IOException {
    Captcha captcha = service.getCaptcha();
    ImageIO.write(captcha.getImage(), format, os);
    return captcha.getChallenge();
  }
View Full Code Here

Examples of cn.dreampie.common.plugin.patchca.service.Captcha

   */
  public void render() {
    ServletOutputStream outputStream = null;

    // 得到验证码对象,有验证码图片和验证码字符串
    Captcha captcha = configurableCaptchaService.getCaptcha();
    // 取得验证码字符串放入Session
    String captchaCode = captcha.getChallenge();
    if (logger.isDebugEnabled()) {
      logger.debug("captcha:" + captchaCode);
    }
    //System.out.println(validationCode);
    Session session = SecurityUtils.getSubject().getSession();
    session.setAttribute(captchaName, EncriptionUtils.encrypt(captchaCode));
    session.setAttribute(captchaName + "_time", new Date().getTime());
//    CookieUtils.addCookie(request, response, AppConstants.CAPTCHA_NAME, EncriptionUtils.encrypt(captchaCode), -1);
    // 取得验证码图片并输出
    BufferedImage bufferedImage = captcha.getImage();

    try {
      outputStream = response.getOutputStream();
      ImageIO.write(bufferedImage, "png", outputStream);
    } catch (Exception e) {
View Full Code Here

Examples of cn.dreampie.common.plugin.patchca.service.Captcha

   */
  public void render() {
    ServletOutputStream outputStream = null;

    // 得到验证码对象,有验证码图片和验证码字符串
    Captcha captcha = configurableCaptchaService.getCaptcha();
    // 取得验证码字符串放入Session
    String captchaCode = captcha.getChallenge();
    if (logger.isDebugEnabled()) {
      logger.debug("captcha:" + captchaCode);
    }
    //System.out.println(validationCode);
    Session session = SecurityUtils.getSubject().getSession();
    session.setAttribute(captchaName, EncriptionUtils.encrypt(captchaCode));
    session.setAttribute(captchaName + "_time", new Date().getTime());
//    CookieUtils.addCookie(request, response, AppConstants.CAPTCHA_NAME, EncriptionUtils.encrypt(captchaCode), -1);
    // 取得验证码图片并输出
    BufferedImage bufferedImage = captcha.getImage();

    try {
      outputStream = response.getOutputStream();
      ImageIO.write(bufferedImage, "png", outputStream);
    } catch (Exception e) {
View Full Code Here

Examples of cn.dreampie.common.plugin.patchca.service.Captcha

   */
  public void render() {
    ServletOutputStream outputStream = null;

    // 得到验证码对象,有验证码图片和验证码字符串
    Captcha captcha = configurableCaptchaService.getCaptcha();
    // 取得验证码字符串放入Session
    String captchaCode = captcha.getChallenge();

    //System.out.println(validationCode);
    Session session = SecurityUtils.getSubject().getSession();
    session.setAttribute(AppConstants.CAPTCHA_NAME, EncriptionUtils.encrypt(captchaCode));
//    CookieUtils.addCookie(request, response, AppConstants.CAPTCHA_NAME, EncriptionUtils.encrypt(captchaCode), -1);
    // 取得验证码图片并输出
    BufferedImage bufferedImage = captcha.getImage();

    try {
      outputStream = response.getOutputStream();
      ImageIO.write(bufferedImage, "png", outputStream);
    } catch (Exception e) {
View Full Code Here

Examples of com.andrewtimberlake.captcha.Captcha

public class CaptchaImageGeneratorService extends HttpServlet {
  private static DateFormat RFC822_FORMAT = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z");

  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    Captcha captcha = new Captcha();
    request.getSession().setAttribute("captcha", captcha);
    response.addHeader("Pragma", "No-cache");
    response.addHeader("Expires", RFC822_FORMAT.format(Calendar.getInstance().getTime()));
    String resource = request.getRequestURI();
    String extension = resource.substring(resource.lastIndexOf('.') + 1).toLowerCase();
    if (extension.equals("jpg") || extension.equals("png")) {
      BufferedImage image = captcha.generateImage();
      response.setContentType("image/" + extension);
      ImageIO.write(image, extension, response.getOutputStream());
    } else {
      BufferedImage image = captcha.generateImage();
      response.setContentType("image/png");
      ImageIO.write(image, "png", response.getOutputStream());
    }
  }
View Full Code Here

Examples of com.andrewtimberlake.captcha.Captcha

        // new account, it did NOT exist
        // validate captcha first
        if (StringUtils.isEmpty(captchaText)) {
          captchaText = "INVALID!";
        }
        Captcha captcha = (Captcha) getThreadLocalRequest().getSession().getAttribute("captcha");
        if (captcha != null && !captcha.isValid(captchaText)) {
          throw new SimpleMessageException("CAPTCHA validation failed");
        }

        User newUser = new User();
        newUser.setUsername(inUser.getUsername().toLowerCase());
View Full Code Here

Examples of com.dotcms.repackage.com.octo.captcha.Captcha

          UserLocalManagerUtil.getDefaultUser(companyId);

        locale = defaultUser.getLocale();
      }

      Captcha captcha = null;

      if (GetterUtil.getBoolean(
          PropsUtil.get(PropsUtil.CAPTCHA_CHALLENGE)) &&
        (config.getPortletName().equals(PortletKeys.MY_ACCOUNT))) {

        captcha = (Captcha)ses.getAttribute(
          WebKeys.CAPTCHA, PortletSession.APPLICATION_SCOPE);

        Boolean validResponse = captcha.validateResponse(
          ParamUtil.getString(req, "captcha_response"));

        if ((validResponse == null) ||
          (validResponse.equals(Boolean.FALSE))) {

          ses.removeAttribute(
            WebKeys.CAPTCHA, PortletSession.APPLICATION_SCOPE);

          throw new CaptchaException();
        }
      }

      UserManagerUtil.addUser(
        companyId, autoUserId, userId, autoPassword, password1,
        password2, passwordReset, firstName, middleName, lastName,
        nickName, male,
        new GregorianCalendar(bdYear, bdMonth, bdDay).getTime(),
        emailAddress, locale);

      if (captcha != null) {
        captcha.disposeChallenge();

        ses.removeAttribute(
          WebKeys.CAPTCHA, PortletSession.APPLICATION_SCOPE);
      }
View Full Code Here

Examples of com.dotcms.repackage.nl.captcha.Captcha

   */
  public static boolean isValidImageCaptcha(HttpServletRequest request){

    HttpSession session = request.getSession();
    String captcha = request.getParameter("captcha");
    Captcha captchaObj = (Captcha) session.getAttribute(Captcha.NAME);
        String captchaSession=captchaObj!=null ? captchaObj.getAnswer() : null;
    if(!UtilMethods.isSet(captcha) || !UtilMethods.isSet(captchaSession) || !captcha.equals(captchaSession)){
      return false;
    }
    return true;

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.