java.lang.Object
com.irurueta.authserver.authorization.api.web.mfa.FactorTimeline

@Component public class FactorTimeline extends Object
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:
  • Field Details

    • factorRegistry

      private final AuthenticationFactorRegistry factorRegistry
      Registry of the known factors.
    • mfaPolicy

      private final MfaPolicy 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

      public List<String> amrValues(org.springframework.security.core.Authentication authentication)
      Lists the amr values 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, by MfaPolicy.isMultiFactor(java.util.Set<com.irurueta.authserver.authorization.domain.mfa.AuthenticationFactor>) over its counted factors.
      Parameters:
      authentication - the authentication.
      Returns:
      true for a multi-factor authentication.
    • authTime

      public Optional<Instant> authTime(org.springframework.security.core.Authentication authentication)
      Finds the instant of the authentication, the one auth_time reports and max_age is 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.