Package oracle.nosql.driver.kv

# Class StoreAccessTokenProvider

java.lang.Object
oracle.nosql.driver.kv.StoreAccessTokenProvider

All Implemented Interfaces:
  `AuthorizationProvider`

public class StoreAccessTokenProvider extends Object implements AuthorizationProvider
On-premises only.

StoreAccessTokenProvider is an `AuthorizationProvider` that performs the following functions:

- Initial (bootstrap) login to store, using credentials provided
- Storage of bootstrap login token for re-use
- Optionally renews the login token before it expires
- Logs out of the store when closed

If accessing an insecure instance of Oracle NoSQL Database the default constructor is used, with no arguments.

If accessing a secure instance of Oracle NoSQL Database a user name and password must be provided. That user must already exist in the NoSQL Database and have sufficient permission to perform table operations. That user's identity is used to authorize all database operations.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StoreAccessTokenProvider()`
  This method is used for access to a store without security enabled.
  `StoreAccessTokenProvider(String userName, char[] password)`
  This constructor is used when accessing a secure store.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  Closes the provider, releasing resources such as a stored login token.
  `String`
  `getEndpoint()`
  Returns the endpoint of the authenticating entity
  `Logger`
  `getLogger()`
  Returns the logger, or null if not set.
  `boolean`
  `isAutoRenew()`
  Returns whether the login token is to be automatically renewed.
  `boolean`
  `isSecure()`
  Returns whether the provider is accessing a secured store
  `StoreAccessTokenProvider`
  `setAutoRenew(boolean autoRenew)`
  Sets the auto-renew state.
  `StoreAccessTokenProvider`
  `setEndpoint(String endpoint)`
  Sets the endpoint of the authenticating entity
  `StoreAccessTokenProvider`
  `setLogger(Logger logger)`
  Sets a Logger instance for this provider.
  `StoreAccessTokenProvider`
  `setSslContext(io.netty.handler.ssl.SslContext sslCtx)`
  Sets the SSL context
  `StoreAccessTokenProvider`
  `setSslHandshakeTimeout(int timeoutMs)`
  Sets the SSL handshake timeout in milliseconds

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface oracle.nosql.driver.AuthorizationProvider

  `flushCache, forCloud, setRequiredHeaders`

- ## Constructor Details

  - ### StoreAccessTokenProvider

    public StoreAccessTokenProvider()
    This method is used for access to a store without security enabled.

  - ### StoreAccessTokenProvider

    public StoreAccessTokenProvider(String userName, char[] password)
    This constructor is used when accessing a secure store.

    This constructor requires a valid user name and password to access the target store. The user must exist and have sufficient permission to perform table operations required by the application. The user identity is used to authorize all operations performed by the application.

    Parameters:
      `userName` - the user name to use for the store. This user must exist in the NoSQL Database and is the identity that is used for authorizing all database operations.
      `password` - the password for the user.
    Throws:
      `IllegalArgumentException` - if one or more of the parameters is malformed or a required parameter is missing.

- ## Method Details

  - ### close

    public void close()
    Closes the provider, releasing resources such as a stored login token.
    Specified by:
      `close` in interface `AuthorizationProvider`

  - ### getLogger

    public Logger getLogger()
    Returns the logger, or null if not set.
    Returns:
      the logger

  - ### setLogger

    public StoreAccessTokenProvider setLogger(Logger logger)
    Sets a Logger instance for this provider.
    Parameters:
      `logger` - the logger
    Returns:
      this

  - ### getEndpoint

    public String getEndpoint()
    Returns the endpoint of the authenticating entity
    Returns:
      the endpoint

  - ### setEndpoint

    public StoreAccessTokenProvider setEndpoint(String endpoint)
    Sets the endpoint of the authenticating entity
    Parameters:
      `endpoint` - the endpoint
    Returns:
      this
    Throws:
      `IllegalArgumentException` - if the endpoint is not correctly formatted

  - ### setSslContext

    public StoreAccessTokenProvider setSslContext(io.netty.handler.ssl.SslContext sslCtx)
    Sets the SSL context
    Parameters:
      `sslCtx` - the context
    Returns:
      this

  - ### setSslHandshakeTimeout

    public StoreAccessTokenProvider setSslHandshakeTimeout(int timeoutMs)
    Sets the SSL handshake timeout in milliseconds
    Parameters:
      `timeoutMs` - the timeout in milliseconds
    Returns:
      this

  - ### isSecure

    public boolean isSecure()
    Returns whether the provider is accessing a secured store
    Returns:
      true if accessing a secure store

  - ### isAutoRenew

    public boolean isAutoRenew()
    Returns whether the login token is to be automatically renewed.
    Returns:
      true if auto-renew is set

  - ### setAutoRenew

    public StoreAccessTokenProvider setAutoRenew(boolean autoRenew)
    Sets the auto-renew state. If true, automatic renewal of the login token is enabled.
    Parameters:
      `autoRenew` - set to true to enable auto-renew
    Returns:
      this