Interface CaptchaService

All Known Implementing Classes:
AltchaCaptchaServiceImpl, CaptchaServiceImpl

public interface CaptchaService
This service for validate the reCaptcha token
Author:
Mohamed Eskander (mohamed.eskander at 4science dot it)
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    bytesToHex(byte[] bytes)
    Encode bytes to hex string
    static String
    calculateHash(String input, String algorithm)
    Calculate a hex string from a digest, given an input string
    void
    processResponse(String response, String action)
    validate the entered reCaptcha token
  • Field Details

  • Method Details

    • processResponse

      void processResponse(String response, String action) throws InvalidReCaptchaException
      validate the entered reCaptcha token
      Parameters:
      response - reCaptcha token to be validated
      action - action of reCaptcha
      Throws:
      InvalidReCaptchaException - if reCaptcha was not successfully validated
    • bytesToHex

      static String bytesToHex(byte[] bytes)
      Encode bytes to hex string
      Parameters:
      bytes - bytes to encode
      Returns:
      hex string
    • calculateHash

      static String calculateHash(String input, String algorithm) throws NoSuchAlgorithmException
      Calculate a hex string from a digest, given an input string
      Parameters:
      input - input string
      algorithm - algorithm key, eg. SHA-256
      Returns:
      Throws:
      NoSuchAlgorithmException