java.lang.Object
net.i2p.i2pcontrol.security.AuthToken

public class AuthTokenextends Object
Authentication token for I2PControl API access. Provides time-limited authentication tokens for secure API access.
  • Field Details

    • VALIDITY_TIME

      static final int VALIDITY_TIME
      The VALIDITY_TIME.
      See Also:
    • EXPIRY_FORMAT

      private static final ThreadLocal<DateFormat> EXPIRY_FORMAT
      Format for writing and reading the expiry date.
    • _secMan

      private final SecurityManager _secMan
      The manager that issued this token.
    • id

      private final String id
      Identifies the user the token belongs to.
    • expiry

      private final Date expiry
      When the token stops being accepted.
  • Constructor Details

    • AuthToken

      public AuthToken(SecurityManager secMan, String password)
      Creates a token from a password hash.
      Parameters:
      secMan - the security manager
      password - the password to hash
  • Method Details

    • getId

      public String getId()
      The unique token ID.
      Returns:
      the token ID
    • isValid

      public boolean isValid()
      Checks whether the AuthToken has expired.
      Returns:
      True if AuthToken hasn't expired. False in any other case.
    • getExpiryTime

      public String getExpiryTime()
      The expiry time as a formatted string.
      Returns:
      the expiry time string
    • toString

      public String toString()
      The token ID as a string.
      Overrides:
      toString in class Object
      Returns:
      the token ID
    • hashCode

      public int hashCode()
      Hash code based on the token ID.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code
    • equals

      public boolean equals(Object o)
      Equality based on the token ID.
      Overrides:
      equals in class Object
      Parameters:
      o - the object to compare
      Returns:
      true if equal