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

public class AuthToken extends Object implements Principal
  • Constructor Details

    • AuthToken

      protected AuthToken()
    • AuthToken

      public AuthToken(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

    • checkForIllegalArgument

      protected static void checkForIllegalArgument(String value, String name)
      Check if the provided value is invalid. Throw an error if it is invalid, NOP otherwise.
      Parameters:
      value - the value to check.
      name - the parameter name to use in an error message if the value is invalid.
    • setMaxInactives

      public void setMaxInactives(long interval)
      Sets the max inactive interval of the token.
      Parameters:
      interval - max inactive interval of the token in milliseconds since the epoch.
    • setExpires

      public void setExpires(long expires)
      Sets the expiration of the token.
      Parameters:
      expires - expiration time of the token in milliseconds since the epoch.
    • isExpired

      public boolean isExpired()
      Returns true if the token has expired.
      Returns:
      true if the token has expired.
    • getUserName

      public String getUserName()
      Returns the user name.
      Returns:
      the user name.
    • getName

      public String getName()
      Returns the principal name (this method name comes from the JDK Principal interface).
      Specified by:
      getName in interface Principal
      Returns:
      the principal name.
    • getType

      public String getType()
      Returns the authentication mechanism of the token.
      Returns:
      the authentication mechanism of the token.
    • getMaxInactives

      public long getMaxInactives()
      Returns the max inactive time of the token.
      Returns:
      the max inactive time of the token, in milliseconds since Epoc.
    • getExpires

      public long getExpires()
      Returns the expiration time of the token.
      Returns:
      the expiration time of the token, in milliseconds since Epoc.
    • toString

      public String toString()
      Returns the string representation of the token.

      This string representation is parseable by the parse(java.lang.String) method.

      Specified by:
      toString in interface Principal
      Overrides:
      toString in class Object
      Returns:
      the string representation of the token.
    • parse

      public static AuthToken parse(String tokenStr) throws AuthenticationException
      Throws:
      AuthenticationException