java.lang.Object
com.couchbase.columnar.client.java.Credential

@ThreadSafe public abstract class Credential extends Object
Create an instance like this:
 Credential.of(username, password)
 

For advanced use cases involving dynamic credentials, see ofDynamic(Supplier).

  • Method Details

    • of

      public static Credential of(String username, String password)
      Returns a new instance that holds the given username and password.
    • ofDynamic

      public static Credential ofDynamic(Supplier<Credential> supplier)
      Returns a new instance of a dynamic credential that invokes the given supplier the supplier every time a credential is required.

      This enables updating a credential without having to restart your application.

      IMPORTANT: The supplier's get() method must not do blocking IO or other expensive operations. It is called from async contexts, where blocking can starve important SDK resources like async event loops.

      Instead of blocking inside the supplier, consider having the supplier return a value from a volatile field. Then keep the field up to date by scheduling a recurring task that reads new credentials from an external source and stores them in the volatile field.