org.apache.hadoop.hdfs.web.oauth2

## Class AccessTokenTimer

- java.lang.Object
- - org.apache.hadoop.hdfs.web.oauth2.AccessTokenTimer

-     @InterfaceAudience.Public
       @InterfaceStability.Evolving
      public class AccessTokenTimer
      extends Object

  Access tokens generally expire. This timer helps keep track of that.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static long` | `EXPIRE_BUFFER_MS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AccessTokenTimer()`
    `AccessTokenTimer(org.apache.hadoop.util.Timer timer)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `long` | `getNextRefreshMSSinceEpoch()` Get next time we should refresh the token.
    `void` | `setExpiresIn(String expiresIn)` Set when the access token will expire as reported by the oauth server, ie in seconds from now.
    `void` | `setExpiresInMSSinceEpoch(String expiresInMSSinceEpoch)` Set when the access token will expire in milliseconds from epoch, as required by the WebHDFS configuration.
    `boolean` | `shouldRefresh()` Return true if the current token has expired or will expire within the EXPIRE_BUFFER_MS (to give ample wiggle room for the call to be made to the server).

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

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

- - ### Field Detail

    - #### EXPIRE_BUFFER_MS

          public static final long EXPIRE_BUFFER_MS

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### AccessTokenTimer

          public AccessTokenTimer()

    - #### AccessTokenTimer

          public AccessTokenTimer(org.apache.hadoop.util.Timer timer)

      Parameters:
        `timer` - Timer instance for unit testing

  - ### Method Detail

    - #### setExpiresIn

          public void setExpiresIn(String expiresIn)

      Set when the access token will expire as reported by the oauth server, ie in seconds from now.
      Parameters:
        `expiresIn` - Access time expiration as reported by OAuth server

    - #### setExpiresInMSSinceEpoch

          public void setExpiresInMSSinceEpoch(String expiresInMSSinceEpoch)

      Set when the access token will expire in milliseconds from epoch, as required by the WebHDFS configuration. This is a bit hacky and lame.
      Parameters:
        `expiresInMSSinceEpoch` - Access time expiration in ms since epoch.

    - #### getNextRefreshMSSinceEpoch

          public long getNextRefreshMSSinceEpoch()

      Get next time we should refresh the token.
      Returns:
        Next time since epoch we'll need to refresh the token.

    - #### shouldRefresh

          public boolean shouldRefresh()

      Return true if the current token has expired or will expire within the EXPIRE_BUFFER_MS (to give ample wiggle room for the call to be made to the server).

Copyright © 2022 Apache Software Foundation. All rights reserved.