public interface

LicenseService

com.atlassian.bitbucket.license.LicenseService

Class Overview

Provides license related functions.

Summary

Public Methods
boolean canLogin(Principal principal)
Check if a user is active and licensed to use the application.
@Nullable BitbucketServerLicense get()
Get the license of this instance.
@Nullable String getAsString()
Get the encoded license for this instance.
int getLicensedUsersCount()
Get the number of licensed users currently in the system.
KeyedMessage getOverLimitMessage()
Get a message if the license is over its limits
KeyedMessage getStatus()
Checks both the license validity and its limits.
KeyedMessage getValidityMessage()
Get a message regarding the validity of the currently configured license
boolean isDataCenter()
Check whether a Data Center license is installed.
boolean isLicenseValid()
Check whether the license is valid, and operations are permitted.
boolean isPresent()
Check whether the current instance has a license.
@Nonnull BitbucketServerLicense set(String license)
Add or replace the license of this instance.
void validateCanAddUserToGroup(String username, String group)
Validate if the named user can be added to the specified group without violating license limits.
void validateCanLicenseGroup(String group, Permission permission)
Validate if the specified group can be licensed without violating license limits.
void validateCanLicenseUser(ApplicationUser user, Permission permission)
Validate if the given user can be licensed without violating license limits

Public Methods

public 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

@Nullable public BitbucketServerLicense get ()

Get the license of this instance.

Returns
  • license of this instance

@Nullable public 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

public int getLicensedUsersCount ()

Get the number of licensed users currently in the system.

Returns
  • The count of licensed users.

public 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

public KeyedMessage getStatus ()

Checks both the license validity and its limits.

Returns
  • a message if the license is invalid or is over its limits.

public 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

public boolean isDataCenter ()

Check whether a Data Center license is installed.

Returns
  • true if a Data Center license is installed; otherwise, false

public 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

public 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.)

@Nonnull public BitbucketServerLicense set (String license)

Add or replace the license of this instance.

Parameters
license new license of this instance
Returns
  • the new license

public void validateCanAddUserToGroup (String username, String group)

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

public void validateCanLicenseGroup (String group, Permission permission)

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

public void validateCanLicenseUser (ApplicationUser user, Permission permission)

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