Class FactorTimeline
java.lang.Object
com.irurueta.authserver.authorization.api.web.mfa.FactorTimeline
Reads, from the
FactorGrantedAuthority instances of an authentication, the factors that prove something
about it and when they were presented. It is the single place the claims (MfaClaimsContributor) and the
step-up checks (StepUpAuthorizationRequestConverter) take amr, acr and auth_time
from, so both always agree:
- only the factors of the
AuthenticationFactorRegistrythatMfaPolicy.isReported(com.irurueta.authserver.authorization.domain.mfa.AuthenticationFactor)accepts count: a remembered (trusted) device does not; - the authentication is multi-factor when
MfaPolicy.isMultiFactor(java.util.Set<com.irurueta.authserver.authorization.domain.mfa.AuthenticationFactor>)says so: at least two distinct factors count, or one counted factor proves a multi-factor authentication alone; auth_timeis when the primary factor was presented (the earliest one when there are several), so a second factor added later never makes the sign-in look newer; without a primary factor it is the earliest counted factor.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AuthenticationFactorRegistryRegistry of the known factors.private final MfaPolicyPolicy that tells which factors are reported and which are primary. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionamrValues(org.springframework.security.core.Authentication authentication) Lists theamrvalues of the counted factors, in the order they were presented, without duplicates.authTime(org.springframework.security.core.Authentication authentication) Finds the instant of the authentication, the oneauth_timereports andmax_ageis measured from.List<org.springframework.security.core.authority.FactorGrantedAuthority> countedFactors(org.springframework.security.core.Authentication authentication) Lists the factor authorities of an authentication that count, oldest first.Finds the earliest issue instant of some factor authorities.private List<org.springframework.security.core.authority.FactorGrantedAuthority> factorsMatching(org.springframework.security.core.Authentication authentication, Predicate<AuthenticationFactor> test) Lists the factor authorities of an authentication whose registered factor passes a test, oldest first.booleanisMultiFactor(org.springframework.security.core.Authentication authentication) Tells whether an authentication is multi-factor, byMfaPolicy.isMultiFactor(java.util.Set<com.irurueta.authserver.authorization.domain.mfa.AuthenticationFactor>)over its counted factors.
-
Field Details
-
factorRegistry
Registry of the known factors. -
mfaPolicy
Policy that tells which factors are reported and which are primary.
-
-
Constructor Details
-
FactorTimeline
public FactorTimeline()
-
-
Method Details
-
countedFactors
public List<org.springframework.security.core.authority.FactorGrantedAuthority> countedFactors(org.springframework.security.core.Authentication authentication) Lists the factor authorities of an authentication that count, oldest first.- Parameters:
authentication- the authentication.- Returns:
- the counted factor authorities, sorted by issue instant; empty when none.
-
amrValues
Lists theamrvalues of the counted factors, in the order they were presented, without duplicates.- Parameters:
authentication- the authentication.- Returns:
- the values; empty when no factor counts.
-
isMultiFactor
public boolean isMultiFactor(org.springframework.security.core.Authentication authentication) Tells whether an authentication is multi-factor, byMfaPolicy.isMultiFactor(java.util.Set<com.irurueta.authserver.authorization.domain.mfa.AuthenticationFactor>)over its counted factors.- Parameters:
authentication- the authentication.- Returns:
truefor a multi-factor authentication.
-
authTime
Finds the instant of the authentication, the oneauth_timereports andmax_ageis measured from.- Parameters:
authentication- the authentication.- Returns:
- the issue instant of the earliest primary factor, or else of the earliest counted factor; empty when no counted factor carries an instant.
-
factorsMatching
private List<org.springframework.security.core.authority.FactorGrantedAuthority> factorsMatching(org.springframework.security.core.Authentication authentication, Predicate<AuthenticationFactor> test) Lists the factor authorities of an authentication whose registered factor passes a test, oldest first.- Parameters:
authentication- the authentication.test- the test of the registered factor.- Returns:
- the matching authorities.
-
earliest
private static Optional<Instant> earliest(List<org.springframework.security.core.authority.FactorGrantedAuthority> factors) Finds the earliest issue instant of some factor authorities.- Parameters:
factors- the authorities.- Returns:
- the earliest instant, or empty when none carries one.
-