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 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.protected booleantokenExpired(@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:AccessTokenServiceAuthenticate by raw token- Specified by:
authenticatein interfaceAccessTokenService- Parameters:
rawToken- created byAccessTokenService.create(CreateAccessTokenRequest)method- Returns:
- Optional with
AccessTokenWhen 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:AccessTokenServiceCreate new access token for user. User can create token only for himself.- Specified by:
createin 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:AccessTokenServiceGet All tokens for given user name. Not admin can only get own tokens. Admins and restricted admins can get all users' tokens.- Specified by:
getAccessTokensByUserNamein interfaceAccessTokenService- Returns:
- list of all user's access tokens
-
deleteByTokenId
public void deleteByTokenId(@NotNull @NotNull String tokenId)Description copied from interface:AccessTokenServiceDelete one token with tokenId.- Specified by:
deleteByTokenIdin interfaceAccessTokenService
-
deleteByTokenIdBecauseOfExpiry
public void deleteByTokenIdBecauseOfExpiry(@NotNull @NotNull String tokenId, @NotNull @NotNull Date expirationDate)Description copied from interface:AccessTokenServiceDelete one token with tokenId because of expiry.- Specified by:
deleteByTokenIdBecauseOfExpiryin interfaceAccessTokenService- Parameters:
tokenId- token idexpirationDate- expiration date
-
deleteByUserName
public void deleteByUserName(@NotNull @NotNull String userName) throws UnauthorisedExceptionDescription copied from interface:AccessTokenServiceDelete all tokens for given user name- Specified by:
deleteByUserNamein interfaceAccessTokenService- Throws:
UnauthorisedException- on non-admin tries to delete other user tokens
-
-