Package net.tanesha.recaptcha

Examples of net.tanesha.recaptcha.ReCaptchaResponse


    }
    ConfigEntity config = VosaoContext.getInstance().getConfig();
    String challenge = parameters.get("recaptcha_challenge_field");
    String response = parameters.get("recaptcha_response_field");
    if (form.isEnableCaptcha() && config.isEnableRecaptcha()) {
      ReCaptchaResponse recaptchaResponse = RecaptchaUtil.check(
          config.getRecaptchaPublicKey(),
          config.getRecaptchaPrivateKey(),
          challenge, response, request);
      if (!recaptchaResponse.isValid()) {
        return createMessage("error", Messages.get("incorrect_captcha"));
      }
    }
    getBusiness().getFormBusiness().submit(form, parameters, files,
        request.getRemoteAddr());
View Full Code Here


      String pageUrl, String challenge, String response,
      HttpServletRequest request) {
   
    ConfigEntity config = getBusiness().getConfigBusiness().getConfig();
    boolean valid = true;
    ReCaptchaResponse recaptchaResponse = null;
    if (config.isEnableRecaptcha()) {
      recaptchaResponse = RecaptchaUtil.check(
          config.getRecaptchaPublicKey(),
          config.getRecaptchaPrivateKey(),
          challenge, response, request);
      valid = recaptchaResponse.isValid();
    }
    if (valid) {
          try {
            addComment(ParamUtil.filterXSS(name),
                ParamUtil.filterXSS(comment), pageUrl);
                return ServiceResponse.createSuccessResponse(
                    Messages.get("comment_success_create"));
          }
          catch (ServiceException e) {
                return ServiceResponse.createErrorResponse(e.getMessage());
          }
        }
        else {
            return ServiceResponse.createErrorResponse(
                recaptchaResponse.getErrorMessage());
        }
  }
View Full Code Here

  @Override
  public ServiceResponse send(String name, Map<String, String> params,
      String challenge, String response, HttpServletRequest request) {

    ConfigEntity config = getBusiness().getConfigBusiness().getConfig();
    ReCaptchaResponse recaptchaResponse = RecaptchaUtil.check(
        config.getRecaptchaPublicKey(),
        config.getRecaptchaPrivateKey(),
        challenge, response, request);
    ServiceResponse result = new ServiceResponse();
        if (recaptchaResponse.isValid()) {
            return send(name, params);
        }
        else {
                result.setResult("error");
                result.setMessage(recaptchaResponse.getErrorMessage());
        }
    return result;
  }
View Full Code Here

   the given challenge.
   */
  public static boolean isCaptchaValid(String aIpAddress, String aChallenge, String aResponse){
    ReCaptchaImpl reCaptcha = new ReCaptchaImpl();
    reCaptcha.setPrivateKey(fPrivateKey);
    ReCaptchaResponse reCaptchaResponse =  reCaptcha.checkAnswer(
      aIpAddress, aChallenge, aResponse
    );
    return reCaptchaResponse.isValid();
  }
View Full Code Here

          errors.add("recaptchaUserResponse", new ActionMessage("content.error.captcha.required"));
        }
        else {
              ReCaptchaImpl reCaptcha = new ReCaptchaImpl();
              reCaptcha.setPrivateKey(captchaPrivateKey);
              ReCaptchaResponse reCaptchaResponse = reCaptcha.checkAnswer(remoteAddr, challenge, uresponse);
              if (!reCaptchaResponse.isValid())
                errors.add("recaptchaUserResponse", new ActionMessage(reCaptchaResponse.getErrorMessage(), false));
        }
    }
      return errors;
    }
View Full Code Here

          errors.add("recaptchaUserResponse", new ActionMessage("content.error.captcha.required"));
        }
        else {
              ReCaptchaImpl reCaptcha = new ReCaptchaImpl();
              reCaptcha.setPrivateKey(captchaPrivateKey);
              ReCaptchaResponse reCaptchaResponse = reCaptcha.checkAnswer(remoteAddr, challenge, uresponse);
              if (!reCaptchaResponse.isValid())
                errors.add("recaptchaUserResponse", new ActionMessage(reCaptchaResponse.getErrorMessage(), false));
        }
    }
      return errors;
    }
View Full Code Here

        ReCaptchaImpl reCaptcha = new ReCaptchaImpl();
        reCaptcha.setPrivateKey(PRIVATE_KEY);

        String challenge = request.getParameter("recaptcha_challenge_field");
        String uresponse = request.getParameter("recaptcha_response_field");
        ReCaptchaResponse reCaptchaResponse = reCaptcha.checkAnswer(remoteAddr, challenge, uresponse);
       
        return reCaptchaResponse.isValid();
    }
View Full Code Here

        }
        String response = request.getParameter(PARAM_CAPTCHA_RESPONSE);
        String challenge = request.getParameter(PARAM_CAPTCHA_CHALLENGE);
        String remoteAddress = request.getRemoteAddr();
        // validate:
        ReCaptchaResponse captchaResponse = captcha.checkAnswer(remoteAddress, challenge, response);
        boolean valid = captchaResponse.isValid();
        if (valid) {
            return true;
        }
        log.warn("Invalid captcha response:  {}", captchaResponse.getErrorMessage());
        return false;

    }
View Full Code Here

      String remoteAddr = req.getRemoteAddr();
      ReCaptchaImpl reCaptcha = new ReCaptchaImpl();
      reCaptcha.setPrivateKey("6LfUNtESAAAAANSiC1e3dD974bMUFY21S5QANakS");
      String challenge = req.getParameter("recaptcha_challenge_field");
      String uresponse = req.getParameter("recaptcha_response_field");
      ReCaptchaResponse reCaptchaResponse = reCaptcha.checkAnswer(
          remoteAddr, challenge, uresponse);

      if (!reCaptchaResponse.isValid()) {
        check.put("capcha", "Please enter exactly what you see.");
      }
      if (check.size() > 0) {
        req.setAttribute("feedback", obj);
        req.setAttribute("check", check);
View Full Code Here

           reCaptcha.setPrivateKey(privateKey);

           String challenge = request.getParameter("recaptcha_challenge_field");
           String uresponse = request.getParameter("recaptcha_response_field");
          
           ReCaptchaResponse reCaptchaResponse = reCaptcha.checkAnswer(remoteAddr, challenge, uresponse);

           return reCaptchaResponse.isValid();
     }
View Full Code Here

TOP

Related Classes of net.tanesha.recaptcha.ReCaptchaResponse

Copyright © 2018 www.massapicom. 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.