Record Class AuthenticationFactor

java.lang.Object
java.lang.Record
com.irurueta.authserver.authorization.domain.mfa.AuthenticationFactor
Record Components:
id - stable identifier of the factor, for example totp.
amrValue - value of the amr claim (RFC 8176) reported when the factor was used, for example otp.
authority - authority granted to an authentication that used the factor, for example FACTOR_TOTP.
strength - how much the factor proves on its own.
multiFactor - whether the factor alone proves a multi-factor authentication, so a session holding only it reaches the multi-factor class (acr) and passes a step-up: for example a sign-in at a provider trusted for, and reporting, its own multi-factor authentication. Only a FactorStrength.PRIMARY_STRONG factor can be one; a strong factor that proves a single thing (a passkey whose user verification is not required, a certificate) is not.

public record AuthenticationFactor(String id, String amrValue, String authority, FactorStrength strength, boolean multiFactor) extends Record
A way of authenticating, as registered by a feature.
  • Field Details

    • id

      private final String id
      The field for the id record component.
    • amrValue

      private final String amrValue
      The field for the amrValue record component.
    • authority

      private final String authority
      The field for the authority record component.
    • strength

      private final FactorStrength strength
      The field for the strength record component.
    • multiFactor

      private final boolean multiFactor
      The field for the multiFactor record component.
  • Constructor Details

    • AuthenticationFactor

      public AuthenticationFactor(String id, String amrValue, String authority, FactorStrength strength, boolean multiFactor)
      Validates the factor.
      Throws:
      IllegalArgumentException - if a text is blank, the strength is missing, or a factor that is not FactorStrength.PRIMARY_STRONG claims to be multi-factor alone.
    • AuthenticationFactor

      public AuthenticationFactor(String id, String amrValue, String authority, FactorStrength strength)
      Creates a factor that does not prove a multi-factor authentication alone, the usual case.
      Parameters:
      id - stable identifier of the factor.
      amrValue - value of the amr claim reported when the factor was used.
      authority - authority granted to an authentication that used the factor.
      strength - how much the factor proves on its own.
      Throws:
      IllegalArgumentException - if a text is blank or the strength is missing.
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • id

      public String id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • amrValue

      public String amrValue()
      Returns the value of the amrValue record component.
      Returns:
      the value of the amrValue record component
    • authority

      public String authority()
      Returns the value of the authority record component.
      Returns:
      the value of the authority record component
    • strength

      public FactorStrength strength()
      Returns the value of the strength record component.
      Returns:
      the value of the strength record component
    • multiFactor

      public boolean multiFactor()
      Returns the value of the multiFactor record component.
      Returns:
      the value of the multiFactor record component