Package net.tanesha.recaptcha

Examples of net.tanesha.recaptcha.ReCaptchaResponse


        }
        */
        ReCaptchaImpl reCaptcha = new ReCaptchaImpl();
          reCaptcha.setPrivateKey(PRIVATE_KEY);
         
          ReCaptchaResponse reCaptchaResponse =
              reCaptcha.checkAnswer(remoteIp, challenge, response);
         
          if (!reCaptchaResponse.isValid()) {
              setError(FIELD_RESPONSE, "Please try again." + reCaptchaResponse.getErrorMessage());
              log.warning(FIELD_RESPONSE + " " + "Please try again." + reCaptchaResponse.getErrorMessage());
          }  
  }
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

    ReCaptchaImpl reCaptcha = new ReCaptchaImpl();
    reCaptcha.setPrivateKey("6LcOO-kSAAAAAM2wCrSSw-0bB-cWMfTxH5YxGUIs");

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

    System.out.println(role);
    if(!role.equals("empty") && reCaptchaResponse.isValid()){
      return new ModelAndView("LoginSuccess");
    }else{
      return new ModelAndView("LoginFailure");
    }
  }
View Full Code Here

    public boolean isSuccessful(String challenge, String response) {
        ReCaptchaImpl reCaptcha = new ReCaptchaImpl();
        reCaptcha.setPrivateKey(PRIVATE_KEY);

        ReCaptchaResponse reCaptchaResponse = reCaptcha.checkAnswer(CAPTCHA_URL, challenge, response);
        if(reCaptchaResponse.isValid()) {
            return true;
        }
        else {
            return false;
        }
View Full Code Here

    if (this.getRecaptchaAfterEnabled()) {
      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

    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

      }
      String remoteAddress = request._remoteAddress();
      if (remoteAddress == null) {
        remoteAddress = WOApplication.application().hostAddress().getHostAddress();
      }
      ReCaptchaResponse recaptchaResponse = recaptcha().checkAnswer(remoteAddress, challenge, response);
      if (!recaptchaResponse.isValid()) {
        String errorMessage = recaptchaResponse.getErrorMessage();
        if (errorMessage != null && errorMessage.equals("incorrect-captcha-sol")) {
          errorMessage = stringValueForBinding("errorMessage");
        }
        validationFailedWithException(new NSValidation.ValidationException(errorMessage), this, ERXSimpleSpamCheck.SPAM_CHECK_KEY);
        setValueForBinding(Boolean.FALSE, "valid");
View Full Code Here

      errors.reject(null, "Код проверки защиты от роботов не указан");
      return;
    }

    try {
      ReCaptchaResponse response = captcha.checkAnswer(request.getRemoteAddr(), captchaChallenge, captchaResponse);

      if (!response.isValid()) {
        errors.reject(null, "Код проверки защиты от роботов не совпадает");
      }
    } catch (ReCaptchaException e) {
      logger.warn("Unable to check captcha", e);
View Full Code Here

  @Override
  public void create(ResearcherDto dto, BindingResult result) {
    checkAllUserInputsForInvalidHtml(dto, result);
    isPasswordValidAndMatchesConfirm(dto, result);

    ReCaptchaResponse response = recaptcha.checkAnswer("http://WHERETHEAPPLICATIONWILLBEHOSTED/cpd/researcher/create", (String) result.getRawFieldValue("recaptcha_challenge_field"), (String) result.getRawFieldValue("recaptcha_response_field"));
    if (!response.isValid()) {
      result.addError(new ObjectError("captcha", "The two words you entered did not match the picture. Please try again."));
    }

    if (Researcher.findResearchersByEmailEquals(dto.getEmail()).getResultList().size() != 0) {
      result.rejectValue("email", "researcher.error.email", "There is already an account under that email address. If you forgot your password use the forgot password link from the login page to get help.");
View Full Code Here

    return passwordEncoder.encodePassword(rawPassword, salt);
  }

  @Override
  public void resetPassword(ForgotPasswordRequest resetRequest, BindingResult result) {
    ReCaptchaResponse response = recaptcha.checkAnswer("http://WHERETHEAPPLICATIONWILLBEHOSTED/cpd/researcher/forgotPassword", (String) result.getRawFieldValue("recaptcha_challenge_field"), (String) result.getRawFieldValue("recaptcha_response_field"));
    if (!response.isValid()) {
      result.addError(new ObjectError("captcha", "The two words you entered did not match the picture. Please try again."));
      return;
    }

    Query queryResult = Researcher.findResearchersByEmailEquals(resetRequest.getEmailAddress());
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.