Package oracle.jdbc

## 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 of `AccessToken` subtypes that Oracle JDBC supports when authenticating with Oracle Database.

Since:
  23

### Method Summary

Static Methods
`static AccessToken` `createJsonWebToken​(char[] token)` Creates an `AccessToken` representing a JSON Web Token (JWT).
`static AccessToken` `createJsonWebToken​(char[] token, PrivateKey privateKey)` Creates an `AccessToken` representing a JSON Web Token (JWT) that requires proof of possession (PoP) of a `privateKey`.
`static java.util.function.Supplier<? extends AccessToken>` `createJsonWebTokenCache​(java.util.function.Supplier<? extends AccessToken> tokenSupplier)` Returns a `Supplier` that caches access tokens generated by a `tokenSupplier`.

### Method Detail

#### createJsonWebToken

    static AccessToken createJsonWebToken​(char[] token,
                                          PrivateKey privateKey)

Creates an `AccessToken` representing a JSON Web Token (JWT) that requires proof of possession (PoP) of a `privateKey`. The `token` 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 the `token` and `privateKey` provided to this method. After this method returns, the original `token` and `privateKey` may be mutated or destroyed by the caller.

Parameters:
  `token` - JWT encoded token. Not `null`.
  `privateKey` - Private key for which the `token` requires proof of possession. Not `null`.
Returns:
  An `AccessToken` representing a JWT that requires proof of possession of a private key. Not null.
Throws:
  `NullPointerException` - If the `token` or `privateKey` are `null`
  `IllegalArgumentException` - If the `token` or `privateKey` have an unrecognized encoding.
  `IllegalStateException` - If security providers required to decode the `privateKey` are not installed.

#### createJsonWebToken

    static AccessToken createJsonWebToken​(char[] token)

Creates an `AccessToken` representing a JSON Web Token (JWT). The `token` 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 the `token` provided to this method. After this method returns, the original `token` may be mutated or destroyed by the caller.

Parameters:
  `token` - JWT encoded token. Not `null`.
Returns:
  An `AccessToken` representing a JWT. Not null.
Throws:
  `NullPointerException` - If the `token` is `null`
  `IllegalArgumentException` - If the `token` 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 a `tokenSupplier`. The `tokenSupplier` must output instances of `AccessToken` created by `createJsonWebToken(char[])` or `createJsonWebToken(char[], PrivateKey)`

The caching `Supplier` returned by this method retains a single `AccessToken` 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 invoking `Supplier.get()` on the `tokenSupplier`.

The caching `Supplier` returned by this method initially retains an empty cache. The `get` method of the `tokenSupplier` is not invoked until the `get` method of the caching `Supplier` has been invoked.

The caching `Supplier` returned by this method will not perform concurrent invocations of `tokenSupplier.get()`.

The caching `Supplier` returned by this method does not handle unchecked `Exception`s thrown by the `tokenSupplier`.

The caching `Supplier` returned by this method throws `NullPointerException` if the `tokenSupplier` returns a `null` value.

The caching `Supplier` returned by this method throws `IllegalArgumentException` if the `tokenSupplier` returns an `AccessToken` not recognized as one created by `createJsonWebToken(char[])` or `createJsonWebToken(char[], PrivateKey)`

Parameters:
  `tokenSupplier` - Supplier of `AccessToken`s. Not null. Retained.
Returns:
  A caching token supplier. Not null.