Interface AccessTokenCache
-
- All Known Implementing Classes:
AccessTokenCacheImpl,RedisAccessTokenCache
@Validated public interface AccessTokenCacheThe access token cache interface.- Author:
- Christian Bremer
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceAccessTokenCache.BuilderThe builder interface.
-
Field Summary
Fields Modifier and Type Field Description static StringCACHE_NAMEThe constant CACHE_NAME.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static AccessTokenCache.Builderbuilder()Creates a new builder.Optional<String>findAccessToken(@NotNull String key)Find not expired access token from cache.static DategetExpirationTime(@NotNull String tokenValue)Gets expiration time.static booleanisExpired(@NotNull String tokenValue, Duration accessTokenThreshold)Checks whether the access token is expired.static com.nimbusds.jwt.JWTparse(@NotNull String tokenValue)Parse jwt.voidputAccessToken(@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
nullif 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
-
-