Token (Apache Hadoop Main 3.5.0 API)
Description: declaration: package: org.apache.hadoop.security.token, class: Token

Package org.apache.hadoop.security.token

# Class Token<T extends TokenIdentifier>

java.lang.Object
org.apache.hadoop.security.token.Token<T>

All Implemented Interfaces:
  `Writable`

@Public @Evolving public class Token<T extends TokenIdentifier> extends Object implements Writable
The client-side form of the token.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `Token.TrivialRenewer`
  A trivial renewer for token kinds that aren't managed.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final org.slf4j.Logger`
  `LOG`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Token()`
  Default constructor.
  `Token(byte[] identifier, byte[] password, Text kind, Text service)`
  Construct a token from the components.
  `Token(Token<T> other)`
  Clone a token.
  `Token(T id, SecretManager<T> mgr)`
  Construct a token given a token identifier and a secret manager for the type of the token identifier.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `buildCacheKey()`
  `void`
  `cancel(Configuration conf)`
  Cancel this delegation token.
  `Token<T>`
  `copyToken()`
  `void`
  `decodeFromUrlString(String newValue)`
  Decode the given url safe string into this token.
  `T`
  `decodeIdentifier()`
  Get the token identifier object, or null if it could not be constructed (because the class could not be loaded, for example).
  `String`
  `encodeToUrlString()`
  Encode this token as a url safe string.
  `boolean`
  `equals(Object right)`
  `byte[]`
  `getIdentifier()`
  Get the token identifier's byte representation.
  `Text`
  `getKind()`
  Get the token kind.
  `byte[]`
  `getPassword()`
  Get the token password/secret.
  `Text`
  `getService()`
  Get the service on which the token is supposed to be used.
  `int`
  `hashCode()`
  `boolean`
  `isManaged()`
  Is this token managed so that it can be renewed or cancelled?
  `boolean`
  `isPrivate()`
  Whether this is a private token.
  `boolean`
  `isPrivateCloneOf(Text thePublicService)`
  Whether this is a private clone of a public token.
  `Token<T>`
  `privateClone(Text newService)`
  Create a private clone of a public token.
  `void`
  `readFields(DataInput in)`
  Deserialize the fields of this object from `in`.
  `long`
  `renew(Configuration conf)`
  Renew this delegation token.
  `void`
  `setID(byte[] bytes)`
  `void`
  `setKind(Text newKind)`
  Set the token kind.
  `void`
  `setPassword(byte[] newPassword)`
  `void`
  `setService(Text newService)`
  Set the service on which the token is supposed to be used.
  `String`
  `toString()`
  `void`
  `write(DataOutput out)`
  Serialize the fields of this object to `out`.

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

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### LOG

    public static final org.slf4j.Logger LOG

- ## Constructor Details

  - ### Token

    public Token(T id, SecretManager<T> mgr)
    Construct a token given a token identifier and a secret manager for the type of the token identifier.
    Parameters:
      `id` - the token identifier
      `mgr` - the secret manager

  - ### Token

    public Token(byte[] identifier, byte[] password, Text kind, Text service)
    Construct a token from the components.
    Parameters:
      `identifier` - the token identifier
      `password` - the token's password
      `kind` - the kind of token
      `service` - the service for this token

  - ### Token

    public Token()
    Default constructor.

  - ### Token

    public Token(Token<T> other)
    Clone a token.
    Parameters:
      `other` - the token to clone

- ## Method Details

  - ### setID

    public void setID(byte[] bytes)

  - ### setPassword

    public void setPassword(byte[] newPassword)

  - ### copyToken

    public Token<T> copyToken()

  - ### getIdentifier

    public byte[] getIdentifier()
    Get the token identifier's byte representation.
    Returns:
      the token identifier's byte representation

  - ### decodeIdentifier

    public T decodeIdentifier() throws IOException
    Get the token identifier object, or null if it could not be constructed (because the class could not be loaded, for example).
    Returns:
      the token identifier, or null if there was no class found for it
    Throws:
      `IOException` - failure to unmarshall the data
      `RuntimeException` - if the token class could not be instantiated.

  - ### getPassword

    public byte[] getPassword()
    Get the token password/secret.
    Returns:
      the token password/secret

  - ### getKind

    public Text getKind()
    Get the token kind.
    Returns:
      the kind of the token

  - ### setKind

    @Private public void setKind(Text newKind)
    Set the token kind. This is only intended to be used by services that wrap another service's token.
    Parameters:
      `newKind` - newKind.

  - ### getService

    public Text getService()
    Get the service on which the token is supposed to be used.
    Returns:
      the service name

  - ### setService

    public void setService(Text newService)
    Set the service on which the token is supposed to be used.
    Parameters:
      `newService` - the service name

  - ### isPrivate

    public boolean isPrivate()
    Whether this is a private token.
    Returns:
      false always for non-private tokens

  - ### isPrivateCloneOf

    public boolean isPrivateCloneOf(Text thePublicService)
    Whether this is a private clone of a public token.
    Parameters:
      `thePublicService` - the public service name
    Returns:
      false always for non-private tokens

  - ### privateClone

    public Token<T> privateClone(Text newService)
    Create a private clone of a public token.
    Parameters:
      `newService` - the new service name
    Returns:
      a private token

  - ### readFields

    public void readFields(DataInput in) throws IOException
    Description copied from interface: `Writable`
    Deserialize the fields of this object from `in`.

    For efficiency, implementations should attempt to re-use storage in the existing object where possible.

    Specified by:
      `readFields` in interface `Writable`
    Parameters:
      `in` - `DataInput` to deseriablize this object from.
    Throws:
      `IOException` - any other problem for readFields.

  - ### write

    public void write(DataOutput out) throws IOException
    Description copied from interface: `Writable`
    Serialize the fields of this object to `out`.
    Specified by:
      `write` in interface `Writable`
    Parameters:
      `out` - `DataOuput` to serialize this object into.
    Throws:
      `IOException` - any other problem for write.

  - ### encodeToUrlString

    public String encodeToUrlString() throws IOException
    Encode this token as a url safe string.
    Returns:
      the encoded string
    Throws:
      `IOException` - raised on errors performing I/O.

  - ### decodeFromUrlString

    public void decodeFromUrlString(String newValue) throws IOException
    Decode the given url safe string into this token.
    Parameters:
      `newValue` - the encoded string
    Throws:
      `IOException` - raised on errors performing I/O.

  - ### equals

    public boolean equals(Object right)
    Overrides:
      `equals` in class `Object`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### buildCacheKey

    public String buildCacheKey()

  - ### isManaged

    public boolean isManaged() throws IOException
    Is this token managed so that it can be renewed or cancelled?
    Returns:
      true, if it can be renewed and cancelled.
    Throws:
      `IOException` - raised on errors performing I/O.

  - ### renew

    public long renew(Configuration conf) throws IOException, InterruptedException
    Renew this delegation token.
    Parameters:
      `conf` - configuration.
    Returns:
      the new expiration time
    Throws:
      `IOException` - raised on errors performing I/O.
      `InterruptedException` - if the thread is interrupted.

  - ### cancel

    public void cancel(Configuration conf) throws IOException, InterruptedException
    Cancel this delegation token.
    Parameters:
      `conf` - configuration.
    Throws:
      `IOException` - raised on errors performing I/O.
      `InterruptedException` - if the thread is interrupted.