Record Class OttProperties

java.lang.Object
java.lang.Record
com.irurueta.authserver.authorization.application.ott.OttProperties
Record Components:
codeLength - number of digits of a code (default 6).
codeTtl - how long a code is valid (default 10 minutes).
linkTtl - how long a magic link is valid (default 15 minutes).
maxAttempts - verification attempts a code allows before it is burnt (default 5).

@ConfigurationProperties("authserver.ott") public record OttProperties(int codeLength, Duration codeTtl, Duration linkTtl, int maxAttempts) extends Record
Settings of the one-time codes, bound from authserver.ott.* once and validated at startup. A missing (or zero, for a number) value takes its default, so the application starts without any setting.
  • Field Details

    • codeLength

      private final int codeLength
      The field for the codeLength record component.
    • codeTtl

      private final Duration codeTtl
      The field for the codeTtl record component.
    • linkTtl

      private final Duration linkTtl
      The field for the linkTtl record component.
    • maxAttempts

      private final int maxAttempts
      The field for the maxAttempts record component.
    • DEFAULT_CODE_LENGTH

      private static final int DEFAULT_CODE_LENGTH
      Default number of digits of a code.
      See Also:
    • DEFAULT_CODE_TTL_MINUTES

      private static final long DEFAULT_CODE_TTL_MINUTES
      Default validity of a code, in minutes.
      See Also:
    • DEFAULT_MAX_ATTEMPTS

      private static final int DEFAULT_MAX_ATTEMPTS
      Default number of verification attempts.
      See Also:
  • Constructor Details

    • OttProperties

      public OttProperties(@DefaultValue("6") int codeLength, @DefaultValue("PT10M") Duration codeTtl, @DefaultValue("PT15M") Duration linkTtl, @DefaultValue("5") int maxAttempts)
      Applies the defaults and validates the settings.
      Throws:
      IllegalArgumentException - if the length or the attempts are negative or a duration is negative.
  • Method Details

    • positiveOrDefault

      private static int positiveOrDefault(int value, int defaultValue, String key)
      Keeps a positive number, replaces zero by its default and rejects a negative one.
      Parameters:
      value - the configured number.
      defaultValue - the default.
      key - the key of the setting below authserver.ott.
      Returns:
      the value to use.
    • positiveOrDefault

      private static Duration positiveOrDefault(Duration value, Duration defaultValue, String key)
      Keeps a positive duration, replaces a missing or zero one by its default and rejects a negative one.
      Parameters:
      value - the configured duration.
      defaultValue - the default.
      key - the key of the setting below authserver.ott.
      Returns:
      the duration to use.
    • 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.
    • codeLength

      public int codeLength()
      Returns the value of the codeLength record component.
      Returns:
      the value of the codeLength record component
    • codeTtl

      public Duration codeTtl()
      Returns the value of the codeTtl record component.
      Returns:
      the value of the codeTtl record component
    • linkTtl

      public Duration linkTtl()
      Returns the value of the linkTtl record component.
      Returns:
      the value of the linkTtl record component
    • maxAttempts

      public int maxAttempts()
      Returns the value of the maxAttempts record component.
      Returns:
      the value of the maxAttempts record component