Package com.oorian.security
Class BruteForceConfig
java.lang.Object
com.oorian.security.BruteForceConfig
Configuration for brute-force attack protection.
Defines thresholds and behavior for tracking failed authentication attempts and locking out users or IP addresses that exceed the configured limits.
Usage:
setBruteForceProtection(BruteForceConfig.create()
.maxAttempts(5)
.lockoutDurationMillis(15 * 60 * 1000) // 15 minutes
.progressiveDelay(true));
- Since:
- 2.1
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbaseDelayMillis(long millis) Sets the base delay in milliseconds for progressive delay.static BruteForceConfigcreate()Creates a new BruteForceConfig with default settings.longReturns the base delay in milliseconds.longReturns the lockout duration in milliseconds.intReturns the maximum number of failed attempts before lockout.booleanReturns whether progressive delay is enabled.lockoutDurationMillis(long millis) Sets the lockout duration in milliseconds.maxAttempts(int max) Sets the maximum number of failed attempts before lockout.progressiveDelay(boolean enabled) Enables or disables progressive delay (exponential backoff).
-
Method Details
-
create
Creates a new BruteForceConfig with default settings.Defaults: 5 max attempts, 15-minute lockout, progressive delay enabled, 1-second base delay.
- Returns:
- a new config instance
-
maxAttempts
Sets the maximum number of failed attempts before lockout.- Parameters:
max- the maximum attempts (default: 5)- Returns:
- this config for chaining
-
lockoutDurationMillis
Sets the lockout duration in milliseconds.After lockout, the user/IP must wait this long before retrying.
- Parameters:
millis- the lockout duration (default: 900000 = 15 minutes)- Returns:
- this config for chaining
-
progressiveDelay
Enables or disables progressive delay (exponential backoff).When enabled, each failed attempt after the first incurs an increasing delay before the next attempt is allowed: base * 2^(attempts-1).
- Parameters:
enabled-trueto enable (default),falseto disable- Returns:
- this config for chaining
-
baseDelayMillis
Sets the base delay in milliseconds for progressive delay.The actual delay for attempt N is: base * 2^(N-1).
- Parameters:
millis- the base delay (default: 1000 = 1 second)- Returns:
- this config for chaining
-
getMaxAttempts
public int getMaxAttempts()Returns the maximum number of failed attempts before lockout.- Returns:
- the max attempts
-
getLockoutDurationMillis
public long getLockoutDurationMillis()Returns the lockout duration in milliseconds.- Returns:
- the lockout duration
-
isProgressiveDelay
public boolean isProgressiveDelay()Returns whether progressive delay is enabled.- Returns:
trueif progressive delay is enabled
-
getBaseDelayMillis
public long getBaseDelayMillis()Returns the base delay in milliseconds.- Returns:
- the base delay
-