Class SimpleMaskingCallback
- All Implemented Interfaces:
MaskingCallback
MaskingCallback
that will replace all the characters in the line with the given mask.
If the given mask is equal to LineReaderImpl.NULL_MASK
then the line will be replaced with an empty String.-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
SimpleMaskingCallback
-
-
Method Details
-
display
Description copied from interface:MaskingCallback
Transforms the line before it is displayed so that sensitive parts can be hidden.This method is called by the LineReader whenever the display needs to be updated. It allows the implementation to replace sensitive information with mask characters or other visual indicators while preserving the actual input for processing.
For example, a password masking implementation might replace each character with an asterisk (*) or hide the input entirely.
- Specified by:
display
in interfaceMaskingCallback
- Parameters:
line
- the current line being edited (contains the actual input)- Returns:
- the modified line to display (with sensitive parts masked)
-
history
Description copied from interface:MaskingCallback
Transforms the line before storing it in the history.This method is called by the LineReader when a line is about to be added to the command history. It allows the implementation to remove or redact sensitive information before it is persisted.
If the return value is empty or null, the line will not be saved in the history at all, which is often appropriate for commands containing passwords or other sensitive data.
For example, a command like "login --password=secret" might be transformed to "login --password=****" or simply "login" before being stored in history.
- Specified by:
history
in interfaceMaskingCallback
- Parameters:
line
- the line to be added to history (contains the actual input)- Returns:
- the modified line for history storage, or null/empty to prevent history storage
-