Interface CaptchaService


public interface CaptchaService
This service is used to help issue and validate a CAPTCHA challenge. It is intended to be used by other plugins such as the Authentication plugin to interact with Bitbucket without having to expose underlying services.
Since:
9.1
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    clear(String username)
    Clears any CAPTCHA challenge that may constrain the user with the supplied username when they authenticate.
    void
    Increments by one the number of failed authentication attempts the user has made.
    boolean
    isRequired(String username)
    Returns whether a CAPTCHA challenge is required for the user with supplied username.
    boolean
    validate(CaptchaResponse captchaResponse)
    Validates a CAPTCHA challenge.
  • Method Details

    • clear

      void clear(@Nonnull String username)
      Clears any CAPTCHA challenge that may constrain the user with the supplied username when they authenticate. Additionally, any counter or metric that contributed towards the user being issued the CAPTCHA challenge (for instance too many consecutive failed logins) will also be reset.
      Parameters:
      username - the user whose captcha challenge should be cleared
      Throws:
      AuthorisationException - when the user does not have admin permissions
      Since:
      9.2
    • incrementFailedAuthenticationAttemptCount

      void incrementFailedAuthenticationAttemptCount(@Nonnull String username)
      Increments by one the number of failed authentication attempts the user has made. Once the user reaches the maximum number of failed login attempts allowed, the user is then required to complete a CAPTCHA challenge.

      This information is local to this Bitbucket instance. It may not correspond with any such count recorded by a remote directory server or remote Crowd.

      Parameters:
      username - the username of the user whose attempt count should be incremented
      Throws:
      ServerException - if Crowd does not permit updating the corresponding attribute
      Since:
      9.2
    • isRequired

      boolean isRequired(@Nonnull String username)
      Returns whether a CAPTCHA challenge is required for the user with supplied username.
      Parameters:
      username - the username of the user to check against
      Returns:
      true if that user must answer a CAPTCHA challenge the next time they authenticate, otherwise false
    • validate

      boolean validate(@Nonnull CaptchaResponse captchaResponse)
      Validates a CAPTCHA challenge.
      Parameters:
      captchaResponse - the response to the CAPTCHA challenge as provided by the user
      Returns:
      true if the CAPTCHA challenge has been resolved correctly, otherwise false