Class AutomaticAgentAuthorizationTokens
- java.lang.Object
-
- jetbrains.buildServer.serverSide.impl.AutomaticAgentAuthorizationTokens
-
- All Implemented Interfaces:
AfterBuildsCleanupExtension
,ServerExtension
,TeamCityExtension
public class AutomaticAgentAuthorizationTokens extends Object implements AfterBuildsCleanupExtension
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AutomaticAgentAuthorizationTokens.ResolvedTokenInfo
-
Constructor Summary
Constructors Constructor Description AutomaticAgentAuthorizationTokens(CustomDataStorageManager customDataStorageManager, TimeService timeService, UserModel userModel, AgentPoolManager agentPoolManager, SecurityContext securityContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterCleanup(CleanupProcessState cleanupState)
Invoked upon finishing of the main cleanup process.List<String>
generateTokens(AgentPool agentPool, Integer timeToLiveSeconds, boolean singleUse, int count)
Generates a list of tokens that can be used to authorize agent in the provided agent pool.boolean
isValidTokenFormat(String token)
Checks if the provided token conforms to the format of the tokens produced bygenerateTokens(AgentPool, Integer, boolean, int)
.AutomaticAgentAuthorizationTokens.ResolvedTokenInfo
resolveToken(String token)
Resolves the provided token and invalidates it if necessary.
-
-
-
Constructor Detail
-
AutomaticAgentAuthorizationTokens
public AutomaticAgentAuthorizationTokens(@NotNull CustomDataStorageManager customDataStorageManager, @NotNull TimeService timeService, @NotNull UserModel userModel, @NotNull AgentPoolManager agentPoolManager, @NotNull SecurityContext securityContext)
-
-
Method Detail
-
generateTokens
@NotNull public List<String> generateTokens(@NotNull AgentPool agentPool, @Nullable Integer timeToLiveSeconds, boolean singleUse, int count)
Generates a list of tokens that can be used to authorize agent in the provided agent pool. Generated tokens can later be resolved usingresolveToken(String)
.- Parameters:
agentPool
- agent pool to associate generated tokens withtimeToLiveSeconds
- tokens expiration time in secondssingleUse
- whether generated tokens shoul be invalidated after successful resolutioncount
- number of expected tokens- Returns:
- list of generated tokens
- Throws:
AccessDeniedException
- in case the current authority does not have enogh permissions to authorize agents in the provided pool
-
resolveToken
@Nullable public AutomaticAgentAuthorizationTokens.ResolvedTokenInfo resolveToken(@NotNull String token)
Resolves the provided token and invalidates it if necessary.- Parameters:
token
- string generated bygenerateTokens(AgentPool, Integer, boolean, int)
- Returns:
- token information in case the token was resolved successfully and null otherwise
-
isValidTokenFormat
public boolean isValidTokenFormat(@NotNull String token)
Checks if the provided token conforms to the format of the tokens produced bygenerateTokens(AgentPool, Integer, boolean, int)
.- Parameters:
token
-- Returns:
- true if token conforms to the defined format and false otherwise
-
afterCleanup
public void afterCleanup(@NotNull CleanupProcessState cleanupState) throws Exception
Description copied from interface:AfterBuildsCleanupExtension
Invoked upon finishing of the main cleanup process. At this point all data for specific builds is deleted.
Note: This extension might not be called for every cleanup run as cleanup process can be interrupted earlier. Extension must check cleanup process state and if it is interrupted, complete its operations and return as quick as possible.- Specified by:
afterCleanup
in interfaceAfterBuildsCleanupExtension
- Parameters:
cleanupState
- cleanup process state- Throws:
CleanupInterruptedException
- if the cleanup process was interruptedException
- on any other error
-
-