Interface AccessToken
-
public interface AccessToken
An access token generated by an authentication service. Subtypes of this interface represent different token formats. This interface defines factory methods for creating instances ofAccessToken
subtypes that Oracle JDBC supports when authenticating with Oracle Database.- Since:
- 23
-
-
Method Summary
Static Methods Modifier and Type Method Description static AccessToken
createJsonWebToken(char[] token)
Creates anAccessToken
representing a JSON Web Token (JWT).static AccessToken
createJsonWebToken(char[] token, java.security.PrivateKey privateKey)
Creates anAccessToken
representing a JSON Web Token (JWT) that requires proof of possession (PoP) of aprivateKey
.static java.util.function.Supplier<? extends AccessToken>
createJsonWebTokenCache(java.util.function.Supplier<? extends AccessToken> tokenSupplier)
Returns aSupplier
that caches access tokens generated by atokenSupplier
.
-
-
-
Method Detail
-
createJsonWebToken
static AccessToken createJsonWebToken(char[] token, java.security.PrivateKey privateKey)
Creates an
AccessToken
representing a JSON Web Token (JWT) that requires proof of possession (PoP) of aprivateKey
. Thetoken
argument to this method must be provided as a string of characters representing a JSON Web Token (JWT) as specified by RFC 7519.Proof of possession is specified by RFC 7800.
The returned
AccessToken
retains copies of thetoken
andprivateKey
provided to this method. After this method returns, the originaltoken
andprivateKey
may be mutated or destroyed by the caller.- Parameters:
token
- JWT encoded token. Notnull
.privateKey
- Private key for which thetoken
requires proof of possession. Notnull
.- Returns:
- An
AccessToken
representing a JWT that requires proof of possession of a private key. Not null. - Throws:
java.lang.NullPointerException
- If thetoken
orprivateKey
arenull
java.lang.IllegalArgumentException
- If thetoken
orprivateKey
have an unrecognized encoding.java.lang.IllegalStateException
- If security providers required to decode theprivateKey
are not installed.
-
createJsonWebToken
static AccessToken createJsonWebToken(char[] token)
Creates an
AccessToken
representing a JSON Web Token (JWT). Thetoken
argument to this method must be provided as a string of characters representing a JSON Web Token (JWT) as specified by RFC 7519.The returned
AccessToken
retains a copy of thetoken
provided to this method. After this method returns, the originaltoken
may be mutated or destroyed by the caller.- Parameters:
token
- JWT encoded token. Notnull
.- Returns:
- An
AccessToken
representing a JWT. Not null. - Throws:
java.lang.NullPointerException
- If thetoken
isnull
java.lang.IllegalArgumentException
- If thetoken
has an unrecognized encoding.
-
createJsonWebTokenCache
static java.util.function.Supplier<? extends AccessToken> createJsonWebTokenCache(java.util.function.Supplier<? extends AccessToken> tokenSupplier)
Returns a
Supplier
that caches access tokens generated by atokenSupplier
. ThetokenSupplier
must output instances ofAccessToken
created bycreateJsonWebToken(char[])
orcreateJsonWebToken(char[], PrivateKey)
The caching
Supplier
returned by this method retains a singleAccessToken
in its cache, which it will continue to output until that token is about to expire. When the cached token is about to expire, a token is requested by invokingSupplier.get()
on thetokenSupplier
.The caching
Supplier
returned by this method initially retains an empty cache. Theget
method of thetokenSupplier
is not invoked until theget
method of the cachingSupplier
has been invoked.The caching
Supplier
returned by this method will not perform concurrent invocations oftokenSupplier.get()
.The caching
Supplier
returned by this method does not handle uncheckedException
s thrown by thetokenSupplier
.The caching
Supplier
returned by this method throwsNullPointerException
if thetokenSupplier
returns anull
value.The caching
Supplier
returned by this method throwsIllegalArgumentException
if thetokenSupplier
returns anAccessToken
not recognized as one created bycreateJsonWebToken(char[])
orcreateJsonWebToken(char[], PrivateKey)
- Parameters:
tokenSupplier
- Supplier ofAccessToken
s. Not null. Retained.- Returns:
- A caching token supplier. Not null.
-
-