Record Class StrongAuthState

java.lang.Object
java.lang.Record
com.iizix.user.StrongAuthState
Record Components:
policy - The effective policy of the application, StrongAuthPolicy.OFF when none.
bound - Whether the policy binds the user of this session - the one held, the one signed in, or every user before a sign-in.
held - Whether a sign-in of this session is held under the policy, for its factors.
stepUp - Whether what is held is a step-up of a signed-in session, not a sign-in.
target - How many different factors the sign-in completes on this client, 0 when not bound.
verified - The factors verified so far, strongest first; unmodifiable.
lacking - The factors this client lacks for a sign-in to be possible, empty when none; unmodifiable.
elsewhere - The allowed factors the user of the held sign-in has enrolled and this client cannot do (a passkey on a client without WebAuthn; the device key of another phone once device keys exist), empty when none or when nothing is held; unmodifiable (CC-SIGNIN-STRONG-UI). The sign-in waits for such a factor, on a client that can do it, or for a recovery code - never for an enrollment in its place: the password alone enrolls nothing for a user who has a factor the policy allows (CC-FIX-STRONG-HELD-PASSKEY).
recovery - Whether a recovery code was used in the held sign-in: it counts as no factor, and the sign-in waits for the enrollment of a replacement.

public record StrongAuthState(StrongAuthPolicy policy, boolean bound, boolean held, boolean stepUp, int target, Set<String> verified, Set<String> lacking, Set<String> elsewhere, boolean recovery) extends Record
Where a client session stands under the strong authentication policy of its application (CC-SIGNIN-STRONG-POLICY): what IUserAuthenticationStrong.getStrongAuthState answers, for the SignIn module to show the right screen. Nothing in it is a secret.
  • Before a sign-in: the policy, the target this client reaches and the factors this client lacks for a sign-in to be possible at all (section 2.5 of the design: when the set is not empty and the policy binds every user, S01 does not offer the sign-in and S32 names the client that works); verified is empty, nothing is held.
  • While a sign-in is held under the policy: held, the target, the factors verified so far, the remaining() count, what to ask next() (strongest first, the mandatory ones first), the factors the user has enrolled that this client cannot do (elsewhere: S16 says "on another device"), and whether a recovery code was used (recovery): the sign-in then completes only by enrolling a replacement factor (SA-D-10).
  • For a signed-in session: the policy, and the factors its sign-in verified.
  • For a session the policy does not bind, or an application whose policy is off: bound false, and the rest says nothing.

The state names the factors of the POLICY alone. A held sign-in whose user has enrolled none of them, and has another second factor (an authenticator app, under a policy whose factors are narrowed to the passkey), first asks for THAT one, as a sign-in without the policy asks it: getSignInMethods lists it and verifySecondFactor takes it. It counts as no factor; the sign-in then waits for the enrollment of an allowed one, as it does after a recovery code (CC-FIX-STRONG-FACTORS-NARROWED). So a sign-in page asks for what getSignInMethods lists, and enrolls when it says enrolmentRequired.

Author:
Christopher Mindus
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final StrongAuthState
    The state of a session under no policy: the policy is off, nothing binds it.
  • Constructor Summary

    Constructors
    Constructor
    Description
    StrongAuthState(StrongAuthPolicy policy, boolean bound, boolean held, boolean stepUp, int target, Set<String> verified, Set<String> lacking, Set<String> elsewhere, boolean recovery)
    Constructs the state: the sets are copied and unmodifiable.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns the value of the bound record component.
    Returns the value of the elsewhere record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    boolean
    Returns the value of the held record component.
    boolean
    Checks if the held sign-in has met its target.
    Returns the value of the lacking record component.
    Gets the allowed factors not verified yet, in the order a sign-in asks them (SA-D-4): the mandatory ones first, then the strongest first.
    Returns the value of the policy record component.
    boolean
    Returns the value of the recovery record component.
    int
    Gets how many factors the held sign-in still verifies to reach its target, the mandatory ones among them.
    boolean
    Returns the value of the stepUp record component.
    int
    Returns the value of the target record component.
    final String
    Returns a string representation of this record class.
    Returns the value of the verified record component.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • NONE

      public static final StrongAuthState NONE
      The state of a session under no policy: the policy is off, nothing binds it.
  • Constructor Details

    • StrongAuthState

      public StrongAuthState(StrongAuthPolicy policy, boolean bound, boolean held, boolean stepUp, int target, Set<String> verified, Set<String> lacking, Set<String> elsewhere, boolean recovery)
      Constructs the state: the sets are copied and unmodifiable.
      Throws:
      NullPointerException - If policy, verified, lacking or elsewhere is null.
  • Method Details

    • remaining

      public int remaining()
      Gets how many factors the held sign-in still verifies to reach its target, the mandatory ones among them.
      Returns:
      The count, 0 when the target is met or nothing is held.
    • next

      public Set<String> next()
      Gets the allowed factors not verified yet, in the order a sign-in asks them (SA-D-4): the mandatory ones first, then the strongest first.
      Returns:
      The factors, unmodifiable; empty when every allowed factor was verified.
    • isMet

      public boolean isMet()
      Checks if the held sign-in has met its target.
      Returns:
      true when nothing remains.
    • 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.
    • policy

      public StrongAuthPolicy policy()
      Returns the value of the policy record component.
      Returns:
      the value of the policy record component
    • bound

      public boolean bound()
      Returns the value of the bound record component.
      Returns:
      the value of the bound record component
    • held

      public boolean held()
      Returns the value of the held record component.
      Returns:
      the value of the held record component
    • stepUp

      public boolean stepUp()
      Returns the value of the stepUp record component.
      Returns:
      the value of the stepUp record component
    • target

      public int target()
      Returns the value of the target record component.
      Returns:
      the value of the target record component
    • verified

      public Set<String> verified()
      Returns the value of the verified record component.
      Returns:
      the value of the verified record component
    • lacking

      public Set<String> lacking()
      Returns the value of the lacking record component.
      Returns:
      the value of the lacking record component
    • elsewhere

      public Set<String> elsewhere()
      Returns the value of the elsewhere record component.
      Returns:
      the value of the elsewhere record component
    • recovery

      public boolean recovery()
      Returns the value of the recovery record component.
      Returns:
      the value of the recovery record component