public interface TokenService
| Modifier and Type | Method and Description |
|---|---|
AccessToken |
createAccessToken(String clientId,
String userKey,
String authorizationCode,
long authorizationDate,
Scope scope)
Creates an Access Token
|
RefreshToken |
createRefreshToken(String clientId,
String userKey,
long authorizationDate,
String accessTokenId,
Scope scope,
String authorizationCode,
int refreshCount)
Creates a Refresh Token
|
List<AccessToken> |
findAccessTokensByUserKey(com.atlassian.sal.api.user.UserKey userKey)
Finds access tokens for userKey
|
Optional<AccessToken> |
findByAccessTokenId(String tokenId)
Tries to find a
AccessToken using the raw token |
Optional<RefreshToken> |
findByRefreshTokenId(String tokenId)
Tries to find a
RefreshToken using the raw token |
List<RefreshToken> |
findRefreshTokensByUserKey(com.atlassian.sal.api.user.UserKey userKey)
Finds refresh tokens for userKey
|
List<RefreshToken> |
findRefreshTokensForClientId(String clientId)
Finds refresh tokens for a client id
|
List<String> |
findUserKeysByClientId(String clientId)
Finds user keys of tokens for a client id
|
boolean |
isAccessTokenValid(String clientId,
String accessTokenId)
Checks if the provided access token is stored against the provided client ID
|
boolean |
isCodeRedeemed(String authorizationCode)
Checks if the provided authorization code is held against
an existing token
|
boolean |
isRefreshTokenValid(String clientId,
String refreshTokenId)
Checks if the provided refresh token is stored against the provided client ID
|
Optional<AccessToken> |
removeAccessTokenAssociatedWith(String refreshTokenId)
Removes token associated with refresh token
|
Optional<AccessToken> |
removeAccessTokenById(String tokenId)
Removes stored token using raw token
|
void |
removeByClientId(String clientId)
Removes all tokens for client id
|
List<AccessToken> |
removeByUserKey(String userKey)
Removes all tokens for user key
|
void |
removeExpiredAccessTokens(Duration expirationPeriod)
Removes all expired access tokens
|
void |
removeExpiredRefreshTokens(Duration expirationPeriod)
Removes all expired refresh tokens
|
Optional<RefreshToken> |
removeRefreshToken(String refreshTokenId)
Removes refresh token
|
Optional<RefreshToken> |
removeRefreshTokenAssociatedWith(String accessTokenId)
Removes token associated with access token
|
List<RefreshToken> |
removeTokensByAuthorizationCode(String authorizationCode)
Removes stored tokens using the provided authorization code
|
boolean |
removeTokensById(String tokenId)
Removes tokens for tokenId, treating it as an access or refresh token and removing either
|
void |
updateAccessTokenLastAccessed(String tokenId)
Updates last accessed time for access token
|
@Nonnull AccessToken createAccessToken(String clientId, String userKey, String authorizationCode, long authorizationDate, Scope scope)
clientId - client id for the tokenuserKey - userKey for tokenauthorizationCode - authorization code used to redeem tokenauthorizationDate - date when authorization was givenscope - scope for access token@Nonnull RefreshToken createRefreshToken(String clientId, String userKey, long authorizationDate, String accessTokenId, Scope scope, String authorizationCode, int refreshCount)
clientId - client id for the tokenuserKey - userKey for tokenauthorizationDate - date when authorization was givenaccessTokenId - associated with refresh tokenscope - scope for refresh tokenrefreshCount - the number of refreshesauthorizationCode - authorization code used to redeem tokenvoid updateAccessTokenLastAccessed(String tokenId)
tokenId - token to update@Nonnull Optional<AccessToken> findByAccessTokenId(String tokenId)
AccessToken using the raw tokentokenId - raw token to search database with@Nonnull Optional<RefreshToken> findByRefreshTokenId(String tokenId)
RefreshToken using the raw tokentokenId - raw token to search database with@Nonnull Optional<AccessToken> removeAccessTokenById(String tokenId)
tokenId - id of the token to remove@Nonnull List<RefreshToken> removeTokensByAuthorizationCode(String authorizationCode)
authorizationCode - authorization code to search forvoid removeByClientId(String clientId)
clientId - client id whose tokens are to be removed@Nonnull List<AccessToken> removeByUserKey(String userKey)
userKey - user key for whose tokens are to be removedvoid removeExpiredAccessTokens(@Nonnull Duration expirationPeriod)
expirationPeriod - the period of time after which we remove access tokensvoid removeExpiredRefreshTokens(@Nonnull Duration expirationPeriod)
expirationPeriod - the period of time after which we remove refresh tokens@Nonnull List<String> findUserKeysByClientId(String clientId)
clientId - client id with tokens to search for@Nonnull List<RefreshToken> findRefreshTokensForClientId(String clientId)
clientId - client id with tokens to search forList<AccessToken> findAccessTokensByUserKey(@Nonnull com.atlassian.sal.api.user.UserKey userKey)
userKey - user key to search withList<RefreshToken> findRefreshTokensByUserKey(@Nonnull com.atlassian.sal.api.user.UserKey userKey)
userKey - user key to search withOptional<AccessToken> removeAccessTokenAssociatedWith(String refreshTokenId)
Optional<RefreshToken> removeRefreshTokenAssociatedWith(String accessTokenId)
boolean isAccessTokenValid(@Nonnull String clientId, @Nonnull String accessTokenId)
clientId - id of the clientaccessTokenId - id of the access token to validateboolean isRefreshTokenValid(@Nonnull String clientId, @Nonnull String refreshTokenId)
clientId - id of the clientrefreshTokenId - id of the refresh token to validateOptional<RefreshToken> removeRefreshToken(String refreshTokenId)
refreshTokenId - - id of the refresh token to removeRefreshToken or emptyboolean isCodeRedeemed(String authorizationCode)
authorizationCode - code to search forCopyright © 2020–2023 Atlassian. All rights reserved.