Class MFAProof
java.lang.Object
com.iizix.user.MFAProof
The proof that a sign-in verified a second factor: the MFA proof of HUB-DESIGN 7.4 (ruling RB-11),
{method, verified, age}. The server that verified the factor issues it and keeps it with the session; a server that receives it inside a session transfer trusts it because an authenticated member sent it, and never verifies the code again - the code was spent once, where it was typed.The age is measured on the issuing server's monotonic clock, so that a change of the wall clock neither ages a proof nor makes it young again. A proof older than MAX_AGE_MS is not fresh and is not sent. A sign-in that verified no second factor has the proof NONE. A passkey that was asserted with user verification is a proof, as a code is (METHOD_PASSKEY).
- Author:
- Christopher Mindus
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longThe age in milliseconds up to which a proof is fresh: 120 seconds (HUB-DESIGN 7.4).final StringThe method that was verified,METHOD_NONEfor none.static final StringThe method ofNONE: no second factor was verified.static final StringThe method of a passkey that was asserted with user verification (CC-LOGIN-M11-PASSKEY-PROOF): the passkey is what the user has, the verification by its authenticator what the user is or knows.static final StringThe method of a recovery code.static final StringThe method of a verification code of an authenticator app (RFC 6238).static final MFAProofThe proof of a sign-in that verified no second factor.final booleanWhether the second factor was verified.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionlongage()Gets the age of the proof now.longage(long now) Gets the age of the proof at a time.booleanisFresh()Checks if the proof may be sent now: a factor was verified, at mostMAX_AGE_MSago.booleanisFresh(long now) Checks if the proof may be sent at a time.static longGets the monotonic clock the age of a proof is measured on.toString()Gets the proof as it is written in a log or sent: the method, whether it was verified and its age now.
Field Details
METHOD_NONE
METHOD_TOTP
The method of a verification code of an authenticator app (RFC 6238).- See Also:
METHOD_RECOVERY
METHOD_PASSKEY
The method of a passkey that was asserted with user verification (CC-LOGIN-M11-PASSKEY-PROOF): the passkey is what the user has, the verification by its authenticator what the user is or knows.- See Also:
MAX_AGE_MS
public static final long MAX_AGE_MSThe age in milliseconds up to which a proof is fresh: 120 seconds (HUB-DESIGN 7.4).- See Also:
NONE
The proof of a sign-in that verified no second factor.method
The method that was verified,METHOD_NONEfor none.verified
public final boolean verifiedWhether the second factor was verified.
Constructor Details
MFAProof
Constructs a proof.- Parameters:
method- The method that was verified.verified- Whether it was verified.verifiedAt- The monotonic clock time in milliseconds it was verified at, seemonotonicMillis().- Throws:
NullPointerException- Ifmethodisnull.
Method Details
monotonicMillis
public static long monotonicMillis()Gets the monotonic clock the age of a proof is measured on.- Returns:
System.nanoTime()in milliseconds.
age
public long age()Gets the age of the proof now.- Returns:
- The milliseconds since the factor was verified, zero for a proof that verified nothing.
age
public long age(long now) Gets the age of the proof at a time.- Parameters:
now- The monotonic clock time in milliseconds.- Returns:
- The milliseconds since the factor was verified, never negative, zero for a proof that verified nothing.
isFresh
public boolean isFresh()Checks if the proof may be sent now: a factor was verified, at mostMAX_AGE_MSago.- Returns:
- true when fresh.
isFresh
public boolean isFresh(long now) Checks if the proof may be sent at a time.- Parameters:
now- The monotonic clock time in milliseconds.- Returns:
- true when a factor was verified, at most
MAX_AGE_MSbefore.
toString