Record Class LoginAttemptConfiguration
java.lang.Object
java.lang.Record
com.svenruppert.jsentinel.bruteforce.LoginAttemptConfiguration
- Record Components:
failureThreshold- failures withinwindowthat trigger a lockoutwindow- rolling window for failure countinginitialLockout- duration of the first lockoutmaxLockout- 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 Summary
ConstructorsConstructorDescriptionLoginAttemptConfiguration(int failureThreshold, Duration window, Duration initialLockout, Duration maxLockout) Creates an instance of aLoginAttemptConfigurationrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic LoginAttemptConfigurationdefaults()Defaults for normal end-user logins: 5 failures / 15 min window / 15 min initial lockout / 4 h cap.final booleanIndicates whether some other object is "equal to" this one.intReturns the value of thefailureThresholdrecord component.final inthashCode()Returns a hash code value for this object.Returns the value of theinitialLockoutrecord component.Returns the value of themaxLockoutrecord component.static LoginAttemptConfigurationStrict defaults intended for the bootstrap-admin endpoint: 3 failures / 1 h window / 1 h initial lockout / 24 h cap.final StringtoString()Returns a string representation of this record class.window()Returns the value of thewindowrecord component.
-
Constructor Details
-
LoginAttemptConfiguration
public LoginAttemptConfiguration(int failureThreshold, Duration window, Duration initialLockout, Duration maxLockout) Creates an instance of aLoginAttemptConfigurationrecord class.- Parameters:
failureThreshold- the value for thefailureThresholdrecord componentwindow- the value for thewindowrecord componentinitialLockout- the value for theinitialLockoutrecord componentmaxLockout- the value for themaxLockoutrecord component
-
-
Method Details
-
defaults
Defaults for normal end-user logins: 5 failures / 15 min window / 15 min initial lockout / 4 h cap. -
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
-
hashCode
-
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 thecomparemethod from their corresponding wrapper classes. -
failureThreshold
public int failureThreshold()Returns the value of thefailureThresholdrecord component.- Returns:
- the value of the
failureThresholdrecord component
-
window
-
initialLockout
Returns the value of theinitialLockoutrecord component.- Returns:
- the value of the
initialLockoutrecord component
-
maxLockout
Returns the value of themaxLockoutrecord component.- Returns:
- the value of the
maxLockoutrecord component
-