Interface AccessTokenCache
-
- All Known Implementing Classes:
AccessTokenCacheImpl
@Validated public interface AccessTokenCache
The access token cache interface.- Author:
- Christian Bremer
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
AccessTokenCache.Builder
The builder interface.
-
Field Summary
Fields Modifier and Type Field Description static String
CACHE_NAME
The constant CACHE_NAME.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static AccessTokenCache.Builder
builder()
Creates a new builder.Optional<String>
findAccessToken(@NotNull String key)
Find not expired access token from cache.static Date
getExpirationTime(@NotNull String tokenValue)
Gets expiration time.static boolean
isExpired(@NotNull String tokenValue, Duration accessTokenThreshold)
Checks whether the access token is expired.static com.nimbusds.jwt.JWT
parse(@NotNull String tokenValue)
Parse jwt.void
putAccessToken(@NotNull String key, @NotNull String accessToken)
Put new access token into the cache.
-
-
-
Field Detail
-
CACHE_NAME
static final String CACHE_NAME
The constant CACHE_NAME.- See Also:
- Constant Field Values
-
-
Method Detail
-
findAccessToken
Optional<String> findAccessToken(@NotNull @NotNull String key)
Find not expired access token from cache.- Parameters:
key
- the key- Returns:
- the access token
-
putAccessToken
void putAccessToken(@NotNull @NotNull String key, @NotNull @NotNull String accessToken)
Put new access token into the cache.- Parameters:
key
- the keyaccessToken
- the access token
-
isExpired
static boolean isExpired(@NotNull @NotNull String tokenValue, Duration accessTokenThreshold)
Checks whether the access token is expired. If no expiration claim is present, the result will always betrue
.- Parameters:
tokenValue
- the token valueaccessTokenThreshold
- the access token threshold- Returns:
- the boolean
-
getExpirationTime
static Date getExpirationTime(@NotNull @NotNull String tokenValue)
Gets expiration time.- Parameters:
tokenValue
- the token value- Returns:
- the expiration time or
null
if there is no expiration claim
-
parse
static com.nimbusds.jwt.JWT parse(@NotNull @NotNull String tokenValue)
Parse jwt.- Parameters:
tokenValue
- the token value- Returns:
- the jwt
-
builder
static AccessTokenCache.Builder builder()
Creates a new builder.- Returns:
- the builder
-
-