Record Class PasswordContext

java.lang.Object
java.lang.Record
com.svenruppert.jsentinel.credential.input.PasswordContext
Record Components:
username - the account login; never null
emailLocalPart - optional — used for the local-part check
emailDomain - optional — used for the domain check
tenant - TenantId.DEFAULT for single-tenant
forbiddenTerms - case-insensitive substrings rejected by the validator; defensively copied

public record PasswordContext(String username, Optional<String> emailLocalPart, Optional<String> emailDomain, TenantId tenant, Set<String> forbiddenTerms) extends Record
Adapter-neutral user / application context consumed by the ContextAwarePasswordValidator.

The Konzept §14 mandates context-specific checks (CWE-521) but deliberately stays away from outdated composition rules (no "must contain a symbol" by default). Operators provide their own forbidden-term list via forbiddenTerms() — typically the application name, the brand and any well-known buzzwords.

Email addresses are split into local part and domain so the validator can flag each independently. None of the fields appear in toString() verbatim beyond what String.toString already produces — the values are non-secret operational metadata, not credentials.

  • Constructor Details

    • PasswordContext

      public PasswordContext(String username, Optional<String> emailLocalPart, Optional<String> emailDomain, TenantId tenant, Set<String> forbiddenTerms)
      Creates an instance of a PasswordContext record class.
      Parameters:
      username - the value for the username record component
      emailLocalPart - the value for the emailLocalPart record component
      emailDomain - the value for the emailDomain record component
      tenant - the value for the tenant record component
      forbiddenTerms - the value for the forbiddenTerms record component
  • Method Details

    • fromEmail

      public static PasswordContext fromEmail(String username, String emailAddress, TenantId tenant, Set<String> forbiddenTerms)
      Convenience: build a context from username plus the literal "local@domain" email string. Splits on the first '@'; passes through empty if either half is blank.
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • username

      public String username()
      Returns the value of the username record component.
      Returns:
      the value of the username record component
    • emailLocalPart

      public Optional<String> emailLocalPart()
      Returns the value of the emailLocalPart record component.
      Returns:
      the value of the emailLocalPart record component
    • emailDomain

      public Optional<String> emailDomain()
      Returns the value of the emailDomain record component.
      Returns:
      the value of the emailDomain record component
    • tenant

      public TenantId tenant()
      Returns the value of the tenant record component.
      Returns:
      the value of the tenant record component
    • forbiddenTerms

      public Set<String> forbiddenTerms()
      Returns the value of the forbiddenTerms record component.
      Returns:
      the value of the forbiddenTerms record component