Class AuthenticationToken

java.lang.Object
org.apache.hadoop.security.authentication.util.AuthToken
org.apache.hadoop.security.authentication.server.AuthenticationToken
All Implemented Interfaces:
Principal

public class AuthenticationToken extends AuthToken
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 Details

    • ANONYMOUS

      public static final AuthenticationToken ANONYMOUS
      Constant that identifies an anonymous request.
  • Constructor Details

    • AuthenticationToken

      public AuthenticationToken(String userName, String principal, String type)
      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:
      setMaxInactives in class AuthToken
      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:
      setExpires in class AuthToken
      Parameters:
      expires - expiration time of the token in milliseconds since the epoch.
    • isExpired

      public boolean isExpired()
      Returns true if the token has expired.
      Overrides:
      isExpired in class AuthToken
      Returns:
      true if the token has expired.
    • parse

      public static AuthenticationToken parse(String tokenStr) throws AuthenticationException
      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.