Interface LicenseService


public interface LicenseService
Provides license related functions.
  • Method Details

    • isLicenseForged

      boolean isLicenseForged()
      Check whether the license is potentially forged.
      Returns:
      true if the license does not pass the necessary checks appearing to look potentially forged, false otherwise
      Since:
      7.13
    • isLicenseValid

      boolean isLicenseValid()
      Check whether the license is valid, and operations are permitted.
      Returns:
      true if the license is valid and not exceeded, or in a grace period, false otherwise
      Since:
      4.8
    • isPresent

      boolean isPresent()
      Check whether the current instance has a license.
      Returns:
      true if the instance has an license (note: this will also return true if the license has expired.)
    • isTestingLicense

      boolean isTestingLicense()
      Checks whether the LicenseType of the license is LicenseType.TESTING
      Returns:
      true if the license is of type LicenseType.TESTING, false otherwise
      Since:
      7.13
    • get

      @Nullable com.atlassian.extras.api.bitbucket.BitbucketServerLicense get()
      Get the license of this instance.
      Returns:
      license of this instance
    • getAsString

      @Nullable String getAsString()
      Get the encoded license for this instance. If no license has been set, this will return null.
      Returns:
      the encoded license string, or null if no license is set
    • getLicensedUsersCount

      int getLicensedUsersCount()
      Get the number of licensed users currently in the system.
      Returns:
      The count of licensed users.
    • set

      @Nonnull com.atlassian.extras.api.bitbucket.BitbucketServerLicense set(@Nonnull String license)
      Add or replace the license of this instance.
      Parameters:
      license - new license of this instance
      Returns:
      the new license
    • getValidityMessage

      KeyedMessage getValidityMessage()
      Get a message regarding the validity of the currently configured license
      Returns:
      null if the license is valid, otherwise a descriptive message about why the license is invalid
    • getOverLimitMessage

      KeyedMessage getOverLimitMessage()
      Get a message if the license is over its limits
      Returns:
      null if the system is within the license limits, otherwise a descriptive message about how the license limits have been exceeeded
    • getStatus

      KeyedMessage getStatus()
      Checks both the license validity and its limits.
      Returns:
      a message if the license is invalid or is over its limits.
    • canLogin

      boolean canLogin(Principal principal)
      Check if a user is active and licensed to use the application.
      Parameters:
      principal - identifier for the user
      Returns:
      true if the user is both active and licensed
    • validateCanLicenseUser

      void validateCanLicenseUser(ApplicationUser user, Permission permission) throws LicenseLimitException
      Validate if the given user can be licensed without violating license limits
      Parameters:
      user - the user to be licensed
      permission - the permission to be granted to the user
      Throws:
      LicenseLimitException - if granting the permission to the specified user would exceed the number of licensed users allowed by the current license
    • validateCanLicenseGroup

      void validateCanLicenseGroup(String group, Permission permission) throws LicenseLimitException
      Validate if the specified group can be licensed without violating license limits. Licensing a group licenses all of the users the group contains.
      Parameters:
      group - the group to be licensed
      permission - the permission to be granted to the group
      Throws:
      LicenseLimitException - if granting the permission to the specified group, and all the users is contains, would exceed the number of licensed users allowed by the current license
    • validateCanAddUserToGroup

      void validateCanAddUserToGroup(String username, String group) throws LicenseLimitException
      Validate if the named user can be added to the specified group without violating license limits.

      If the group is not does not grant LICENSED_USER, this check will always pass. Otherwise, it validates that licensing an additional user would comply with license limits and will throw a LicenseLimitException if not.

      Parameters:
      username - the user to be added to the group
      group - the group the user is to be added to
      Throws:
      LicenseLimitException - if adding the user to the group would exceed the number of licensed users allowed by the current license