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 Summary
FieldsModifier and TypeFieldDescriptionprivate final intThe field for thecodeLengthrecord component.private final DurationThe field for thecodeTtlrecord component.private static final intDefault number of digits of a code.private static final longDefault validity of a code, in minutes.private static final longDefault validity of a link, in minutes.private static final intDefault number of verification attempts.private final DurationThe field for thelinkTtlrecord component.private final intThe field for themaxAttemptsrecord component. -
Constructor Summary
ConstructorsConstructorDescriptionOttProperties(int codeLength, Duration codeTtl, Duration linkTtl, int maxAttempts) Applies the defaults and validates the settings. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the value of thecodeLengthrecord component.codeTtl()Returns the value of thecodeTtlrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.linkTtl()Returns the value of thelinkTtlrecord component.intReturns the value of themaxAttemptsrecord component.private static intpositiveOrDefault(int value, int defaultValue, String key) Keeps a positive number, replaces zero by its default and rejects a negative one.private static DurationpositiveOrDefault(Duration value, Duration defaultValue, String key) Keeps a positive duration, replaces a missing or zero one by its default and rejects a negative one.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
codeLength
private final int codeLengthThe field for thecodeLengthrecord component. -
codeTtl
The field for thecodeTtlrecord component. -
linkTtl
The field for thelinkTtlrecord component. -
maxAttempts
private final int maxAttemptsThe field for themaxAttemptsrecord component. -
DEFAULT_CODE_LENGTH
private static final int DEFAULT_CODE_LENGTHDefault number of digits of a code.- See Also:
-
DEFAULT_CODE_TTL_MINUTES
private static final long DEFAULT_CODE_TTL_MINUTESDefault validity of a code, in minutes.- See Also:
-
DEFAULT_LINK_TTL_MINUTES
private static final long DEFAULT_LINK_TTL_MINUTESDefault validity of a link, in minutes.- See Also:
-
DEFAULT_MAX_ATTEMPTS
private static final int DEFAULT_MAX_ATTEMPTSDefault 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
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 belowauthserver.ott.- Returns:
- the value to use.
-
positiveOrDefault
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 belowauthserver.ott.- Returns:
- the duration to use.
-
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
codeLength
public int codeLength()Returns the value of thecodeLengthrecord component.- Returns:
- the value of the
codeLengthrecord component
-
codeTtl
Returns the value of thecodeTtlrecord component.- Returns:
- the value of the
codeTtlrecord component
-
linkTtl
Returns the value of thelinkTtlrecord component.- Returns:
- the value of the
linkTtlrecord component
-
maxAttempts
public int maxAttempts()Returns the value of themaxAttemptsrecord component.- Returns:
- the value of the
maxAttemptsrecord component
-