Package net.tanesha.recaptcha

Examples of net.tanesha.recaptcha.ReCaptchaImpl


  /**
   Return <tt>true</tt> only if the user has supplied a valid response for
   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


            String uresponse = request.getParameter("recaptcha_response_field");
        if (Format.isNullOrEmpty(uresponse)) {
          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

            String uresponse = request.getParameter("recaptcha_response_field");
        if (Format.isNullOrEmpty(uresponse)) {
          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

        return c.createRecaptchaHtml(null, null);
    }
   
    public static boolean checkRecaptchaResponse(HttpServletRequest request) {
        String remoteAddr = request.getRemoteAddr();
        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

        obj.setMessage(message);
      }

      // check cap.cha
      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.");
      }
View Full Code Here

               return false;
           }
          
           String privateKey = props.getProperty(RECAPTCHA_PRIVATE_KEY);
            
           ReCaptchaImpl reCaptcha = new ReCaptchaImpl();
           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

        reCaptchaResp = reCaptchaResp.submit(challenge, response, PRIVATE_KEY, remoteIp);
        if (!reCaptchaResp.getIsValid()){
          setError(FIELD_RESPONSE, reCaptchaResp.getErrorCode());
        }
        */
        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

    LoginAttemptBO loginAttemptBO = (LoginAttemptBO)appContext.getBean("loginAttemptBO");

    String role = "";

    String remoteAddr = req.getRemoteAddr();
    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{
View Full Code Here

    private static final String PRIVATE_KEY = "6Le8WNISAAAAAAOO9H7DqIfADsDTnppfbXUN9r1r";

    private static final String CAPTCHA_URL = "http://www.google.com/recaptcha/api/verify";

    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

 
  @Override
  public void validate() {
    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

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.