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
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordOne second factor of a user.static final recordThe entry of a user's authenticator app, as the app shows it: the issuer and the account of theotpauth://URI the enrolment's QR code carried (CC-FIX-SIGNIN-RECOVERY).Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe recovery codes left at which the user is warned to get new ones: three or fewer (decision D-32 of the SignIn flow design).static final SignInMethodsThe methods of nobody: no session user, no sign-in that waits.Constructor Summary
ConstructorsConstructorDescriptionSignInMethods(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.SignInMethods(boolean pending, boolean enrolmentRequired, List<SignInMethods.Method> methods, long lastPasswordChange, boolean emailVerificationRequired, SignInMethods.TotpEntry totp) Creates an instance of aSignInMethodsrecord class.Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the value of theemailVerificationRequiredrecord component.booleanReturns the value of theenrolmentRequiredrecord component.final booleanIndicates whether some other object is "equal to" this one.Gets a second factor of the user.booleanChecks if the user is to be warned to get new recovery codes.final inthashCode()Returns a hash code value for this object.booleanChecks if the user has a second factor that is not the recovery codes, which stand in for one and are none by themselves.longReturns the value of thelastPasswordChangerecord component.methods()Returns the value of themethodsrecord component.booleanpending()Returns the value of thependingrecord component.intGets the recovery codes the user has left.final StringtoString()Returns a string representation of this record class.totp()Returns the value of thetotprecord component.
Field Details
FEW_RECOVERY_CODES
public static final int FEW_RECOVERY_CODESThe 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
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 aSignInMethodsrecord class.- Parameters:
pending- the value for thependingrecord componentenrolmentRequired- the value for theenrolmentRequiredrecord componentmethods- the value for themethodsrecord componentlastPasswordChange- the value for thelastPasswordChangerecord componentemailVerificationRequired- the value for theemailVerificationRequiredrecord componenttotp- the value for thetotprecord component
Method Details
get
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_CODESor fewer of them left.
toString
hashCode
equals
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 withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes.pending
enrolmentRequired
public boolean enrolmentRequired()Returns the value of theenrolmentRequiredrecord component.- Returns:
- the value of the
enrolmentRequiredrecord component
methods
lastPasswordChange
public long lastPasswordChange()Returns the value of thelastPasswordChangerecord component.- Returns:
- the value of the
lastPasswordChangerecord component
emailVerificationRequired
public boolean emailVerificationRequired()Returns the value of theemailVerificationRequiredrecord component.- Returns:
- the value of the
emailVerificationRequiredrecord component
totp