Class KeyboardLayout
java.lang.Object
org.hibernate.validator.spi.password.KeyboardLayout
Defines a keyboard layout as a mapping from characters to physical key positions.
Used by the
noKeyboardWalk() password policy rule to detect walks across
adjacent keys.
Pre-built layouts are available as constants. Custom layouts can be created via
of(String[], String[], String[], String[]), where each array represents
a keyboard row (top to bottom) and each string in the array groups all characters
produced by the same physical key (e.g. "aAą" for a key that produces
a, A, and ą).
- Since:
- 9.2.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final KeyboardLayoutFrench AZERTY layout, including diacritical characters on dedicated keys.static final KeyboardLayoutUkrainian Cyrillic (ЙЦУКЕН) layout.static final KeyboardLayoutDvorak simplified layout.static final KeyboardLayoutNordic QWERTY layout (Swedish/Finnish variant) with Å, Ä, Ö keys.static final KeyboardLayoutStandard US QWERTY layout. -
Method Summary
Modifier and TypeMethodDescriptionbooleanareAdjacent(char a, char b) Returns whether two characters occupy physically adjacent keys on this layout.static KeyboardLayoutCreates a custom keyboard layout from four rows of key groups.
-
Field Details
-
QWERTY
Standard US QWERTY layout. -
AZERTY
French AZERTY layout, including diacritical characters on dedicated keys. -
DVORAK
Dvorak simplified layout. -
NORDIC
Nordic QWERTY layout (Swedish/Finnish variant) with Å, Ä, Ö keys. -
CYRILLIC_UA
Ukrainian Cyrillic (ЙЦУКЕН) layout.
-
-
Method Details
-
of
Creates a custom keyboard layout from four rows of key groups.Each row is an array of strings. Each string groups all characters produced by the same physical key — for example,
"aAą"means thata,A, andąall occupy the same physical position.Rows are ordered top to bottom (number row, top letter row, home row, bottom row). The standard keyboard row stagger is applied automatically.
- Parameters:
row0- number/symbol row (topmost)row1- top letter rowrow2- middle letter rowrow3- bottom letter row- Returns:
- a new keyboard layout
-
areAdjacent
public boolean areAdjacent(char a, char b) Returns whether two characters occupy physically adjacent keys on this layout. Returnsfalseif either character is not present in this layout.- Parameters:
a- the first characterb- the second character- Returns:
trueif both characters are present and their keys are adjacent
-