@InterfaceAudience.Public @InterfaceStability.Evolving public class Token<T extends TokenIdentifier> extends Object implements Writable
Modifier and Type | Class and Description |
---|---|
static class |
Token.TrivialRenewer
A trivial renewer for token kinds that aren't managed.
|
Modifier and Type | Field and Description |
---|---|
static org.slf4j.Logger |
LOG |
Constructor and 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.
|
Modifier and Type | Method and 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 |
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 . |
public Token(T id, SecretManager<T> mgr)
id
- the token identifiermgr
- the secret managerpublic Token(byte[] identifier, byte[] password, Text kind, Text service)
identifier
- the token identifierpassword
- the token's passwordkind
- the kind of tokenservice
- the service for this tokenpublic Token()
public void setID(byte[] bytes)
public void setPassword(byte[] newPassword)
public byte[] getIdentifier()
public T decodeIdentifier() throws IOException
IOException
- failure to unmarshall the dataRuntimeException
- if the token class could not be instantiated.public byte[] getPassword()
public Text getKind()
public Text getService()
public void setService(Text newService)
newService
- the service namepublic boolean isPrivate()
public boolean isPrivateCloneOf(Text thePublicService)
thePublicService
- the public service namepublic Token<T> privateClone(Text newService)
newService
- the new service namepublic void readFields(DataInput in) throws IOException
Writable
in
.
For efficiency, implementations should attempt to re-use storage in the existing object where possible.
readFields
in interface Writable
in
- DataInput
to deseriablize this object from.IOException
- any other problem for readFields.public void write(DataOutput out) throws IOException
Writable
out
.write
in interface Writable
out
- DataOuput
to serialize this object into.IOException
- any other problem for write.public String encodeToUrlString() throws IOException
IOException
- raised on errors performing I/O.public void decodeFromUrlString(String newValue) throws IOException
newValue
- the encoded stringIOException
- raised on errors performing I/O.public String buildCacheKey()
public boolean isManaged() throws IOException
IOException
- raised on errors performing I/O.public long renew(Configuration conf) throws IOException, InterruptedException
conf
- configuration.IOException
- raised on errors performing I/O.InterruptedException
- if the thread is interrupted.public void cancel(Configuration conf) throws IOException, InterruptedException
conf
- configuration.IOException
- raised on errors performing I/O.InterruptedException
- if the thread is interrupted.Copyright © 2023 Apache Software Foundation. All rights reserved.