Interface AccessToken
-
public interface AccessTokenAn access token generated by an authentication service. Subtypes of this interface represent different token formats. This interface defines factory methods for creating instances ofAccessTokensubtypes that Oracle JDBC supports when authenticating with Oracle Database.- Since:
- 23
-
-
Method Summary
Static Methods Modifier and Type Method Description static AccessTokencreateJsonWebToken(char[] token)Creates anAccessTokenrepresenting a JSON Web Token (JWT).static AccessTokencreateJsonWebToken(char[] token, java.security.PrivateKey privateKey)Creates anAccessTokenrepresenting 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 aSupplierthat caches access tokens generated by atokenSupplier.
-
-
-
Method Detail
-
createJsonWebToken
static AccessToken createJsonWebToken(char[] token, java.security.PrivateKey privateKey)
Creates an
AccessTokenrepresenting a JSON Web Token (JWT) that requires proof of possession (PoP) of aprivateKey. Thetokenargument 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
AccessTokenretains copies of thetokenandprivateKeyprovided to this method. After this method returns, the originaltokenandprivateKeymay be mutated or destroyed by the caller.- Parameters:
token- JWT encoded token. Notnull.privateKey- Private key for which thetokenrequires proof of possession. Notnull.- Returns:
- An
AccessTokenrepresenting a JWT that requires proof of possession of a private key. Not null. - Throws:
java.lang.NullPointerException- If thetokenorprivateKeyarenulljava.lang.IllegalArgumentException- If thetokenorprivateKeyhave an unrecognized encoding.java.lang.IllegalStateException- If security providers required to decode theprivateKeyare not installed.
-
createJsonWebToken
static AccessToken createJsonWebToken(char[] token)
Creates an
AccessTokenrepresenting a JSON Web Token (JWT). Thetokenargument to this method must be provided as a string of characters representing a JSON Web Token (JWT) as specified by RFC 7519.The returned
AccessTokenretains a copy of thetokenprovided to this method. After this method returns, the originaltokenmay be mutated or destroyed by the caller.- Parameters:
token- JWT encoded token. Notnull.- Returns:
- An
AccessTokenrepresenting a JWT. Not null. - Throws:
java.lang.NullPointerException- If thetokenisnulljava.lang.IllegalArgumentException- If thetokenhas an unrecognized encoding.
-
createJsonWebTokenCache
static java.util.function.Supplier<? extends AccessToken> createJsonWebTokenCache(java.util.function.Supplier<? extends AccessToken> tokenSupplier)
Returns a
Supplierthat caches access tokens generated by atokenSupplier. ThetokenSuppliermust output instances ofAccessTokencreated bycreateJsonWebToken(char[])orcreateJsonWebToken(char[], PrivateKey)The caching
Supplierreturned by this method retains a singleAccessTokenin 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
Supplierreturned by this method initially retains an empty cache. Thegetmethod of thetokenSupplieris not invoked until thegetmethod of the cachingSupplierhas been invoked.The caching
Supplierreturned by this method will not perform concurrent invocations oftokenSupplier.get().The caching
Supplierreturned by this method does not handle uncheckedExceptions thrown by thetokenSupplier.The caching
Supplierreturned by this method throwsNullPointerExceptionif thetokenSupplierreturns anullvalue.The caching
Supplierreturned by this method throwsIllegalArgumentExceptionif thetokenSupplierreturns anAccessTokennot recognized as one created bycreateJsonWebToken(char[])orcreateJsonWebToken(char[], PrivateKey)- Parameters:
tokenSupplier- Supplier ofAccessTokens. Not null. Retained.- Returns:
- A caching token supplier. Not null.
-
-