Package net.tanesha.recaptcha

Examples of net.tanesha.recaptcha.ReCaptcha


      final String publicKey,
      final String privateKey,
      final String challenge,
      final String response, HttpServletRequest request) {

    ReCaptcha captcha = ReCaptchaFactory.newReCaptcha(publicKey,
        privateKey, false);
    String address = request.getRemoteAddr();
    return captcha.checkAnswer(address,  challenge, response);
  }
View Full Code Here


    private static final String PRIVATE_KEY = "6Lerle0SAAAAAF4lafLy5LywL3k850X1IJ3al5uO";
   
    private ReCaptchaUtils() {}
   
    public static String createRecaptchaHtml() {
        ReCaptcha c = ReCaptchaFactory.newReCaptcha(PUBLIC_KEY, PRIVATE_KEY, true);
        return c.createRecaptchaHtml(null, null);
    }
View Full Code Here

            log.error("ReCaptcha service is enabled, however, private or public keys are not defined.");
            return true;
        }

        boolean secure = request.isSecure();
        ReCaptcha captcha;
        if (secure) {
            captcha = ReCaptchaFactory.newSecureReCaptcha(publicKey, privateKey, createNoScript);
        } else {
            captcha = ReCaptchaFactory.newReCaptcha(publicKey, privateKey, createNoScript);
        }
        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());
View Full Code Here

            if (StringUtils.isBlank(privateKey) || StringUtils.isBlank(publicKey)) {
                return invalidConfigurationMessage;
            }
            boolean secure = request.isSecure();

            ReCaptcha captcha;
            if (secure) {
                captcha = ReCaptchaFactory.newSecureReCaptcha(publicKey, privateKey, createNoScript);
            } else {
                captcha = ReCaptchaFactory.newReCaptcha(publicKey, privateKey, createNoScript);
            }

            return captcha.createRecaptchaHtml(null, null);
        }
        return "";
    }
View Full Code Here

          
           if (keySuccess) {
               String publicKey = props.getProperty(RECAPTCHA_PUBLIC_KEY);
               String privateKey = props.getProperty(RECAPTCHA_PRIVATE_KEY);
        
               ReCaptcha c = ReCaptchaFactory.newReCaptcha(publicKey, privateKey, false);
          
               request.getSession().setAttribute(CHALLENGE, c.createRecaptchaHtml(null, null));
           } else {
               request.getSession().setAttribute(CHALLENGE, "failed to retrieve public and/or private reCAPTCHA key. Is the reCAPTCHA module configured?");
           }
     }
View Full Code Here

            log.error("ReCaptcha service is enabled, however, private or public keys are not defined.");
            return true;
        }

        boolean secure = request.isSecure();
        ReCaptcha captcha;
        if (secure) {
            captcha = ReCaptchaFactory.newSecureReCaptcha(publicKey, privateKey, createNoScript);
        } else {
            captcha = ReCaptchaFactory.newReCaptcha(publicKey, privateKey, createNoScript);
        }
        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());
View Full Code Here

            if (StringUtils.isBlank(privateKey) || StringUtils.isBlank(publicKey)) {
                return invalidConfigurationMessage;
            }
            boolean secure = request.isSecure();

            ReCaptcha captcha;
            if (secure) {
                captcha = ReCaptchaFactory.newSecureReCaptcha(publicKey, privateKey, createNoScript);
            } else {
                captcha = ReCaptchaFactory.newReCaptcha(publicKey, privateKey, createNoScript);
            }

            return captcha.createRecaptchaHtml(null, null);
        }
        return "";
    }
View Full Code Here

    String publicKey = ERXProperties.stringForKey("er.captcha.recaptcha.publicKey");
    String privateKey = ERXProperties.stringForKey("er.captcha.recaptcha.privateKey");
    if (publicKey == null || privateKey == null) {
      throw new IllegalStateException("You have not set 'er.captcha.recaptcha.publicKey' or 'er.captcha.recaptcha.publicKey'. Please go to http://recaptcha.net and sign up for a key.");
    }
    ReCaptcha recaptcha;
    boolean secure = booleanValueForBinding("secure", ERXRequest.isRequestSecure(context().request()));
    if (secure) {
      recaptcha = ReCaptchaFactory.newSecureReCaptcha(publicKey, privateKey, false);
    }
    else {
View Full Code Here

TOP

Related Classes of net.tanesha.recaptcha.ReCaptcha

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.