Class Authentication

java.lang.Object
io.deephaven.client.impl.Authentication

public final class Authentication extends Object
  • Field Details

    • AUTHORIZATION_HEADER

      public static final io.grpc.Metadata.Key<String> AUTHORIZATION_HEADER
      The "authorization" header. This is a misnomer in the specification, this is really an "authentication" header.
  • Method Details

    • authenticate

      public static Authentication authenticate(DeephavenChannel channel, String authenticationTypeAndValue)
      Starts an authentication request.
      Parameters:
      channel - the channel
      authenticationTypeAndValue - the authentication type and optional value
      Returns:
      the authentication
    • await

      public void await() throws InterruptedException
      Causes the current thread to wait until the authentication request is finished, unless the thread is interrupted.
      Throws:
      InterruptedException - if the current thread is interrupted while waiting
    • await

      public boolean await(Duration duration) throws InterruptedException
      Causes the current thread to wait for up to duration until the authentication request is finished, unless the thread is interrupted, or the specified waiting time elapses.
      Parameters:
      duration - the duration to wait
      Returns:
      true if the authentication request is done and false if the waiting time elapsed before the request is done
      Throws:
      InterruptedException - if the current thread is interrupted while waiting
    • awaitOrCancel

      public void awaitOrCancel() throws InterruptedException
      Waits for the request to finish. On interrupted, will cancel the request, and re-throw the interrupted exception.
      Throws:
      InterruptedException - if the current thread is interrupted while waiting
    • awaitOrCancel

      public boolean awaitOrCancel(Duration duration) throws InterruptedException
      Causes the current thread to wait for up to duration until the authentication request is finished, unless the thread is interrupted, or the specified waiting time elapses. On interrupted, will cancel the request, and re-throw the interrupted exception. On timed-out, will cancel the request.
      Parameters:
      duration - the duration to wait
      Returns:
      true if the authentication request is done and false if the waiting time elapsed before the request is done
      Throws:
      InterruptedException - if the current thread is interrupted while waiting
    • future

      The future. Is always completed successfully with this when done. The caller is still responsible for checking error() as necessary. Presented as an alternative to the await methods.
      Returns:
      the future
    • cancel

      public void cancel(String message, Throwable cause)
      Cancels the request.
      Parameters:
      message - the message
      cause - the cause
    • bearerChannel

      public Optional<DeephavenChannel> bearerChannel()
      Upon success, will return a channel that handles setting the Bearer token when messages are sent, and handles updating the Bearer token when messages are received. The request must already be finished.

      Note: the caller is responsible for ensuring at least some messages are sent as appropriate during the token timeout schedule. See configurationConstants().

    • configurationConstants

      public Optional<ConfigurationConstantsResponse> configurationConstants()
      The configuration constants. The request must already be finished.
      Returns:
      the configuration constants
    • error

      public Optional<Throwable> error()
      The error. The request must already be finished.
      Returns:
      the error
    • throwOnError

      public void throwOnError()
      Throws if an error has been returned. The request must already be finished.
      Throws:
      RuntimeException - if an error has been returned