Class ClientTokenUtil

java.lang.Object
org.apache.hadoop.hbase.security.token.ClientTokenUtil

@Public public final class ClientTokenUtil extends Object
Utility methods for obtaining authentication tokens, that do not require hbase-server.
  • Field Details

    • LOG

      private static final org.slf4j.Logger LOG
    • injectedException

      private static org.apache.hbase.thirdparty.com.google.protobuf.ServiceException injectedException
  • Constructor Details

  • Method Details

    • injectFault

      private static void injectFault() throws org.apache.hbase.thirdparty.com.google.protobuf.ServiceException
      Throws:
      org.apache.hbase.thirdparty.com.google.protobuf.ServiceException
    • obtainToken

      @Private public static CompletableFuture<org.apache.hadoop.security.token.Token<AuthenticationTokenIdentifier>> obtainToken(AsyncConnection conn)
      Obtain and return an authentication token for the current user.
      Parameters:
      conn - The async HBase cluster connection
      Returns:
      the authentication token instance, wrapped by a CompletableFuture.
    • obtainToken

      @Private static org.apache.hadoop.security.token.Token<AuthenticationTokenIdentifier> obtainToken(Connection conn) throws IOException
      Obtain and return an authentication token for the current user.
      Parameters:
      conn - The HBase cluster connection
      Returns:
      the authentication token instance
      Throws:
      IOException - if a remote error or serialization problem occurs.
    • toToken

      @Private static org.apache.hadoop.hbase.shaded.protobuf.generated.AuthenticationProtos.Token toToken(org.apache.hadoop.security.token.Token<AuthenticationTokenIdentifier> token)
      Converts a Token instance (with embedded identifier) to the protobuf representation.
      Parameters:
      token - the Token instance to copy
      Returns:
      the protobuf Token message
    • toToken

      @Private static org.apache.hadoop.security.token.Token<AuthenticationTokenIdentifier> toToken(org.apache.hadoop.hbase.shaded.protobuf.generated.AuthenticationProtos.Token proto)
      Converts a protobuf Token message back into a Token instance.
      Parameters:
      proto - the protobuf Token message
      Returns:
      the Token instance
    • obtainToken

      @Private static org.apache.hadoop.security.token.Token<AuthenticationTokenIdentifier> obtainToken(Connection conn, User user) throws IOException, InterruptedException
      Obtain and return an authentication token for the given user.
      Parameters:
      conn - The HBase cluster connection
      user - The user to obtain a token for
      Returns:
      the authentication token instance
      Throws:
      IOException
      InterruptedException
    • obtainAndCacheToken

      public static void obtainAndCacheToken(Connection conn, User user) throws IOException, InterruptedException
      Obtain an authentication token for the given user and add it to the user's credentials.
      Parameters:
      conn - The HBase cluster connection
      user - The user for whom to obtain the token
      Throws:
      IOException - If making a remote call to the authentication service fails
      InterruptedException - If executing as the given user is interrupted