Class MfaPolicy
java.lang.Object
com.irurueta.authserver.authorization.domain.mfa.MfaPolicy
The rule that decides when the factors of an authentication are enough, and when they are required. It is pure: it
knows nothing about sessions, requests or storage.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intMinimum number of distinct reported factors of a multi-factor authentication. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static booleanhasStrength(Set<AuthenticationFactor> factors, FactorStrength strength) Tells whether any factor has a strength.booleanisMultiFactor(Set<AuthenticationFactor> factors) Tells whether the factors of an authentication make it multi-factor, the one rule behind theamrmfavalue, the multi-factoracrand every step-up check: at leastMIN_MULTI_FACTORSdistinct reported factors, or one reported factor that proves a multi-factor authentication alone (AuthenticationFactor.multiFactor()).booleanisPrimary(AuthenticationFactor factor) Tells whether a factor is the primary one of an authentication, the oneauth_timeandmax_ageare measured from.booleanisReported(AuthenticationFactor factor) Tells whether a factor proves something about the authentication it was presented in, and is therefore reported (amr,acr,auth_time) and counted by a step-up request.booleanisRequired(boolean clientRequires, boolean userRequires) Tells whether multi-factor authentication is required, which is when either the client or the user demands it.booleanisSatisfied(Set<AuthenticationFactor> factors) Tells whether a set of factors satisfies the sign-in policy: aFactorStrength.PRIMARY_STRONGfactor alone, or aFactorStrength.PRIMARYfactor together with aFactorStrength.SECONDor aFactorStrength.REMEMBEREDone (a trusted device skips the second factor of a sign-in).
-
Field Details
-
MIN_MULTI_FACTORS
public static final int MIN_MULTI_FACTORSMinimum number of distinct reported factors of a multi-factor authentication.- See Also:
-
-
Constructor Details
-
MfaPolicy
public MfaPolicy()
-
-
Method Details
-
isSatisfied
Tells whether a set of factors satisfies the sign-in policy: aFactorStrength.PRIMARY_STRONGfactor alone, or aFactorStrength.PRIMARYfactor together with aFactorStrength.SECONDor aFactorStrength.REMEMBEREDone (a trusted device skips the second factor of a sign-in).- Parameters:
factors- the factors used by the authentication; must not benull.- Returns:
truewhen the factors are enough.
-
isReported
Tells whether a factor proves something about the authentication it was presented in, and is therefore reported (amr,acr,auth_time) and counted by a step-up request. AFactorStrength.REMEMBEREDfactor is not: it only recalls a second factor presented earlier.- Parameters:
factor- the factor.- Returns:
trueunless the factor isFactorStrength.REMEMBERED.
-
isMultiFactor
Tells whether the factors of an authentication make it multi-factor, the one rule behind theamrmfavalue, the multi-factoracrand every step-up check: at leastMIN_MULTI_FACTORSdistinct reported factors, or one reported factor that proves a multi-factor authentication alone (AuthenticationFactor.multiFactor()). AFactorStrength.PRIMARY_STRONGfactor alone satisfies the sign-in policy (isSatisfied(java.util.Set<com.irurueta.authserver.authorization.domain.mfa.AuthenticationFactor>)) but is multi-factor only when it says so: a passkey or a certificate proves one thing, however strongly.- Parameters:
factors- the factors used by the authentication; must not benull.- Returns:
truefor a multi-factor authentication.
-
isPrimary
Tells whether a factor is the primary one of an authentication, the oneauth_timeandmax_ageare measured from.- Parameters:
factor- the factor.- Returns:
truefor aFactorStrength.PRIMARYorFactorStrength.PRIMARY_STRONGfactor.
-
isRequired
public boolean isRequired(boolean clientRequires, boolean userRequires) Tells whether multi-factor authentication is required, which is when either the client or the user demands it.- Parameters:
clientRequires- whether the client being served requires it.userRequires- whether the user's account requires it.- Returns:
truewhen a second factor is required.
-
hasStrength
Tells whether any factor has a strength.- Parameters:
factors- the factors to inspect.strength- the strength to look for.- Returns:
truewhen at least one factor has that strength.
-