Package com.atlassian.bamboo.accesstoken
Class DefaultAccessTokenService
- java.lang.Object
-
- com.atlassian.bamboo.accesstoken.DefaultAccessTokenService
-
- All Implemented Interfaces:
AccessTokenService
public class DefaultAccessTokenService extends Object implements AccessTokenService
-
-
Constructor Summary
Constructors Constructor Description DefaultAccessTokenService(AccessTokenDao accessTokenDao, AccessTokenGenerator accessTokenGenerator, BambooAuthenticationContext bambooAuthenticationContext, BambooPermissionManager bambooPermissionManager, com.atlassian.event.api.EventPublisher eventPublisher, BambooUserManager bambooUserManager, AuditLogService auditLogService, AdministrationConfigurationAccessor administrationConfigurationAccessor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @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 Detail
-
DefaultAccessTokenService
public DefaultAccessTokenService(AccessTokenDao accessTokenDao, AccessTokenGenerator accessTokenGenerator, BambooAuthenticationContext bambooAuthenticationContext, BambooPermissionManager bambooPermissionManager, com.atlassian.event.api.EventPublisher eventPublisher, BambooUserManager bambooUserManager, AuditLogService auditLogService, AdministrationConfigurationAccessor administrationConfigurationAccessor)
-
-
Method Detail
-
authenticate
@NotNull public @NotNull Optional<AccessToken> authenticate(@NotNull @NotNull String rawToken)
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
@VisibleForTesting protected boolean tokenExpired(@NotNull @NotNull AccessToken token)
-
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
public void deleteByTokenId(@NotNull @NotNull String tokenId)
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
public void deleteByUserName(@NotNull @NotNull String userName) throws UnauthorisedException
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
-
-