Record Class TotpEnrolment

java.lang.Object
java.lang.Record
com.iizix.user.TotpEnrolment
Record Components:
account - The account name the authenticator app shows: the user name.
issuer - The issuer the authenticator app shows: the application.
setupKey - The Base32 shared secret, for an app that cannot scan the QR code.
uri - The otpauth://totp/ URI: what the QR code holds, and the link that opens the authenticator app on the phone it is installed on.
qrCode - The QR code as the source of an HTML image (the data URL of an SVG image), or null when the image could not be made; the setup key is then shown alone.
algorithm - The hashing algorithm as the URI names it, e.g. SHA1.
digits - The number of digits of a code.
period - The time in seconds a code is valid.

public record TotpEnrolment(String account, String issuer, String setupKey, String uri, String qrCode, String algorithm, int digits, int period) extends Record
What a user needs to enrol an authenticator app as the second factor: the QR code to scan, the link that opens the app on a phone, and the setup key for an app that does neither. It exists from IUserAuthenticationSecondFactor.beginTotpEnrolment until the enrolment is confirmed with a first valid code, or abandoned; the setup key in it is shown to the user once and is never stored or logged in clear.
Author:
Christopher Mindus
  • Constructor Details

    • TotpEnrolment

      public TotpEnrolment(String account, String issuer, String setupKey, String uri, String qrCode, String algorithm, int digits, int period)
      Creates an instance of a TotpEnrolment record class.
      Parameters:
      account - the value for the account record component
      issuer - the value for the issuer record component
      setupKey - the value for the setupKey record component
      uri - the value for the uri record component
      qrCode - the value for the qrCode record component
      algorithm - the value for the algorithm record component
      digits - the value for the digits record component
      period - the value for the period record component
  • Method Details

    • toString

      public String toString()
      Gets the enrolment without its secret, for a log or a debugger: the account, the issuer and the parameters.
      Specified by:
      toString in class Record
      Returns:
      The text, with no setup key, no URI and no QR code in it.
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • account

      public String account()
      Returns the value of the account record component.
      Returns:
      the value of the account record component
    • issuer

      public String issuer()
      Returns the value of the issuer record component.
      Returns:
      the value of the issuer record component
    • setupKey

      public String setupKey()
      Returns the value of the setupKey record component.
      Returns:
      the value of the setupKey record component
    • uri

      public String uri()
      Returns the value of the uri record component.
      Returns:
      the value of the uri record component
    • qrCode

      public String qrCode()
      Returns the value of the qrCode record component.
      Returns:
      the value of the qrCode record component
    • algorithm

      public String algorithm()
      Returns the value of the algorithm record component.
      Returns:
      the value of the algorithm record component
    • digits

      public int digits()
      Returns the value of the digits record component.
      Returns:
      the value of the digits record component
    • period

      public int period()
      Returns the value of the period record component.
      Returns:
      the value of the period record component