Class Auth.TokenDetails

java.lang.Object
io.ably.lib.rest.Auth.TokenDetails
Enclosing class:
Auth

public static class Auth.TokenDetails
extends java.lang.Object
Contains an Ably Token and its associated metadata.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    java.lang.String capability
    The capabilities associated with this Ably Token.
    java.lang.String clientId
    The client ID, if any, bound to this Ably Token.
    long expires
    The timestamp at which this token expires as milliseconds since the Unix epoch.
    long issued
    The timestamp at which this token was issued as milliseconds since the Unix epoch.
    java.lang.String token
    The Ably Token itself.
  • Constructor Summary

    Constructors 
    Constructor Description
    TokenDetails()  
    TokenDetails​(java.lang.String token)  
  • Method Summary

    Modifier and Type Method Description
    java.lang.String asJson()
    Convert a TokenDetails into a JSON string.
    com.google.gson.JsonObject asJsonElement()
    Convert a TokenDetails into a JSON object.
    boolean equals​(java.lang.Object obj)
    Check equality of a TokenDetails
    static Auth.TokenDetails fromJson​(java.lang.String json)
    A static factory method to create a TokenDetails object from a deserialized TokenDetails-like object or a JSON stringified TokenDetails object.
    static Auth.TokenDetails fromJSON​(com.google.gson.JsonObject json)
    Deprecated.
    static Auth.TokenDetails fromJsonElement​(com.google.gson.JsonObject json)
    A static factory method to create a TokenDetails object from a deserialized TokenDetails-like object or a JSON stringified TokenDetails object.
    int hashCode()  

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • token

      public java.lang.String token
      The Ably Token itself.

      A typical Ably Token string appears with the form xVLyHw.A-pwh7wicf3afTfgiw4k2Ku33kcnSA7z6y8FjuYpe3QaNRTEo4.

      Spec: TD2

    • expires

      public long expires
      The timestamp at which this token expires as milliseconds since the Unix epoch.

      Spec: TD3

    • issued

      public long issued
      The timestamp at which this token was issued as milliseconds since the Unix epoch.

      Spec: TD4

    • capability

      public java.lang.String capability
      The capabilities associated with this Ably Token. The capabilities value is a JSON-encoded representation of the resource paths and associated operations. Read more about capabilities in the capabilities docs.

      Spec: TD5

    • clientId

      public java.lang.String clientId
      The client ID, if any, bound to this Ably Token. If a client ID is included, then the Ably Token authenticates its bearer as that client ID, and the Ably Token may only be used to perform operations on behalf of that client ID. The client is then considered to be an identified client.

      Spec: TD6

  • Constructor Details

  • Method Details

    • fromJSON

      @Deprecated public static Auth.TokenDetails fromJSON​(com.google.gson.JsonObject json)
      Deprecated.
      A static factory method to create a TokenDetails object from a deserialized TokenDetails-like object or a JSON stringified TokenDetails object. This method is provided to minimize bugs as a result of differing types by platform for fields such as timestamp or ttl. For example, in Ruby ttl in the TokenDetails object is exposed in seconds as that is idiomatic for the language, yet when serialized to JSON using to_json it is automatically converted to the Ably standard which is milliseconds. By using the fromJson() method when constructing a TokenDetails object, Ably ensures that all fields are consistently serialized and deserialized across platforms.

      Spec: TD7

      Parameters:
      json - A deserialized TokenDetails-like object or a JSON stringified TokenDetails object.
      Returns:
      An Ably authentication token.
    • fromJson

      public static Auth.TokenDetails fromJson​(java.lang.String json)
      A static factory method to create a TokenDetails object from a deserialized TokenDetails-like object or a JSON stringified TokenDetails object. This method is provided to minimize bugs as a result of differing types by platform for fields such as timestamp or ttl. For example, in Ruby ttl in the TokenDetails object is exposed in seconds as that is idiomatic for the language, yet when serialized to JSON using to_json it is automatically converted to the Ably standard which is milliseconds. By using the fromJson() method when constructing a TokenDetails object, Ably ensures that all fields are consistently serialized and deserialized across platforms.

      Spec: TD7

      Parameters:
      json - A deserialized TokenDetails-like object or a JSON stringified TokenDetails object.
      Returns:
      An Ably authentication token.
    • fromJsonElement

      public static Auth.TokenDetails fromJsonElement​(com.google.gson.JsonObject json)
      A static factory method to create a TokenDetails object from a deserialized TokenDetails-like object or a JSON stringified TokenDetails object. This method is provided to minimize bugs as a result of differing types by platform for fields such as timestamp or ttl. For example, in Ruby ttl in the TokenDetails object is exposed in seconds as that is idiomatic for the language, yet when serialized to JSON using to_json it is automatically converted to the Ably standard which is milliseconds. By using the fromJson() method when constructing a TokenDetails object, Ably ensures that all fields are consistently serialized and deserialized across platforms.

      Spec: TD7

      Parameters:
      json - A deserialized TokenDetails-like object or a JSON stringified TokenDetails object.
      Returns:
      An Ably authentication token.
    • asJsonElement

      public com.google.gson.JsonObject asJsonElement()
      Convert a TokenDetails into a JSON object.
    • asJson

      public java.lang.String asJson()
      Convert a TokenDetails into a JSON string.
    • equals

      public boolean equals​(java.lang.Object obj)
      Check equality of a TokenDetails
      Overrides:
      equals in class java.lang.Object
      Parameters:
      obj -
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object