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
The client-side form of the token.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA trivial renewer for token kinds that aren't managed. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionToken()Default constructor.Construct a token from the components.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 TypeMethodDescriptionvoidcancel(Configuration conf) Cancel this delegation token.voiddecodeFromUrlString(String newValue) Decode the given url safe string into this token.Get the token identifier object, or null if it could not be constructed (because the class could not be loaded, for example).Encode this token as a url safe string.booleanbyte[]Get the token identifier's byte representation.getKind()Get the token kind.byte[]Get the token password/secret.Get the service on which the token is supposed to be used.inthashCode()booleanIs this token managed so that it can be renewed or cancelled?booleanWhether this is a private token.booleanisPrivateCloneOf(Text thePublicService) Whether this is a private clone of a public token.privateClone(Text newService) Create a private clone of a public token.voidreadFields(DataInput in) Deserialize the fields of this object fromin.longrenew(Configuration conf) Renew this delegation token.voidsetID(byte[] bytes) voidsetKind(Text newKind) Set the token kind.voidsetPassword(byte[] newPassword) voidsetService(Text newService) Set the service on which the token is supposed to be used.toString()voidwrite(DataOutput out) Serialize the fields of this object toout.
-
Field Details
-
LOG
public static final org.slf4j.Logger LOG
-
-
Constructor Details
-
Token
Construct a token given a token identifier and a secret manager for the type of the token identifier.- Parameters:
id- the token identifiermgr- the secret manager
-
Token
Construct a token from the components.- Parameters:
identifier- the token identifierpassword- the token's passwordkind- the kind of tokenservice- the service for this token
-
Token
public Token()Default constructor. -
Token
Clone a token.- Parameters:
other- the token to clone
-
-
Method Details
-
setID
public void setID(byte[] bytes) -
setPassword
public void setPassword(byte[] newPassword) -
copyToken
-
getIdentifier
public byte[] getIdentifier()Get the token identifier's byte representation.- Returns:
- the token identifier's byte representation
-
decodeIdentifier
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 dataRuntimeException- if the token class could not be instantiated.
-
getPassword
public byte[] getPassword()Get the token password/secret.- Returns:
- the token password/secret
-
getKind
Get the token kind.- Returns:
- the kind of the token
-
setKind
Set the token kind. This is only intended to be used by services that wrap another service's token.- Parameters:
newKind- newKind.
-
getService
Get the service on which the token is supposed to be used.- Returns:
- the service name
-
setService
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
Whether this is a private clone of a public token.- Parameters:
thePublicService- the public service name- Returns:
- false always for non-private tokens
-
privateClone
Create a private clone of a public token.- Parameters:
newService- the new service name- Returns:
- a private token
-
readFields
Description copied from interface:WritableDeserialize the fields of this object fromin.For efficiency, implementations should attempt to re-use storage in the existing object where possible.
- Specified by:
readFieldsin interfaceWritable- Parameters:
in-DataInputto deseriablize this object from.- Throws:
IOException- any other problem for readFields.
-
write
Description copied from interface:WritableSerialize the fields of this object toout.- Specified by:
writein interfaceWritable- Parameters:
out-DataOuputto serialize this object into.- Throws:
IOException- any other problem for write.
-
encodeToUrlString
Encode this token as a url safe string.- Returns:
- the encoded string
- Throws:
IOException- raised on errors performing I/O.
-
decodeFromUrlString
Decode the given url safe string into this token.- Parameters:
newValue- the encoded string- Throws:
IOException- raised on errors performing I/O.
-
equals
-
hashCode
public int hashCode() -
toString
-
buildCacheKey
-
isManaged
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
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
Cancel this delegation token.- Parameters:
conf- configuration.- Throws:
IOException- raised on errors performing I/O.InterruptedException- if the thread is interrupted.
-