public interface

LicenseService

com.atlassian.stash.license.LicenseService

Class Overview

The Stash License Service. Provides license related functions

Summary

Public Methods
boolean canLogin(Principal principal)
Check if a user is active and licensed to use Stash.
@Nullable StashLicense 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 isPresent()
Check whether the current instance has a license.
@Nonnull StashLicense set(String license)
Add or replace the license of this instance.
@Deprecated void update(String license)
This method is deprecated. since 3.5, for removal in 4.0. Use set(String) instead.
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(StashUser 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 Stash.

Parameters
principal identifier for the user
Returns
  • true if the user is both active and licensed

@Nullable public StashLicense get ()

Get the license of this instance.

Returns
  • license

@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 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 StashLicense set (String license)

Add or replace the license of this instance.

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

@Deprecated public void update (String license)

This method is deprecated.
since 3.5, for removal in 4.0. Use set(String) instead.

Add or replace the license of this instance.

Parameters
license new license of this instance

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 (StashUser 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