Class AuthenticationToken
java.lang.Object
org.apache.hadoop.security.authentication.util.AuthToken
org.apache.hadoop.security.authentication.server.AuthenticationToken
- All Implemented Interfaces:
Principal
The
AuthenticationToken contains information about an authenticated
HTTP client and doubles as the Principal to be returned by
authenticated HttpServletRequests
The token can be serialized/deserialized to and from a string as it is sent
and received in HTTP client responses and requests as a HTTP cookie (this is
done by the AuthenticationFilter).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final AuthenticationTokenConstant that identifies an anonymous request. -
Constructor Summary
ConstructorsConstructorDescriptionAuthenticationToken(String userName, String principal, String type) Creates an authentication token. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns true if the token has expired.static AuthenticationTokenParses a string into an authentication token.voidsetExpires(long expires) Sets the expiration of the token.voidsetMaxInactives(long maxInactives) Sets the max inactive time of the token.Methods inherited from class org.apache.hadoop.security.authentication.util.AuthToken
checkForIllegalArgument, getExpires, getMaxInactives, getName, getType, getUserName, toString
-
Field Details
-
ANONYMOUS
Constant that identifies an anonymous request.
-
-
Constructor Details
-
AuthenticationToken
Creates an authentication token.- Parameters:
userName- user name.principal- principal (commonly matches the user name, with Kerberos is the full/long principal name while the userName is the short name).type- the authentication mechanism name. (System.currentTimeMillis() + validityPeriod).
-
-
Method Details
-
setMaxInactives
public void setMaxInactives(long maxInactives) Sets the max inactive time of the token.- Overrides:
setMaxInactivesin classAuthToken- Parameters:
maxInactives- inactive time of the token in milliseconds since the epoch.
-
setExpires
public void setExpires(long expires) Sets the expiration of the token.- Overrides:
setExpiresin classAuthToken- Parameters:
expires- expiration time of the token in milliseconds since the epoch.
-
isExpired
public boolean isExpired()Returns true if the token has expired. -
parse
Parses a string into an authentication token.- Parameters:
tokenStr- string representation of a token.- Returns:
- the parsed authentication token.
- Throws:
AuthenticationException- thrown if the string representation could not be parsed into an authentication token.
-