Record Class SignInMethods

java.lang.Object
java.lang.Record
com.iizix.user.SignInMethods
Record Components:
pending - Whether a sign-in of this session waits for its second factor: the first factor passed and no user is signed in.
enrolmentRequired - Whether the waiting sign-in cannot be completed with a code because the policy requires a second factor and the user has none: one is enrolled first, and the enrolment completes the sign-in.
methods - The second factors the user has and the policy allows, strongest first; unmodifiable, empty when the user has none.
lastPasswordChange - The time the password was last changed, milliseconds since the epoch, zero when it is not known.
emailVerificationRequired - Whether the account must verify its e-mail address to sign in: the address is not verified and the days of the policy have passed.
totp - The entry of the user's authenticator app as the app shows it, so that the code page names it (CC-FIX-SIGNIN-RECOVERY); null when the user has no app, or nobody is the subject.

public record SignInMethods(boolean pending, boolean enrolmentRequired, List<SignInMethods.Method> methods, long lastPasswordChange, boolean emailVerificationRequired, SignInMethods.TotpEntry totp) extends Record
The ways a user signs in, as the user's own pages and the second step of a sign-in show them (SignIn L-6; gap G-7 of the SignIn flow design): what is enrolled, since when, how many recovery codes are left - and never a secret: no setup key, no code, no hash.

It is about the user this session has signed in, or, while a sign-in waits for its second factor, about the user whose first factor passed; about nobody otherwise.

Author:
Christopher Mindus
  • Field Details

    • FEW_RECOVERY_CODES

      public static final int FEW_RECOVERY_CODES
      The recovery codes left at which the user is warned to get new ones: three or fewer (decision D-32 of the SignIn flow design).
      See Also:
    • NONE

      public static final SignInMethods NONE
      The methods of nobody: no session user, no sign-in that waits.
  • Constructor Details

    • SignInMethods

      public SignInMethods(boolean pending, boolean enrolmentRequired, List<SignInMethods.Method> methods, long lastPasswordChange, boolean emailVerificationRequired)
      Creates the methods without the entry of an authenticator app: as before CC-FIX-SIGNIN-RECOVERY, for a caller that has none to give.
      Parameters:
      pending - Whether a sign-in of this session waits for its second factor.
      enrolmentRequired - Whether the waiting sign-in waits for an enrolment first.
      methods - The second factors, strongest first.
      lastPasswordChange - The time the password was last changed, zero when not known.
      emailVerificationRequired - Whether the account must verify its e-mail address to sign in.
    • SignInMethods

      public SignInMethods(boolean pending, boolean enrolmentRequired, List<SignInMethods.Method> methods, long lastPasswordChange, boolean emailVerificationRequired, SignInMethods.TotpEntry totp)
      Creates an instance of a SignInMethods record class.
      Parameters:
      pending - the value for the pending record component
      enrolmentRequired - the value for the enrolmentRequired record component
      methods - the value for the methods record component
      lastPasswordChange - the value for the lastPasswordChange record component
      emailVerificationRequired - the value for the emailVerificationRequired record component
      totp - the value for the totp record component
  • Method Details

    • get

      public SignInMethods.Method get(String kind)
      Gets a second factor of the user.
      Parameters:
      kind - The method.
      Returns:
      The second factor, null when the user has none of this kind.
    • hasSecondFactor

      public boolean hasSecondFactor()
      Checks if the user has a second factor that is not the recovery codes, which stand in for one and are none by themselves.
      Returns:
      true when the user has one.
    • recoveryCodesLeft

      public int recoveryCodesLeft()
      Gets the recovery codes the user has left.
      Returns:
      The count, zero when the user has none.
    • hasFewRecoveryCodes

      public boolean hasFewRecoveryCodes()
      Checks if the user is to be warned to get new recovery codes.
      Returns:
      true when the user has recovery codes, and FEW_RECOVERY_CODES or fewer of them left.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
    • pending

      public boolean pending()
      Returns the value of the pending record component.
      Returns:
      the value of the pending record component
    • enrolmentRequired

      public boolean enrolmentRequired()
      Returns the value of the enrolmentRequired record component.
      Returns:
      the value of the enrolmentRequired record component
    • methods

      public List<SignInMethods.Method> methods()
      Returns the value of the methods record component.
      Returns:
      the value of the methods record component
    • lastPasswordChange

      public long lastPasswordChange()
      Returns the value of the lastPasswordChange record component.
      Returns:
      the value of the lastPasswordChange record component
    • emailVerificationRequired

      public boolean emailVerificationRequired()
      Returns the value of the emailVerificationRequired record component.
      Returns:
      the value of the emailVerificationRequired record component
    • totp

      public SignInMethods.TotpEntry totp()
      Returns the value of the totp record component.
      Returns:
      the value of the totp record component