Package com.atlassian.bamboo.accesstoken
Interface AccessTokenService
- All Known Implementing Classes:
DefaultAccessTokenService
public interface AccessTokenService
Service for managing
AccessTokens and authenticating them.- Since:
- 6.10
-
Method Summary
Modifier and TypeMethodDescription@NotNull Optional<AccessToken>authenticate(@NotNull String rawToken) Authenticate by raw token@NotNull RawAccessTokencreate(@NotNull CreateAccessTokenRequest createAccessTokenRequest) Create new access token for user.voiddeleteByTokenId(@NotNull String tokenId) Delete one token with tokenId.voiddeleteByTokenIdBecauseOfExpiry(@NotNull String tokenId, @NotNull Date expirationDate) Delete one token with tokenId because of expiry.voiddeleteByUserName(@NotNull String userName) Delete all tokens for given user name@NotNull List<AccessToken>getAccessTokensByUserName(@NotNull String userName) Get All tokens for given user name.
-
Method Details
-
create
@NotNull @NotNull RawAccessToken create(@NotNull @NotNull CreateAccessTokenRequest createAccessTokenRequest) throws TokenLimitExceededException, CreateTokenFailedException, UnauthorisedException, TokenWithNameExistsException Create new access token for user. User can create token only for himself.- Parameters:
createAccessTokenRequest-- Returns:
RawAccessToken,RawAccessToken.getRawToken()can be used inauthenticate(String)- Throws:
TokenLimitExceededException- when user already has maximum number of tokensCreateTokenFailedException- when can not generate unique token idUnauthorisedException- when try create token for other user than current logged inTokenWithNameExistsException- when user already has token with name
-
getAccessTokensByUserName
@NotNull @NotNull List<AccessToken> getAccessTokensByUserName(@NotNull @NotNull String userName) throws UnauthorisedException Get All tokens for given user name. Not admin can only get own tokens. Admins and restricted admins can get all users' tokens.- Parameters:
userName-- Returns:
- list of all user's access tokens
- Throws:
UnauthorisedException- on non-admin tries to get other user tokens
-
deleteByTokenId
Delete one token with tokenId.- Parameters:
tokenId-- Throws:
UnauthorisedException- on non-admin tries to delete other user token
-
deleteByTokenIdBecauseOfExpiry
void deleteByTokenIdBecauseOfExpiry(@NotNull @NotNull String tokenId, @NotNull @NotNull Date expirationDate) Delete one token with tokenId because of expiry.- Parameters:
tokenId- token idexpirationDate- expiration date
-
deleteByUserName
Delete all tokens for given user name- Parameters:
userName-- Throws:
UnauthorisedException- on non-admin tries to delete other user tokens
-
authenticate
Authenticate by raw token- Parameters:
rawToken- created bycreate(CreateAccessTokenRequest)method- Returns:
- Optional with
AccessTokenWhen user exists & is enabled and token is valid, otherwiseOptional.empty()
-