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."));
}
}