Package com.atlassian.bamboo.accesstoken
Class DefaultAccessTokenService
java.lang.Object
com.atlassian.bamboo.accesstoken.DefaultAccessTokenService
- All Implemented Interfaces:
AccessTokenService
-
Constructor Summary
ConstructorDescriptionDefaultAccessTokenService
(AccessTokenDao accessTokenDao, AccessTokenGenerator accessTokenGenerator, BambooAuthenticationContext bambooAuthenticationContext, BambooPermissionManager bambooPermissionManager, com.atlassian.event.api.EventPublisher eventPublisher, BambooUserManager bambooUserManager, AuditLogService auditLogService, AdministrationConfigurationAccessor administrationConfigurationAccessor) -
Method Summary
Modifier and TypeMethodDescription@NotNull Optional<AccessToken>
authenticate
(@NotNull String rawToken) Authenticate by raw token@NotNull RawAccessToken
create
(@NotNull CreateAccessTokenRequest createAccessTokenRequest) Create new access token for user.void
deleteByTokenId
(@NotNull String tokenId) Delete one token with tokenId.void
deleteByTokenIdBecauseOfExpiry
(@NotNull String tokenId, @NotNull Date expirationDate) Delete one token with tokenId because of expiry.void
deleteByUserName
(@NotNull String userName) Delete all tokens for given user name@NotNull List<AccessToken>
getAccessTokensByUserName
(@NotNull String userName) Get All tokens for given user name.protected boolean
tokenExpired
(@NotNull AccessToken token)
-
Constructor Details
-
DefaultAccessTokenService
public DefaultAccessTokenService(AccessTokenDao accessTokenDao, AccessTokenGenerator accessTokenGenerator, BambooAuthenticationContext bambooAuthenticationContext, BambooPermissionManager bambooPermissionManager, com.atlassian.event.api.EventPublisher eventPublisher, BambooUserManager bambooUserManager, AuditLogService auditLogService, AdministrationConfigurationAccessor administrationConfigurationAccessor)
-
-
Method Details
-
authenticate
Description copied from interface:AccessTokenService
Authenticate by raw token- Specified by:
authenticate
in interfaceAccessTokenService
- Parameters:
rawToken
- created byAccessTokenService.create(CreateAccessTokenRequest)
method- Returns:
- Optional with
AccessToken
When user exists & is enabled and token is valid, otherwiseOptional.empty()
-
tokenExpired
-
create
@NotNull public @NotNull RawAccessToken create(@NotNull @NotNull CreateAccessTokenRequest createAccessTokenRequest) throws TokenLimitExceededException, CreateTokenFailedException, TokenWithNameExistsException Description copied from interface:AccessTokenService
Create new access token for user. User can create token only for himself.- Specified by:
create
in interfaceAccessTokenService
- Returns:
RawAccessToken
,RawAccessToken.getRawToken()
can be used inAccessTokenService.authenticate(String)
- Throws:
TokenLimitExceededException
- when user already has maximum number of tokensCreateTokenFailedException
- when can not generate unique token idTokenWithNameExistsException
- when user already has token with name
-
getAccessTokensByUserName
@NotNull public @NotNull List<AccessToken> getAccessTokensByUserName(@NotNull @NotNull String userName) Description copied from interface:AccessTokenService
Get All tokens for given user name. Not admin can only get own tokens. Admins and restricted admins can get all users' tokens.- Specified by:
getAccessTokensByUserName
in interfaceAccessTokenService
- Returns:
- list of all user's access tokens
-
deleteByTokenId
Description copied from interface:AccessTokenService
Delete one token with tokenId.- Specified by:
deleteByTokenId
in interfaceAccessTokenService
-
deleteByTokenIdBecauseOfExpiry
public void deleteByTokenIdBecauseOfExpiry(@NotNull @NotNull String tokenId, @NotNull @NotNull Date expirationDate) Description copied from interface:AccessTokenService
Delete one token with tokenId because of expiry.- Specified by:
deleteByTokenIdBecauseOfExpiry
in interfaceAccessTokenService
- Parameters:
tokenId
- token idexpirationDate
- expiration date
-
deleteByUserName
Description copied from interface:AccessTokenService
Delete all tokens for given user name- Specified by:
deleteByUserName
in interfaceAccessTokenService
- Throws:
UnauthorisedException
- on non-admin tries to delete other user tokens
-