Class C4ReCaptchaValidationService

java.lang.Object
com.c4_soft.springaddons.starter.recaptcha.C4ReCaptchaValidationService

@Service public class C4ReCaptchaValidationService extends Object
Usage:
 if (Boolean.FALSE.equals(captcha.checkV2(reCaptcha).block())) {
        throw new RuntimeException("Are you a robot?");
 }
 
Author:
Jérôme Wacongne ch4mp@c4-soft.com
  • Constructor Details

    • C4ReCaptchaValidationService

      public C4ReCaptchaValidationService()
  • Method Details

    • checkV2

      public reactor.core.publisher.Mono<Boolean> checkV2(String response)
      Checks a reCaptcha V2 challenge response
      Parameters:
      response - answer provided by the client
      Returns:
      true / false
    • checkV3

      public reactor.core.publisher.Mono<Double> checkV3(String response) throws ReCaptchaValidationException
      Checks a reCaptcha V3 challenge response
      Parameters:
      response - answer provided by the client
      Returns:
      a score between 0 and 1
      Throws:
      ReCaptchaValidationException - if response wasn't a valid reCAPTCHA token for your site or score is below configured threshold