Class SessionManager

java.lang.Object
net.smoofyuniverse.ore.SessionManager

public class SessionManager extends Object
A manager for the session.
  • Constructor Details

    • SessionManager

      public SessionManager(URL authenticationUrl, String apiKey, com.google.gson.Gson gson)
      Creates a session manager.
      Parameters:
      authenticationUrl - The authentication endpoint.
      apiKey - The API key.
      gson - The Gson.
  • Method Details

    • getExpiration

      public Instant getExpiration()
      Gets the expiration instant of the current session.
      Returns:
      The expiration instant.
    • getSession

      public Optional<String> getSession()
      Gets the current session token.
      Returns:
      The session token.
    • getOrCreateSession

      public String getOrCreateSession() throws IOException
      Gets the session token. If uninitialized or outdated, a new token is created.
      Returns:
      The session token.
      Throws:
      IOException - if an I/O error occurs.
    • authenticate

      public void authenticate() throws IOException
      Authenticates and stores a new session token.
      Throws:
      IOException - if an I/O error occurs.