Package net.tanesha.recaptcha

Examples of net.tanesha.recaptcha.ReCaptchaImpl


      return;
    }
    super.validate();
    if (this.getRecaptchaEnabled()) {
      String remoteAddr = ServletActionContext.getRequest().getRemoteAddr();
      ReCaptchaImpl reCaptcha = new ReCaptchaImpl();
      String privateKey = this.getConfigManager().getParam(JpwebdynamicformSystemConstants.RECAPTCHA_PRIVATEKEY_PARAM_NAME);
      reCaptcha.setPrivateKey(privateKey);
      ReCaptchaResponse reCaptchaResponse = reCaptcha.checkAnswer(remoteAddr,
          this.getRecaptcha_challenge_field(), this.getRecaptcha_response_field());
      if (!reCaptchaResponse.isValid()) {
        this.addFieldError("recaptcha_response_field", this.getText("Errors.webdynamicform.captcha.notValid"));
      }
    }
View Full Code Here


    @Override
    public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
        HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();

        String remoteAddr = request.getRemoteAddr();
        ReCaptchaImpl reCaptcha = new ReCaptchaImpl();
        reCaptcha.setPrivateKey(config.getString("recaptcha.privatekey"));

        String challenge = request.getParameter("recaptcha_challenge_field");
        String uresponse = request.getParameter("recaptcha_response_field");
        if (challenge == null || uresponse == null) {
          throw new ValidatorException(new FacesMessage("No ReCaptcha text. Maybe you have JavaScript disabled. Please enable and retry."));
        }
        ReCaptchaResponse reCaptchaResponse = reCaptcha.checkAnswer(remoteAddr, challenge, uresponse);

        if (reCaptchaResponse.isValid()) {
            return;
        } else {
            throw new ValidatorException(new FacesMessage("Invalid ReCaptcha text. Please try again."));
View Full Code Here

TOP

Related Classes of net.tanesha.recaptcha.ReCaptchaImpl

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.