Record Class LoginAttemptContext
java.lang.Object
java.lang.Record
com.svenruppert.jsentinel.bruteforce.LoginAttemptContext
- Record Components:
username- the username being attempted; may benullif not yet known (e.g. raw form submission)clientAddress- the remote client address as observed by the adapter; may benullif unavailablesessionId- session identifier, ornullif there is no session yettimestamp- when the attempt is observed; defaults to "now" vianow(String, String, String)
public record LoginAttemptContext(String username, String clientAddress, String sessionId, Instant timestamp)
extends Record
Adapter-neutral input to a
LoginAttemptPolicy decision.
The username and client address are normalised before throttling — the caller is expected to pass them as-is, the policy does the lower-casing and trimming so identical user / client pairs collapse into the same counter.
-
Constructor Summary
ConstructorsConstructorDescriptionLoginAttemptContext(String username, String clientAddress, String sessionId, Instant timestamp) Creates an instance of aLoginAttemptContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theclientAddressrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static LoginAttemptContextFactory for the common case — the policy supplies the timestamp.Returns the value of thesessionIdrecord component.Returns the value of thetimestamprecord component.final StringtoString()Returns a string representation of this record class.username()Returns the value of theusernamerecord component.
-
Constructor Details
-
LoginAttemptContext
public LoginAttemptContext(String username, String clientAddress, String sessionId, Instant timestamp) Creates an instance of aLoginAttemptContextrecord class.- Parameters:
username- the value for theusernamerecord componentclientAddress- the value for theclientAddressrecord componentsessionId- the value for thesessionIdrecord componenttimestamp- the value for thetimestamprecord component
-
-
Method Details
-
now
Factory for the common case — the policy supplies the timestamp.- Parameters:
username- attempted username (may benullfor anonymous flows; throttling does not apply)clientAddress- remote client address (may benull)sessionId- bound session id, if available (may benull)- Returns:
- a context with
Instant.now()as the timestamp
-
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. All components in this record class are compared withObjects::equals(Object,Object). -
username
-
clientAddress
Returns the value of theclientAddressrecord component.- Returns:
- the value of the
clientAddressrecord component
-
sessionId
-
timestamp
-