Package jetbrains.buildServer.license
Class ServerLicenseManager
- java.lang.Object
-
- jetbrains.buildServer.license.ServerLicenseManager
-
- All Implemented Interfaces:
LicenseTokenManager
,LicenseKeysManager
public class ServerLicenseManager extends Object implements LicenseTokenManager, LicenseKeysManager
- Author:
- yole
-
-
Field Summary
Fields Modifier and Type Field Description static String
JWT_FEATURE_TOGGLE
static String
LICENSES_FILE
-
Constructor Summary
Constructors Constructor Description ServerLicenseManager(SQLRunnerEx sqlRunner, ServerPaths paths, SecurityContextEx securityContext, ServerResponsibility serverResponsibility, ProjectManagerEx projectManager, FileWatcherFactory fileWatcherFactory, EventDispatcher<BuildServerListener> serverEventDispatcher, ServiceLocator serviceLocator, SettingsPersister settingsPersister, ExecutorServices executorServices)
-
Method Summary
-
-
-
Field Detail
-
LICENSES_FILE
public static final String LICENSES_FILE
- See Also:
- Constant Field Values
-
JWT_FEATURE_TOGGLE
public static final String JWT_FEATURE_TOGGLE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ServerLicenseManager
public ServerLicenseManager(@NotNull SQLRunnerEx sqlRunner, @NotNull ServerPaths paths, @NotNull SecurityContextEx securityContext, @NotNull ServerResponsibility serverResponsibility, @NotNull ProjectManagerEx projectManager, @NotNull FileWatcherFactory fileWatcherFactory, @NotNull EventDispatcher<BuildServerListener> serverEventDispatcher, @NotNull ServiceLocator serviceLocator, @NotNull SettingsPersister settingsPersister, @NotNull ExecutorServices executorServices)
-
-
Method Detail
-
getAuthorizedAgentsCountProvider
public AuthorizedAgentsCountProvider getAuthorizedAgentsCountProvider()
-
shutdown
public void shutdown()
-
getLicensedAgentsCount
public int getLicensedAgentsCount()
-
getLicensedBuildTypesCount
public int getLicensedBuildTypesCount()
-
getLicensingPolicy
@NotNull public LicensingPolicyEx getLicensingPolicy()
- Specified by:
getLicensingPolicy
in interfaceLicenseKeysManager
-
updateLicenses
public void updateLicenses()
-
markJwtLicenseAsExpiredIfNeeded
public void markJwtLicenseAsExpiredIfNeeded(@NotNull JwtLicenseKey key)
-
addKeys
@NotNull public List<LicenseKey> addKeys(@NotNull List<String> keys) throws PersistFailedException
- Specified by:
addKeys
in interfaceLicenseKeysManager
- Throws:
PersistFailedException
-
removeKey
public void removeKey(@NotNull String key) throws PersistFailedException
Description copied from interface:LicenseKeysManager
Removes a single key.- Specified by:
removeKey
in interfaceLicenseKeysManager
- Parameters:
key
- a key to remove- Throws:
PersistFailedException
- in case of error saving license keys on disk
-
removeAllKeys
public void removeAllKeys(@NotNull List<String> keys) throws PersistFailedException
Description copied from interface:LicenseKeysManager
Removes all of the provided keys. In case of any error no keys will be removed.- Specified by:
removeAllKeys
in interfaceLicenseKeysManager
- Parameters:
keys
- keys to remove- Throws:
PersistFailedException
- in case of error saving license keys on disk
-
addJwtKey
@NotNull public LicenseKey addJwtKey(@NotNull String key) throws PersistFailedException, InvalidLicenseKeyException
Description copied from interface:LicenseKeysManager
Adds JWT key.- Specified by:
addJwtKey
in interfaceLicenseKeysManager
- Returns:
- parsed license key
- Throws:
PersistFailedException
InvalidLicenseKeyException
-
removeJwtKey
public void removeJwtKey() throws PersistFailedException
Description copied from interface:LicenseKeysManager
Removes JWT key.- Specified by:
removeJwtKey
in interfaceLicenseKeysManager
- Throws:
PersistFailedException
- in case of error saving license keys on disk
-
validateKeys
@NotNull public List<LicenseKey> validateKeys(@NotNull List<String> keys)
- Specified by:
validateKeys
in interfaceLicenseKeysManager
-
addListener
public void addListener(@NotNull LicenseKeysListener listener)
Description copied from interface:LicenseKeysManager
Adds listener to license keys manager- Specified by:
addListener
in interfaceLicenseKeysManager
- Parameters:
listener
- listener
-
removeListener
public void removeListener(@NotNull LicenseKeysListener listener)
Description copied from interface:LicenseKeysManager
Removes listener from the license keys manager- Specified by:
removeListener
in interfaceLicenseKeysManager
- Parameters:
listener
- listener
-
hasInvalidKeys
public static boolean hasInvalidKeys(@NotNull List<LicenseKey> addedKeys)
-
getLicenseList
@NotNull public LicenseList getLicenseList()
- Specified by:
getLicenseList
in interfaceLicenseKeysManager
-
getAuthorizedAgentsCount
public int getAuthorizedAgentsCount()
-
getDaysToLicenseExpiration
public int getDaysToLicenseExpiration()
-
grantLicense
public void grantLicense(@NotNull BuildAgentEx agent) throws LicenseNotGrantedException
Description copied from interface:LicenseTokenManager
Checks whether a license token can be granted to the specified agent. If token cannot be granted LicenseNotGrantedException is thrown.- Specified by:
grantLicense
in interfaceLicenseTokenManager
- Parameters:
agent
- agent to grant license to- Throws:
LicenseNotGrantedException
- if there is not enough license tokens
-
getData
public PerUsageLicenseData getData()
-
-