Record Class LoginAttemptConfiguration

java.lang.Object
java.lang.Record
com.svenruppert.jsentinel.bruteforce.LoginAttemptConfiguration
Record Components:
failureThreshold - failures within window that trigger a lockout
window - rolling window for failure counting
initialLockout - duration of the first lockout
maxLockout - cap for the progressive backoff

public record LoginAttemptConfiguration(int failureThreshold, Duration window, Duration initialLockout, Duration maxLockout) extends Record
Tunable thresholds for InMemoryLoginAttemptPolicy and any other LoginAttemptPolicy that wants the same vocabulary.

The lockout escalates exponentially: the first breach of failureThreshold locks for initialLockout, the next for initialLockout × 2, then × 4, and so on, capped at maxLockout. The window bounds the rolling failure count: failures older than window drop out of the count.

  • Constructor Details

    • LoginAttemptConfiguration

      public LoginAttemptConfiguration(int failureThreshold, Duration window, Duration initialLockout, Duration maxLockout)
      Creates an instance of a LoginAttemptConfiguration record class.
      Parameters:
      failureThreshold - the value for the failureThreshold record component
      window - the value for the window record component
      initialLockout - the value for the initialLockout record component
      maxLockout - the value for the maxLockout record component
  • Method Details

    • defaults

      public static LoginAttemptConfiguration defaults()
      Defaults for normal end-user logins: 5 failures / 15 min window / 15 min initial lockout / 4 h cap.
    • strictBootstrap

      public static LoginAttemptConfiguration strictBootstrap()
      Strict defaults intended for the bootstrap-admin endpoint: 3 failures / 1 h window / 1 h initial lockout / 24 h cap.

      The bootstrap endpoint hands out the very first administrator account; a successful guess gives full control. The threshold sits deliberately below the normal-login defaults.

    • 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 the compare method from their corresponding wrapper classes.
      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.
    • failureThreshold

      public int failureThreshold()
      Returns the value of the failureThreshold record component.
      Returns:
      the value of the failureThreshold record component
    • window

      public Duration window()
      Returns the value of the window record component.
      Returns:
      the value of the window record component
    • initialLockout

      public Duration initialLockout()
      Returns the value of the initialLockout record component.
      Returns:
      the value of the initialLockout record component
    • maxLockout

      public Duration maxLockout()
      Returns the value of the maxLockout record component.
      Returns:
      the value of the maxLockout record component