Class CaptchaHelper

java.lang.Object
org.ametys.core.captcha.CaptchaHelper
All Implemented Interfaces:
Disposable, Initializable, Serviceable

public final class CaptchaHelper extends Object implements Serviceable, Initializable, Disposable
Helper for generating a captcha regardless of its implementation
  • Field Details

    • ROLE

      public static final String ROLE
      The avalon role
  • Constructor Details

  • Method Details

    • initialize

      public void initialize() throws Exception
      Specified by:
      initialize in interface Initializable
      Throws:
      Exception
    • service

      public void service(ServiceManager manager) throws ServiceException
      Specified by:
      service in interface Serviceable
      Throws:
      ServiceException
    • getCaptchaType

      public static String getCaptchaType()
      Retrieve the type of captcha used
      Returns:
      The type of captcha.
    • getCaptcha

      public static Captcha getCaptcha()
      Retrieve the used captcha
      Returns:
      The captcha.
    • checkAndInvalidate

      public static boolean checkAndInvalidate(String key, String value)
      Check a captcha
      Parameters:
      key - The captcha key. Can be empty or null when using reCaptcha.
      value - The value to check
      Returns:
      true if the captcha is valid, false otherwise.
    • getFailedI18NKey

      public static String getFailedI18NKey()
      Get the i18n key to use for the message to display when captcha verification has failed
      Returns:
      The i18n key.
    • getFailedI18NCatalog

      public static String getFailedI18NCatalog()
      Get the catalog to use for the message to display when captcha verification has failed
      Returns:
      The catalog.
    • getTooManyAttemptI18NKey

      Get the i18n key to use for the message to display when too many connection attempts have been made
      Returns:
      The key.
    • getTooManyAttemptI18NCatalog

      Get the catalog to use for the message to display when too many connection attempts have been made
      Returns:
      The catalog.
    • getUsedUrlPatterns

      Get the minimal url patterns used by the captcha implementation. This is necessary to grant those url even when the user is not authentified (in particular to set a catpcha on the login page). Do no put a too wide range (such as ^.*$) since it may introduce security issues.
      Returns:
      The minimal url patterns used by the captcha implementation.
    • requiresUserInteraction

      public static boolean requiresUserInteraction()
      Determine if the captcha provider requires user interaction If not, no visible rendering should be done
      Returns:
      true if user interaction are needed
    • dispose

      public void dispose()
      Specified by:
      dispose in interface Disposable
    • staticDispose

      public static void staticDispose()
      Dispose the CaptchaHelper