Class Auth.TokenRequest

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

public static class Auth.TokenRequest
extends Auth.TokenParams
Contains the properties of a request for a token to Ably. Tokens are generated using Auth.requestToken(io.ably.lib.rest.Auth.TokenParams, io.ably.lib.rest.Auth.AuthOptions).
  • Field Summary

    Fields 
    Modifier and Type Field Description
    java.lang.String keyName
    The name of the key against which this request is made.
    java.lang.String mac
    The Message Authentication Code for this request.
    java.lang.String nonce
    A cryptographically secure random string of at least 16 characters, used to ensure the TokenRequest cannot be reused.

    Fields inherited from class io.ably.lib.rest.Auth.TokenParams

    capability, clientId, timestamp, ttl
  • Constructor Summary

    Constructors 
    Constructor Description
    TokenRequest()  
    TokenRequest​(Auth.TokenParams params)  
  • Method Summary

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

    Methods inherited from class io.ably.lib.rest.Auth.TokenParams

    asMap

    Methods inherited from class java.lang.Object

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

    • keyName

      public java.lang.String keyName
      The name of the key against which this request is made. The key name is public, whereas the key secret is private.

      Spec: TE2

    • nonce

      public java.lang.String nonce
      A cryptographically secure random string of at least 16 characters, used to ensure the TokenRequest cannot be reused.

      Spec: TE2

    • mac

      public java.lang.String mac
      The Message Authentication Code for this request.

      Spec: TE2

  • Constructor Details

  • Method Details

    • fromJSON

      @Deprecated public static Auth.TokenRequest fromJSON​(com.google.gson.JsonObject json)
      Deprecated.
      use fromJsonElement(JsonObject json) instead
      A static factory method to create a TokenRequest object from a deserialized TokenRequest-like object or a JSON stringified TokenRequest 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 TokenRequest 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 TokenRequest object, Ably ensures that all fields are consistently serialized and deserialized across platforms.

      Spec: TE6

      Parameters:
      json - A deserialized TokenRequest-like object or a JSON stringified TokenRequest object to create a TokenRequest.
      Returns:
      An Ably token request object.
    • fromJsonElement

      public static Auth.TokenRequest fromJsonElement​(com.google.gson.JsonObject json)
      A static factory method to create a TokenRequest object from a deserialized TokenRequest-like object or a JSON stringified TokenRequest 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 TokenRequest 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 TokenRequest object, Ably ensures that all fields are consistently serialized and deserialized across platforms.

      Spec: TE6

      Parameters:
      json - A deserialized TokenRequest-like object or a JSON stringified TokenRequest object to create a TokenRequest.
      Returns:
      An Ably token request object.
    • fromJson

      public static Auth.TokenRequest fromJson​(java.lang.String json)
      A static factory method to create a TokenRequest object from a deserialized TokenRequest-like object or a JSON stringified TokenRequest 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 TokenRequest 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 TokenRequest object, Ably ensures that all fields are consistently serialized and deserialized across platforms.

      Spec: TE6

      Parameters:
      json - A deserialized TokenRequest-like object or a JSON stringified TokenRequest object to create a TokenRequest.
      Returns:
      An Ably token request object.
    • asJsonElement

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

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

      public boolean equals​(java.lang.Object obj)
      Check equality of a TokenRequest
      Overrides:
      equals in class Auth.TokenParams
      Parameters:
      obj -