Package com.atlassian.bitbucket.license
Interface LicenseService
public interface LicenseService
Provides license related functions.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Check if a user is active and licensed to use the application.com.atlassian.extras.api.bitbucket.BitbucketServerLicense
get()
Get the license of this instance.Get the encoded license for this instance.int
Get the number of licensed users currently in the system.Get a message if the license is over its limitsChecks both the license validity and its limits.Get a message regarding the validity of the currently configured licenseboolean
Check whether the license is potentially forged.boolean
Check whether the license is valid, and operations are permitted.boolean
Check whether the current instance has a license.boolean
Checks whether theLicenseType
of the license isLicenseType.TESTING
com.atlassian.extras.api.bitbucket.BitbucketServerLicense
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
-
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 returntrue
if the license has expired.)
-
isTestingLicense
boolean isTestingLicense()Checks whether theLicenseType
of the license isLicenseType.TESTING
- Returns:
true
if the license is of typeLicenseType.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
Get the encoded license for this instance. If no license has been set, this will returnnull
.- 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
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
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 andlicensed
-
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 licensedpermission
- 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
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 licensedpermission
- 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
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 aLicenseLimitException
if not.- Parameters:
username
- the user to be added to the groupgroup
- 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
-