Class MFAProof
{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).
A sign-in under a strong authentication policy verifies SEVERAL factors (CC-SIGNIN-STRONG-POLICY, section 2.6 of the design of order 475): the proof carries the set of them, methods, strongest first; method stays the first one, for the readers of one method. A hub member that receives the proof compares the set with its own resolved policy (StrongAuthPolicy.accepts): a proof that falls short is not accepted, and the user is asked the rest.
- 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: the first ofmethods, the strongest.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).Every method that was verified, strongest first, unmodifiable; empty forNONE.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.booleanChecks if a method was verified.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.static MFAProofMakes the proof of several methods (CC-SIGNIN-STRONG-POLICY).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: the first ofmethods, the strongest.methods
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.
of
Makes the proof of several methods (CC-SIGNIN-STRONG-POLICY).- Parameters:
methods- The methods that were verified; copied and ordered: the strong factors strongest first (StrongAuthPolicy.ALL_FACTORS), then the rest as given.verified- Whether they were verified.verifiedAt- The monotonic clock time in milliseconds the last was verified at, seemonotonicMillis().- Returns:
- The proof.
- Throws:
NullPointerException- Ifmethodsisnull.IllegalArgumentException- Ifmethodsis empty, or namesMETHOD_NONE.
has
Checks if a method was verified.- Parameters:
method- The method, null for none.- Returns:
- true when the proof is verified and has the method.
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
Gets the proof as it is written in a log or sent: the method, whether it was verified and its age now. Nothing in it is a secret.