org.apache.hadoop.security.token
Class Token<T extends TokenIdentifier>

java.lang.Object
  extended by org.apache.hadoop.security.token.Token<T>
All Implemented Interfaces:
Writable

public class Token<T extends TokenIdentifier>
extends Object
implements Writable

The client-side form of the token.


Nested Class Summary
static class Token.TrivialRenewer
          A trivial renewer for token kinds that aren't managed.
 
Field Summary
static org.apache.commons.logging.Log LOG
           
 
Constructor Summary
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
 void cancel(Configuration conf)
          Cancel this delegation token
 void decodeFromUrlString(String newValue)
          Decode the given url safe string into this token.
 String encodeToUrlString()
          Encode this token as a url safe string
 boolean equals(Object right)
           
 byte[] getIdentifier()
          Get the token identifier
 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?
 void readFields(DataInput in)
          Deserialize the fields of this object from in.
 long renew(Configuration conf)
          Renew this delegation token
 void setKind(Text newKind)
          Set the token kind.
 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 Detail

LOG

public static final org.apache.commons.logging.Log LOG
Constructor Detail

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 Detail

getIdentifier

public byte[] getIdentifier()
Get the token identifier

Returns:
the token identifier

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

@InterfaceAudience.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, such as HFTP wrapping HDFS.

Parameters:
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

readFields

public void readFields(DataInput in)
                throws IOException
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

write

public void write(DataOutput out)
           throws IOException
Serialize the fields of this object to out.

Specified by:
write in interface Writable
Parameters:
out - DataOuput to serialize this object into.
Throws:
IOException

encodeToUrlString

public String encodeToUrlString()
                         throws IOException
Encode this token as a url safe string

Returns:
the encoded string
Throws:
IOException

decodeFromUrlString

public void decodeFromUrlString(String newValue)
                         throws IOException
Decode the given url safe string into this token.

Parameters:
newValue - the encoded string
Throws:
IOException

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

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

renew

public long renew(Configuration conf)
           throws IOException,
                  InterruptedException
Renew this delegation token

Returns:
the new expiration time
Throws:
IOException
InterruptedException

cancel

public void cancel(Configuration conf)
            throws IOException,
                   InterruptedException
Cancel this delegation token

Throws:
IOException
InterruptedException


Copyright © 2009 The Apache Software Foundation